44 lines
918 B
Vue
44 lines
918 B
Vue
|
|
<script>
|
||
|
|
import * as api from '@/utils/api.js';
|
||
|
|
export default {
|
||
|
|
onLaunch: function() {
|
||
|
|
setTimeout(() => {
|
||
|
|
console.log('onLaunch执行完毕')
|
||
|
|
}, 100);
|
||
|
|
this.checkIsLogin()
|
||
|
|
},
|
||
|
|
onShow: function() {
|
||
|
|
console.log('App Show')
|
||
|
|
},
|
||
|
|
onHide: function() {
|
||
|
|
console.log('App Hide')
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
checkIsLogin() {
|
||
|
|
let token = uni.getStorageSync('token')
|
||
|
|
//请求后端接口查看token是否有效
|
||
|
|
api.calluser("auth/check?Authorization=" + token, {}, "get").then((
|
||
|
|
res) => {
|
||
|
|
if (res.code == 200) {
|
||
|
|
let url = "/pages/home/home";
|
||
|
|
setTimeout(() => {
|
||
|
|
uni.reLaunch({
|
||
|
|
url
|
||
|
|
})
|
||
|
|
}, 50)
|
||
|
|
}
|
||
|
|
|
||
|
|
})
|
||
|
|
},
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss">
|
||
|
|
/*每个页面公共css */
|
||
|
|
@import "@/static/iconfont.css";
|
||
|
|
@import './common/uni.css';
|
||
|
|
@import './colorui/main.css';
|
||
|
|
@import './colorui/icon.css';
|
||
|
|
@import "./common/uni-main.scss";
|
||
|
|
</style>
|