43 lines
997 B
Vue
43 lines
997 B
Vue
<script>
|
|
import { initLogin,checkLoginStatus } from '@/utils/login';
|
|
export default {
|
|
onLaunch: function() {
|
|
console.log('App Launch')
|
|
this.initLoginStatus();
|
|
},
|
|
onShow: function() {
|
|
console.log('App Show')
|
|
},
|
|
onHide: function() {
|
|
},
|
|
methods:{
|
|
async initLoginStatus() {
|
|
try {
|
|
// 初始化登录
|
|
if (checkLoginStatus()) {
|
|
console.log('登录状态初始化成功');
|
|
return
|
|
}
|
|
const success = await initLogin();
|
|
if (success) {
|
|
console.log('登录状态初始化成功');
|
|
} else {
|
|
throw new Error('登录状态初始化失败');
|
|
}
|
|
} catch (error) {
|
|
uni.showToast({
|
|
title: '自动登录失败,请手动登录',
|
|
icon: 'none'
|
|
});
|
|
} finally {
|
|
uni.hideLoading();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
/*每个页面公共css */
|
|
</style>
|