index.vue
1.5 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
<template>
<view class="content">
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad(){
this.loadExecution()
},
methods: {
loadExecution: function(){
/**
* 获取本地存储中launchFlag的值
* 若存在,说明不是首次启动,直接进入首页;
* 若不存在,说明是首次启动,进入引导页;
*/
try {
const value = uni.getStorageSync('launchFlag');
console.log('666',value)
if (value) {
if (value == true) {
uni.redirectTo({
url: '/pages/index/index'
});
} else {
uni.redirectTo({
url: '/pages/yindao/guide'
});
}
} else {
uni.setStorage({
key: 'launchFlag',
data: true,
success: function() {
console.log('存储launchFlag');
}
});
uni.redirectTo({
url: '/pages/yindao/guide'
});
}
} catch(e) {
// error
uni.setStorage({
key: 'launchFlag',
data: true,
success: function () {
console.log('error时存储launchFlag');
}
});
uni.redirectTo({ url: '/pages/yindao/guide' });
}
return;
uni.redirectTo({
url: '/pages/index/index'
});
}
}
}
</script>
<style>
</style>