登录禁用账户跳转优化

This commit is contained in:
Eratosici
2022-01-18 09:23:14 +08:00
parent d6d37720e2
commit f0c3b808ca
2 changed files with 34 additions and 24 deletions

View File

@@ -138,7 +138,7 @@
// credentials: this.credentials,
// loginType: 0, //账号登录
// }
// // #endif
// // #endif
if (this.principal.length == 0) {
this.setData({
@@ -164,9 +164,9 @@
},
callBack: res => {
console.log("login",res)
var loginResult = '';
uni.setStorageSync("loginResult",res);
uni.setStorageSync('token', 'bearer' + res.access_token);
// var loginResult = '';
// uni.setStorageSync("loginResult",res);
// uni.setStorageSync('token', 'bearer' + res.access_token);
// return
http.loginSuccess(res, () => {
uni.showToast({
@@ -179,7 +179,7 @@
url: '/pages/index/index'
});
},1000)
}
})
})

View File

@@ -12,7 +12,7 @@ function request(params, isGetTonken) {
// globalData.requestQueue.push(params);
// return;
// }
if (Object.prototype.toString.call(params.data) == '[object Array]') {
params.data = JSON.stringify(params.data);
} else if (Object.prototype.toString.call(params.data) == '[object Number]') {
@@ -81,7 +81,7 @@ function request(params, isGetTonken) {
url = '/pages/accountLogin/accountLogin'
}
// #endif
// #ifdef APP-PLUS
var url = '/pages/accountLogin/accountLogin'
// #endif
@@ -104,12 +104,12 @@ function request(params, isGetTonken) {
success: res => {
if (res.confirm) {
// 跳转登录页面
// #ifdef H5
// #ifdef H5
uni.navigateTo({
url: uni.getStorageSync('appType') == AppType.MP ? '/pages/login/login' : '/pages/accountLogin/accountLogin'
})
// #endif
// #ifdef MP-WEIXIN
uni.navigateTo({
url: '/pages/login/login'
@@ -123,12 +123,12 @@ function request(params, isGetTonken) {
}
})
// // 跳转登录页面
// // #ifdef H5
// // #ifdef H5
// uni.navigateTo({
// url: uni.getStorageSync('appType') == AppType.MP ? '/pages/login/login' : '/pages/accountLogin/accountLogin'
// })
// // #endif
// // #ifdef MP-WEIXIN
// uni.navigateTo({
// url: '/pages/login/login'
@@ -145,7 +145,7 @@ function request(params, isGetTonken) {
} else {
//如果有定义了params.errCallBack则调用 params.errCallBack(res.data)
if (params.errCallBack) {
params.errCallBack(res);
}
uni.hideLoading();
@@ -247,6 +247,25 @@ var getToken = function (fn) {
* @param {Object} fn 登录成功后的回调
*/
function loginSuccess (result, fn) {
if (!result.enabled) {
uni.showModal({
showCancel: false,
title: "提示",
content: "您已被禁用,不能购买,请联系客服",
cancelText: "取消",
confirmText: "确定",
success: function (res) {
if (res.confirm) {
wx.switchTab({
url: '/pages/index/index'
});
}
}
})
wx.setStorageSync('token', '');
return
}
// 保存登陆信息
wx.setStorageSync('loginResult', result)
// 保存成功登录标识,token过期判断
@@ -255,18 +274,9 @@ function loginSuccess (result, fn) {
// if (!result.pic) {
// updateUserInfo();
// }
if (!result.enabled) {
uni.showModal({
showCancel: false,
title: "提示",
content: "您已被禁用,不能购买,请联系客服",
cancelText: "取消",
confirmText: "确定"
})
wx.setStorageSync('token', '');
} else {
wx.setStorageSync('token', 'bearer' + result.access_token); //把token存入缓存请求接口数据时要用
}
wx.setStorageSync('token', 'bearer' + result.access_token); //把token存入缓存请求接口数据时要用
if (result.userId) {
wx.setStorageSync('hadBindUser', true);
getCartCount()