修改请求接口地址,修改登录参数
This commit is contained in:
@@ -7,7 +7,7 @@ VITE_APP_BASE_API=/dev-api
|
|||||||
# 接口地址
|
# 接口地址
|
||||||
|
|
||||||
# VITE_APP_API_URL=https://admintestpapi.sxczgkj.cn/ # 线上
|
# 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=https://api.youlai.tech # 线上
|
||||||
# VITE_APP_API_URL=http://localhost:8989 # 本地
|
# VITE_APP_API_URL=http://localhost:8989 # 本地
|
||||||
|
|||||||
61
src/api/account/login.ts
Normal file
61
src/api/account/login.ts
Normal 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;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import { store } from "@/store";
|
|||||||
import { usePermissionStoreHook } from "@/store/modules/permission";
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||||
import { useDictStoreHook } from "@/store/modules/dict";
|
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 UserAPI, { type UserInfo } from "@/api/system/user";
|
||||||
|
|
||||||
import { setToken, setRefreshToken, getRefreshToken, clearToken } from "@/utils/auth";
|
import { setToken, setRefreshToken, getRefreshToken, clearToken } from "@/utils/auth";
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ service.interceptors.response.use(
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { code, data, message } = response.data;
|
const { code, data, msg } = response.data;
|
||||||
if (code === ResultEnum.SUCCESS || code === undefined || code === null) {
|
if (code === ResultEnum.SUCCESS || code === undefined || code === null || code === 200) {
|
||||||
return data ? data : response.data;
|
return data ? data : response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElMessage.error(message || "系统出错");
|
ElMessage.error(msg || "系统出错");
|
||||||
return Promise.reject(new Error(message || "Error"));
|
return Promise.reject(new Error(msg || "Error"));
|
||||||
},
|
},
|
||||||
async (error: any) => {
|
async (error: any) => {
|
||||||
// 非 2xx 状态码处理 401、403、500 等
|
// 非 2xx 状态码处理 401、403、500 等
|
||||||
|
|||||||
@@ -78,10 +78,9 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { encrypt } from "@/utils/rsaEncrypt";
|
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 { $douyin_checkIn } from "@/api/coup/index";
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
import qs from "qs";
|
|
||||||
import Background from "@/assets/images/background_img.jpg";
|
import Background from "@/assets/images/background_img.jpg";
|
||||||
import { useUserStore } from "@/store";
|
import { useUserStore } from "@/store";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
@@ -127,9 +126,9 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
function getCode() {
|
function getCode() {
|
||||||
getCodeImg().then((res) => {
|
$API_login.getCaptcha().then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
state.codeUrl = res.img;
|
state.codeUrl = res.code;
|
||||||
state.loginForm.uuid = res.uuid;
|
state.loginForm.uuid = res.uuid;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user