authRequest 清除没有用的userToken,这样下次不用发送请求

wechat_user_type
Ge Hao 8 years ago
parent 312734bde4
commit 4ebc9e7cd8
  1. 9
      app.js

@ -59,6 +59,12 @@ App({
var that = this
if (!that.globalData.token) {
var token = wx.getStorageSync('userToken')
if (!token) {
wx.redirectTo({
url: '../mine/mine'
})
return
}
that.globalData.token = token
that.request({
url: `${that.globalData.API_URL}/sessions/new`,
@ -70,6 +76,9 @@ App({
content: '请前往 “我的” 页面绑定手机号',
showCancel: false,
success: function(res) {
// 清除没用的token
wx.removeStorage({key: 'userToken'})
that.globalData.token = undefined
if (getCurrentPages().length > 1) {
wx.navigateBack()
}

Loading…
Cancel
Save