修改请求接口地址,修改登录参数

This commit is contained in:
YeMingfei666 2025-02-11 18:10:25 +08:00
parent 6a10005af5
commit a599adc63e
5 changed files with 70 additions and 10 deletions

View File

@ -7,7 +7,7 @@ VITE_APP_BASE_API=/dev-api
# 接口地址
# VITE_APP_API_URL=https://admintestpapi.sxczgkj.cn/ # 线上
VITE_APP_API_URL=https://cashieradmin.sxczgkj.cn/ # 正式
VITE_APP_API_URL=https://tapi.cashier.sxczgkj.cn/ # 正式
# VITE_APP_API_URL=https://api.youlai.tech # 线上
# VITE_APP_API_URL=http://localhost:8989 # 本地

61
src/api/account/login.ts Normal file
View File

@ -0,0 +1,61 @@
import request from "@/utils/request";
const baseURL = "account/admin/";
const AuthAPI = {
/** 登录接口*/
login(data: LoginFormData) {
return request<any, LoginResult>({
url: `${baseURL}auth/login`,
method: "post",
data: data,
});
},
/** 获取验证码接口*/
getCaptcha() {
return request<any, CaptchaInfo>({
url: `${baseURL}auth/captcha`,
method: "get",
});
},
/**getPermission */
getPermission() {
return request<any, CaptchaInfo>({
url: `${baseURL}auth/permission`,
method: "get",
});
},
};
export default AuthAPI;
/** 登录表单数据 */
export interface LoginFormData {
/** 用户名 */
username: string;
/** 密码 */
password: string;
/** 验证码缓存uuid */
uuid: string;
/** 验证码 */
code: string;
/**
* 0:商户登录
* 1:员工登录
*/
loginType: number;
}
/** 登录响应 */
export interface LoginResult {
/** 访问令牌 */
token: string;
}
/** 验证码信息 */
export interface CaptchaInfo {
/** 验证码缓存uuid */
uuid: string;
/** 验证码图片Base64字符串 */
code: string;
}

View File

@ -2,7 +2,7 @@ import { store } from "@/store";
import { usePermissionStoreHook } from "@/store/modules/permission";
import { useDictStoreHook } from "@/store/modules/dict";
import AuthAPI, { type LoginFormData } from "@/api/auth";
import AuthAPI, { type LoginFormData } from "@/api/account/login";
import UserAPI, { type UserInfo } from "@/api/system/user";
import { setToken, setRefreshToken, getRefreshToken, clearToken } from "@/utils/auth";

View File

@ -36,13 +36,13 @@ service.interceptors.response.use(
return response;
}
const { code, data, message } = response.data;
if (code === ResultEnum.SUCCESS || code === undefined || code === null) {
const { code, data, msg } = response.data;
if (code === ResultEnum.SUCCESS || code === undefined || code === null || code === 200) {
return data ? data : response.data;
}
ElMessage.error(message || "系统出错");
return Promise.reject(new Error(message || "Error"));
ElMessage.error(msg || "系统出错");
return Promise.reject(new Error(msg || "Error"));
},
async (error: any) => {
// 非 2xx 状态码处理 401、403、500 等

View File

@ -78,10 +78,9 @@
<script setup>
import { encrypt } from "@/utils/rsaEncrypt";
import { getCodeImg } from "@/api/login";
import $API_login from "@/api/account/login";
import { $douyin_checkIn } from "@/api/coup/index";
import Cookies from "js-cookie";
import qs from "qs";
import Background from "@/assets/images/background_img.jpg";
import { useUserStore } from "@/store";
import { useRoute } from "vue-router";
@ -127,9 +126,9 @@ onMounted(() => {
}
});
function getCode() {
getCodeImg().then((res) => {
$API_login.getCaptcha().then((res) => {
console.log(res);
state.codeUrl = res.img;
state.codeUrl = res.code;
state.loginForm.uuid = res.uuid;
});
}