// app.js App({ onLaunch() { // 展示本地存储能力 const logs = wx.getStorageSync('logs') || [] logs.unshift(Date.now()) wx.setStorageSync('logs', logs) // 登录 let token = wx.getStorageSync('token') let time = wx.getStorageSync('time')//登录时间 let Time = new Date()//当前时间 //console.log('时间差为' + parseInt(Time - time)/1000) let currentTime = wx.getStorageSync('currentTime')//过期时间 if(token != ''){ if(parseInt(Time - time)/1000 < currentTime){ wx.switchTab({url: 'pages/scene/scene'}) } else{ } } wx.login({ success: res => { // 发送 res.code 到后台换取 openId, sessionKey, unionId } }) }, globalData: { userInfo: null }, })