Files
bsmall/pages/welcome/welcome.js
2021-05-27 16:55:16 +08:00

48 lines
1.1 KiB
JavaScript
Executable File

const api = require("../../api/api")
const app = getApp()
Page({
onLoad() {
console.log('1111')
let userToken = my.getStorageSync({key:"userToken"}).data || null,
atTime = Math.round(new Date() / 1000)
if(userToken != null){
if(atTime < userToken.expires){
// 获取最新的用户信息
my.showLoading();
api.userinfo(userToken.token).then(res=>{
my.switchTab({
url: '../index/index'
});
my.hideLoading();
})
}else{
my.alert({
title : '温馨提示',
content : '登录已过期,请重新登录',
buttonText: '去登录',
success: () => {
console.log("去登陆")
my.showLoading();
my.removeStorage({
key : 'userToken',
success : (res)=> {
my.reLaunch({
url: "../login/login"
})
my.hideLoading();
}
});
}
});
}
}else{
my.reLaunch({
url: "../login/login"
})
}
}
});