rk
4 天以前 cf1d82548a1bd8155ffe9b486df8167aa9e63a7d
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<template>
    <view class="profile-page">
        <view class="profile-header">
            <image class="avatar" src="/static/images/ic_pic@2x.png" mode="aspectFill"></image>
            <view class="profile-info">
                <view class="profile-name">{{ displayName }}</view>
                <view class="profile-mobile">{{ displayMobile }}</view>
            </view>
        </view>
 
        <view class="menu-card">
            <view class="menu-item" v-for="item in menuList" :key="item.id" @click="handleMenu(item)">
                <view class="menu-text">{{ item.name }}</view>
                <image class="menu-arrow" src="/static/icon/ar_detail@2x.png" mode="aspectFit"></image>
            </view>
        </view>
 
        <view class="logout-btn" @click="logout">退出登录</view>
    </view>
</template>
 
<script>
    import { mapState } from 'vuex'
 
    export default {
        computed: {
            ...mapState(['userInfo']),
            displayName() {
                return this.userInfo.nickName || this.userInfo.nickname || this.userInfo.name || '未登录用户'
            },
            displayMobile() {
                const mobile = this.userInfo.mobile || ''
                if (!mobile) {
                    return '请先绑定手机号'
                }
                return mobile.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
            }
        },
        data() {
            return {
                menuList: [
                    { id: 1, name: '结算退押金' },
                    { id: 2, name: '消费明细', url: '/pages/consumptionDetails/consumptionDetails' },
                    { id: 3, name: '车辆计价规则', url: '/pages/pricingRules/pricingRules' },
                    { id: 4, name: '抖音兑换说明' },
                    { id: 5, name: '联系客服' },
                    { id: 6, name: '运营中心' }
                ]
            }
        },
        methods: {
            handleMenu(item) {
                if (item.url) {
                    uni.navigateTo({
                        url: item.url
                    })
                    return
                }
 
                if (item.id === 1) {
                    uni.showToast({
                        title: '请在首页发起退押金',
                        icon: 'none'
                    })
                    return
                }
 
                if (item.id === 4) {
                    uni.showToast({
                        title: '兑换说明暂未配置',
                        icon: 'none'
                    })
                    return
                }
 
                if (item.id === 5) {
                    uni.showToast({
                        title: '暂未配置客服电话',
                        icon: 'none'
                    })
                    return
                }
 
                if (item.id === 6) {
                    uni.navigateTo({
                        url: this.userInfo.sysuser ? '/pages/operationsCenter/operationsCenter' : '/pages/operationLogin/operationLogin'
                    })
                }
            },
            logout() {
                uni.showLoading({ title: '加载中' })
                this.$u.api.logout()
                    .then(res => {
                        uni.hideLoading()
                        if (res.code === 200) {
                            this.$store.commit('setUserInfo', res.data)
                            this.$store.commit('setToken', '')
                            uni.reLaunch({
                                url: '/pages/index/index'
                            })
                        }
                    })
                    .catch(() => {
                        uni.hideLoading()
                        uni.showToast({
                            title: '退出失败,请稍后重试',
                            icon: 'none'
                        })
                    })
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .profile-page {
        width: 100%;
        min-height: 100vh;
        padding: 30rpx;
        box-sizing: border-box;
        background: #ffffff;
    }
 
    .profile-header {
        display: flex;
        align-items: center;
        padding-top: 6rpx;
    }
 
    .avatar {
        width: 92rpx;
        height: 92rpx;
        border-radius: 46rpx;
        flex-shrink: 0;
    }
 
    .profile-info {
        margin-left: 20rpx;
        min-width: 0;
    }
 
    .profile-name {
        font-weight: 600;
        font-size: 36rpx;
        color: #222222;
    }
 
    .profile-mobile {
        margin-top: 10rpx;
        font-weight: 400;
        font-size: 26rpx;
        color: #666666;
    }
 
    .menu-card {
        margin-top: 62rpx;
        background: #F8F9FB;
        border-radius: 24rpx;
        overflow: hidden;
    }
 
    .menu-item {
        height: 106rpx;
        padding: 0 28rpx 0 30rpx;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 2rpx solid #E5E5E5;
 
        &:last-child {
            border-bottom: 0;
        }
    }
 
    .menu-text {
        font-weight: 500;
        font-size: 30rpx;
        color: #222222;
    }
 
    .menu-arrow {
        width: 30rpx;
        height: 30rpx;
        flex-shrink: 0;
    }
 
    .logout-btn {
        width: 200rpx;
        height: 72rpx;
        margin: 70rpx auto 0;
        border-radius: 36rpx;
        border: 1rpx solid #999999;
        font-weight: 400;
        font-size: 28rpx;
        color: #333333;
        line-height: 72rpx;
        text-align: center;
        box-sizing: border-box;
        background: #ffffff;
    }
</style>