index.vue
3.05 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
<template>
<view class="mine-index">
<template v-if="!is_login">
<view class="not-logged-in row verCenter" @click="toUrl">
<view class="row verCenter">
<image class="uni-img" src="http://img.ichunt.com/images/ichunt/minProgram/scm/14ec21333cd69cc5269772811b46b7ac.png" mode="aspectFill"></image>
<view class="text column"><text class="t1">未登录</text></view>
</view>
</view>
</template>
<template v-else>
<view class="logged-in row bothSide verCenter">
<view class="row verCenter">
<image class="uni-img" src="http://img.ichunt.com/images/ichunt/minProgram/scm/14ec21333cd69cc5269772811b46b7ac.png" mode="aspectFill"></image>
<view class="text column">
<text class="t1">{{ userInfo.name }}</text>
<text class="t2">{{ userInfo.email }}</text>
</view>
</view>
</view>
<view class="list column"></view>
<view class="exit row rowCenter verCenter" @click="exit()">退出账号</view>
</template>
</view>
</template>
<script>
import { API } from '@/util/api.js';
export default {
data() {
return {
is_login: false,
userInfo: {}
};
},
onShow() {
this.getData();
},
methods: {
getData() {
this.request(API.userInfo, 'POST', {}, false).then(res => {
if (res.err_code === 0) {
this.userInfo = res.data;
this.is_login = true;
} else {
this.is_login = false;
}
});
},
toUrl() {
// #ifdef MP-WEIXIN
uni.navigateTo({
url: '/pages/mine/auth'
});
// #endif
// #ifdef APP-PLUS
uni.navigateTo({
url: '/pages/mine/login'
});
// #endif
},
exit() {
uni.showModal({
title: '提示',
content: '您确定退出系统嘛',
success: res => {
if (res.confirm) {
this.request(API.unBindUserInfo, 'POST', {}, true).then(res => {});
uni.removeStorageSync('token');
uni.removeStorageSync('email');
uni.switchTab({
url: '/pages/home/index'
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
}
};
</script>
<style lang="scss">
@import '../../assets/css/mine/index.scss';
</style>