xcx 4 years ago
parent
commit
3229c1ab80
2 changed files with 3 additions and 2 deletions
  1. 1
    1
      project.config.json
  2. 2
    1
      src/util/PublicMethod/index.js

+ 1
- 1
project.config.json View File

27
 			"outputPath": ""
27
 			"outputPath": ""
28
 		},
28
 		},
29
 		"useIsolateContext": true,
29
 		"useIsolateContext": true,
30
-		"useCompilerModule": true,
30
+		"useCompilerModule": false,
31
 		"userConfirmedUseCompilerModuleSwitch": false
31
 		"userConfirmedUseCompilerModuleSwitch": false
32
 	},
32
 	},
33
 	"compileType": "miniprogram",
33
 	"compileType": "miniprogram",

+ 2
- 1
src/util/PublicMethod/index.js View File

32
       config.url += '?' + queryData
32
       config.url += '?' + queryData
33
     }
33
     }
34
     let Header = {}
34
     let Header = {}
35
-    if (wx.getStorageSync('token') !== '') { // 本地获取token
35
+    if (wx.getStorageSync('token') !== '' && wx.getStorageSync('tokentime') !== '' && wx.getStorageSync('tokentime') - 0 + 24 * 60 * 60 * 1000 >= Date.now()) { // 本地获取token
36
       Header['X-Authorization-Jwt'] = wx.getStorageSync('token')
36
       Header['X-Authorization-Jwt'] = wx.getStorageSync('token')
37
     }
37
     }
38
     wx.request({
38
     wx.request({
44
         const token = res.header['X-Authorization-Jwt'] || res.header['X-Authorization-JWT']
44
         const token = res.header['X-Authorization-Jwt'] || res.header['X-Authorization-JWT']
45
         if (token) { // 更新本地存储token
45
         if (token) { // 更新本地存储token
46
           wx.setStorageSync('token', token)
46
           wx.setStorageSync('token', token)
47
+          wx.setStorageSync('tokentime', Date.now())
47
         }
48
         }
48
         if (res.data.code - 0 === 1001) { // token失效
49
         if (res.data.code - 0 === 1001) { // token失效
49
           // wx.login({ // 微信获取code
50
           // wx.login({ // 微信获取code