登录禁用账户跳转优化

master
Eratosici 4 years ago
parent d6d37720e2
commit f0c3b808ca

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

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

Loading…
Cancel
Save