wangzhibo
2025-10-23 cad64c1de2c45856b0774933c5801b05b64984e8
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
<template>
    <view class="center">
        <view class="userInfo" @click="gotoSetting">
            <view v-if="userStore.username">
                <image :src="userStore.avatarUrl"
                    class="w-16 h-16 rounded-full" />
                <view class="center">
                    <text class="uer-name">{{ userStore.username }}</text>
                </view>
            </view>
            <view v-else>
                <image :src="defaultAvatar" class="w-16 h-16 rounded-full" />
                <view class="center">
                    <text class="uer-name">未登录</text>
                </view>
            </view>
 
        </view>
        <uni-list class="center-list">
            <uni-list-item :title="ucenterList[0].title" link clickable=true :to="ucenterList[0].to" show-extra-icon="true"
                :extraIcon="{type:ucenterList[0].icon,color:'#999'}">
            </uni-list-item>
            <uni-list-item :title="ucenterList[1].title" link clickable=true :to="ucenterList[1].to" show-extra-icon="true"
                :extraIcon="{type:ucenterList[1].icon,color:'#999'}">
            </uni-list-item>
            <uni-list-item :title="ucenterList[2].title" link clickable=true :to="ucenterList[2].to" show-extra-icon="true"
                :extraIcon="{type:ucenterList[2].icon,color:'#999'}">
            </uni-list-item>
            <uni-list-item :title="ucenterList[3].title" link clickable=true @click="callServiceNumber" show-extra-icon="true"
                :extraIcon="{type:ucenterList[3].icon,color:'#999'}">
            </uni-list-item>
        <!--</uni-list>
        <uni-list class="center-list">-->
            <uni-list-item :title="ucenterList[4].title" link clickable=true @click="gotoSetting" show-extra-icon="true"
                :extraIcon="{type:ucenterList[4].icon,color:'#999'}">
            </uni-list-item>
        </uni-list>
    </view>
</template>
 
<script setup>
    import {
        useUserStore
    } from '@/stores/user'
 
    const userStore = useUserStore()
 
    const defaultAvatar = "https://farm.evcc.top/Uploads/yuanboyuan/avatars/user.png"
    const ucenterList = [{
            "title": '我的预约',
            "to": '/pages/ucenter/my-booking',
            "icon": "compose"
        },
        {
            "title": '我的投诉建议',
            "to": '/pages/ucenter/my-advice',
            "icon": "compose"
        },
        {
            "title": 'WIFI服务',
            "to": '/pages/index/wifi',
            "icon": "star"
        },
        {
            "title": '咨询电话',
            "event": 'callServiceNumber',
            "icon": "flag"
        },
        {
            "title": '设置',
            "to": '/pages/ucenter/settings',
            "icon": "settings"
        }
    ];
 
    function callServiceNumber() {
        uni.makePhoneCall({
            phoneNumber: "0724-6033555"
        });
    }
 
    function gotoSetting() {
        uni.navigateTo({
            url: '/pages/ucenter/settings'
        })
    }
    /**
     * 个人中心项目列表点击事件
     */
    function ucenterListClick(item) {
        if (!item.to && item.event) {
            this[item.event]();
        }
    }
</script>
 
<style>
    /* 居中容器 */
    .center {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
 
    /* 用户信息 */
    .userInfo {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 1rem;
        cursor: pointer;
    }
 
    /* 头像 */
    .w-16 {
        width: 4rem;
    }
 
    .h-16 {
        height: 4rem;
    }
 
    .rounded-full {
        border-radius: 9999px;
    }
 
    /* 用户名 */
    .uer-name {
        margin-top: 0.5rem;
        font-size: 1rem;
        color: #000000;
    }
 
    /* 列表容器 */
    .center-list {
        width: 100%;
        margin-top: 1rem;
    }
 
    /* uni-list-item 内 footer 自定义 */
    .item-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 0.5rem;
    }
 
    .item-footer-text {
        font-size: 0.875rem;
        color: #666666;
    }
 
    .item-footer-badge {
        width: 0.75rem;
        height: 0.75rem;
        background-color: red;
        border-radius: 50%;
    }
</style>