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.
49 lines
1.0 KiB
Vue
49 lines
1.0 KiB
Vue
<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="scss">
|
|
// @import "@/uni_modules/uview-ui/index.scss";
|
|
// @import "common/css/demo.scss";
|
|
@import "common/css/iconfont.css";
|
|
</style>
|