loading.vue
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
<view class="loading-page">
<text class="loading-text">正在启动...</text>
<review-probe-bar />
</view>
</template>
<script type='text/ecmascript-6'>
import ReviewProbeBar from '@/components/ReviewProbeBar.vue'
export default {
components: { ReviewProbeBar },
name: '',
data () {
return {}
},
mounted () {
console.warn('[boot] loading.mounted start')
this._bootFallbackTimer = setTimeout(() => {
console.warn('[boot] loading 5s fallback -> login')
this.toLogin()
}, 5000)
try {
const userInfo = uni.$storage.get('userInfo')
if (userInfo) {
console.warn('[boot] loading -> equity')
if (this._bootFallbackTimer) {
clearTimeout(this._bootFallbackTimer)
this._bootFallbackTimer = null
}
uni.reLaunch({
url: '/pages/equity/index'
})
} else {
console.warn('[boot] loading -> login (no userInfo)')
this.toLogin()
}
} catch (e) {
console.warn('[boot] loading error -> login', e)
this.toLogin()
}
},
beforeDestroy () {
if (this._bootFallbackTimer) {
clearTimeout(this._bootFallbackTimer)
this._bootFallbackTimer = null
}
},
methods: {
async toLogin () {
if (this._bootFallbackTimer) {
clearTimeout(this._bootFallbackTimer)
this._bootFallbackTimer = null
}
await uni.$storage.rm("userInfo")
uni.reLaunch({
url: '/pages/common/login'
})
}
}
}
</script>
<style scoped lang='scss'>
.loading-page {
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #f7f8fa;
}
.loading-text {
font-size: 32rpx;
color: #666;
}
</style>