inti
This commit is contained in:
65
App.vue
Normal file
65
App.vue
Normal file
@@ -0,0 +1,65 @@
|
||||
<script>
|
||||
import {
|
||||
get,
|
||||
post
|
||||
} from '@/common/request.js'
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
const token = uni.getStorageSync('token')
|
||||
|
||||
console.log('token', token)
|
||||
if (!token) {
|
||||
uni.showLoading({
|
||||
title: '请先登录!',
|
||||
mask: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.navigateTo({
|
||||
url: '/pages/my/login'
|
||||
})
|
||||
}, 1000)
|
||||
} else {
|
||||
|
||||
const res = post('/myapi/api/yq_driver/autoLogin', {
|
||||
token
|
||||
})
|
||||
|
||||
if (res.code == 1) {
|
||||
uni.seteStorageSync('token')
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url: '/pages/my/index'
|
||||
})
|
||||
}, 500)
|
||||
} else {
|
||||
uni.removeStorageSync('token')
|
||||
|
||||
uni.showLoading({
|
||||
title: '请重新登录!',
|
||||
mask: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.navigateTo({
|
||||
url: '/pages/my/login'
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
|
||||
@import "uview-ui/index.scss";
|
||||
</style>
|
||||
Reference in New Issue
Block a user