/** 检查token实效 */ import * as API_Passport from '../api/passport.js' import * as Common from '../utils/common' const app=getApp() export function checkToken(){ return new Promise((resolve,reject)=>{ const authorInfo=app.globalData.authorInfo if(authorInfo==null||authorInfo==''){ //自动登陆尝试 wx.removeStorageSync('login_result') console.log('checkTokenAutoLogin') Common.toAutoLogin() return } const access_token_timeout = authorInfo.access_token_timeout const refresh_token_timeout=authorInfo.refresh_token_timeout const now=Date.parse(new Date())/1000 console.log('test',!refresh_token_timeout||refresh_token_timeout{ console.log(res) const {access_token_timeout,refresh_token_timeout}=res app.globalData.authorInfo={...res,'access_token_timeout':access_token_timeout+now-500,'refresh_token_timeout':refresh_token_timeout+now-500} wx.setStorageSync('authorInfo', app.globalData.authorInfo) resolve() }).catch(err=>{ console.log(err) reject() }) } else{ resolve() } }) }