Commit 90c10a27 by daqian

add: 请重新授权跳转首页

parent 4b4064af
......@@ -11,6 +11,9 @@ App({
onLaunch: function (e) {
// this.checkFullSucreen()
// "navigationStyle": "custom"
// 默认 false
wx.setStorageSync('reLoginErr', false)
try {
let res = wx.getSystemInfoSync();
config.pixelRate = res.windowWidth / 750;
......@@ -35,7 +38,6 @@ App({
},
onShow: function (options = {}) {
console.log('app-onshow', options)
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
if (options.referrerInfo.extraData!=null){
const { activate_ticket, card_id, code, errCode, wx_activate_after_submit_url } = options.referrerInfo.extraData
......
......@@ -48,7 +48,6 @@ wxService.page({
wxService.post(`/member/activateCard`, currentObj).then(res => {
const {result,data} = res.data
if(result == 0){
// debugger
// 激活成功 变更 _激活状态
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
baseUserInfo.memberActivateStatus = true
......@@ -83,6 +82,7 @@ wxService.page({
brandId: app.globalData.brandId,
}).then(response=>{
let dataResp = response.data.data
wx.setStorageSync('reLoginErr', false)
wx.setStorageSync('token', dataResp.token)
wx.setStorageSync('_baseUserInfo', dataResp)
return Promise.resolve({ response })
......
......@@ -38,6 +38,7 @@ wxService.page({
title: '加载中'
})
wxService.get(`/member/memberPoint/getMyPointInfo`).then(res => {
if(res) {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
......@@ -45,7 +46,7 @@ wxService.page({
integralNum: data.point
})
}
}
})
},
getIntegralList() {
......@@ -57,6 +58,7 @@ wxService.page({
pageSize: this.data.pageSize
}
wxService.post(`/member/memberPointLog/findPage?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`, params).then(res=> {
if(res) {
const {result,data} = res.data
if(result == 0){
wx.hideLoading()
......@@ -64,6 +66,7 @@ wxService.page({
integralList: data.content.slice(0,30)
})
}
}
})
},
// 点击跳转至会员规则页
......
......@@ -71,20 +71,45 @@ wxService.page({
// 取会员卡号
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
const cardMember = wx.getStorageSync('_cardMember')
// 登录接口返回err
const reLoginErrFlag = wx.getStorageSync('reLoginErr')
// _cardMemebr
if (baseUserInfo){
// if (baseUserInfo){
// this.setData({
// token: wx.getStorageSync('token'),
// baseUserInfo,
// cardMember,
// isAuthorization: false
// })
// // 积分数量
// this.getMemberPointInfo()
// // 优惠券数量
// this.getMemberCouponInfo()
// } else {
// this.setData({
// isAuthorization: true
// })
// }
if (baseUserInfo && !reLoginErrFlag){
this.setData({
token: wx.getStorageSync('token'),
baseUserInfo,
cardMember,
isAuthorization: false
})
},()=>{
// 积分数量
this.getMemberPointInfo()
// 优惠券数量
this.getMemberCouponInfo()
} else {
})
}
else if(!baseUserInfo && reLoginErrFlag){
this.setData({
isAuthorization: true
})
}
else {
this.setData({
isAuthorization: true
})
......@@ -122,10 +147,10 @@ wxService.page({
})
}
} else {
wx.showToast({
title: '请求失败',
icon: 'none'
})
// wx.showToast({
// title: '请求失败',
// icon: 'none'
// })
}
})
},
......
......@@ -111,10 +111,10 @@ wxService.page({
})
}
} else {
wx.showToast({
title: '请求失败',
icon: 'none'
})
// wx.showToast({
// title: '请求失败',
// icon: 'none'
// })
}
})
},
......
......@@ -121,7 +121,6 @@ function aspectRatio(h,w) {
// function checkFullSucreen () {
// const self = this
// wxService.getSystemInfo().then(res => {
// debugger
// if ((res.screenHeight - res.windowHeight - res.statusBarHeight - 32) > 72) {
//      // 处理相关逻辑
// self.globalData.isFullSucreen = true
......@@ -269,6 +268,7 @@ function getUserInfoByBtn(userInfo) {
}).then((res) => {
logger.log(' wx _userInfo success res --->', res)
wx.setStorageSync('_userInfo', res[0].userInfo)
wx.setStorageSync('reLoginErr', false)
wx.showLoading({
title: '正在加载...',
icon: 'none',
......
......@@ -30,8 +30,8 @@ class WXService extends Http {
}
/**
* 所有接口中返回401就登录
* 返回402 重试 (getUserInfoLimitCount:重试次数),超过重试次数提示会员系统异常,请联系管理员
* 所有接口中
* 返回401 重试 (getUserInfoLimitCount:重试次数),超过重试次数提示会员系统异常,请联系管理员
*/
request ({
url,
......@@ -47,66 +47,63 @@ class WXService extends Http {
this.setPageLoadStatus()
wx.hideLoading()
}).catch(res => {
if (res.msg && res.msg.indexOf('未登录') > -1) {
// 判断是否登陆过 登陆过 重新登陆 未登陆 跳转首页
const baseUserInfo = this.getBaseUserInfo()
if(!baseUserInfo) {
wxService.router('/pages/userCenter/userCenter').replace()
return false
}
// 条件限制 getUserInfoLimitCount:重试次数
if (!this.getUserInfoLimitCount) {
this.getUserInfoLimitCount = 1
} else {
this.getUserInfoLimitCount++
}
if (this.getUserInfoLimitCount > 3) {
wx.showToast({
title: '登录超出重试次数!',
icon: 'none'
})
wxService.router(`/pages/userCenter/userCenter`).replace()
return false
} else {
// 重新登陆 更新缓存
this.reLogin()
}
// 用户未登录
// if (res.msg && res.msg.indexOf('未登录') > -1) {
// // 判断是否登陆过 登陆过 重新登陆 未登陆 跳转首页
// const baseUserInfo = this.getBaseUserInfo()
// if(!baseUserInfo) {
// wxService.router('/pages/userCenter/userCenter').replace()
// return false
// }
// // 条件限制 getUserInfoLimitCount:重试次数
// if (!this.getUserInfoLimitCount) {
// this.getUserInfoLimitCount = 1
// } else {
// this.getUserInfoLimitCount++
// }
// if (this.getUserInfoLimitCount > 3) {
// wx.showToast({
// title: '登录超出重试次数!',
// icon: 'none'
// })
// wxService.router(`/pages/userCenter/userCenter`).replace()
// return false
// } else {
// // 重新登陆 更新缓存
// this.reLogin()
setTimeout(()=>{
const pages = getCurrentPages()
const perpage = pages[pages.length - 1]
perpage.onShow()
},2000)
// setTimeout(()=>{
// const pages = getCurrentPages()
// const perpage = pages[pages.length - 1]
// perpage.onShow()
// },2000)
} else if (res.state === 402) {
return this.getUserInfo().then(() => {
// }
// }
console.log('--mmmmm--',res.msg)
if (res.msg && res.msg.indexOf('未登录') > -1) {
if (!this.getUserInfoLimitCount) {
this.getUserInfoLimitCount = 1
} else {
this.getUserInfoLimitCount++
}
console.log('count', this.getUserInfoLimitCount)
if (this.getUserInfoLimitCount > 3) {
wx.showToast({
title: '会员系统异常,请联系管理员',
icon: 'none'
icon: 'none',
duration: 2000
})
} else {
this.request({
url,
data,
header: {
'buyer-token': this.getToken()
},
method,
dataType,
responseType,
success,
fail,
complete
})
console.log('===重新=', this.getUserInfoLimitCount)
this.reLogin()
}
})
return false
} else if(res.msg && res.msg.indexOf('请重新授权') > -1) {
wx.setStorageSync('reLoginErr', true)
wxService.router(`/pages/userCenter/userCenter`).replace()
}
})
}
......@@ -147,6 +144,7 @@ class WXService extends Http {
*/
reLogin() {
wx.setStorageSync('token', '')
wx.setStorageSync('reLoginErr', false)
const app = getApp()
var _this = this
return _this.login().then(result=>{
......@@ -156,10 +154,19 @@ class WXService extends Http {
wechatInfo: null,
brandId: app.globalData.brandId,
}).then(response=>{
if(response){
let dataResp = response.data.data
wx.setStorageSync('token', dataResp.token)
wx.setStorageSync('_baseUserInfo', dataResp)
wx.setStorageSync('reLoginErr', false)
// 刷新页面
setTimeout(()=>{
const pages = getCurrentPages()
const perpage = pages[pages.length - 1]
perpage.onShow()
},2000)
return Promise.resolve({ response })
}
}).catch(err=>{
return Promise.reject(err)
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment