index.vue
9.6 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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<template>
<view class="profile-page">
<!-- User Profile Section -->
<view class="user-profile-section">
<image :src="userInfo.avatar_url || defaultAvatar" class="user-avatar" mode="aspectFill" />
<text class="user-name">{{ userInfo.nickname }}</text>
<text class="user-phone">{{ userInfo.phone }}</text>
<nut-button class="edit-profile-btn" @click="onEditProfile">
编辑资料
</nut-button>
<!-- Stats Row -->
<view class="stats-row">
<view class="stat-item">
<text class="stat-number">{{ userInfo.favorite_count }}</text>
<text class="stat-label">关注</text>
</view>
<view class="stat-item" @click="onOrderManagement">
<text class="stat-number">{{ userInfo.order_count }}</text>
<text class="stat-label">订单</text>
</view>
<view class="stat-item">
<text class="stat-number">{{ userInfo.follower_count }}</text>
<text class="stat-label">被关注</text>
</view>
</view>
</view>
<!-- Quick Actions -->
<view class="quick-actions">
<view class="action-item" @click="onMyFavorites">
<Heart size="22" color="#6b7280" />
<text class="action-text">我的关注</text>
</view>
<view class="action-item" @click="onOrderManagement">
<Clock size="22" color="#6b7280" />
<text class="action-text">我的订单</text>
</view>
</view>
<!-- Menu Items -->
<view class="menu-section">
<view class="menu-item" @click="onMessages">
<Notice size="20" color="#6b7280" />
<text class="menu-text">我的消息</text>
<Right size="18" color="#9ca3af" />
</view>
<view class="menu-item" @click="onMyCar">
<Cart size="20" color="#6b7280" />
<text class="menu-text">我卖的车</text>
<Right size="18" color="#9ca3af" />
</view>
<view class="menu-item" @click="onMyAuthCar">
<StarN size="20" color="#6b7280" />
<text class="menu-text">我的认证</text>
<Right size="18" color="#9ca3af" />
</view>
<view class="menu-item" @click="onCollectionSettings">
<Scan size="20" color="#6b7280" />
<text class="menu-text">收款设置</text>
<Right size="18" color="#9ca3af" />
</view>
<view class="menu-item" @click="onFeedback">
<Message size="20" color="#6b7280" />
<text class="menu-text">意见反馈</text>
<Right size="18" color="#9ca3af" />
</view>
<view class="menu-item" @click="onHelpCenter">
<Tips size="20" color="#6b7280" />
<text class="menu-text">帮助中心</text>
<Right size="18" color="#9ca3af" />
</view>
</view>
<!-- 自定义TabBar -->
<TabBar />
<!-- 隐私政策同意弹框 -->
<PrivacyAgreementModal
v-model:visible="showPrivacyModal"
@confirm="onPrivacyConfirm"
@cancel="onPrivacyCancel"
/>
</view>
</template>
<script setup>
import { computed, ref } from 'vue'
import { Heart, Clock, Notice, Cart, Message, Tips, Right, StarN, Scan } from '@nutui/icons-vue-taro'
import Taro, { useDidShow } from '@tarojs/taro'
import TabBar from '@/components/TabBar.vue'
import PrivacyAgreementModal from '@/components/PrivacyAgreementModal.vue'
import { useUserStore } from '@/stores/user'
// 默认头像
const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg'
// 用户状态管理
const userStore = useUserStore()
// 用户信息计算属性
const userInfo = computed(() => userStore.userInfo)
// 隐私政策弹框状态
const showPrivacyModal = ref(false)
// 隐私政策弹框触发来源('editProfile' 或 'collectionSettings')
const privacyModalSource = ref('editProfile')
useDidShow(async () => {
await userStore.fetchUserInfo()
})
/**
* 编辑个人资料
*/
const onEditProfile = async () => {
// 检查用户是否已完善资料
const hasCompleteProfile = userStore.hasCompleteProfile
if (hasCompleteProfile) {
// 已完善资料,直接进入编辑页面
Taro.navigateTo({
url: '/pages/editProfile/index'
})
} else {
// 未完善资料,显示隐私政策同意弹框
privacyModalSource.value = 'editProfile'
showPrivacyModal.value = true
}
}
/**
* 隐私政策确认
*/
const onPrivacyConfirm = () => {
// 根据触发来源跳转到不同页面
if (privacyModalSource.value === 'editProfile') {
// 从编辑资料触发,跳转到编辑资料页面
Taro.navigateTo({
url: '/pages/editProfile/index'
})
} else if (privacyModalSource.value === 'collectionSettings') {
// 从收款设置触发,跳转到收款设置页面
Taro.navigateTo({
url: '/pages/collectionSettings/index'
})
}
}
/**
* 隐私政策取消
*/
const onPrivacyCancel = () => {
// 用户取消,不做任何操作
}
/**
* 我的关注
*/
const onMyFavorites = async () => {
// const hasPermission = await checkPermission(PERMISSION_TYPES.BASIC_INFO)
// if (hasPermission) {
// }
Taro.navigateTo({
url: '/pages/myFavorites/index'
})
}
/**
* 订单管理
*/
const onOrderManagement = async () => {
// const hasPermission = await checkPermission(PERMISSION_TYPES.ORDER_MANAGEMENT)
// if (hasPermission) {
// }
Taro.navigateTo({
url: '/pages/myOrders/index'
})
}
/**
* 我的消息
*/
const onMessages = async () => {
// const hasPermission = await checkPermission(PERMISSION_TYPES.MESSAGE)
// if (hasPermission) {
// }
Taro.navigateTo({
url: '/pages/messages/index'
})
}
/**
* 我卖的车
*/
const onMyCar = () => {
Taro.navigateTo({
url: '/pages/myCar/index'
})
}
/**
* 帮助中心
*/
const onHelpCenter = () => {
Taro.navigateTo({
url: '/pages/helpCenter/index'
})
}
/**
* 意见反馈
*/
const onFeedback = () => {
Taro.navigateTo({
url: '/pages/feedBackList/index'
})
}
/**
* 收款设置
*/
const onCollectionSettings = async () => {
// 检查用户是否已完善收款信息
const hasCompleteCollectionInfo = userStore.hasCompleteCollectionInfo
if (hasCompleteCollectionInfo) {
// 已完善收款信息,直接进入收款设置页面
Taro.navigateTo({
url: '/pages/collectionSettings/index'
})
} else {
// 未完善收款信息,显示隐私政策同意弹框
privacyModalSource.value = 'collectionSettings'
showPrivacyModal.value = true
}
}
/**
* 我的认证车
*/
const onMyAuthCar = () => {
Taro.navigateTo({
url: '/pages/myAuthCar/index'
})
}
</script>
<style lang="less">
.profile-page {
min-height: 100vh;
background-color: #f8fafc;
padding-bottom: 240rpx;
}
.header {
background: #fb923c;
padding: 64rpx 0 32rpx;
position: relative;
.header-content {
padding: 0 48rpx;
display: flex;
justify-content: space-between;
align-items: center;
.header-title {
font-size: 40rpx;
font-weight: 700;
color: white;
}
}
}
.user-profile-section {
background: white;
padding: 64rpx 48rpx;
margin-bottom: 32rpx;
text-align: center;
.user-avatar {
width: 160rpx;
height: 160rpx;
border-radius: 80rpx;
margin-bottom: 32rpx;
}
.user-name {
font-size: 40rpx;
font-weight: 600;
color: #1e293b;
margin-bottom: 8rpx;
display: block;
}
.user-phone {
font-size: 28rpx;
color: #64748b;
margin-bottom: 40rpx;
display: block;
}
.edit-profile-btn {
background-color: #f1f5f9;
color: #475569;
border: none;
border-radius: 40rpx;
padding: 16rpx 48rpx;
font-size: 28rpx;
margin-bottom: 48rpx;
}
.stats-row {
display: flex;
justify-content: space-around;
.stat-item {
text-align: center;
.stat-number {
font-size: 36rpx;
font-weight: 600;
color: #1e293b;
display: block;
margin-bottom: 8rpx;
}
.stat-label {
font-size: 24rpx;
color: #64748b;
}
}
}
}
.quick-actions {
background: white;
padding: 40rpx 48rpx;
margin-bottom: 32rpx;
display: flex;
justify-content: space-around;
.action-item {
display: flex;
flex-direction: column;
align-items: center;
gap: 16rpx;
.action-text {
font-size: 24rpx;
color: #64748b;
}
}
}
.menu-section {
background: white;
.menu-item {
display: flex;
align-items: center;
padding: 32rpx 48rpx;
border-bottom: 1px solid #f1f5f9;
gap: 32rpx;
&:last-child {
border-bottom: none;
}
.menu-text {
flex: 1;
font-size: 32rpx;
color: #1e293b;
}
}
}
</style>