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="建议尽快设置密码"
|
2026-05-13 12:43:01 +08:00
|
|
|
|
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-05-18 09:46:11 +08:00
|
|
|
|
<div class="stat-item" @click="openOrders">
|
2026-03-26 10:28:28 +08:00
|
|
|
|
<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">
|
2026-05-18 09:46:11 +08:00
|
|
|
|
<a-list :data-source="profileMenuItems" :split="false">
|
2026-02-13 17:34:32 +08:00
|
|
|
|
<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>
|
2026-05-21 18:43:59 +08:00
|
|
|
|
<div class="menu-icon" :style="{ backgroundColor: item.bgColor, color: item.iconColor }">
|
2026-02-13 17:34:32 +08:00
|
|
|
|
<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"
|
2026-03-26 11:41:38 +08:00
|
|
|
|
:ok-button-props="{ disabled: avatarUploadPending }"
|
2026-02-24 16:07:09 +08:00
|
|
|
|
>
|
2026-03-26 12:04:02 +08:00
|
|
|
|
<DraftActions
|
|
|
|
|
|
:saved-at="draftSavedAt"
|
|
|
|
|
|
:disabled="avatarUploadPending"
|
|
|
|
|
|
@save="handleSaveDraft"
|
|
|
|
|
|
@clear="handleClearDraft"
|
|
|
|
|
|
/>
|
2026-02-24 16:07:09 +08:00
|
|
|
|
<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>
|
2026-03-26 11:41:38 +08:00
|
|
|
|
<a-progress
|
|
|
|
|
|
v-if="avatarUploadPending"
|
|
|
|
|
|
:percent="Math.round(avatarUploadProgress)"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
status="active"
|
|
|
|
|
|
class="avatar-upload-progress"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div v-if="avatarUploadPending" class="avatar-upload-status">头像上传中,上传完成前不可保存。</div>
|
2026-02-24 16:07:09 +08:00
|
|
|
|
<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-05-18 09:46:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* ProfileView page script.
|
|
|
|
|
|
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
|
|
|
|
|
*/
|
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-05-18 09:46:11 +08:00
|
|
|
|
BellOutlined,
|
|
|
|
|
|
CalendarOutlined,
|
2026-03-26 10:28:28 +08:00
|
|
|
|
CreditCardOutlined,
|
|
|
|
|
|
HeartOutlined,
|
|
|
|
|
|
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-03-26 12:04:02 +08:00
|
|
|
|
import DraftActions from '@/components/DraftActions.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-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: UserVO supports ProfileView.vue by holding or executing the user vo page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-03-26 10:28:28 +08:00
|
|
|
|
import { userApi, type UserVO } from '@/api/user'
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: ChunkUploadTask supports ProfileView.vue by holding or executing the chunk upload task page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-03-26 11:41:38 +08:00
|
|
|
|
import { createChunkUploadTask, type ChunkUploadTask } from '@/utils/chunk-upload'
|
2026-03-26 12:04:02 +08:00
|
|
|
|
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
|
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-05-13 12:43:01 +08:00
|
|
|
|
import { runWithGlobalLoading } from '@/utils/action-loading'
|
2026-05-21 18:43:59 +08:00
|
|
|
|
import { notifyShopThemeChanged } from '@/utils/shop-theme'
|
2026-02-13 17:34:32 +08:00
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: router supports ProfileView.vue by holding or executing the router page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-02-13 17:34:32 +08:00
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: userInfo supports ProfileView.vue by holding or executing the user info page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
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: ''
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** editModalVisible is a reactive state variable used by the template and event handlers. */
|
2026-02-24 16:07:09 +08:00
|
|
|
|
const editModalVisible = ref(false)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** saving is a reactive state variable used by the template and event handlers. */
|
2026-02-24 16:07:09 +08:00
|
|
|
|
const saving = ref(false)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** needSetPassword is a reactive state variable used by the template and event handlers. */
|
2026-03-26 10:28:28 +08:00
|
|
|
|
const needSetPassword = ref(false)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** hasNotification is a reactive state variable used by the template and event handlers. */
|
2026-03-26 10:28:28 +08:00
|
|
|
|
const hasNotification = ref(false)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** unreadMessageCount is a reactive state variable used by the template and event handlers. */
|
|
|
|
|
|
const unreadMessageCount = ref(0)
|
|
|
|
|
|
/** orderCount is a reactive state variable used by the template and event handlers. */
|
2026-02-27 16:44:41 +08:00
|
|
|
|
const orderCount = ref(0)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** couponCount is a reactive state variable used by the template and event handlers. */
|
2026-02-28 14:32:28 +08:00
|
|
|
|
const couponCount = ref(0)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** wishlistCount is a reactive state variable used by the template and event handlers. */
|
2026-03-03 17:50:10 +08:00
|
|
|
|
const wishlistCount = ref(0)
|
2026-05-21 18:43:59 +08:00
|
|
|
|
/** artistCalendarAccessible controls whether the appointment calendar entry is shown. */
|
|
|
|
|
|
const artistCalendarAccessible = ref(false)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** shopSwitchVisible is a reactive state variable used by the template and event handlers. */
|
2026-03-26 10:28:28 +08:00
|
|
|
|
const shopSwitchVisible = ref(false)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** shopSwitchLoading is a reactive state variable used by the template and event handlers. */
|
2026-03-26 10:28:28 +08:00
|
|
|
|
const shopSwitchLoading = ref(false)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: selectedShopId supports ProfileView.vue by holding or executing the selected shop id page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-03-26 10:28:28 +08:00
|
|
|
|
const selectedShopId = ref<string>()
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** avatarUploadProgress is a reactive state variable used by the template and event handlers. */
|
2026-03-26 11:41:38 +08:00
|
|
|
|
const avatarUploadProgress = ref(0)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** avatarUploadPending is a reactive state variable used by the template and event handlers. */
|
2026-03-26 11:41:38 +08:00
|
|
|
|
const avatarUploadPending = ref(false)
|
|
|
|
|
|
let avatarUploadTask: ChunkUploadTask<string> | null = null
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: draftSavedAt supports ProfileView.vue by holding or executing the draft saved at page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-03-26 12:04:02 +08:00
|
|
|
|
const draftSavedAt = ref<number | null>(null)
|
2026-02-27 15:57:14 +08:00
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: editForm supports ProfileView.vue by holding or executing the edit form page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
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-05-18 09:46:11 +08:00
|
|
|
|
/** getDraftKey is a local helper used by this page script. */
|
2026-03-26 12:04:02 +08:00
|
|
|
|
const getDraftKey = () => buildDraftStorageKey('profile-edit')
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** buildDraftPayload is a local helper used by this page script. */
|
2026-03-26 12:04:02 +08:00
|
|
|
|
const buildDraftPayload = () => ({
|
|
|
|
|
|
nickname: editForm.nickname,
|
|
|
|
|
|
avatar: editForm.avatar,
|
|
|
|
|
|
signature: editForm.signature
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** restoreDraft is a local helper used by this page script. */
|
2026-03-26 12:04:02 +08:00
|
|
|
|
const restoreDraft = () => {
|
|
|
|
|
|
const draft = loadDraftRecord<ReturnType<typeof buildDraftPayload>>(getDraftKey())
|
|
|
|
|
|
if (!draft) {
|
|
|
|
|
|
draftSavedAt.value = null
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
Object.assign(editForm, draft.payload)
|
|
|
|
|
|
draftSavedAt.value = draft.savedAt
|
|
|
|
|
|
message.success('已恢复暂存内容')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleSaveDraft is a local helper used by this page script. */
|
2026-03-26 12:04:02 +08:00
|
|
|
|
const handleSaveDraft = () => {
|
|
|
|
|
|
if (avatarUploadPending.value) {
|
|
|
|
|
|
message.warning('头像上传完成后才能暂存')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
const draft = saveDraftRecord(getDraftKey(), buildDraftPayload())
|
|
|
|
|
|
draftSavedAt.value = draft.savedAt
|
|
|
|
|
|
message.success('已暂存到本地')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleClearDraft is a local helper used by this page script. */
|
2026-03-26 12:04:02 +08:00
|
|
|
|
const handleClearDraft = (showMessage = true) => {
|
|
|
|
|
|
clearDraftRecord(getDraftKey())
|
|
|
|
|
|
draftSavedAt.value = null
|
|
|
|
|
|
if (showMessage) {
|
|
|
|
|
|
message.success('已清除暂存')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** shopOptions is a reactive state variable used by the template and event handlers. */
|
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}`
|
|
|
|
|
|
}))
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** currentShopName is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const currentShopName = computed(() => userInfo.value.shopName || '当前暂无可用门店')
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** shopSwitchTip is a reactive state variable used by the template and event handlers. */
|
2026-03-26 10:28:28 +08:00
|
|
|
|
const shopSwitchTip = computed(() => {
|
|
|
|
|
|
if (shopOptions.value.length > 1) {
|
|
|
|
|
|
return `可切换 ${shopOptions.value.length} 家门店`
|
|
|
|
|
|
}
|
|
|
|
|
|
if (shopOptions.value.length === 1) {
|
|
|
|
|
|
return '点击查看当前门店详情'
|
|
|
|
|
|
}
|
2026-05-13 12:43:01 +08:00
|
|
|
|
return '当前暂无可用门店'
|
2026-03-26 10:28:28 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: coreMenuItems supports ProfileView.vue by holding or executing the core menu items page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const coreMenuItems = [
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'orders',
|
|
|
|
|
|
title: '我的订单',
|
|
|
|
|
|
desc: '查看预约状态、取消订单',
|
|
|
|
|
|
icon: ShoppingOutlined,
|
2026-05-21 18:43:59 +08:00
|
|
|
|
bgColor: 'var(--theme-primary-soft)',
|
|
|
|
|
|
iconColor: 'var(--theme-primary)'
|
2026-05-13 12:43:01 +08:00
|
|
|
|
},
|
2026-05-18 09:46:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
key: 'artist-calendar',
|
|
|
|
|
|
title: '预约日历',
|
|
|
|
|
|
desc: '查看未来 7 天属于自己的预约',
|
|
|
|
|
|
icon: CalendarOutlined,
|
2026-05-21 18:43:59 +08:00
|
|
|
|
bgColor: 'var(--theme-primary-soft)',
|
|
|
|
|
|
iconColor: 'var(--theme-accent)',
|
2026-05-18 09:46:11 +08:00
|
|
|
|
serviceOnly: true
|
|
|
|
|
|
},
|
2026-05-13 12:43:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
key: 'wishlist',
|
|
|
|
|
|
title: '我的收藏',
|
|
|
|
|
|
desc: '快速回到喜欢的作品',
|
|
|
|
|
|
icon: HeartOutlined,
|
2026-05-21 18:43:59 +08:00
|
|
|
|
bgColor: 'var(--theme-primary-soft)',
|
|
|
|
|
|
iconColor: 'var(--theme-primary)'
|
2026-05-13 12:43:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'coupons',
|
|
|
|
|
|
title: '我的优惠券',
|
|
|
|
|
|
desc: '查看可用优惠和 VIP 折扣',
|
|
|
|
|
|
icon: CreditCardOutlined,
|
2026-05-21 18:43:59 +08:00
|
|
|
|
bgColor: 'var(--theme-primary-soft)',
|
|
|
|
|
|
iconColor: 'var(--theme-accent)'
|
2026-05-13 12:43:01 +08:00
|
|
|
|
},
|
2026-05-18 09:46:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
key: 'vip',
|
|
|
|
|
|
title: 'VIP 中心',
|
|
|
|
|
|
desc: '查看会员等级、余额和变动记录',
|
|
|
|
|
|
icon: CreditCardOutlined,
|
2026-05-21 18:43:59 +08:00
|
|
|
|
bgColor: 'var(--theme-primary-soft)',
|
|
|
|
|
|
iconColor: 'var(--theme-accent)'
|
2026-05-18 09:46:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'notifications',
|
|
|
|
|
|
title: '消息通知',
|
|
|
|
|
|
desc: '查看店铺通知和系统消息',
|
|
|
|
|
|
icon: BellOutlined,
|
2026-05-21 18:43:59 +08:00
|
|
|
|
bgColor: 'var(--theme-primary-soft)',
|
|
|
|
|
|
iconColor: 'var(--theme-primary)'
|
2026-05-18 09:46:11 +08:00
|
|
|
|
},
|
2026-05-13 12:43:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
key: 'settings',
|
|
|
|
|
|
title: '设置中心',
|
|
|
|
|
|
desc: '统一管理账号安全和更多入口',
|
|
|
|
|
|
icon: SettingOutlined,
|
2026-05-21 18:43:59 +08:00
|
|
|
|
bgColor: 'var(--theme-primary-soft)',
|
|
|
|
|
|
iconColor: 'var(--theme-accent)'
|
2026-05-13 12:43:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** profileMenuItems is a reactive state variable used by the template and event handlers. */
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const canViewArtistCalendar = computed(() => {
|
2026-05-18 09:46:11 +08:00
|
|
|
|
const userType = userInfo.value.type
|
2026-05-21 18:43:59 +08:00
|
|
|
|
return userType === 3 || (userType === 2 && artistCalendarAccessible.value)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: profileMenuItems supports ProfileView.vue by holding or executing the profile menu items page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const profileMenuItems = computed(() => {
|
|
|
|
|
|
return coreMenuItems.filter((item: any) => !item.serviceOnly || canViewArtistCalendar.value)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
/** isServiceUser is a reactive state variable used by the template and event handlers. */
|
|
|
|
|
|
const isServiceUser = computed(() => {
|
|
|
|
|
|
const userType = userInfo.value.type
|
|
|
|
|
|
return userType === 2 || userType === 3
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
/** persistUserSession is a local helper used by this page script. */
|
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)
|
2026-05-21 18:43:59 +08:00
|
|
|
|
notifyShopThemeChanged()
|
2026-03-26 10:28:28 +08:00
|
|
|
|
if (payload.needSetPassword) {
|
|
|
|
|
|
localStorage.setItem('needSetPassword', 'true')
|
|
|
|
|
|
} else {
|
|
|
|
|
|
localStorage.removeItem('needSetPassword')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-02-13 17:34:32 +08:00
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** fetchUserInfo is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-02-24 16:07:09 +08:00
|
|
|
|
const fetchUserInfo = async () => {
|
|
|
|
|
|
try {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
artistCalendarAccessible.value = false
|
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-05-21 18:43:59 +08:00
|
|
|
|
artistCalendarAccessible.value = response.type === 3
|
|
|
|
|
|
if (response.type === 2) {
|
|
|
|
|
|
const artistInfo = await userApi.getNailArtistInfo(response.id).catch(() => null)
|
|
|
|
|
|
artistCalendarAccessible.value = Number(artistInfo?.participateProduction) === 1
|
|
|
|
|
|
}
|
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-05-18 09:46:11 +08:00
|
|
|
|
/** loadCounts is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-03-26 10:28:28 +08:00
|
|
|
|
const loadCounts = async () => {
|
|
|
|
|
|
try {
|
2026-05-18 09:46:11 +08:00
|
|
|
|
const orderListRequest = isServiceUser.value ? orderApi.getArtistOrders() : orderApi.getOrderList()
|
|
|
|
|
|
const [orders, coupons, wishlist, unreadMessages] = await Promise.all([
|
|
|
|
|
|
orderListRequest,
|
2026-03-26 10:28:28 +08:00
|
|
|
|
couponApi.listUserCoupons(),
|
2026-05-18 09:46:11 +08:00
|
|
|
|
wishlistApi.getWishlist(),
|
|
|
|
|
|
userApi.getMyUnreadMessageCount()
|
2026-03-26 10:28:28 +08:00
|
|
|
|
])
|
|
|
|
|
|
orderCount.value = Array.isArray(orders) ? orders.length : 0
|
|
|
|
|
|
couponCount.value = Array.isArray(coupons) ? coupons.length : 0
|
|
|
|
|
|
wishlistCount.value = Array.isArray(wishlist) ? wishlist.length : 0
|
2026-05-18 09:46:11 +08:00
|
|
|
|
unreadMessageCount.value = Number(unreadMessages?.unreadCount || 0)
|
|
|
|
|
|
hasNotification.value = unreadMessageCount.value > 0
|
2026-03-26 10:28:28 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('加载个人中心统计失败:', error)
|
2026-02-24 16:07:09 +08:00
|
|
|
|
}
|
2026-03-26 10:28:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** openOrders is a local helper used by this page script. */
|
|
|
|
|
|
const openOrders = () => {
|
|
|
|
|
|
router.push(isServiceUser.value ? '/artist-orders' : '/orders')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** handleEditProfile is a local helper used by this page script. */
|
2026-03-26 10:28:28 +08:00
|
|
|
|
const handleEditProfile = () => {
|
2026-03-26 11:41:38 +08:00
|
|
|
|
avatarUploadTask?.cancel()
|
|
|
|
|
|
avatarUploadTask = null
|
|
|
|
|
|
avatarUploadPending.value = false
|
|
|
|
|
|
avatarUploadProgress.value = 0
|
2026-03-26 10:28:28 +08:00
|
|
|
|
editForm.nickname = userInfo.value.nickname || ''
|
|
|
|
|
|
editForm.avatar = userInfo.value.avatar || ''
|
|
|
|
|
|
editForm.signature = userInfo.value.signature || ''
|
2026-03-26 12:04:02 +08:00
|
|
|
|
restoreDraft()
|
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
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleAvatarUpload is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-02-24 16:07:09 +08:00
|
|
|
|
const handleAvatarUpload = async (options: any) => {
|
2026-03-26 11:41:38 +08:00
|
|
|
|
const { file, onProgress, onSuccess, onError } = options
|
|
|
|
|
|
|
|
|
|
|
|
avatarUploadTask?.cancel()
|
|
|
|
|
|
avatarUploadProgress.value = 0
|
|
|
|
|
|
avatarUploadPending.value = true
|
|
|
|
|
|
|
|
|
|
|
|
const task = createChunkUploadTask({
|
|
|
|
|
|
file: file as File,
|
|
|
|
|
|
scene: 'profile-avatar',
|
|
|
|
|
|
api: {
|
|
|
|
|
|
initUpload: fileApi.initAvatarChunkUpload,
|
|
|
|
|
|
uploadChunk: fileApi.uploadAvatarChunk,
|
|
|
|
|
|
completeUpload: fileApi.completeAvatarChunkUpload,
|
|
|
|
|
|
cancelUpload: fileApi.cancelAvatarChunkUpload
|
|
|
|
|
|
},
|
|
|
|
|
|
onProgress: (percent) => {
|
|
|
|
|
|
avatarUploadProgress.value = percent
|
|
|
|
|
|
onProgress?.({ percent })
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
avatarUploadTask = task
|
|
|
|
|
|
|
2026-02-24 16:07:09 +08:00
|
|
|
|
try {
|
2026-03-26 11:41:38 +08:00
|
|
|
|
const { response } = await task.promise
|
|
|
|
|
|
editForm.avatar = response as unknown as string
|
|
|
|
|
|
avatarUploadProgress.value = 100
|
|
|
|
|
|
onSuccess?.({ url: response })
|
2026-02-24 16:07:09 +08:00
|
|
|
|
message.success('头像上传成功')
|
|
|
|
|
|
} catch (error) {
|
2026-03-26 11:41:38 +08:00
|
|
|
|
const errorMessage = (error as Error)?.message || '头像上传失败'
|
|
|
|
|
|
if (errorMessage !== '上传已取消' && errorMessage !== 'canceled') {
|
|
|
|
|
|
console.error('头像上传失败:', error)
|
|
|
|
|
|
message.error(errorMessage)
|
|
|
|
|
|
onError?.(error)
|
|
|
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
if (avatarUploadTask === task) {
|
|
|
|
|
|
avatarUploadTask = null
|
|
|
|
|
|
avatarUploadPending.value = false
|
|
|
|
|
|
}
|
2026-02-24 16:07:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleDeleteAvatar is a local helper used by this page script. */
|
2026-02-24 16:07:09 +08:00
|
|
|
|
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 {
|
2026-05-13 12:43:01 +08:00
|
|
|
|
await runWithGlobalLoading(() => 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
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleSaveProfile is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-26 11:41:38 +08:00
|
|
|
|
if (avatarUploadPending.value) {
|
|
|
|
|
|
message.warning('头像上传完成前不可保存')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-24 16:07:09 +08:00
|
|
|
|
saving.value = true
|
|
|
|
|
|
try {
|
2026-05-13 12:43:01 +08:00
|
|
|
|
await runWithGlobalLoading(async () => {
|
|
|
|
|
|
await userApi.updateUserInfo({
|
|
|
|
|
|
nickname: editForm.nickname,
|
|
|
|
|
|
avatar: editForm.avatar,
|
|
|
|
|
|
signature: editForm.signature
|
|
|
|
|
|
})
|
|
|
|
|
|
await fetchUserInfo()
|
2026-03-26 10:28:28 +08:00
|
|
|
|
})
|
2026-02-24 16:07:09 +08:00
|
|
|
|
message.success('资料更新成功')
|
2026-03-26 12:04:02 +08:00
|
|
|
|
handleClearDraft(false)
|
2026-02-24 16:07:09 +08:00
|
|
|
|
editModalVisible.value = false
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('保存资料失败:', error)
|
|
|
|
|
|
message.error('保存资料失败')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
saving.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleCancelEdit is a local helper used by this page script. */
|
2026-02-24 16:07:09 +08:00
|
|
|
|
const handleCancelEdit = () => {
|
2026-03-26 11:41:38 +08:00
|
|
|
|
avatarUploadTask?.cancel()
|
|
|
|
|
|
avatarUploadTask = null
|
|
|
|
|
|
avatarUploadPending.value = false
|
|
|
|
|
|
avatarUploadProgress.value = 0
|
2026-02-24 16:07:09 +08:00
|
|
|
|
editModalVisible.value = false
|
2026-02-13 17:34:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleShopCardClick is a local helper used by this page script. */
|
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
|
|
|
|
|
|
}
|
2026-05-13 12:43:01 +08:00
|
|
|
|
message.info('当前暂无可用门店')
|
2026-03-26 10:28:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleConfirmSwitchShop is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-03-26 10:28:28 +08:00
|
|
|
|
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-05-13 12:43:01 +08:00
|
|
|
|
await runWithGlobalLoading(async () => {
|
|
|
|
|
|
const response = await authApi.switchShop({ shopId: selectedShopId.value })
|
|
|
|
|
|
persistUserSession(response as any)
|
|
|
|
|
|
await Promise.all([fetchUserInfo(), loadCounts()])
|
|
|
|
|
|
})
|
2026-03-26 10:28:28 +08:00
|
|
|
|
message.success('门店已切换')
|
|
|
|
|
|
shopSwitchVisible.value = false
|
|
|
|
|
|
} 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-05-18 09:46:11 +08:00
|
|
|
|
/** handleMenuClick is a local helper used by this page script. */
|
2026-02-13 17:34:32 +08:00
|
|
|
|
const handleMenuClick = (key: string) => {
|
2026-03-26 10:28:28 +08:00
|
|
|
|
if (key === 'orders') {
|
2026-05-18 09:46:11 +08:00
|
|
|
|
openOrders()
|
|
|
|
|
|
} else if (key === 'artist-calendar') {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
if (!canViewArtistCalendar.value) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-05-18 09:46:11 +08:00
|
|
|
|
router.push('/artist-calendar')
|
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-05-18 09:46:11 +08:00
|
|
|
|
} else if (key === 'vip') {
|
|
|
|
|
|
router.push('/vip-center')
|
|
|
|
|
|
} else if (key === 'notifications') {
|
|
|
|
|
|
router.push('/notifications')
|
2026-05-13 12:43:01 +08:00
|
|
|
|
} else if (key === 'settings') {
|
|
|
|
|
|
router.push('/settings')
|
2026-02-13 17:34:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleLogout is a local helper used by this page script. */
|
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 () => {
|
2026-05-13 12:43:01 +08:00
|
|
|
|
await runWithGlobalLoading(async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await authApi.logout()
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('退出登录接口调用失败:', error)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
localStorage.removeItem('accessToken')
|
|
|
|
|
|
localStorage.removeItem('refreshToken')
|
|
|
|
|
|
localStorage.removeItem('userInfo')
|
|
|
|
|
|
localStorage.removeItem('needSetPassword')
|
|
|
|
|
|
sessionStorage.removeItem('accessToken')
|
2026-05-21 18:43:59 +08:00
|
|
|
|
notifyShopThemeChanged()
|
2026-05-13 12:43:01 +08:00
|
|
|
|
message.success('已退出登录')
|
|
|
|
|
|
router.push('/')
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2026-02-24 14:12:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2026-02-13 17:34:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleSettingsClick is a local helper used by this page script. */
|
2026-02-13 17:34:32 +08:00
|
|
|
|
const handleSettingsClick = () => {
|
|
|
|
|
|
router.push('/settings')
|
|
|
|
|
|
}
|
2026-02-24 16:07:09 +08:00
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleSetPassword is a local helper used by this page script. */
|
2026-03-03 14:39:02 +08:00
|
|
|
|
const handleSetPassword = () => {
|
|
|
|
|
|
router.push('/settings/password')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
|
onMounted(async () => {
|
2026-05-18 09:46:11 +08:00
|
|
|
|
await fetchUserInfo()
|
|
|
|
|
|
await 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;
|
2026-05-21 18:43:59 +08:00
|
|
|
|
background:
|
|
|
|
|
|
linear-gradient(rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.92)),
|
|
|
|
|
|
var(--theme-background-image),
|
|
|
|
|
|
var(--theme-page-bg);
|
|
|
|
|
|
background-size: cover, cover, auto;
|
|
|
|
|
|
background-position: center top;
|
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;
|
2026-05-21 18:43:59 +08:00
|
|
|
|
background: var(--theme-gradient);
|
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-05-21 18:43:59 +08:00
|
|
|
|
background: var(--theme-gradient-soft);
|
2026-02-24 16:07:09 +08:00
|
|
|
|
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;
|
2026-05-21 18:43:59 +08:00
|
|
|
|
background: var(--theme-gradient);
|
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 {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
color: #76768a;
|
|
|
|
|
|
font-size: 16px;
|
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-05-21 18:43:59 +08:00
|
|
|
|
background: var(--theme-gradient);
|
2026-03-26 10:28:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.stat-icon.wishlist {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
background: linear-gradient(135deg, var(--theme-accent) 0%, var(--theme-primary) 100%);
|
2026-03-26 10:28:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.stat-icon.coupons {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
background: linear-gradient(135deg, var(--theme-secondary) 0%, var(--theme-primary) 100%);
|
2026-03-26 10:28:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.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;
|
2026-05-21 18:43:59 +08:00
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.menu-item :deep(.ant-list-item-action .anticon) {
|
|
|
|
|
|
color: #76768a;
|
|
|
|
|
|
font-size: 14px;
|
2026-03-26 10:28:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.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;
|
2026-05-21 18:43:59 +08:00
|
|
|
|
color: var(--theme-primary);
|
2026-02-13 17:34:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-26 11:41:38 +08:00
|
|
|
|
.avatar-upload-progress {
|
|
|
|
|
|
width: 220px;
|
|
|
|
|
|
margin-top: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.avatar-upload-status {
|
|
|
|
|
|
font-size: 12px;
|
2026-05-21 18:43:59 +08:00
|
|
|
|
color: var(--theme-accent);
|
2026-03-26 11:41:38 +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>
|