2026-02-13 17:34:32 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="mobile-container">
|
2026-02-24 16:07:09 +08:00
|
|
|
<div class="header-bg"></div>
|
2026-03-26 10:28:28 +08:00
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
<header class="header">
|
|
|
|
|
<h1>个人中心</h1>
|
|
|
|
|
<a-button class="settings-btn" type="text" @click="handleSettingsClick">
|
|
|
|
|
<SettingOutlined :style="{ fontSize: '20px' }" />
|
|
|
|
|
</a-button>
|
|
|
|
|
</header>
|
2026-03-26 10:28:28 +08:00
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
<div class="profile-info">
|
|
|
|
|
<a-card :bordered="false" class="profile-card">
|
|
|
|
|
<div class="avatar-section">
|
|
|
|
|
<a-badge :dot="hasNotification" :offset="[-5, 5]">
|
2026-02-24 16:07:09 +08:00
|
|
|
<a-avatar :size="90" :src="userInfo.avatar || DEFAULT_AVATAR" class="user-avatar" />
|
2026-02-13 17:34:32 +08:00
|
|
|
</a-badge>
|
|
|
|
|
<div class="user-details">
|
2026-02-24 16:07:09 +08:00
|
|
|
<h2 class="username">{{ userInfo.nickname || '用户' }}</h2>
|
2026-03-26 10:28:28 +08:00
|
|
|
<p class="account">{{ userInfo.account }}</p>
|
2026-02-24 16:07:09 +08:00
|
|
|
<p class="signature" v-if="userInfo.signature">{{ userInfo.signature }}</p>
|
2026-02-13 17:34:32 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-03-26 10:28:28 +08:00
|
|
|
|
|
|
|
|
<div class="shop-card" @click="handleShopCardClick">
|
|
|
|
|
<div class="shop-icon-wrapper">
|
|
|
|
|
<ShopOutlined class="shop-icon" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="shop-content">
|
|
|
|
|
<p class="shop-label">当前登录门店</p>
|
|
|
|
|
<h3 class="shop-name">{{ currentShopName }}</h3>
|
|
|
|
|
<p class="shop-tip">{{ shopSwitchTip }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="shop-arrow">
|
|
|
|
|
<RightOutlined />
|
2026-02-24 16:07:09 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-03-26 10:28:28 +08:00
|
|
|
|
2026-03-03 14:39:02 +08:00
|
|
|
<div v-if="needSetPassword" class="password-tip">
|
|
|
|
|
<a-alert
|
|
|
|
|
type="warning"
|
2026-03-26 10:28:28 +08:00
|
|
|
message="建议尽快设置密码"
|
|
|
|
|
description="你当前更适合使用手机号验证码登录,设置密码后账号会更方便也更安全。"
|
2026-03-03 14:39:02 +08:00
|
|
|
show-icon
|
|
|
|
|
>
|
|
|
|
|
<template #action>
|
|
|
|
|
<a-button size="small" type="primary" @click="handleSetPassword">去设置</a-button>
|
|
|
|
|
</template>
|
|
|
|
|
</a-alert>
|
|
|
|
|
</div>
|
2026-03-26 10:28:28 +08:00
|
|
|
|
2026-02-24 16:07:09 +08:00
|
|
|
<a-button type="primary" block @click="handleEditProfile" class="edit-btn">
|
2026-02-13 17:34:32 +08:00
|
|
|
编辑资料
|
|
|
|
|
</a-button>
|
|
|
|
|
</a-card>
|
|
|
|
|
</div>
|
2026-03-26 10:28:28 +08:00
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
<div class="stats-section">
|
2026-02-24 16:07:09 +08:00
|
|
|
<a-card :bordered="false" class="stats-card">
|
|
|
|
|
<a-row :gutter="16">
|
|
|
|
|
<a-col :span="8">
|
2026-03-26 10:28:28 +08:00
|
|
|
<div class="stat-item" @click="router.push('/orders')">
|
|
|
|
|
<div class="stat-icon orders">
|
2026-02-24 16:07:09 +08:00
|
|
|
<ShoppingOutlined />
|
|
|
|
|
</div>
|
2026-02-27 16:44:41 +08:00
|
|
|
<a-statistic title="订单" :value="orderCount" />
|
2026-02-24 16:07:09 +08:00
|
|
|
</div>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :span="8">
|
2026-03-26 10:28:28 +08:00
|
|
|
<div class="stat-item" @click="router.push('/wishlist')">
|
|
|
|
|
<div class="stat-icon wishlist">
|
2026-02-24 16:07:09 +08:00
|
|
|
<HeartOutlined />
|
|
|
|
|
</div>
|
2026-03-03 17:50:10 +08:00
|
|
|
<a-statistic title="收藏" :value="wishlistCount" />
|
2026-02-24 16:07:09 +08:00
|
|
|
</div>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :span="8">
|
2026-03-26 10:28:28 +08:00
|
|
|
<div class="stat-item" @click="router.push('/coupons')">
|
|
|
|
|
<div class="stat-icon coupons">
|
2026-02-24 16:07:09 +08:00
|
|
|
<CreditCardOutlined />
|
|
|
|
|
</div>
|
2026-02-28 14:32:28 +08:00
|
|
|
<a-statistic title="优惠券" :value="couponCount" />
|
2026-02-24 16:07:09 +08:00
|
|
|
</div>
|
|
|
|
|
</a-col>
|
|
|
|
|
</a-row>
|
|
|
|
|
</a-card>
|
2026-02-13 17:34:32 +08:00
|
|
|
</div>
|
2026-03-26 10:28:28 +08:00
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
<div class="menu-section">
|
|
|
|
|
<a-card :bordered="false" class="menu-card">
|
|
|
|
|
<a-list :data-source="menuItems" :split="false">
|
|
|
|
|
<template #renderItem="{ item }">
|
2026-02-24 16:07:09 +08:00
|
|
|
<a-list-item class="menu-item" @click="handleMenuClick(item.key)">
|
2026-02-13 17:34:32 +08:00
|
|
|
<template #actions>
|
|
|
|
|
<RightOutlined />
|
|
|
|
|
</template>
|
|
|
|
|
<a-list-item-meta>
|
|
|
|
|
<template #avatar>
|
|
|
|
|
<div class="menu-icon" :style="{ backgroundColor: item.bgColor }">
|
|
|
|
|
<component :is="item.icon" />
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template #title>
|
|
|
|
|
<span>{{ item.title }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
<template #description v-if="item.desc">
|
|
|
|
|
<span>{{ item.desc }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</a-list-item-meta>
|
|
|
|
|
</a-list-item>
|
|
|
|
|
</template>
|
|
|
|
|
</a-list>
|
|
|
|
|
</a-card>
|
|
|
|
|
</div>
|
2026-02-27 15:57:14 +08:00
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
<div class="logout-section">
|
|
|
|
|
<a-button danger block @click="handleLogout">
|
|
|
|
|
退出登录
|
|
|
|
|
</a-button>
|
|
|
|
|
</div>
|
2026-03-26 10:28:28 +08:00
|
|
|
|
2026-02-24 16:07:09 +08:00
|
|
|
<a-modal
|
2026-03-26 10:28:28 +08:00
|
|
|
v-model:open="editModalVisible"
|
2026-02-24 16:07:09 +08:00
|
|
|
title="编辑资料"
|
|
|
|
|
@ok="handleSaveProfile"
|
|
|
|
|
@cancel="handleCancelEdit"
|
|
|
|
|
:confirmLoading="saving"
|
|
|
|
|
>
|
|
|
|
|
<a-form layout="vertical">
|
|
|
|
|
<a-form-item label="头像">
|
|
|
|
|
<div class="avatar-upload-section">
|
|
|
|
|
<a-upload
|
|
|
|
|
name="file"
|
|
|
|
|
:show-upload-list="false"
|
|
|
|
|
:before-upload="beforeUploadAvatar"
|
|
|
|
|
:custom-request="handleAvatarUpload"
|
|
|
|
|
accept="image/*"
|
|
|
|
|
>
|
|
|
|
|
<a-avatar :size="80" :src="editForm.avatar || DEFAULT_AVATAR" />
|
|
|
|
|
<div class="upload-hint">点击更换头像</div>
|
|
|
|
|
</a-upload>
|
|
|
|
|
<a-button v-if="editForm.avatar" type="text" danger size="small" @click="handleDeleteAvatar">
|
|
|
|
|
删除头像
|
|
|
|
|
</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item label="昵称">
|
|
|
|
|
<a-input v-model:value="editForm.nickname" placeholder="请输入昵称" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item label="个性签名">
|
|
|
|
|
<a-textarea v-model:value="editForm.signature" placeholder="请输入个性签名" :rows="3" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-form>
|
|
|
|
|
</a-modal>
|
2026-03-26 10:28:28 +08:00
|
|
|
|
|
|
|
|
<a-modal
|
|
|
|
|
v-model:open="shopSwitchVisible"
|
|
|
|
|
title="切换登录门店"
|
|
|
|
|
:confirm-loading="shopSwitchLoading"
|
|
|
|
|
@ok="handleConfirmSwitchShop"
|
|
|
|
|
>
|
|
|
|
|
<a-radio-group v-model:value="selectedShopId" class="shop-option-group">
|
|
|
|
|
<a-radio
|
|
|
|
|
v-for="shop in shopOptions"
|
|
|
|
|
:key="String(shop.id)"
|
|
|
|
|
:value="String(shop.id)"
|
|
|
|
|
class="shop-option"
|
|
|
|
|
>
|
|
|
|
|
<div class="shop-option-name">{{ shop.shopName }}</div>
|
|
|
|
|
</a-radio>
|
|
|
|
|
</a-radio-group>
|
|
|
|
|
<a-empty v-if="!shopOptions.length" description="当前账号没有可切换的门店" />
|
|
|
|
|
</a-modal>
|
2026-02-13 17:34:32 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-03-26 10:28:28 +08:00
|
|
|
import { computed, onMounted, reactive, ref } from 'vue'
|
2026-02-13 17:34:32 +08:00
|
|
|
import { useRouter } from 'vue-router'
|
2026-02-24 16:07:09 +08:00
|
|
|
import {
|
2026-02-13 17:34:32 +08:00
|
|
|
BellOutlined,
|
2026-03-26 10:28:28 +08:00
|
|
|
CreditCardOutlined,
|
|
|
|
|
HeartOutlined,
|
2026-02-24 16:07:09 +08:00
|
|
|
QuestionCircleOutlined,
|
2026-03-26 10:28:28 +08:00
|
|
|
RightOutlined,
|
|
|
|
|
SettingOutlined,
|
|
|
|
|
ShopOutlined,
|
|
|
|
|
ShoppingOutlined
|
2026-02-13 17:34:32 +08:00
|
|
|
} from '@ant-design/icons-vue'
|
2026-02-25 09:13:45 +08:00
|
|
|
import { message, Modal } from 'ant-design-vue'
|
|
|
|
|
import type { UploadProps } from 'ant-design-vue'
|
2026-02-24 14:12:27 +08:00
|
|
|
import { authApi } from '@/api/auth'
|
2026-03-26 10:28:28 +08:00
|
|
|
import { couponApi } from '@/api/coupon'
|
2026-02-24 16:07:09 +08:00
|
|
|
import { fileApi } from '@/api/file'
|
2026-02-27 15:57:14 +08:00
|
|
|
import { orderApi } from '@/api/order'
|
2026-03-26 10:28:28 +08:00
|
|
|
import { userApi, type UserVO } from '@/api/user'
|
2026-03-03 17:50:10 +08:00
|
|
|
import { wishlistApi } from '@/api/wishlist'
|
2026-02-24 16:07:09 +08:00
|
|
|
import { DEFAULT_AVATAR } from '@/constants'
|
2026-02-13 17:34:32 +08:00
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
2026-02-24 16:07:09 +08:00
|
|
|
const userInfo = ref<UserVO>({
|
|
|
|
|
id: 0,
|
|
|
|
|
nickname: '',
|
|
|
|
|
account: '',
|
2026-03-02 10:13:20 +08:00
|
|
|
avatar: '',
|
|
|
|
|
type: 0,
|
|
|
|
|
status: 0,
|
2026-02-24 16:07:09 +08:00
|
|
|
createTime: '',
|
|
|
|
|
updateTime: ''
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const editModalVisible = ref(false)
|
|
|
|
|
const saving = ref(false)
|
2026-03-26 10:28:28 +08:00
|
|
|
const needSetPassword = ref(false)
|
|
|
|
|
const hasNotification = ref(false)
|
2026-02-27 16:44:41 +08:00
|
|
|
const orderCount = ref(0)
|
2026-02-28 14:32:28 +08:00
|
|
|
const couponCount = ref(0)
|
2026-03-03 17:50:10 +08:00
|
|
|
const wishlistCount = ref(0)
|
2026-03-26 10:28:28 +08:00
|
|
|
const shopSwitchVisible = ref(false)
|
|
|
|
|
const shopSwitchLoading = ref(false)
|
|
|
|
|
const selectedShopId = ref<string>()
|
2026-02-27 15:57:14 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const editForm = reactive({
|
2026-02-24 16:07:09 +08:00
|
|
|
nickname: '',
|
|
|
|
|
avatar: '',
|
|
|
|
|
signature: ''
|
|
|
|
|
})
|
2026-02-13 17:34:32 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const shopOptions = computed(() => {
|
|
|
|
|
const ids = userInfo.value.shopIds || []
|
|
|
|
|
const names = userInfo.value.shopNames || []
|
|
|
|
|
return ids.map((id, index) => ({
|
|
|
|
|
id,
|
|
|
|
|
shopName: names[index] || `门店 ${id}`
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const currentShopName = computed(() => userInfo.value.shopName || '暂未选择门店')
|
|
|
|
|
const shopSwitchTip = computed(() => {
|
|
|
|
|
if (shopOptions.value.length > 1) {
|
|
|
|
|
return `可切换 ${shopOptions.value.length} 家门店`
|
|
|
|
|
}
|
|
|
|
|
if (shopOptions.value.length === 1) {
|
|
|
|
|
return '点击查看当前门店详情'
|
|
|
|
|
}
|
|
|
|
|
return '当前账号暂无可切换门店'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const menuItems = [
|
2026-02-24 16:07:09 +08:00
|
|
|
{
|
|
|
|
|
key: 'orders',
|
|
|
|
|
title: '我的订单',
|
2026-03-26 10:28:28 +08:00
|
|
|
desc: '查看预约状态、取消订单',
|
2026-02-13 17:34:32 +08:00
|
|
|
icon: ShoppingOutlined,
|
|
|
|
|
bgColor: '#e6f7ff'
|
|
|
|
|
},
|
2026-02-24 16:07:09 +08:00
|
|
|
{
|
|
|
|
|
key: 'wishlist',
|
|
|
|
|
title: '我的收藏',
|
2026-03-26 10:28:28 +08:00
|
|
|
desc: '快速回到喜欢的作品',
|
2026-02-13 17:34:32 +08:00
|
|
|
icon: HeartOutlined,
|
|
|
|
|
bgColor: '#fff1f0'
|
|
|
|
|
},
|
2026-02-24 16:07:09 +08:00
|
|
|
{
|
2026-03-26 10:28:28 +08:00
|
|
|
key: 'coupons',
|
|
|
|
|
title: '我的优惠券',
|
|
|
|
|
desc: '查看可用优惠和 VIP 折扣',
|
2026-02-13 17:34:32 +08:00
|
|
|
icon: CreditCardOutlined,
|
|
|
|
|
bgColor: '#fff7e6'
|
|
|
|
|
},
|
2026-02-24 16:07:09 +08:00
|
|
|
{
|
|
|
|
|
key: 'notifications',
|
|
|
|
|
title: '消息通知',
|
2026-03-26 10:28:28 +08:00
|
|
|
desc: '消息中心功能开发中',
|
2026-02-13 17:34:32 +08:00
|
|
|
icon: BellOutlined,
|
|
|
|
|
bgColor: '#f9f0ff'
|
|
|
|
|
},
|
2026-02-24 16:07:09 +08:00
|
|
|
{
|
|
|
|
|
key: 'help',
|
|
|
|
|
title: '帮助与支持',
|
2026-03-26 10:28:28 +08:00
|
|
|
desc: '常见问题功能开发中',
|
2026-02-13 17:34:32 +08:00
|
|
|
icon: QuestionCircleOutlined,
|
2026-03-26 10:28:28 +08:00
|
|
|
bgColor: '#eef9ff'
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-03-26 10:28:28 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const persistUserSession = (payload: any) => {
|
|
|
|
|
localStorage.setItem('accessToken', payload.accessToken)
|
|
|
|
|
localStorage.setItem('refreshToken', payload.refreshToken)
|
|
|
|
|
localStorage.setItem('userInfo', JSON.stringify(payload.userInfo))
|
|
|
|
|
sessionStorage.setItem('accessToken', payload.accessToken)
|
|
|
|
|
if (payload.needSetPassword) {
|
|
|
|
|
localStorage.setItem('needSetPassword', 'true')
|
|
|
|
|
} else {
|
|
|
|
|
localStorage.removeItem('needSetPassword')
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-13 17:34:32 +08:00
|
|
|
|
2026-02-24 16:07:09 +08:00
|
|
|
const fetchUserInfo = async () => {
|
|
|
|
|
try {
|
2026-03-26 10:28:28 +08:00
|
|
|
const response = await userApi.getUserInfo()
|
2026-03-02 10:13:20 +08:00
|
|
|
userInfo.value = response
|
2026-03-03 14:39:02 +08:00
|
|
|
needSetPassword.value = localStorage.getItem('needSetPassword') === 'true'
|
2026-03-26 10:28:28 +08:00
|
|
|
selectedShopId.value = response.shopId ? String(response.shopId) : undefined
|
2026-02-24 16:07:09 +08:00
|
|
|
} catch (error) {
|
2026-03-26 10:28:28 +08:00
|
|
|
console.error('获取用户信息失败:', error)
|
2026-02-24 16:07:09 +08:00
|
|
|
message.error('获取用户信息失败')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const loadCounts = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const [orders, coupons, wishlist] = await Promise.all([
|
|
|
|
|
orderApi.getOrderList(),
|
|
|
|
|
couponApi.listUserCoupons(),
|
|
|
|
|
wishlistApi.getWishlist()
|
|
|
|
|
])
|
|
|
|
|
orderCount.value = Array.isArray(orders) ? orders.length : 0
|
|
|
|
|
couponCount.value = Array.isArray(coupons) ? coupons.length : 0
|
|
|
|
|
wishlistCount.value = Array.isArray(wishlist) ? wishlist.length : 0
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('加载个人中心统计失败:', error)
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
2026-03-26 10:28:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleEditProfile = () => {
|
|
|
|
|
editForm.nickname = userInfo.value.nickname || ''
|
|
|
|
|
editForm.avatar = userInfo.value.avatar || ''
|
|
|
|
|
editForm.signature = userInfo.value.signature || ''
|
2026-02-24 16:07:09 +08:00
|
|
|
editModalVisible.value = true
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const beforeUploadAvatar: UploadProps['beforeUpload'] = file => {
|
2026-02-24 16:07:09 +08:00
|
|
|
const isImage = file.type.startsWith('image/')
|
2026-02-27 11:05:15 +08:00
|
|
|
const isLt20M = file.size / 1024 / 1024 < 20
|
2026-02-24 16:07:09 +08:00
|
|
|
|
|
|
|
|
if (!isImage) {
|
2026-03-26 10:28:28 +08:00
|
|
|
message.error('只能上传图片文件')
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
2026-02-27 11:05:15 +08:00
|
|
|
if (!isLt20M) {
|
2026-03-26 10:28:28 +08:00
|
|
|
message.error('图片大小不能超过 20MB')
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
2026-02-27 11:05:15 +08:00
|
|
|
return isImage && isLt20M
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleAvatarUpload = async (options: any) => {
|
|
|
|
|
const { file } = options
|
|
|
|
|
try {
|
|
|
|
|
const res = await fileApi.uploadAvatar(file)
|
2026-03-26 10:28:28 +08:00
|
|
|
editForm.avatar = res as unknown as string
|
2026-02-24 16:07:09 +08:00
|
|
|
message.success('头像上传成功')
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('头像上传失败:', error)
|
|
|
|
|
message.error('头像上传失败')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDeleteAvatar = () => {
|
|
|
|
|
Modal.confirm({
|
2026-03-26 10:28:28 +08:00
|
|
|
title: '确认删除头像',
|
|
|
|
|
content: '删除后会恢复为默认头像。',
|
|
|
|
|
okText: '确认',
|
|
|
|
|
cancelText: '取消',
|
2026-02-25 09:13:45 +08:00
|
|
|
onOk: async () => {
|
2026-03-26 10:28:28 +08:00
|
|
|
editForm.avatar = ''
|
2026-02-25 09:13:45 +08:00
|
|
|
try {
|
|
|
|
|
await userApi.updateUserInfo({ avatar: '' })
|
2026-03-26 10:28:28 +08:00
|
|
|
userInfo.value.avatar = ''
|
2026-02-25 09:13:45 +08:00
|
|
|
message.success('头像删除成功')
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('删除头像失败:', error)
|
|
|
|
|
message.error('删除头像失败')
|
|
|
|
|
}
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSaveProfile = async () => {
|
2026-03-26 10:28:28 +08:00
|
|
|
if (!editForm.nickname.trim()) {
|
2026-02-24 16:07:09 +08:00
|
|
|
message.error('请输入昵称')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saving.value = true
|
|
|
|
|
try {
|
2026-03-26 10:28:28 +08:00
|
|
|
await userApi.updateUserInfo({
|
|
|
|
|
nickname: editForm.nickname,
|
|
|
|
|
avatar: editForm.avatar,
|
|
|
|
|
signature: editForm.signature
|
|
|
|
|
})
|
2026-02-24 16:07:09 +08:00
|
|
|
message.success('资料更新成功')
|
|
|
|
|
editModalVisible.value = false
|
|
|
|
|
await fetchUserInfo()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('保存资料失败:', error)
|
|
|
|
|
message.error('保存资料失败')
|
|
|
|
|
} finally {
|
|
|
|
|
saving.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleCancelEdit = () => {
|
|
|
|
|
editModalVisible.value = false
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const handleShopCardClick = () => {
|
|
|
|
|
if (shopOptions.value.length > 1) {
|
|
|
|
|
shopSwitchVisible.value = true
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (userInfo.value.shopId) {
|
|
|
|
|
router.push(`/shop/${userInfo.value.shopId}`)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
message.info('当前账号还没有可用门店')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleConfirmSwitchShop = async () => {
|
|
|
|
|
if (!selectedShopId.value) {
|
|
|
|
|
message.warning('请选择要切换的门店')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (String(userInfo.value.shopId || '') === selectedShopId.value) {
|
|
|
|
|
shopSwitchVisible.value = false
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shopSwitchLoading.value = true
|
2026-02-27 15:57:14 +08:00
|
|
|
try {
|
2026-03-26 10:28:28 +08:00
|
|
|
const response = await authApi.switchShop({ shopId: selectedShopId.value })
|
|
|
|
|
persistUserSession(response as any)
|
|
|
|
|
message.success('门店已切换')
|
|
|
|
|
shopSwitchVisible.value = false
|
|
|
|
|
await Promise.all([fetchUserInfo(), loadCounts()])
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
console.error('切换门店失败:', error)
|
|
|
|
|
message.error(error?.message || '切换门店失败')
|
2026-02-27 15:57:14 +08:00
|
|
|
} finally {
|
2026-03-26 10:28:28 +08:00
|
|
|
shopSwitchLoading.value = false
|
2026-02-27 15:57:14 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
const handleMenuClick = (key: string) => {
|
2026-03-26 10:28:28 +08:00
|
|
|
if (key === 'orders') {
|
2026-02-27 15:57:14 +08:00
|
|
|
router.push('/orders')
|
2026-03-26 10:28:28 +08:00
|
|
|
} else if (key === 'wishlist') {
|
|
|
|
|
router.push('/wishlist')
|
2026-02-27 15:57:14 +08:00
|
|
|
} else if (key === 'coupons') {
|
2026-02-28 15:45:16 +08:00
|
|
|
router.push('/coupons')
|
2026-02-13 17:34:32 +08:00
|
|
|
} else if (key === 'notifications') {
|
2026-03-26 10:28:28 +08:00
|
|
|
message.info('消息通知功能开发中')
|
2026-02-13 17:34:32 +08:00
|
|
|
} else if (key === 'help') {
|
2026-03-26 10:28:28 +08:00
|
|
|
message.info('帮助中心功能开发中')
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleLogout = () => {
|
2026-02-24 14:12:27 +08:00
|
|
|
Modal.confirm({
|
|
|
|
|
title: '确认退出登录',
|
2026-03-26 10:28:28 +08:00
|
|
|
content: '退出后需要重新登录才能继续下单和查看订单。',
|
2026-03-21 14:33:33 +08:00
|
|
|
okText: '确认',
|
2026-02-24 14:12:27 +08:00
|
|
|
cancelText: '取消',
|
|
|
|
|
onOk: async () => {
|
|
|
|
|
try {
|
|
|
|
|
await authApi.logout()
|
|
|
|
|
} catch (error) {
|
2026-03-26 10:28:28 +08:00
|
|
|
console.error('退出登录接口调用失败:', error)
|
2026-02-24 14:12:27 +08:00
|
|
|
} finally {
|
|
|
|
|
localStorage.removeItem('accessToken')
|
|
|
|
|
localStorage.removeItem('refreshToken')
|
2026-03-03 14:39:02 +08:00
|
|
|
localStorage.removeItem('userInfo')
|
|
|
|
|
localStorage.removeItem('needSetPassword')
|
2026-02-24 14:12:27 +08:00
|
|
|
sessionStorage.removeItem('accessToken')
|
|
|
|
|
message.success('已退出登录')
|
2026-02-27 22:20:25 +08:00
|
|
|
router.push('/')
|
2026-02-24 14:12:27 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSettingsClick = () => {
|
|
|
|
|
router.push('/settings')
|
|
|
|
|
}
|
2026-02-24 16:07:09 +08:00
|
|
|
|
2026-03-03 14:39:02 +08:00
|
|
|
const handleSetPassword = () => {
|
|
|
|
|
router.push('/settings/password')
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
onMounted(async () => {
|
|
|
|
|
await Promise.all([fetchUserInfo(), loadCounts()])
|
2026-02-24 16:07:09 +08:00
|
|
|
})
|
2026-02-13 17:34:32 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.mobile-container {
|
|
|
|
|
padding-top: 60px;
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
background: #f5f5f5;
|
2026-02-24 16:07:09 +08:00
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.header-bg {
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
2026-03-26 10:28:28 +08:00
|
|
|
height: 200px;
|
|
|
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 45%, #f093fb 100%);
|
2026-02-24 16:07:09 +08:00
|
|
|
z-index: 0;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.header {
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
z-index: 100;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 10px 15px;
|
2026-02-24 16:07:09 +08:00
|
|
|
color: white;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.header h1 {
|
|
|
|
|
margin: 0;
|
2026-03-26 10:28:28 +08:00
|
|
|
font-size: 18px;
|
|
|
|
|
font-weight: 700;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.settings-btn {
|
2026-02-24 16:07:09 +08:00
|
|
|
color: white;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.profile-info,
|
|
|
|
|
.stats-section,
|
|
|
|
|
.menu-section,
|
|
|
|
|
.logout-section {
|
2026-02-24 16:07:09 +08:00
|
|
|
position: relative;
|
|
|
|
|
z-index: 1;
|
2026-03-26 10:28:28 +08:00
|
|
|
padding: 0 15px 15px;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.profile-info {
|
|
|
|
|
padding-top: 15px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.profile-card,
|
|
|
|
|
.stats-card,
|
|
|
|
|
.menu-card {
|
|
|
|
|
border-radius: 22px;
|
|
|
|
|
box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.profile-card :deep(.ant-card-body) {
|
2026-02-24 16:07:09 +08:00
|
|
|
padding: 28px 24px 24px;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.avatar-section {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2026-02-24 16:07:09 +08:00
|
|
|
gap: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.user-avatar {
|
|
|
|
|
border: 4px solid white;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.username {
|
2026-03-26 10:28:28 +08:00
|
|
|
margin: 0 0 6px;
|
2026-02-24 16:07:09 +08:00
|
|
|
font-size: 24px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
color: #1a1a2e;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.account,
|
2026-02-24 16:07:09 +08:00
|
|
|
.signature {
|
2026-02-13 17:34:32 +08:00
|
|
|
margin: 0;
|
2026-03-26 10:28:28 +08:00
|
|
|
color: #7c7c8a;
|
|
|
|
|
line-height: 1.7;
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-card {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 14px;
|
2026-03-26 10:28:28 +08:00
|
|
|
margin-top: 24px;
|
2026-02-24 16:07:09 +08:00
|
|
|
padding: 18px;
|
2026-03-26 10:28:28 +08:00
|
|
|
border-radius: 18px;
|
2026-02-24 16:07:09 +08:00
|
|
|
background: linear-gradient(135deg, #f5f7ff 0%, #e8ecff 100%);
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-icon-wrapper {
|
|
|
|
|
width: 52px;
|
|
|
|
|
height: 52px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
2026-03-26 10:28:28 +08:00
|
|
|
border-radius: 14px;
|
|
|
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-icon {
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
color: white;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-content {
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-label {
|
2026-03-26 10:28:28 +08:00
|
|
|
margin: 0 0 4px;
|
2026-02-24 16:07:09 +08:00
|
|
|
font-size: 12px;
|
|
|
|
|
color: #8b8b9a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-name {
|
|
|
|
|
margin: 0;
|
2026-03-26 10:28:28 +08:00
|
|
|
font-size: 18px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
color: #1a1a2e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-tip {
|
|
|
|
|
margin: 6px 0 0;
|
|
|
|
|
color: #6b6b7a;
|
|
|
|
|
font-size: 13px;
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-arrow {
|
|
|
|
|
color: #c4c4d0;
|
2026-03-26 10:28:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.password-tip {
|
|
|
|
|
margin-top: 20px;
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.edit-btn {
|
2026-03-26 10:28:28 +08:00
|
|
|
margin-top: 20px;
|
2026-02-24 16:07:09 +08:00
|
|
|
height: 48px;
|
2026-03-26 10:28:28 +08:00
|
|
|
border-radius: 14px;
|
2026-02-24 16:07:09 +08:00
|
|
|
font-size: 15px;
|
2026-03-26 10:28:28 +08:00
|
|
|
font-weight: 700;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stats-card :deep(.ant-card-body) {
|
|
|
|
|
padding: 20px 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-item {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-icon {
|
|
|
|
|
width: 52px;
|
|
|
|
|
height: 52px;
|
|
|
|
|
border-radius: 16px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
color: white;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-icon.orders {
|
2026-02-24 16:07:09 +08:00
|
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
2026-03-26 10:28:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-icon.wishlist {
|
|
|
|
|
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-icon.coupons {
|
|
|
|
|
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu-card :deep(.ant-card-body) {
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu-item {
|
|
|
|
|
padding: 18px 16px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
border-bottom: 1px solid #f5f5f7;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu-item:last-child {
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu-icon {
|
|
|
|
|
width: 44px;
|
|
|
|
|
height: 44px;
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
color: white;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logout-section :deep(.ant-btn-dangerous) {
|
|
|
|
|
height: 50px;
|
|
|
|
|
border-radius: 25px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
font-size: 16px;
|
2026-02-24 16:07:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.avatar-upload-section {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.upload-hint {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #667eea;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.shop-option-group {
|
2026-02-24 16:07:09 +08:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
2026-02-27 15:57:14 +08:00
|
|
|
gap: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.shop-option {
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 12px 14px;
|
|
|
|
|
border: 1px solid #e8ecff;
|
|
|
|
|
border-radius: 14px;
|
2026-02-27 15:57:14 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.shop-option-name {
|
2026-02-27 15:57:14 +08:00
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
2026-03-24 09:50:55 +08:00
|
|
|
|
2026-03-24 09:59:52 +08:00
|
|
|
@media (min-width: 992px) {
|
|
|
|
|
.profile-info,
|
|
|
|
|
.stats-section,
|
|
|
|
|
.menu-section,
|
2026-03-26 10:28:28 +08:00
|
|
|
.logout-section {
|
|
|
|
|
max-width: var(--frontend-content-max-width);
|
2026-03-24 09:59:52 +08:00
|
|
|
margin-left: auto;
|
|
|
|
|
margin-right: auto;
|
|
|
|
|
}
|
2026-03-24 09:50:55 +08:00
|
|
|
}
|
2026-03-21 14:33:33 +08:00
|
|
|
</style>
|