setting.vue
1.78 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<template>
<view>
<view class="setting-content">
<uni-list>
<uni-list-item title="关于我们" clickable @click="toAboutOur" showArrow></uni-list-item>
<uni-list-item title="清除缓存" clickable @click="cleanStorage" ></uni-list-item>
</uni-list>
<view class="uni-padding-wrap uni-common-mt">
<button type="warn" @click="loginOutAlert">退出登录</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
toAboutOur() {
uni.navigateTo({
url: '../aboutOur/aboutOur'
});
},
cleanStorage() {
uni.clearStorageSync();
uni.showToast({
title: "清理缓存成功",
mask: false,
duration:2000
})
},
loginOutAlert(){
let that = this;
uni.showModal({
title:'提示',
content:'是否确定退出登录?',
success: (res) => {
if(res.confirm){
that.loginOut();
}else if(res.cancel){
console.log('用户点击取消')
}
}
})
},
loginOut(){
let that = this;
that.$myRequest({
url: that.$common.userLoginout,
method: 'POST',
data: that.$common.requestSign()
}).then(res => {
// 获取真实数据之前,务必判断状态是否为200
console.log('退出:' + JSON.stringify(res));
if (res.code == 0) {
uni.clearStorageSync();
uni.reLaunch({
url: "../index/index"
})
uni.hideLoading();
} else {
uni.clearStorageSync();
uni.reLaunch({
url: "../index/index"
})
uni.hideLoading();
}
})
}
}
}
</script>
<style lang="scss">
.setting-content {
background-color: #f6f6f6;
height: 100vh;
}
</style>