Commit 90c10a27 by daqian

add: 请重新授权跳转首页

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