You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
988 B
Vue

2 years ago
<script>
import {
mapState,
mapActions
} from 'vuex';
2 years ago
export default {
globalData: {
latitude: '',
longitude: '',
version: '',
city:'',
cityCode:'',
isLogin: true,
},
onLaunch: function() {
this.checkToken();
2 years ago
console.log('App Launch')
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
methods:{
...mapActions([
'setUserInfo'
]),
checkToken(){
2 years ago
const tokenStartTime = uni.getStorageSync('tokenStartTime');
const userToken = uni.getStorageSync('userToken');
const timeOver = 1 * 24 * 3600 * 1000
let date = new Date().getTime()
if(date - tokenStartTime > timeOver || !tokenStartTime || !userToken) {
console.log('token已过期');
uni.removeStorageSync('userToken')
uni.removeStorageSync('tokenStartTime')
}
}
},
2 years ago
}
</script>
<style lang="less">
2 years ago
@import "common/css/iconfont.css";
@import "common/css/common.less";
2 years ago
</style>