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.
|
|
|
<script>
|
|
|
|
import {
|
|
|
|
mapState,
|
|
|
|
mapActions
|
|
|
|
} from 'vuex';
|
|
|
|
export default {
|
|
|
|
globalData: {
|
|
|
|
latitude: '',
|
|
|
|
longitude: '',
|
|
|
|
version: '',
|
|
|
|
city:'',
|
|
|
|
cityCode:'',
|
|
|
|
isLogin: true,
|
|
|
|
},
|
|
|
|
onLaunch: function() {
|
|
|
|
this.checkToken();
|
|
|
|
console.log('App Launch')
|
|
|
|
},
|
|
|
|
onShow: function() {
|
|
|
|
console.log('App Show')
|
|
|
|
},
|
|
|
|
onHide: function() {
|
|
|
|
console.log('App Hide')
|
|
|
|
},
|
|
|
|
methods:{
|
|
|
|
...mapActions([
|
|
|
|
'setUserInfo'
|
|
|
|
]),
|
|
|
|
checkToken(){
|
|
|
|
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')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less">
|
|
|
|
@import "common/css/iconfont.css";
|
|
|
|
@import "common/css/common.less";
|
|
|
|
</style>
|