优化管理端和卖家端登录

master
paulGao 2022-01-17 18:00:49 +08:00
parent cf740d9605
commit 1bee69cefb
6 changed files with 47 additions and 11 deletions

View File

@ -7,6 +7,7 @@ import {
importRequest, importRequest,
getRequestWithNoToken, getRequestWithNoToken,
putRequestWithNoForm, putRequestWithNoForm,
postRequestWithNoTokenData,
postRequestWithNoForm, postRequestWithNoForm,
managerUrl managerUrl
} from "@/libs/axios"; } from "@/libs/axios";
@ -47,7 +48,7 @@ export const getNoticePage = (params) => {
// 登陆 // 登陆
export const login = (params) => { export const login = (params) => {
return getRequestWithNoToken("/user/login", params); return postRequestWithNoTokenData("/user/login", params);
}; };
// 登出 // 登出

View File

@ -342,3 +342,19 @@ export const postRequestWithNoToken = (url, params) => {
params: params params: params
}); });
}; };
/**
* 无需token验证的请求 避免旧token过期导致请求失败
* @param {*} url
* @param {*} params
*/
export const postRequestWithNoTokenData = (url, params) => {
return service({
method: "post",
url: `${url}`,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: params
});
};

View File

@ -111,10 +111,11 @@ export default {
if (!con.status) return; if (!con.status) return;
this.loading = true; this.loading = true;
login({
username: this.form.username, let fd = new FormData();
password: this.md5(this.form.password), fd.append('username',this.form.username)
}) fd.append('password',this.md5(this.form.password))
login(fd)
.then((res) => { .then((res) => {
if (res && res.success) { if (res && res.success) {
this.afterLogin(res); this.afterLogin(res);

View File

@ -5,7 +5,7 @@ import {
putRequest, putRequest,
deleteRequest, deleteRequest,
getRequestWithNoToken, getRequestWithNoToken,
postRequestWithNoToken, postRequestWithNoTokenData,
commonUrl, commonUrl,
} from "@/libs/axios"; } from "@/libs/axios";
@ -29,7 +29,7 @@ export const getSellerHomeData = params => {
// 登陆 // 登陆
export const login = params => { export const login = params => {
return postRequestWithNoToken("/login/userLogin", params); return postRequestWithNoTokenData("/login/userLogin", params);
}; };
// 登出 // 登出

View File

@ -350,3 +350,20 @@ export const postRequestWithNoToken = (url, params) => {
params: params params: params
}); });
}; };
/**
* 无需token验证的请求 避免旧token过期导致请求失败
* @param {*} url
* @param {*} params
*/
export const postRequestWithNoTokenData = (url, params) => {
return service({
method: "post",
url: `${url}`,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: params
});
};

View File

@ -137,10 +137,11 @@ export default {
if (!con.status) return; if (!con.status) return;
this.loading = true; this.loading = true;
login({
username: this.form.username, let fd = new FormData();
password: this.md5(this.form.password), fd.append('username',this.form.username)
}) fd.append('password',this.md5(this.form.password))
login(fd)
.then((res) => { .then((res) => {
this.loading = false; this.loading = false;
if (res && res.success) { if (res && res.success) {