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

90 lines
1.7 KiB

<script>
import helper from 'common/helper.js'
export default {
globalData: {
map: null
},
onLaunch: function() {
/* #ifndef H5 */
const getInfo = (token) => {
uni.request({
url: `${helper.serverUrl}/user/getInfo`,
header: {
Authorization: `Bearer ${token}`
},
success(resp) {
console.log('success', resp);
if (resp?.data?.code !== 200) {
uni.reLaunch({
url: '/pages/login/login',
success() {
plus.navigator.closeSplashscreen();
},
fail(err) {
console.log('reLaunch', err);
}
})
} else {
uni.reLaunch({
url: '/pages/index/index',
success() {
plus.navigator.closeSplashscreen();
},
fail(err) {
console.log('reLaunch', err);
}
})
}
},
fail(err) {
console.log('error', err);
uni.reLaunch({
url: '/pages/login/login',
success() {
plus.navigator.closeSplashscreen();
}
})
}
})
}
uni.getStorage({
key: 'token',
success(token) {
console.log('token', token)
getInfo(token.data)
},
fail(err) {
console.log('err', err)
getInfo()
}
})
/* #endif */
},
onShow: function() {},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style lang="scss">
/*每个页面公共css */
@import '@/uni_modules/uni-scss/index.scss';
/* #ifndef APP-NVUE */
@import '@/static/customicons.css';
@import './common/uni.css';
// 设置整个项目的背景色
page {
background-color: #f5f5f5;
}
/* #endif */
.example-info {
font-size: 14px;
color: #333;
padding: 10px;
}
</style>