完成JC-ArtList与JC-Salon端侧清理和统一命名

This commit is contained in:
2026-08-25 16:21:05 +08:00
parent aa93695704
commit abce4a2787
1839 changed files with 653 additions and 50415 deletions
@@ -0,0 +1,831 @@
<template>
<div class="mobile-container">
<!-- 头部区域 -->
<header class="header">
<a-button class="back-btn" type="text" @click="handleBackClick">
<LeftOutlined :style="{ fontSize: '20px' }" />
</a-button>
<h1>账号设置</h1>
<div class="empty"></div>
</header>
<!-- 账号设置内容 -->
<div class="account-settings">
<!-- 账号设置选项 -->
<a-card :bordered="false" class="settings-card">
<a-list :data-source="accountSettings" :split="false">
<template #renderItem="{ item }">
<a-list-item class="setting-item" @click="handleSettingClick(item.key)">
<template #actions>
<RightOutlined />
</template>
<a-list-item-meta>
<template #avatar>
<div class="setting-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>
<!-- 绑定手机号弹窗 -->
<a-modal
v-model:visible="bindPhoneModalVisible"
title="绑定手机号"
@ok="handleBindPhoneSubmit"
@cancel="handleBindPhoneCancel"
:confirmLoading="bindPhoneLoading"
>
<DraftActions
:saved-at="bindPhoneDraftSavedAt"
@save="handleSaveBindPhoneDraft"
@clear="handleClearBindPhoneDraft"
/>
<a-form layout="vertical">
<a-form-item label="手机号" name="phone">
<a-input
v-model:value="bindPhoneForm.phone"
placeholder="请输入手机号"
:disabled="!!userInfo.phone"
/>
</a-form-item>
<a-form-item label="验证码" name="verificationCode">
<a-input
v-model:value="bindPhoneForm.verificationCode"
placeholder="请输入验证码"
>
<template #suffix>
<a-button
type="link"
:disabled="countdown > 0 || !bindPhoneForm.phone"
@click="handleSendVerificationCode"
>
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
</a-button>
</template>
</a-input>
</a-form-item>
</a-form>
</a-modal>
<!-- 修改手机号弹窗 -->
<a-modal
v-model:visible="changePhoneModalVisible"
title="修改手机号"
@ok="handleChangePhoneSubmit"
@cancel="handleChangePhoneCancel"
:confirmLoading="changePhoneLoading"
>
<DraftActions
:saved-at="changePhoneDraftSavedAt"
@save="handleSaveChangePhoneDraft"
@clear="handleClearChangePhoneDraft"
/>
<a-form layout="vertical">
<a-form-item label="旧手机号">
<a-input :value="userInfo.phone" disabled />
</a-form-item>
<a-form-item label="新手机号" name="newPhone">
<a-input
v-model:value="changePhoneForm.newPhone"
placeholder="请输入新手机号"
/>
</a-form-item>
<a-form-item label="验证码" name="verificationCode">
<a-input
v-model:value="changePhoneForm.verificationCode"
placeholder="请输入验证码"
>
<template #suffix>
<a-button
type="link"
:disabled="countdown > 0 || !changePhoneForm.newPhone"
@click="handleSendChangePhoneVerificationCode"
>
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
</a-button>
</template>
</a-input>
</a-form-item>
</a-form>
</a-modal>
<!-- 修改密码弹窗 -->
<a-modal
v-model:visible="changePasswordModalVisible"
title="修改密码"
@ok="handleChangePasswordSubmit"
@cancel="handleChangePasswordCancel"
:confirmLoading="changePasswordLoading"
>
<DraftActions
:saved-at="changePasswordDraftSavedAt"
@save="handleSaveChangePasswordDraft"
@clear="handleClearChangePasswordDraft"
/>
<a-form layout="vertical">
<a-form-item label="手机号">
<a-input :value="userInfo.phone" disabled />
</a-form-item>
<a-form-item label="验证码" name="verificationCode">
<a-input
v-model:value="changePasswordForm.verificationCode"
placeholder="请输入验证码"
>
<template #suffix>
<a-button
type="link"
:disabled="countdown > 0"
@click="handleSendChangePasswordVerificationCode"
>
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
</a-button>
</template>
</a-input>
</a-form-item>
<a-form-item label="新密码" name="password">
<a-input-password
v-model:value="changePasswordForm.password"
placeholder="请输入新密码"
/>
<div class="password-tip">
密码长度至少8位,包含字母和数字
</div>
</a-form-item>
<a-form-item label="确认密码" name="confirmPassword">
<a-input-password
v-model:value="changePasswordForm.confirmPassword"
placeholder="请再次输入新密码"
/>
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
<script setup lang="ts">
/**
* AccountSettingsView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { ref, reactive, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { LeftOutlined, RightOutlined, LockOutlined, PhoneOutlined } from '@ant-design/icons-vue'
import { message, Modal } from 'ant-design-vue'
import DraftActions from '@/components/DraftActions.vue'
import { userApi } from '@/api/user'
import type { UserVO } from '@/api/user'
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
import { runWithGlobalLoading } from '@/utils/action-loading'
/**
* Purpose: router supports AccountSettingsView.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.
*/
const router = useRouter()
// 用户信息
const userInfo = ref<UserVO>({
id: 0,
nickname: '',
account: '',
avatar: '',
type: 0,
status: 0,
createTime: '',
updateTime: ''
})
// 状态标识
/** hasPassword is a reactive state variable used by the template and event handlers. */
const hasPassword = ref(false)
/** hasPhone is a reactive state variable used by the template and event handlers. */
const hasPhone = ref(false)
// 绑定手机号表单
/** bindPhoneModalVisible is a reactive state variable used by the template and event handlers. */
const bindPhoneModalVisible = ref(false)
/** bindPhoneLoading is a reactive state variable used by the template and event handlers. */
const bindPhoneLoading = ref(false)
/**
* Purpose: bindPhoneDraftSavedAt supports AccountSettingsView.vue by holding or executing the bind phone 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.
*/
const bindPhoneDraftSavedAt = ref<number | null>(null)
/**
* Purpose: bindPhoneForm supports AccountSettingsView.vue by holding or executing the bind phone 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.
*/
const bindPhoneForm = reactive({
phone: '',
verificationCode: ''
})
// 修改手机号表单
/** changePhoneModalVisible is a reactive state variable used by the template and event handlers. */
const changePhoneModalVisible = ref(false)
/** changePhoneLoading is a reactive state variable used by the template and event handlers. */
const changePhoneLoading = ref(false)
/**
* Purpose: changePhoneDraftSavedAt supports AccountSettingsView.vue by holding or executing the change phone 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.
*/
const changePhoneDraftSavedAt = ref<number | null>(null)
/**
* Purpose: changePhoneForm supports AccountSettingsView.vue by holding or executing the change phone 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.
*/
const changePhoneForm = reactive({
newPhone: '',
verificationCode: ''
})
// 修改密码表单
/** changePasswordModalVisible is a reactive state variable used by the template and event handlers. */
const changePasswordModalVisible = ref(false)
/** changePasswordLoading is a reactive state variable used by the template and event handlers. */
const changePasswordLoading = ref(false)
/**
* Purpose: changePasswordDraftSavedAt supports AccountSettingsView.vue by holding or executing the change password 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.
*/
const changePasswordDraftSavedAt = ref<number | null>(null)
/**
* Purpose: changePasswordForm supports AccountSettingsView.vue by holding or executing the change password 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.
*/
const changePasswordForm = reactive({
verificationCode: '',
password: '',
confirmPassword: ''
})
/**
* Purpose: restoreSessionDraft supports AccountSettingsView.vue by holding or executing the restore session draft 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.
*/
const restoreSessionDraft = <T extends Record<string, any>>(key: string, target: T, savedAtRef: typeof bindPhoneDraftSavedAt) => {
const draft = loadDraftRecord<T>(key, 'session')
if (!draft) {
savedAtRef.value = null
return
}
Object.assign(target, draft.payload)
savedAtRef.value = draft.savedAt
message.success('已恢复暂存内容')
}
/**
* Purpose: saveSessionDraft supports AccountSettingsView.vue by holding or executing the save session draft 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.
*/
const saveSessionDraft = <T>(key: string, payload: T, savedAtRef: typeof bindPhoneDraftSavedAt, successMessage = '已暂存到当前会话') => {
const draft = saveDraftRecord(key, payload, 'session')
savedAtRef.value = draft.savedAt
message.success(successMessage)
}
/** clearSessionDraft is a local helper used by this page script. */
const clearSessionDraft = (key: string, savedAtRef: typeof bindPhoneDraftSavedAt, showMessage = true) => {
clearDraftRecord(key, 'session')
savedAtRef.value = null
if (showMessage) {
message.success('已清除暂存')
}
}
/**
* Purpose: bindPhoneDraftKey supports AccountSettingsView.vue by holding or executing the bind phone draft key 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.
*/
const bindPhoneDraftKey = buildDraftStorageKey('account-settings', 'bind-phone')
/**
* Purpose: changePhoneDraftKey supports AccountSettingsView.vue by holding or executing the change phone draft key 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.
*/
const changePhoneDraftKey = buildDraftStorageKey('account-settings', 'change-phone')
/**
* Purpose: changePasswordDraftKey supports AccountSettingsView.vue by holding or executing the change password draft key 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.
*/
const changePasswordDraftKey = buildDraftStorageKey('account-settings', 'change-password')
/** handleSaveBindPhoneDraft is a local helper used by this page script. */
const handleSaveBindPhoneDraft = () => {
saveSessionDraft(bindPhoneDraftKey, { ...bindPhoneForm }, bindPhoneDraftSavedAt)
}
/** handleClearBindPhoneDraft is a local helper used by this page script. */
const handleClearBindPhoneDraft = (showMessage = true) => {
clearSessionDraft(bindPhoneDraftKey, bindPhoneDraftSavedAt, showMessage)
}
/** handleSaveChangePhoneDraft is a local helper used by this page script. */
const handleSaveChangePhoneDraft = () => {
saveSessionDraft(changePhoneDraftKey, { ...changePhoneForm }, changePhoneDraftSavedAt)
}
/** handleClearChangePhoneDraft is a local helper used by this page script. */
const handleClearChangePhoneDraft = (showMessage = true) => {
clearSessionDraft(changePhoneDraftKey, changePhoneDraftSavedAt, showMessage)
}
/** handleSaveChangePasswordDraft is a local helper used by this page script. */
const handleSaveChangePasswordDraft = () => {
saveSessionDraft(changePasswordDraftKey, { ...changePasswordForm }, changePasswordDraftSavedAt)
}
/** handleClearChangePasswordDraft is a local helper used by this page script. */
const handleClearChangePasswordDraft = (showMessage = true) => {
clearSessionDraft(changePasswordDraftKey, changePasswordDraftSavedAt, showMessage)
}
// 倒计时
/** countdown is a reactive state variable used by the template and event handlers. */
const countdown = ref(0)
// 账号设置选项
/** accountSettings is a reactive state variable used by the template and event handlers. */
const accountSettings = ref([
{
key: 'changePhone',
title: '修改手机号',
icon: PhoneOutlined,
bgColor: '#e6f7ff'
},
{
key: 'changePassword',
title: '修改密码',
icon: LockOutlined,
bgColor: '#f6ffed'
},
{
key: 'deactivateAccount',
title: '注销账号',
icon: LockOutlined,
bgColor: '#fff1f0'
}
])
// 根据用户状态动态更新账号设置选项
/** updateAccountSettings is a local helper used by this page script. */
const updateAccountSettings = () => {
const settings = []
// 手机号相关
if (!hasPhone.value) {
settings.push({
key: 'bindPhone',
title: '绑定手机号',
icon: PhoneOutlined,
bgColor: '#e6f7ff'
})
} else {
settings.push({
key: 'changePhone',
title: '修改手机号',
icon: PhoneOutlined,
bgColor: '#e6f7ff'
})
}
// 密码相关
if (!hasPassword.value) {
settings.push({
key: 'setPassword',
title: '设置密码',
icon: LockOutlined,
bgColor: '#fff7e6'
})
} else {
settings.push({
key: 'changePassword',
title: '修改密码',
icon: LockOutlined,
bgColor: '#f6ffed'
})
}
// 注销账号
settings.push({
key: 'deactivateAccount',
title: '注销账号',
icon: LockOutlined,
bgColor: '#fff1f0'
})
accountSettings.value = settings
}
// 获取用户信息
/** fetchUserInfo is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const fetchUserInfo = async () => {
try {
const response = await userApi.getUserInfo() as any
userInfo.value = response
// 检查是否绑定手机号
hasPhone.value = !!userInfo.value.phone
// 检查是否设置密码(通过localStorage中的标识)
hasPassword.value = localStorage.getItem('needSetPassword') !== 'true'
// 更新账号设置选项
updateAccountSettings()
} catch (error) {
console.error('获取用户信息失败:', error)
message.error('获取用户信息失败')
}
}
// 处理返回
/** handleBackClick is a local helper used by this page script. */
const handleBackClick = () => {
router.back()
}
// 处理设置项点击
/** handleSettingClick is a local helper used by this page script. */
const handleSettingClick = (key: string) => {
switch (key) {
case 'bindPhone':
restoreSessionDraft(bindPhoneDraftKey, bindPhoneForm, bindPhoneDraftSavedAt)
bindPhoneModalVisible.value = true
break
case 'changePhone':
restoreSessionDraft(changePhoneDraftKey, changePhoneForm, changePhoneDraftSavedAt)
changePhoneModalVisible.value = true
break
case 'setPassword':
handleSetPassword()
break
case 'changePassword':
restoreSessionDraft(changePasswordDraftKey, changePasswordForm, changePasswordDraftSavedAt)
changePasswordModalVisible.value = true
break
case 'deactivateAccount':
handleDeactivateAccount()
break
default:
break
}
}
// 处理设置密码
/** handleSetPassword is a local helper used by this page script. */
const handleSetPassword = () => {
router.push('/settings/password')
}
// 发送绑定手机号验证码
/** handleSendVerificationCode is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleSendVerificationCode = async () => {
if (!bindPhoneForm.phone) {
message.error('请输入手机号')
return
}
const phoneRegex = /^1[3-9]\d{9}$/
if (!phoneRegex.test(bindPhoneForm.phone)) {
message.error('手机号格式不正确')
return
}
try {
await runWithGlobalLoading(() => userApi.sendVerificationCode({
phone: bindPhoneForm.phone,
sceneCode: 'USER_BIND_PHONE_SMS_CODE'
}))
message.success('验证码发送成功')
startCountdown()
} catch (error) {
console.error('发送验证码失败:', error)
message.error('发送验证码失败')
}
}
// 发送修改手机号验证码
/** handleSendChangePhoneVerificationCode is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleSendChangePhoneVerificationCode = async () => {
if (!changePhoneForm.newPhone) {
message.error('请输入新手机号')
return
}
const phoneRegex = /^1[3-9]\d{9}$/
if (!phoneRegex.test(changePhoneForm.newPhone)) {
message.error('手机号格式不正确')
return
}
try {
await runWithGlobalLoading(() => userApi.sendVerificationCode({
phone: changePhoneForm.newPhone,
sceneCode: 'USER_CHANGE_PHONE_SMS_CODE'
}))
message.success('验证码发送成功')
startCountdown()
} catch (error) {
console.error('发送验证码失败:', error)
message.error('发送验证码失败')
}
}
// 发送修改密码验证码
/** handleSendChangePasswordVerificationCode is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleSendChangePasswordVerificationCode = async () => {
if (!userInfo.value.phone) {
message.error('请先绑定手机号')
return
}
const phone = userInfo.value.phone
const phoneRegex = /^1[3-9]\d{9}$/
if (!phoneRegex.test(phone)) {
message.error('手机号格式不正确')
return
}
try {
await runWithGlobalLoading(() => userApi.sendVerificationCode({
phone,
sceneCode: 'USER_CHANGE_PASSWORD_SMS_CODE'
}))
message.success('验证码发送成功')
startCountdown()
} catch (error) {
console.error('发送验证码失败:', error)
message.error('发送验证码失败')
}
}
// 开始倒计时
/** startCountdown is a local helper used by this page script. */
const startCountdown = () => {
countdown.value = 60
const timer = setInterval(() => {
countdown.value--
if (countdown.value <= 0) {
clearInterval(timer)
}
}, 1000)
}
// 处理绑定手机号提交
/** handleBindPhoneSubmit is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleBindPhoneSubmit = async () => {
if (!bindPhoneForm.phone || !bindPhoneForm.verificationCode) {
message.error('请填写完整信息')
return
}
bindPhoneLoading.value = true
try {
await runWithGlobalLoading(async () => {
await userApi.bindPhone({
phone: bindPhoneForm.phone,
verificationCode: bindPhoneForm.verificationCode
})
await fetchUserInfo()
})
message.success('手机号绑定成功')
handleClearBindPhoneDraft(false)
bindPhoneModalVisible.value = false
} catch (error: any) {
console.error('绑定手机号失败:', error)
message.error(error.message || '绑定手机号失败')
} finally {
bindPhoneLoading.value = false
}
}
// 处理绑定手机号取消
/** handleBindPhoneCancel is a local helper used by this page script. */
const handleBindPhoneCancel = () => {
bindPhoneModalVisible.value = false
bindPhoneForm.phone = ''
bindPhoneForm.verificationCode = ''
}
// 处理修改手机号提交
/** handleChangePhoneSubmit is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleChangePhoneSubmit = async () => {
if (!changePhoneForm.newPhone || !changePhoneForm.verificationCode) {
message.error('请填写完整信息')
return
}
changePhoneLoading.value = true
try {
await runWithGlobalLoading(async () => {
await userApi.updatePhone({
oldPhone: userInfo.value.phone!,
newPhone: changePhoneForm.newPhone,
verificationCode: changePhoneForm.verificationCode
})
await fetchUserInfo()
})
message.success('手机号修改成功')
handleClearChangePhoneDraft(false)
changePhoneModalVisible.value = false
} catch (error: any) {
console.error('修改手机号失败:', error)
message.error(error.message || '修改手机号失败')
} finally {
changePhoneLoading.value = false
}
}
// 处理修改手机号取消
/** handleChangePhoneCancel is a local helper used by this page script. */
const handleChangePhoneCancel = () => {
changePhoneModalVisible.value = false
changePhoneForm.newPhone = ''
changePhoneForm.verificationCode = ''
}
// 处理修改密码提交
/** handleChangePasswordSubmit is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleChangePasswordSubmit = async () => {
if (!changePasswordForm.verificationCode || !changePasswordForm.password || !changePasswordForm.confirmPassword) {
message.error('请填写完整信息')
return
}
if (changePasswordForm.password !== changePasswordForm.confirmPassword) {
message.error('两次输入的密码不一致')
return
}
changePasswordLoading.value = true
try {
await runWithGlobalLoading(() => userApi.updatePassword({
password: changePasswordForm.password,
verificationCode: changePasswordForm.verificationCode
}))
message.success('密码修改成功')
handleClearChangePasswordDraft(false)
changePasswordModalVisible.value = false
// 清除需要设置密码的标识
localStorage.removeItem('needSetPassword')
hasPassword.value = true
updateAccountSettings()
} catch (error: any) {
console.error('修改密码失败:', error)
message.error(error.message || '修改密码失败')
} finally {
changePasswordLoading.value = false
}
}
// 处理修改密码取消
/** handleChangePasswordCancel is a local helper used by this page script. */
const handleChangePasswordCancel = () => {
changePasswordModalVisible.value = false
changePasswordForm.verificationCode = ''
changePasswordForm.password = ''
changePasswordForm.confirmPassword = ''
}
// 处理注销账号
/** handleDeactivateAccount is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleDeactivateAccount = async () => {
Modal.confirm({
title: '确认注销账号',
content: '注销账号后,您的所有数据将被删除且无法恢复。确定要注销账号吗?',
okText: '确认注销',
okType: 'danger',
cancelText: '取消',
onOk: async () => {
await runWithGlobalLoading(async () => {
try {
await userApi.deactivateAccount()
message.success('账号注销成功')
} catch (error) {
console.error('注销账号失败:', error)
message.error('注销账号失败')
} finally {
// 无论成功或失败,都清除本地存储的用户信息
localStorage.removeItem('accessToken')
localStorage.removeItem('refreshToken')
localStorage.removeItem('userInfo')
localStorage.removeItem('needSetPassword')
localStorage.removeItem('userPermissions')
sessionStorage.removeItem('accessToken')
// 跳转到登录页
router.push('/')
}
})
}
})
}
// 生命周期
onMounted(() => {
fetchUserInfo()
})
</script>
<style scoped>
.mobile-container {
min-height: 100vh;
background: var(--theme-page-bg);
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 15px;
background: var(--theme-card-bg);
border-bottom: 1px solid var(--theme-border);
}
.header h1 {
font-size: 18px;
font-weight: bold;
margin: 0;
}
.back-btn,
.empty {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
}
.account-settings {
padding: 15px;
}
.status-tips {
margin-bottom: 15px;
}
.settings-card {
border-radius: 16px;
overflow: hidden;
background: var(--theme-card-bg);
}
.settings-card :deep(.ant-card-body) {
padding: 0;
}
.setting-item {
padding: 16px;
cursor: pointer;
transition: background 0.3s;
border-bottom: 1px solid var(--theme-border);
}
.setting-item:hover {
background: var(--theme-primary-soft);
}
.setting-item:last-child {
border-bottom: none;
}
.setting-item :deep(.ant-list-item-action) {
margin-left: 8px;
color: var(--text-secondary);
}
.setting-icon {
width: 40px;
height: 40px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
color: white;
}
.setting-item :deep(.ant-list-item-meta-title) {
font-size: 15px;
font-weight: 500;
color: var(--text-primary);
}
.setting-item :deep(.ant-list-item-meta-description) {
font-size: 12px;
color: var(--text-secondary);
}
.password-tip {
font-size: 12px;
color: var(--text-secondary);
margin-top: 8px;
}
</style>
@@ -0,0 +1,141 @@
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { LeftOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { afterSaleApi, orderApi } from '../api/order'
import type { IdType } from '@/utils/id'
import { runWithGlobalLoading } from '@/utils/action-loading'
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const submitting = ref(false)
const order = ref<any | null>(null)
const orderId = computed(() => String(route.query.orderId || ''))
const items = computed(() => Array.isArray(order.value?.items) ? order.value.items : [])
const form = reactive({
orderItemId: undefined as IdType | undefined,
type: 'REFUND',
reason: '',
refundAmount: undefined as number | undefined
})
const formatMoney = (value?: number | string) => {
const amount = Number(value)
return Number.isFinite(amount) ? `¥${amount.toFixed(2)}` : '¥0.00'
}
const loadOrder = async () => {
if (!orderId.value) return
loading.value = true
try {
order.value = await orderApi.getOrderDetail(orderId.value)
const preferredItemId = String(route.query.orderItemId || '')
const firstItem = items.value.find((item: any) => String(item.id) === preferredItemId) || items.value[0]
form.orderItemId = firstItem?.id
form.refundAmount = Number(order.value?.actualAmount || order.value?.totalAmount || 0)
} catch (error: any) {
message.error(error?.message || '订单信息加载失败')
} finally {
loading.value = false
}
}
const submit = async () => {
if (!orderId.value) {
message.warning('缺少订单信息')
return
}
if (!form.reason.trim()) {
message.warning('请填写售后原因')
return
}
submitting.value = true
try {
await runWithGlobalLoading(() => afterSaleApi.apply({
orderId: orderId.value,
orderItemId: form.orderItemId,
type: form.type,
reason: form.reason.trim(),
refundAmount: form.refundAmount
}))
message.success('售后申请已提交')
router.replace({ path: '/after-sales', query: { orderId: orderId.value } })
} catch (error: any) {
message.error(error?.message || '售后申请提交失败')
} finally {
submitting.value = false
}
}
onMounted(loadOrder)
</script>
<template>
<div class="apply-page">
<header class="header">
<a-button type="text" @click="router.back()">
<LeftOutlined />
</a-button>
<h1>申请售后</h1>
<a-button type="link" @click="router.push('/after-sales')">记录</a-button>
</header>
<main class="content">
<section class="hero-card">
<span>售后申请</span>
<h2>{{ order?.orderNo || (orderId ? `订单 ${orderId}` : '选择订单') }}</h2>
<p>{{ order ? `可申请金额 ${formatMoney(order.actualAmount || order.totalAmount)}` : '从订单详情或订单中心进入可自动带入订单信息' }}</p>
</section>
<a-spin :spinning="loading">
<a-empty v-if="!orderId" description="缺少订单参数">
<a-button type="primary" @click="router.push('/orders')">选择订单</a-button>
</a-empty>
<section v-else class="form-card">
<a-form layout="vertical">
<a-form-item label="订单项目">
<a-select v-model:value="form.orderItemId" allow-clear placeholder="默认整单">
<a-select-option v-for="item in items" :key="item.id" :value="item.id">
{{ item.productTitle || `项目 ${item.id}` }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="售后类型" required>
<a-select v-model:value="form.type">
<a-select-option value="REFUND">退款</a-select-option>
<a-select-option value="AFTER_SALE">售后服务</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="退款金额">
<a-input-number v-model:value="form.refundAmount" :min="0" :step="0.01" style="width: 100%" />
</a-form-item>
<a-form-item label="原因说明" required>
<a-textarea v-model:value="form.reason" :rows="5" :maxlength="300" placeholder="请说明退款或售后原因" />
</a-form-item>
<a-button type="primary" block :loading="submitting" @click="submit">提交申请</a-button>
</a-form>
</section>
</a-spin>
</main>
</div>
</template>
<style scoped>
.apply-page { min-height: 100vh; padding-top: 60px; background: var(--theme-page-bg); color: var(--text-primary); }
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 9px 14px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
.header h1 { margin: 0; font-size: 18px; }
.content { padding: 16px 14px 32px; }
.hero-card, .form-card { border: 1px solid var(--theme-border); border-radius: 20px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); box-shadow: 0 18px 44px rgba(74, 68, 63, 0.08); }
.hero-card { padding: 22px; margin-bottom: 14px; background: var(--theme-gradient-soft); }
.hero-card span { color: var(--theme-primary); font-size: 12px; font-weight: 700; letter-spacing: .05em; }
.hero-card h2 { margin: 10px 0 6px; font-size: 21px; }
.hero-card p { margin: 0; color: var(--text-secondary); line-height: 1.6; }
.form-card { padding: 16px; }
:deep(.ant-btn-primary) { background: var(--theme-primary); border-color: var(--theme-primary); }
:deep(.ant-btn-link) { color: var(--theme-primary); }
:deep(.ant-input:focus), :deep(.ant-input-focused), :deep(.ant-select-focused .ant-select-selector) { border-color: var(--theme-primary) !important; box-shadow: var(--theme-focus-shadow) !important; }
</style>
@@ -0,0 +1,122 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { LeftOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { afterSaleApi, type AfterSaleVO } from '../api/order'
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const records = ref<AfterSaleVO[]>([])
const focusOrderId = computed(() => String(route.query.orderId || ''))
const focusedRecords = computed(() => {
if (!focusOrderId.value) return records.value
return records.value.filter(item => String(item.orderId) === focusOrderId.value)
})
const statusText = (status?: string) => {
if (status === 'PENDING') return '审核中'
if (status === 'APPROVED') return '已通过'
if (status === 'REJECTED') return '已拒绝'
return status || '处理中'
}
const typeText = (type?: string) => type === 'REFUND' ? '退款' : (type || '售后')
const formatMoney = (value?: number) => value === undefined || value === null ? '--' : `¥${Number(value).toFixed(2)}`
const formatTime = (value?: string) => value ? String(value).replace('T', ' ').slice(0, 16) : '--'
const loadRecords = async () => {
loading.value = true
try {
const page = await afterSaleApi.listMy({ page: 1, size: 50 })
records.value = page?.list || []
} catch (error: any) {
records.value = []
message.error(error?.message || '售后记录加载失败')
} finally {
loading.value = false
}
}
onMounted(loadRecords)
</script>
<template>
<div class="after-sales-page">
<header class="header">
<a-button type="text" @click="router.back()">
<LeftOutlined />
</a-button>
<h1>售后记录</h1>
<a-button type="link" @click="loadRecords">刷新</a-button>
</header>
<main class="content">
<section class="hero-card">
<span>售后服务</span>
<h2>{{ focusedRecords.length }} 条记录</h2>
<p>{{ focusOrderId ? `订单 ${focusOrderId} 的售后进度` : '查看退款、售后审核与处理说明' }}</p>
</section>
<a-spin :spinning="loading">
<a-empty v-if="!focusedRecords.length" description="暂无售后记录">
<a-button type="primary" @click="router.push('/orders')">查看订单</a-button>
</a-empty>
<article v-for="item in focusedRecords" :key="item.id" class="record-card">
<div class="record-head">
<div>
<span class="record-label">{{ typeText(item.type) }}</span>
<h3>{{ item.afterSaleNo || `售后 ${item.id}` }}</h3>
</div>
<strong>{{ statusText(item.status) }}</strong>
</div>
<dl>
<div>
<dt>订单</dt>
<dd>{{ item.orderId }}</dd>
</div>
<div>
<dt>金额</dt>
<dd>{{ formatMoney(item.refundAmount) }}</dd>
</div>
<div>
<dt>提交时间</dt>
<dd>{{ formatTime(item.createTime) }}</dd>
</div>
</dl>
<p v-if="item.reason">原因:{{ item.reason }}</p>
<p v-if="item.auditReason">处理说明:{{ item.auditReason }}</p>
<div class="actions">
<a-button size="small" @click="router.push(`/orders/${item.orderId}`)">订单详情</a-button>
<a-button size="small" @click="router.push({ path: '/service-progress', query: { orderId: String(item.orderId) } })">服务进度</a-button>
</div>
</article>
</a-spin>
</main>
</div>
</template>
<style scoped>
.after-sales-page { min-height: 100vh; padding-top: 60px; background: var(--theme-page-bg); color: var(--text-primary); }
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 9px 14px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
.header h1 { margin: 0; font-size: 18px; }
.content { padding: 16px 14px 32px; }
.hero-card, .record-card { border: 1px solid var(--theme-border); border-radius: 20px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); box-shadow: 0 18px 44px rgba(74, 68, 63, 0.08); }
.hero-card { padding: 22px; margin-bottom: 14px; background: var(--theme-gradient-soft); }
.hero-card span, .record-label { color: var(--theme-primary); font-size: 12px; font-weight: 700; letter-spacing: .05em; }
.hero-card h2 { margin: 10px 0 6px; font-size: 21px; }
.hero-card p, .record-card p { margin: 0; color: var(--text-secondary); line-height: 1.6; }
.record-card { padding: 16px; margin-top: 14px; }
.record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.record-head h3 { margin: 6px 0 0; font-size: 17px; }
.record-head strong { flex: 0 0 auto; padding: 6px 12px; border-radius: 999px; background: var(--theme-primary-soft); color: var(--theme-primary); font-size: 12px; }
dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
dt { color: var(--text-secondary); font-size: 12px; }
dd { margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
:deep(.ant-btn-primary) { background: var(--theme-primary); border-color: var(--theme-primary); }
:deep(.ant-btn-link) { color: var(--theme-primary); }
</style>
@@ -0,0 +1,340 @@
<script setup lang="ts">
import { computed, ref, shallowRef, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import {
CalendarOutlined,
LeftOutlined,
RightOutlined,
StarFilled,
UserOutlined
} from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { nailArtistApi, type NailArtistListItemVO } from '@/api/nail-artist'
const route = useRoute()
const router = useRouter()
const artists = ref<NailArtistListItemVO[]>([])
const loading = shallowRef(false)
const loadError = shallowRef('')
const shopId = computed(() => String(route.params.shopId || ''))
const pageTitle = computed(() => String(route.query.shopName || '美甲师'))
const formatRating = (value?: number | string) => {
const rating = Number(value || 0)
return rating > 0 ? rating.toFixed(1) : '暂无'
}
const parseSkillTags = (skills?: string) => {
return String(skills || '')
.split(/[,;,;、\s]+/)
.map(tag => tag.trim())
.filter(Boolean)
.slice(0, 4)
}
const formatWorkTime = (artist: NailArtistListItemVO) => {
const start = String(artist.workStartTime || '').slice(0, 5)
const end = String(artist.workEndTime || '').slice(0, 5)
return start && end ? `${start}-${end}` : '到店确认'
}
const displayName = (artist: NailArtistListItemVO) => artist.nickname || artist.identity || '美甲师'
const openArtist = (artist: NailArtistListItemVO) => {
const artistId = artist.userId
if (!artistId) {
message.info('美甲师信息暂未完善')
return
}
router.push(`/artist/${artistId}`)
}
const loadArtists = async () => {
if (!shopId.value) {
loadError.value = '缺少店铺信息'
return
}
loading.value = true
loadError.value = ''
try {
artists.value = await nailArtistApi.listByShopId(shopId.value)
} catch (error) {
loadError.value = error instanceof Error ? error.message : '美甲师列表加载失败'
message.error(loadError.value)
} finally {
loading.value = false
}
}
watch(shopId, loadArtists, { immediate: true })
</script>
<template>
<div class="artist-list-page">
<header class="artist-list-topbar">
<a-button class="nav-button" type="text" aria-label="返回" @click="router.back()">
<LeftOutlined />
</a-button>
<h1>{{ pageTitle }}</h1>
<span class="topbar-count">{{ artists.length }} 位</span>
</header>
<main class="artist-list-body">
<a-spin :spinning="loading">
<a-result v-if="loadError" status="warning" title="暂时无法查看美甲师" :sub-title="loadError">
<template #extra>
<a-button type="primary" @click="loadArtists">重试</a-button>
</template>
</a-result>
<template v-else>
<section class="list-summary">
<span>Artists</span>
<h2>本店美甲师</h2>
<p>选择熟悉的美甲师进入主页,查看作品、评价和近期可预约时间。</p>
</section>
<div v-if="artists.length" class="artist-cards">
<button
v-for="artist in artists"
:key="artist.userId || artist.id"
class="artist-card"
type="button"
@click="openArtist(artist)"
>
<a-avatar :size="56" class="artist-avatar">
<UserOutlined />
</a-avatar>
<div class="artist-copy">
<div class="artist-heading">
<strong>{{ displayName(artist) }}</strong>
<span :class="['status-chip', artist.status === 1 ? 'status-chip--active' : '']">
{{ artist.status === 1 ? '可预约' : '休息中' }}
</span>
</div>
<p>{{ artist.signature || artist.identity || '专注细节与稳定出品' }}</p>
<div class="artist-meta">
<span><StarFilled /> {{ formatRating(artist.rating) }}</span>
<span><CalendarOutlined /> {{ formatWorkTime(artist) }}</span>
</div>
<div v-if="parseSkillTags(artist.skills).length" class="tag-row">
<span v-for="tag in parseSkillTags(artist.skills)" :key="tag">{{ tag }}</span>
</div>
</div>
<RightOutlined class="card-arrow" />
</button>
</div>
<a-empty v-else class="empty-state" description="本店暂未配置可展示的美甲师" />
</template>
</a-spin>
</main>
</div>
</template>
<style scoped>
.artist-list-page {
min-height: 100vh;
background:
radial-gradient(circle at 18% 0%, rgba(232, 180, 184, 0.28), transparent 34%),
var(--theme-page-bg);
color: var(--text-primary);
}
.artist-list-topbar {
position: sticky;
top: 0;
z-index: 20;
display: grid;
grid-template-columns: 44px minmax(0, 1fr) 52px;
align-items: center;
height: 58px;
max-width: 960px;
margin: 0 auto;
padding: 0 14px;
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
border-bottom: 1px solid var(--theme-border);
backdrop-filter: blur(14px);
}
.nav-button {
width: 40px;
height: 40px;
}
.artist-list-topbar h1 {
margin: 0;
overflow: hidden;
font-size: 17px;
font-weight: 700;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
}
.topbar-count {
color: var(--text-secondary);
font-size: 13px;
text-align: right;
}
.artist-list-body {
max-width: 960px;
margin: 0 auto;
padding: 18px 14px 36px;
}
.list-summary {
padding: 20px;
background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent);
border: 1px solid color-mix(in srgb, var(--theme-border) 78%, transparent);
border-radius: 16px;
box-shadow: 0 16px 40px rgba(124, 83, 87, 0.08);
backdrop-filter: blur(18px);
}
.list-summary span {
color: var(--theme-primary);
font-size: 12px;
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.list-summary h2 {
margin: 8px 0;
font-size: 22px;
line-height: 1.2;
}
.list-summary p {
margin: 0;
color: var(--text-secondary);
line-height: 1.7;
}
.artist-cards {
display: grid;
gap: 12px;
margin-top: 16px;
}
.artist-card {
display: grid;
grid-template-columns: 56px minmax(0, 1fr) 18px;
gap: 14px;
align-items: center;
width: 100%;
padding: 16px;
color: inherit;
text-align: left;
cursor: pointer;
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
border: 1px solid color-mix(in srgb, var(--theme-border) 82%, transparent);
border-radius: 16px;
box-shadow: 0 12px 28px rgba(124, 83, 87, 0.06);
}
.artist-avatar {
color: var(--theme-primary);
background: var(--theme-primary-soft);
border: 2px solid #fff;
}
.artist-copy {
min-width: 0;
}
.artist-heading {
display: flex;
gap: 8px;
align-items: center;
justify-content: space-between;
}
.artist-heading strong {
overflow: hidden;
font-size: 17px;
text-overflow: ellipsis;
white-space: nowrap;
}
.status-chip {
flex: 0 0 auto;
padding: 4px 8px;
color: var(--text-secondary);
font-size: 12px;
background: color-mix(in srgb, var(--theme-card-bg) 70%, var(--theme-primary-soft));
border-radius: 999px;
}
.status-chip--active {
color: var(--theme-primary);
background: var(--theme-primary-soft);
}
.artist-copy p {
display: -webkit-box;
margin: 6px 0 10px;
overflow: hidden;
color: var(--text-secondary);
font-size: 13px;
line-height: 1.5;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.artist-meta,
.tag-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.artist-meta span {
display: inline-flex;
gap: 4px;
align-items: center;
color: var(--text-secondary);
font-size: 12px;
}
.artist-meta svg {
color: var(--theme-primary);
}
.tag-row {
margin-top: 10px;
}
.tag-row span {
padding: 4px 8px;
color: var(--theme-primary);
font-size: 12px;
background: var(--theme-primary-soft);
border-radius: 999px;
}
.card-arrow {
color: var(--text-secondary);
font-size: 12px;
}
.empty-state {
margin-top: 48px;
}
@media (max-width: 640px) {
.artist-list-body {
padding: 14px 12px 30px;
}
.artist-card {
grid-template-columns: 52px minmax(0, 1fr) 16px;
gap: 12px;
padding: 14px;
}
}
</style>
@@ -0,0 +1,951 @@
<script setup lang="ts">
import { computed, onMounted, ref, shallowRef } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import {
CalendarOutlined,
HeartOutlined,
LeftOutlined,
MessageOutlined,
SafetyCertificateOutlined,
ShareAltOutlined,
ShopOutlined,
StarFilled,
UserOutlined
} from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
import {
getPublicImageFileIds,
refreshPublicImageUrl,
resolvePublicImageUrl,
resolvePublicImageUrlsSync
} from '@/utils/public-image-assets'
import {
nailArtistApi,
type NailArtistAvailabilityVO,
type NailArtistProfileVO,
type NailArtistReviewVO,
type NailArtistWorkVO
} from '@/api/nail-artist'
import { productApi, type ProductVO } from '@/api/product'
const route = useRoute()
const router = useRouter()
const profile = shallowRef<NailArtistProfileVO | null>(null)
const workImageUrls = ref<Record<string, string>>({})
const reviews = ref<NailArtistReviewVO[]>([])
const availability = ref<NailArtistAvailabilityVO[]>([])
const loading = shallowRef(false)
const loadError = shallowRef('')
const selectedDate = shallowRef('')
const workFilter = shallowRef('全部')
const artistId = computed(() => String(route.params.id || ''))
const artistName = computed(() => profile.value?.artistName || '美甲师')
const ratingValue = computed(() => Number(profile.value?.rating || 0))
const ratingText = computed(() => ratingValue.value > 0 ? ratingValue.value.toFixed(1) : '暂无')
const serviceCountText = computed(() => formatCompactNumber(Number(profile.value?.serviceCount || 0)))
const goodRateText = computed(() => ratingValue.value > 0 ? `${Math.min(99, Math.round((ratingValue.value / 5) * 100))}%` : '暂无')
const works = computed<NailArtistWorkVO[]>(() => profile.value?.works || [])
const styleTags = computed(() => profile.value?.styleTags?.filter(Boolean) || [])
const firstWorkImage = computed(() => {
const firstWork = works.value.find(work => getWorkImage(work) !== DEFAULT_PRODUCT_IMAGE)
return firstWork ? getWorkImage(firstWork) : DEFAULT_PRODUCT_IMAGE
})
const workTimeText = computed(() => {
const start = profile.value?.workStartTime?.slice(0, 5)
const end = profile.value?.workEndTime?.slice(0, 5)
return start && end ? `${start}-${end}` : '到店确认'
})
const availabilityGroups = computed(() => {
const groupMap = new Map<string, NailArtistAvailabilityVO[]>()
availability.value
.filter(slot => slot.available !== false)
.forEach(slot => {
const date = slot.dateText || String(slot.startTime || '').slice(0, 10)
if (!date) return
const slots = groupMap.get(date) || []
slots.push(slot)
groupMap.set(date, slots)
})
return Array.from(groupMap.entries()).map(([date, slots]) => ({
date,
label: formatDateLabel(date),
week: formatWeekLabel(date),
slots
}))
})
const selectedDateSlots = computed(() => {
return availabilityGroups.value.find(group => group.date === selectedDate.value)?.slots || []
})
const workFilterOptions = computed(() => {
const tags = new Set<string>()
works.value.forEach(work => work.tags?.filter(Boolean).forEach(tag => tags.add(tag)))
return ['全部', ...Array.from(tags).slice(0, 5)]
})
const filteredWorks = computed(() => {
if (workFilter.value === '全部') {
return works.value
}
return works.value.filter(work => work.tags?.includes(workFilter.value))
})
const PROFILE_WORK_LIMIT = 20
const certificationText = computed(() => {
const identity = profile.value?.identity || '认证美甲师'
const experience = Number(profile.value?.experience || 0)
return experience > 0 ? `${identity} · ${experience} 年经验` : identity
})
function formatCompactNumber(value: number) {
if (value >= 1000) {
return `${(value / 1000).toFixed(1)}k+`
}
return String(value || 0)
}
function formatDateLabel(dateText: string) {
const date = new Date(`${dateText}T00:00:00`)
if (Number.isNaN(date.getTime())) {
return dateText
}
return `${date.getMonth() + 1}.${date.getDate()}`
}
function formatWeekLabel(dateText: string) {
const date = new Date(`${dateText}T00:00:00`)
if (Number.isNaN(date.getTime())) {
return '可约'
}
const today = new Date()
today.setHours(0, 0, 0, 0)
const diffDays = Math.round((date.getTime() - today.getTime()) / 86400000)
if (diffDays === 0) return '今天'
if (diffDays === 1) return '明天'
return ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][date.getDay()]
}
const formatDateTime = (value?: string) => {
if (!value) {
return ''
}
return value.replace('T', ' ').slice(0, 16)
}
const roundedRating = (value?: number | string) => Math.round(Number(value || 0))
const openProduct = (work: NailArtistWorkVO) => {
if (!work.id) {
return
}
router.push(`/product/${work.id}`)
}
const getWorkImage = (work: NailArtistWorkVO) => workImageUrls.value[String(work.id)] || work.coverImageUrl || DEFAULT_PRODUCT_IMAGE
const isArtistBookableForProduct = (product: ProductVO) => {
const ids = String(product.bookableArtists || '')
.split(',')
.map(id => id.trim())
.filter(Boolean)
return ids.includes(artistId.value)
}
const mapProductToWork = (product: ProductVO): NailArtistWorkVO & { imageFileIds?: string } => ({
id: product.id,
title: product.title || product.name,
description: product.description,
price: product.price,
imageUrls: product.imageUrls,
imageFileIds: product.imageFileIds,
tags: product.tagList || product.tags?.split(/[;,,、]/).map(tag => tag.trim()).filter(Boolean),
likeCount: product.likeCount,
collectCount: product.collectCount
})
const loadSupplementWorks = async (existingWorks: NailArtistWorkVO[]): Promise<NailArtistWorkVO[]> => {
if (existingWorks.length >= PROFILE_WORK_LIMIT) {
return existingWorks.slice(0, PROFILE_WORK_LIMIT)
}
const existingIds = new Set(existingWorks.map(work => String(work.id)))
const products = await productApi.getAllProducts().catch(() => [])
const supplementWorks = products
.filter(product => !existingIds.has(String(product.id)))
.filter(product => !profile.value?.shopId || String(product.shopId || '') === String(profile.value.shopId))
.filter(isArtistBookableForProduct)
.slice(0, PROFILE_WORK_LIMIT - existingWorks.length)
.map(mapProductToWork)
return [...existingWorks, ...supplementWorks]
}
const loadWorkImages = async (nextWorks: NailArtistWorkVO[]) => {
const entries = await Promise.all(nextWorks.map(async work => {
const cachedUrls = resolvePublicImageUrlsSync(work as NailArtistWorkVO & Record<string, unknown>, '')
const imageUrl = cachedUrls[0] || await resolvePublicImageUrl(work as NailArtistWorkVO & Record<string, unknown>, DEFAULT_PRODUCT_IMAGE)
return [String(work.id), imageUrl] as const
}))
workImageUrls.value = Object.fromEntries(entries)
}
const handleWorkImageError = async (work: NailArtistWorkVO) => {
const fileId = getPublicImageFileIds(work as NailArtistWorkVO & Record<string, unknown>)[0]
const imageUrl = fileId ? await refreshPublicImageUrl(fileId, DEFAULT_PRODUCT_IMAGE) : DEFAULT_PRODUCT_IMAGE
workImageUrls.value = { ...workImageUrls.value, [String(work.id)]: imageUrl }
}
const openShop = () => {
if (!profile.value?.shopId) {
message.info('门店信息暂未完善')
return
}
router.push(`/shop/${profile.value.shopId}`)
}
const handleBookNow = () => {
const firstWork = works.value[0]
if (firstWork?.id) {
openProduct(firstWork)
return
}
openShop()
}
const handleConsult = () => {
if (profile.value?.shopId) {
router.push(`/shop/${profile.value.shopId}`)
return
}
message.info('请先选择作品后联系门店')
}
const handleShare = async () => {
const shareTitle = `${artistName.value}的美甲师主页`
const shareUrl = window.location.href
try {
if (navigator.share) {
await navigator.share({ title: shareTitle, url: shareUrl })
return
}
await navigator.clipboard.writeText(shareUrl)
message.success('主页链接已复制')
} catch {
message.info('分享已取消')
}
}
const loadProfile = async () => {
if (!artistId.value) {
loadError.value = '缺少美甲师信息'
return
}
loading.value = true
loadError.value = ''
try {
const [profileData, availabilityData, reviewData] = await Promise.all([
nailArtistApi.getPublicProfile(artistId.value),
nailArtistApi.getAvailability(artistId.value),
nailArtistApi.listReviews(artistId.value)
])
profile.value = profileData
availability.value = availabilityData || profileData.availability || []
reviews.value = reviewData || profileData.reviews || []
const nextWorks = await loadSupplementWorks(profileData.works || [])
profile.value = { ...profileData, works: nextWorks }
await loadWorkImages(nextWorks)
selectedDate.value = availability.value[0]?.dateText || String(availability.value[0]?.startTime || '').slice(0, 10)
} catch (error) {
loadError.value = error instanceof Error ? error.message : '美甲师个人页加载失败'
message.error(loadError.value)
} finally {
loading.value = false
}
}
onMounted(loadProfile)
</script>
<template>
<div class="artist-profile">
<header class="artist-topbar">
<a-button type="text" class="icon-btn" aria-label="返回" @click="router.back()">
<LeftOutlined />
</a-button>
<h1>美甲师</h1>
<a-button type="text" class="icon-btn" aria-label="分享" @click="handleShare">
<ShareAltOutlined />
</a-button>
</header>
<main class="artist-body">
<a-spin :spinning="loading">
<a-result v-if="loadError" status="warning" title="暂时无法查看个人页" :sub-title="loadError">
<template #extra>
<a-button type="primary" @click="loadProfile">重试</a-button>
</template>
</a-result>
<template v-else-if="profile">
<section class="profile-card">
<img class="profile-glow-image" :src="firstWorkImage" alt="" aria-hidden="true" />
<div class="avatar-wrap">
<a-avatar :size="112" :src="profile.avatar">
<UserOutlined />
</a-avatar>
<span class="top-badge">TOP 1%</span>
</div>
<h2>{{ artistName }}</h2>
<div class="rating-line">
<span class="star-row">
<StarFilled v-for="star in 5" :key="star" :class="{ active: star <= roundedRating(profile.rating) }" />
</span>
<strong>{{ ratingText }}</strong>
<span>{{ reviews.length }} 条评价</span>
</div>
<p>{{ profile.signature || profile.identity || '专注细节与稳定出品,让每一次指尖细节都更贴合你的风格。' }}</p>
<button type="button" class="shop-link" @click="openShop">
<ShopOutlined />
<span>{{ profile.shopName || '门店待确认' }}</span>
</button>
<div class="style-tags">
<span v-for="tag in styleTags" :key="tag">{{ tag }}</span>
<span v-if="!styleTags.length">风格待补充</span>
</div>
</section>
<section class="stats-section">
<div class="stat-card">
<strong>{{ serviceCountText }}</strong>
<span>累计服务</span>
</div>
<div class="stat-card">
<strong>{{ goodRateText }}</strong>
<span>好评率</span>
</div>
<div class="cert-card">
<SafetyCertificateOutlined />
<div>
<span>认证资质</span>
<strong>{{ certificationText }}</strong>
</div>
</div>
</section>
<section class="content-section">
<div class="section-head">
<div>
<span>Schedule</span>
<h3>可预约时间</h3>
</div>
<small>{{ workTimeText }}</small>
</div>
<div v-if="availabilityGroups.length" class="date-strip">
<button
v-for="group in availabilityGroups"
:key="group.date"
type="button"
:class="['date-card', { active: selectedDate === group.date }]"
@click="selectedDate = group.date"
>
<span>{{ group.week }}</span>
<strong>{{ group.label }}</strong>
</button>
</div>
<div v-if="selectedDateSlots.length" class="time-grid">
<button v-for="slot in selectedDateSlots" :key="slot.startTime" type="button" class="time-chip">
{{ slot.timeText }}
</button>
</div>
<a-empty v-else description="近期暂未放出可预约时间" />
</section>
<section class="content-section">
<div class="section-head">
<div>
<span>Portfolio</span>
<h3>作品集</h3>
</div>
</div>
<div v-if="workFilterOptions.length > 1" class="filter-row">
<button
v-for="option in workFilterOptions"
:key="option"
type="button"
:class="['filter-chip', { active: workFilter === option }]"
@click="workFilter = option"
>
{{ option }}
</button>
</div>
<div v-if="filteredWorks.length" class="work-grid">
<button v-for="work in filteredWorks" :key="work.id" type="button" class="work-card" @click="openProduct(work)">
<img :src="getWorkImage(work)" :alt="work.title || '作品'" loading="lazy" decoding="async" @error="handleWorkImageError(work)" />
<span>{{ work.title || '美甲作品' }}</span>
</button>
</div>
<a-empty v-else description="作品正在整理中" />
</section>
<section class="content-section review-section">
<div class="section-head">
<div>
<span>Reviews</span>
<h3>用户评价</h3>
</div>
<small>{{ reviews.length }} 条</small>
</div>
<div v-if="reviews.length" class="review-list">
<article v-for="review in reviews" :key="review.id" class="review-item">
<div class="review-top">
<a-avatar :size="44" :src="review.customerAvatar">
<UserOutlined />
</a-avatar>
<div class="review-author">
<strong>{{ review.customerName || '匿名用户' }}</strong>
<span class="star-row">
<StarFilled v-for="star in 5" :key="star" :class="{ active: star <= roundedRating(review.rating) }" />
</span>
</div>
<time>{{ formatDateTime(review.submittedAt) }}</time>
</div>
<p>{{ review.content || '这位用户没有填写文字评价' }}</p>
<div v-if="review.imageUrls?.length" class="review-images">
<img v-for="url in review.imageUrls" :key="url" :src="url" alt="评价图片" loading="lazy" decoding="async" />
</div>
</article>
</div>
<a-empty v-else description="还没有公开评价" />
</section>
</template>
</a-spin>
</main>
<footer v-if="profile" class="booking-bar">
<button type="button" class="bar-icon-btn" @click="handleConsult">
<MessageOutlined />
<span>咨询</span>
</button>
<button type="button" class="bar-icon-btn" @click="message.info('收藏功能即将开放')">
<HeartOutlined />
<span>收藏</span>
</button>
<button type="button" class="book-btn" @click="handleBookNow">
<CalendarOutlined />
<span>立即预约</span>
</button>
</footer>
</div>
</template>
<style scoped>
.artist-profile {
min-height: 100vh;
background:
linear-gradient(180deg, rgba(232, 180, 184, 0.24), rgba(255, 248, 244, 0) 260px),
var(--theme-page-bg);
color: var(--text-primary);
}
.artist-topbar {
position: sticky;
top: 0;
z-index: 30;
display: grid;
grid-template-columns: 44px minmax(0, 1fr) 44px;
align-items: center;
height: 62px;
max-width: 960px;
margin: 0 auto;
padding: 0 14px;
background: color-mix(in srgb, var(--theme-card-bg) 86%, transparent);
border-bottom: 1px solid color-mix(in srgb, var(--theme-border) 72%, transparent);
backdrop-filter: blur(18px);
}
.artist-topbar h1 {
margin: 0;
font-size: 17px;
font-weight: 700;
text-align: center;
}
.icon-btn {
width: 40px;
height: 40px;
}
.artist-body {
max-width: 960px;
margin: 0 auto;
padding: 22px 14px 116px;
}
.profile-card,
.content-section,
.stat-card,
.cert-card,
.review-item {
background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent);
border: 1px solid color-mix(in srgb, var(--theme-border) 72%, transparent);
box-shadow: 0 18px 48px rgba(124, 83, 87, 0.08);
backdrop-filter: blur(18px);
}
.profile-card {
position: relative;
display: grid;
justify-items: center;
padding: 34px 20px 24px;
overflow: hidden;
text-align: center;
border-radius: 24px;
}
.profile-glow-image {
position: absolute;
inset: 0;
width: 100%;
height: 170px;
object-fit: cover;
opacity: 0.18;
filter: blur(14px);
transform: scale(1.08);
}
.avatar-wrap {
position: relative;
z-index: 1;
}
.avatar-wrap :deep(.ant-avatar) {
color: var(--theme-primary);
background: var(--theme-primary-soft);
border: 4px solid #fff;
box-shadow: 0 16px 36px rgba(124, 83, 87, 0.18);
}
.top-badge {
position: absolute;
right: -8px;
bottom: 8px;
padding: 5px 8px;
color: #fff;
font-size: 11px;
font-weight: 800;
background: var(--theme-primary);
border: 2px solid #fff;
border-radius: 999px;
}
.profile-card h2 {
position: relative;
margin: 18px 0 8px;
font-size: 26px;
line-height: 1.2;
}
.rating-line {
position: relative;
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
justify-content: center;
color: var(--text-secondary);
font-size: 13px;
}
.rating-line strong {
color: var(--text-primary);
}
.star-row {
display: inline-flex;
gap: 2px;
color: color-mix(in srgb, var(--theme-border) 70%, #fff);
}
.star-row .active {
color: #b88935;
}
.profile-card p {
position: relative;
max-width: 640px;
margin: 14px 0;
color: var(--text-secondary);
line-height: 1.75;
}
.shop-link {
position: relative;
display: inline-flex;
gap: 8px;
align-items: center;
max-width: 100%;
padding: 8px 12px;
color: var(--theme-primary);
cursor: pointer;
background: var(--theme-primary-soft);
border: 0;
border-radius: 999px;
}
.shop-link span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.style-tags {
position: relative;
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
margin-top: 18px;
}
.style-tags span,
.filter-chip {
padding: 7px 11px;
color: var(--theme-primary);
font-size: 12px;
background: color-mix(in srgb, var(--theme-primary-soft) 86%, #fff);
border: 1px solid color-mix(in srgb, var(--theme-primary) 18%, transparent);
border-radius: 999px;
}
.stats-section {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
margin-top: 18px;
}
.stat-card {
display: grid;
gap: 6px;
min-height: 96px;
padding: 18px;
border-radius: 18px;
}
.stat-card strong {
color: var(--theme-primary);
font-size: 24px;
line-height: 1.1;
}
.stat-card span,
.cert-card span {
color: var(--text-secondary);
font-size: 13px;
}
.cert-card {
grid-column: 1 / -1;
display: flex;
gap: 12px;
align-items: center;
padding: 16px;
border-radius: 18px;
}
.cert-card svg {
color: #b88935;
font-size: 24px;
}
.cert-card div {
display: grid;
gap: 4px;
min-width: 0;
}
.cert-card strong {
overflow: hidden;
font-size: 15px;
text-overflow: ellipsis;
white-space: nowrap;
}
.content-section {
margin-top: 22px;
padding: 18px;
border-radius: 22px;
}
.section-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 16px;
}
.section-head span {
color: var(--theme-primary);
font-size: 12px;
font-weight: 800;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.section-head h3 {
margin: 4px 0 0;
font-size: 19px;
line-height: 1.25;
}
.section-head small {
color: var(--text-secondary);
font-size: 12px;
}
.date-strip {
display: flex;
gap: 10px;
overflow-x: auto;
padding-bottom: 4px;
}
.date-card {
display: grid;
flex: 0 0 80px;
gap: 8px;
place-items: center;
min-height: 92px;
color: var(--text-secondary);
cursor: pointer;
background: color-mix(in srgb, var(--theme-card-bg) 72%, var(--theme-primary-soft));
border: 1px solid color-mix(in srgb, var(--theme-border) 72%, transparent);
border-radius: 18px;
}
.date-card strong {
color: var(--text-primary);
font-size: 18px;
}
.date-card.active {
color: #fff;
background: var(--theme-primary);
border-color: var(--theme-primary);
}
.date-card.active strong {
color: #fff;
}
.time-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 10px;
margin-top: 14px;
}
.time-chip {
min-height: 44px;
color: var(--theme-primary);
font-weight: 700;
cursor: default;
background: var(--theme-primary-soft);
border: 1px solid color-mix(in srgb, var(--theme-primary) 18%, transparent);
border-radius: 14px;
}
.filter-row {
display: flex;
gap: 8px;
overflow-x: auto;
margin-bottom: 14px;
}
.filter-chip {
flex: 0 0 auto;
cursor: pointer;
}
.filter-chip.active {
color: #fff;
background: var(--theme-primary);
}
.work-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.work-card {
position: relative;
min-height: 0;
padding: 0;
overflow: hidden;
cursor: pointer;
background: var(--theme-primary-soft);
border: 0;
border-radius: 22px;
aspect-ratio: 3 / 4;
}
.work-card img {
width: 100%;
height: 100%;
object-fit: cover;
}
.work-card::after {
position: absolute;
inset: auto 0 0;
height: 46%;
content: "";
background: linear-gradient(180deg, transparent, rgba(31, 27, 23, 0.62));
}
.work-card span {
position: absolute;
right: 12px;
bottom: 12px;
left: 12px;
z-index: 1;
overflow: hidden;
color: #fff;
font-weight: 700;
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
}
.review-list {
display: grid;
gap: 12px;
}
.review-item {
padding: 14px;
border-radius: 18px;
}
.review-top {
display: grid;
grid-template-columns: 44px minmax(0, 1fr) auto;
gap: 10px;
align-items: center;
}
.review-author {
display: grid;
gap: 4px;
min-width: 0;
}
.review-author strong {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.review-top time {
color: var(--text-secondary);
font-size: 12px;
}
.review-item p {
margin: 12px 0 0;
color: var(--text-secondary);
line-height: 1.7;
white-space: pre-wrap;
}
.review-images {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 12px;
}
.review-images img {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: 14px;
}
.booking-bar {
position: fixed;
right: 0;
bottom: 0;
left: 0;
z-index: 40;
display: grid;
grid-template-columns: 64px 64px minmax(0, 1fr);
gap: 10px;
align-items: center;
max-width: 960px;
margin: 0 auto;
padding: 12px 14px max(12px, env(safe-area-inset-bottom));
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
border-top: 1px solid var(--theme-border);
box-shadow: 0 -16px 40px rgba(124, 83, 87, 0.1);
backdrop-filter: blur(18px);
}
.bar-icon-btn,
.book-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 48px;
cursor: pointer;
border: 0;
border-radius: 999px;
}
.bar-icon-btn {
flex-direction: column;
gap: 2px;
color: var(--theme-primary);
font-size: 11px;
background: var(--theme-primary-soft);
}
.book-btn {
gap: 8px;
color: #fff;
font-size: 15px;
font-weight: 800;
background: var(--theme-primary);
}
@media (max-width: 640px) {
.artist-body {
padding: 18px 12px 112px;
}
.profile-card {
padding: 30px 16px 22px;
}
.profile-card h2 {
font-size: 24px;
}
.content-section {
padding: 16px;
}
.time-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
</style>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,446 @@
<template>
<div class="mobile-container">
<header class="header">
<a-button type="text" class="back-btn" @click="router.back()">
<LeftOutlined />
</a-button>
<h1>我的优惠券</h1>
<div class="placeholder"></div>
</header>
<div class="coupon-section">
<a-card :bordered="false" class="filter-card">
<a-segmented
v-model:value="activeFilter"
:options="filterOptions"
class="filter-segmented"
/>
</a-card>
<a-card v-if="loading" :bordered="false" class="content-card">
<a-skeleton :paragraph="{ rows: 3 }" />
</a-card>
<a-card v-else-if="coupons.length === 0" :bordered="false" class="content-card">
<a-empty description="暂无优惠券">
<a-button type="primary">去领取</a-button>
</a-empty>
</a-card>
<div v-else class="coupon-list">
<a-card
v-for="coupon in filteredCoupons"
:key="coupon.id"
class="coupon-card"
:class="{ 'expired': coupon.status === 3 }"
>
<div class="coupon-content">
<div class="coupon-value">
{{ coupon.couponType === 1 ? `${coupon.discountValue}折` : `¥${coupon.reduceAmount}` }}
</div>
<div class="coupon-info">
<div class="coupon-name">{{ coupon.couponName }}</div>
<div class="coupon-condition" v-if="coupon.couponType === 2">
满{{ coupon.minAmount }}元可用
</div>
<div class="coupon-time">
{{ formatDate(coupon.startTime) }} 至 {{ formatDate(coupon.endTime) }}
</div>
<div :class="['coupon-status', getStatusClass(coupon.status)]">
{{ coupon.statusName }}
</div>
</div>
</div>
</a-card>
</div>
</div>
</div>
</template>
<script setup lang="ts">
/**
* CouponView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { LeftOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { couponApi } from '@/api/coupon'
/**
* Purpose: router supports CouponView.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.
*/
const router = useRouter()
/** loading is a reactive state variable used by the template and event handlers. */
const loading = ref(false)
/**
* Purpose: coupons supports CouponView.vue by holding or executing the coupons 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.
*/
const coupons = ref<any[]>([])
/** activeFilter is a reactive state variable used by the template and event handlers. */
const activeFilter = ref('all')
/**
* Purpose: filterOptions supports CouponView.vue by holding or executing the filter options 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.
*/
const filterOptions = [
{ label: '全部', value: 'all' },
{ label: '未使用', value: 'available' },
{ label: '已使用', value: 'used' },
{ label: '已过期', value: 'expired' }
]
/** filteredCoupons is a reactive state variable used by the template and event handlers. */
const filteredCoupons = computed(() => {
if (activeFilter.value === 'all') {
return coupons.value
} else if (activeFilter.value === 'available') {
return coupons.value.filter(coupon => coupon.status === 1)
} else if (activeFilter.value === 'used') {
return coupons.value.filter(coupon => coupon.status === 2)
} else if (activeFilter.value === 'expired') {
return coupons.value.filter(coupon => coupon.status === 3)
}
return coupons.value
})
/** loadCoupons is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadCoupons = async () => {
loading.value = true
try {
const response = await couponApi.listUserCoupons() as any
coupons.value = response || []
} catch (error) {
console.error('获取优惠券列表失败:', error)
message.error('获取优惠券列表失败')
} finally {
loading.value = false
}
}
/** getStatusClass is a local helper used by this page script. */
const getStatusClass = (status: number) => {
switch (status) {
case 1:
return 'available'
case 2:
return 'used'
case 3:
return 'expired'
default:
return ''
}
}
/** formatDate is a local helper used by this page script. */
const formatDate = (dateString: string) => {
if (!dateString) return ''
const date = new Date(dateString)
return date.toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit'
})
}
onMounted(() => {
loadCoupons()
})
</script>
<style scoped>
.mobile-container {
padding-top: 60px;
min-height: 100vh;
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;
}
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
justify-content: space-between;
align-items: center;
height: 60px;
padding: 10px 15px;
background: rgba(255, 255, 255, 0.92);
border-bottom: 1px solid var(--theme-border);
backdrop-filter: blur(14px);
}
.header h1 {
font-size: 18px;
font-weight: bold;
margin: 0;
color: var(--text-primary);
}
.back-btn {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
color: var(--text-primary);
}
.placeholder {
width: 40px;
}
.coupon-section {
padding: 15px;
}
.filter-card {
border-radius: 14px;
margin-bottom: 15px;
background: var(--theme-card-bg);
border: 1px solid var(--theme-border);
box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08);
}
.filter-segmented {
width: 100%;
}
.content-card {
border-radius: 14px;
background: var(--theme-card-bg);
border: 1px solid var(--theme-border);
box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08);
padding: 40px 20px;
}
.coupon-list {
display: flex;
flex-direction: column;
gap: 15px;
}
.coupon-card {
border-radius: 14px;
overflow: hidden;
background: var(--theme-gradient-soft);
border: 1px solid var(--theme-border);
transition: all 0.3s ease;
box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08);
}
.coupon-card:hover {
transform: translateY(-2px);
box-shadow: 0 18px 44px rgba(122, 67, 88, 0.12);
}
.coupon-card.expired {
opacity: 0.66;
background: var(--theme-card-bg);
}
.coupon-content {
display: flex;
align-items: center;
gap: 20px;
padding: 20px;
}
.coupon-value {
font-size: 24px;
font-weight: 700;
color: var(--theme-primary);
padding: 20px;
background: var(--theme-primary-soft);
border-radius: 8px;
min-width: 100px;
text-align: center;
}
.coupon-card.expired .coupon-value {
color: var(--text-secondary);
background: var(--theme-primary-soft);
}
.coupon-info {
flex: 1;
display: flex;
flex-direction: column;
gap: 8px;
}
.coupon-name {
font-size: 16px;
font-weight: 600;
color: var(--text-primary);
}
.coupon-condition {
font-size: 12px;
color: var(--theme-primary);
}
.coupon-time {
font-size: 12px;
color: var(--text-secondary);
}
.coupon-status {
font-size: 12px;
font-weight: 600;
padding: 2px 8px;
border-radius: 8px;
align-self: flex-start;
}
.coupon-status.available {
background: var(--theme-primary-soft);
color: var(--theme-primary);
}
.coupon-status.used {
background: var(--theme-primary-soft);
color: var(--text-secondary);
}
.coupon-status.expired {
background: var(--theme-primary-soft);
color: var(--theme-accent);
}
:deep(.ant-segmented) {
background: var(--theme-primary-soft);
}
:deep(.ant-segmented-item-selected) {
background: var(--theme-primary);
color: #fff;
}
:deep(.ant-btn-primary) {
background: var(--theme-primary);
border-color: var(--theme-primary);
}
.mobile-container {
padding-top: 68px;
background:
radial-gradient(circle at 84% 0%, color-mix(in srgb, var(--theme-primary) 26%, transparent), transparent 32%),
linear-gradient(180deg, color-mix(in srgb, var(--theme-card-bg) 78%, transparent), var(--theme-page-bg));
}
.header {
height: 64px;
padding: 12px 18px 10px;
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
}
.header h1 {
font-size: 17px;
font-weight: 820;
}
.back-btn {
border-radius: 999px;
background: color-mix(in srgb, var(--theme-card-bg) 74%, transparent);
}
.coupon-section {
padding: 18px;
}
.filter-card,
.content-card {
border-radius: 22px;
background: color-mix(in srgb, var(--theme-card-bg) 90%, transparent);
box-shadow: 0 18px 40px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
}
.coupon-list {
gap: 14px;
}
.coupon-card {
position: relative;
overflow: hidden;
border-radius: 24px;
background:
linear-gradient(135deg, color-mix(in srgb, var(--theme-card-bg) 88%, transparent), color-mix(in srgb, var(--theme-primary) 20%, var(--theme-card-bg)));
box-shadow: 0 20px 42px color-mix(in srgb, var(--theme-neutral) 9%, transparent);
}
.coupon-card::before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 112px;
width: 1px;
background: linear-gradient(var(--theme-border) 52%, transparent 0);
background-size: 1px 12px;
}
.coupon-content {
gap: 18px;
padding: 18px;
}
.coupon-value {
min-width: 78px;
padding: 16px 8px;
border-radius: 18px;
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-primary) 24%, var(--theme-card-bg));
font-family: Georgia, 'Times New Roman', serif;
}
.coupon-name {
font-weight: 820;
}
.coupon-condition,
.coupon-status.available {
color: var(--theme-primary-action);
}
:deep(.ant-segmented) {
width: 100%;
padding: 4px;
border-radius: 16px;
background: color-mix(in srgb, var(--theme-primary) 16%, var(--theme-card-bg));
}
:deep(.ant-segmented-item) {
border-radius: 13px;
}
:deep(.ant-segmented-item-selected) {
background: var(--theme-card-bg);
color: var(--theme-primary-action);
box-shadow: 0 10px 20px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
}
:deep(.ant-btn-primary) {
border-color: transparent;
background: linear-gradient(135deg, var(--theme-primary-action), var(--theme-secondary));
}
@media (min-width: 992px) {
.coupon-section {
max-width: 960px;
margin: 0 auto;
padding: 24px;
}
}
</style>
@@ -0,0 +1,96 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { LeftOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { userApi, type ContactInfoVO } from '@/api/user'
import { BRAND_CONFIG } from '@/config/brand'
const router = useRouter()
const loading = ref(false)
const contact = ref<ContactInfoVO | null>(null)
const loadContact = async () => {
loading.value = true
try {
contact.value = await userApi.getPlatformContact()
} catch (error: any) {
contact.value = null
message.warning(error?.message || '暂时无法加载客服信息')
} finally {
loading.value = false
}
}
onMounted(loadContact)
</script>
<template>
<div class="help-page">
<header class="header">
<a-button type="text" @click="router.back()">
<LeftOutlined />
</a-button>
<h1>帮助与客服</h1>
<a-button type="link" @click="loadContact">刷新</a-button>
</header>
<main class="content">
<section class="hero-card">
<span>{{ BRAND_CONFIG.appName }}客服</span>
<h2>帮助与客服</h2>
<p>订单、预约、售后和账号问题都可以从这里继续处理。</p>
</section>
<a-spin :spinning="loading">
<section class="section-card">
<h3>平台联系信息</h3>
<p v-if="contact?.contactName">{{ contact.contactName }} {{ contact.roleLabel || '' }}</p>
<p v-if="contact?.phoneAvailable && contact.phone">电话:{{ contact.phone }}</p>
<p v-if="contact?.wechatAvailable && contact.wechatId">微信:{{ contact.wechatId }}</p>
<p v-if="contact?.platformContactText">{{ contact.platformContactText }}</p>
<p v-if="!contact">暂无可展示的客服信息,请稍后重试或通过订单详情联系服务人员。</p>
</section>
<section class="quick-grid">
<button type="button" @click="router.push('/orders')">
<strong>订单中心</strong>
<span>查看预约、支付、评价</span>
</button>
<button type="button" @click="router.push('/after-sales')">
<strong>售后记录</strong>
<span>查看退款和处理进度</span>
</button>
<button type="button" @click="router.push('/notifications')">
<strong>消息中心</strong>
<span>查看系统通知</span>
</button>
<button type="button" @click="router.push('/settings')">
<strong>账号设置</strong>
<span>修改资料、手机号和密码</span>
</button>
</section>
</a-spin>
</main>
</div>
</template>
<style scoped>
.help-page { min-height: 100vh; padding-top: 66px; background: linear-gradient(180deg, color-mix(in srgb, var(--theme-card-bg) 76%, transparent), var(--theme-page-bg)); color: var(--text-primary); }
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 11px 18px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
.header h1 { margin: 0; font-size: 17px; font-weight: 820; }
.content { padding: 18px 18px 34px; }
.hero-card, .section-card, .quick-grid button { border: 1px solid var(--theme-border); border-radius: 24px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); box-shadow: 0 18px 44px color-mix(in srgb, var(--theme-neutral) 8%, transparent); }
.hero-card { padding: 24px; margin-bottom: 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--theme-primary) 24%, var(--theme-card-bg)), color-mix(in srgb, var(--theme-secondary) 18%, var(--theme-card-bg))); }
.hero-card span { color: var(--theme-primary-action); font-family: Georgia, 'Times New Roman', serif; font-size: 12px; font-weight: 800; }
.hero-card h2 { margin: 10px 0 6px; font-size: 21px; font-weight: 850; }
.hero-card p, .section-card p, .quick-grid span { margin: 0; color: var(--text-secondary); line-height: 1.6; }
.section-card { padding: 16px; }
.section-card h3 { margin: 0 0 12px; font-size: 17px; }
.section-card p + p { margin-top: 8px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.quick-grid button { display: grid; gap: 6px; min-height: 112px; padding: 16px; border-color: var(--theme-border); text-align: left; color: var(--text-primary); cursor: pointer; }
.quick-grid strong { font-size: 16px; }
.quick-grid span { font-size: 13px; }
:deep(.ant-btn-link) { color: var(--theme-primary-action); }
</style>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,224 @@
<template>
<div class="not-found-container">
<header class="not-found-topbar">
<button class="not-found-back" type="button" aria-label="返回" @click="handleBackClick">
<LeftOutlined />
</button>
<strong>{{ BRAND_CONFIG.appName }}</strong>
<span class="not-found-topbar-spacer" aria-hidden="true"></span>
</header>
<div class="not-found-content">
<span class="not-found-kicker">{{ BRAND_CONFIG.appName }}</span>
<div class="error-code">404</div>
<h1>这页去做护理了</h1>
<p>您访问的页面不存在或已被删除,我们带您回到首页继续浏览作品。</p>
<p class="redirect-message">
将在 <span class="countdown">{{ countdown }}</span> 秒后自动跳转到首页...
</p>
<a-button type="primary" @click="redirectToHome">立即前往首页</a-button>
</div>
</div>
</template>
<script setup lang="ts">
/**
* NotFoundView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { ref, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import { LeftOutlined } from '@ant-design/icons-vue'
import { BRAND_CONFIG } from '@/config/brand'
/**
* Purpose: router supports NotFoundView.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.
*/
const router = useRouter()
/** countdown is a reactive state variable used by the template and event handlers. */
const countdown = ref(5)
let timer: number | null = null
const clearRedirectTimer = () => {
if (timer) {
clearInterval(timer)
timer = null
}
}
const handleBackClick = () => {
clearRedirectTimer()
if (window.history.length > 1) {
router.back()
return
}
router.push('/home')
}
/** redirectToHome is a local helper used by this page script. */
const redirectToHome = () => {
clearRedirectTimer()
router.push('/home')
}
onMounted(() => {
timer = window.setInterval(() => {
if (countdown.value > 0) {
countdown.value--
} else {
if (timer) {
clearInterval(timer)
}
redirectToHome()
}
}, 1000)
})
onUnmounted(() => {
clearRedirectTimer()
})
</script>
<style scoped>
.not-found-container {
position: relative;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background:
radial-gradient(circle at 82% 12%, color-mix(in srgb, var(--theme-primary) 30%, transparent), transparent 34%),
linear-gradient(180deg, var(--theme-tertiary), color-mix(in srgb, var(--theme-secondary) 14%, var(--theme-tertiary)));
padding: 20px;
}
.not-found-topbar {
position: fixed;
top: 12px;
left: 50%;
z-index: 20;
display: grid;
grid-template-columns: 40px minmax(0, 1fr) 40px;
align-items: center;
width: min(calc(100% - 32px), var(--app-mobile-max-width, 480px));
height: 44px;
transform: translateX(-50%);
}
.not-found-back {
display: inline-grid;
width: 36px;
height: 36px;
place-items: center;
border: 1px solid color-mix(in srgb, var(--theme-border) 78%, transparent);
border-radius: 999px;
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent);
box-shadow: 0 10px 24px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
cursor: pointer;
}
.not-found-topbar strong {
overflow: hidden;
color: var(--text-primary);
font-size: 16px;
font-weight: 800;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
}
.not-found-topbar-spacer {
width: 36px;
height: 36px;
}
.not-found-content {
background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent);
border: 1px solid var(--theme-border);
border-radius: 28px;
padding: 48px 28px;
text-align: center;
box-shadow: 0 24px 54px color-mix(in srgb, var(--theme-neutral) 12%, transparent);
max-width: 500px;
width: 100%;
backdrop-filter: blur(16px);
}
.not-found-kicker {
color: var(--theme-secondary);
font-family: Georgia, 'Times New Roman', serif;
font-size: 13px;
font-weight: 800;
}
.error-code {
font-size: 104px;
font-weight: 900;
color: var(--theme-primary-action);
margin: 10px 0 14px;
line-height: 1;
}
.not-found-content h1 {
font-size: 28px;
font-weight: 700;
color: var(--text-primary);
margin: 0 0 16px 0;
}
.not-found-content p {
font-size: 16px;
color: var(--text-secondary);
margin: 0 0 24px 0;
line-height: 1.6;
}
.redirect-message {
margin: 20px 0 30px 0;
color: var(--text-secondary);
font-size: 14px;
}
.countdown {
color: var(--theme-primary-action);
font-weight: bold;
font-size: 18px;
margin: 0 4px;
}
:deep(.ant-btn-primary) {
background: linear-gradient(135deg, var(--theme-primary-action), var(--theme-secondary));
border: none;
padding: 12px 32px;
font-size: 16px;
font-weight: 600;
border-radius: 25px;
box-shadow: var(--theme-button-shadow);
transition: all 0.3s ease;
}
:deep(.ant-btn-primary:hover) {
transform: translateY(-2px);
box-shadow: var(--theme-button-shadow);
}
@media (max-width: 768px) {
.not-found-content {
padding: 40px 20px;
}
.error-code {
font-size: 80px;
}
.not-found-content h1 {
font-size: 24px;
}
.not-found-content p {
font-size: 14px;
}
}
</style>
@@ -0,0 +1,331 @@
<template>
<div class="notifications-page">
<header class="page-header">
<button class="back-btn" type="button" @click="router.back()">‹</button>
<div>
<h1>消息通知</h1>
<p>{{ unreadCount }} 条未读消息</p>
</div>
</header>
<main class="message-list">
<button
v-for="item in messages"
:key="item.id"
class="message-item"
:class="{ unread: item.readStatus !== 1 }"
type="button"
@click="openMessage(item)"
>
<span class="dot"></span>
<span class="message-main">
<strong>{{ item.title }}</strong>
<small>{{ item.publisherName || '系统消息' }} · {{ item.publishTime || item.createTime }}</small>
<em v-if="item.imageUrl">含图片</em>
</span>
</button>
<a-empty v-if="!loading && messages.length === 0" description="暂无消息" />
</main>
<a-modal v-model:open="detailVisible" title="消息详情" @ok="detailVisible = false">
<h3>{{ currentMessage?.title }}</h3>
<p class="message-meta">{{ currentMessage?.publisherName || '系统消息' }} · {{ currentMessage?.publishTime }}</p>
<div v-if="currentMessageContentHtml" class="message-content" v-html="currentMessageContentHtml"></div>
<img v-if="currentMessage?.imageUrl" class="message-image" :src="currentMessage.imageUrl" alt="消息图片" />
</a-modal>
</div>
</template>
<script setup lang="ts">
/**
* NotificationsView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { message } from 'ant-design-vue'
/**
* Purpose: SystemMessageVO supports NotificationsView.vue by holding or executing the system message 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.
*/
import { userApi, type SystemMessageVO } from '@/api/user'
import { buildSystemMessageActionPath } from '@/utils/system-message-action'
import { renderRichContent } from '@/utils/rich-content'
/**
* Purpose: router supports NotificationsView.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.
*/
const router = useRouter()
/** loading is a reactive state variable used by the template and event handlers. */
const loading = ref(false)
/**
* Purpose: messages supports NotificationsView.vue by holding or executing the messages 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.
*/
const messages = ref<SystemMessageVO[]>([])
/** detailVisible is a reactive state variable used by the template and event handlers. */
const detailVisible = ref(false)
/**
* Purpose: currentMessage supports NotificationsView.vue by holding or executing the current message 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.
*/
const currentMessage = ref<SystemMessageVO | null>(null)
/** unreadCount is a reactive state variable used by the template and event handlers. */
const unreadCount = computed(() => messages.value.filter(item => item.readStatus !== 1).length)
const currentMessageContentHtml = computed(() => renderRichContent(currentMessage.value?.content || ''))
/**
* Purpose: resolveSystemMessageActionPath supports NotificationsView.vue by holding or executing the resolve system message action path 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.
*/
const resolveSystemMessageActionPath = (item: SystemMessageVO) => buildSystemMessageActionPath(item)
/**
* Purpose: markMessageReadIfNeeded supports NotificationsView.vue by holding or executing the mark message read if needed 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.
*/
const markMessageReadIfNeeded = async (item: SystemMessageVO) => {
if (item.readStatus === 1) {
return
}
await userApi.markMessageRead(item.id)
item.readStatus = 1
}
/** loadMessages is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadMessages = async () => {
loading.value = true
try {
messages.value = await userApi.listMyMessages()
} catch (error: any) {
message.error(error?.message || '消息加载失败')
} finally {
loading.value = false
}
}
/** openMessage is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const openMessage = async (item: SystemMessageVO) => {
try {
await markMessageReadIfNeeded(item)
} catch (error: any) {
message.error(error?.message || '标记已读失败')
return
}
const actionPath = resolveSystemMessageActionPath(item)
if (actionPath) {
await router.push(actionPath)
return
}
currentMessage.value = item
detailVisible.value = true
}
onMounted(loadMessages)
</script>
<style scoped>
.notifications-page {
min-height: 100vh;
background: var(--theme-page-bg);
padding: 18px;
}
.page-header {
display: flex;
gap: 14px;
align-items: center;
margin-bottom: 18px;
}
.page-header h1 {
margin: 0;
font-size: 20px;
}
.page-header p {
margin: 4px 0 0;
color: var(--text-secondary);
}
.back-btn {
width: 40px;
height: 40px;
border: 0;
border-radius: 20px;
background: var(--theme-card-bg);
font-size: 28px;
}
.message-list {
display: grid;
gap: 10px;
}
.message-item {
display: flex;
align-items: center;
gap: 12px;
width: 100%;
padding: 16px;
border: 0;
border-radius: 8px;
background: var(--theme-card-bg);
border: 1px solid var(--theme-border);
text-align: left;
}
.message-item .dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--theme-border);
}
.message-item.unread .dot {
background: var(--theme-primary);
}
.message-main {
display: grid;
gap: 4px;
}
.message-main em {
width: fit-content;
padding: 2px 8px;
border-radius: 999px;
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-size: 12px;
font-style: normal;
}
.message-main small,
.message-meta {
color: var(--text-secondary);
}
.message-content {
line-height: 1.8;
overflow-wrap: break-word;
}
.message-content :deep(*) {
max-width: 100%;
}
.message-content :deep(p),
.message-content :deep(ul),
.message-content :deep(ol),
.message-content :deep(blockquote),
.message-content :deep(pre),
.message-content :deep(table) {
margin: 0 0 12px;
}
.message-content :deep(p:last-child),
.message-content :deep(ul:last-child),
.message-content :deep(ol:last-child),
.message-content :deep(blockquote:last-child),
.message-content :deep(pre:last-child),
.message-content :deep(table:last-child) {
margin-bottom: 0;
}
.message-content :deep(ul),
.message-content :deep(ol) {
padding-left: 1.25em;
}
.message-content :deep(a) {
color: var(--theme-primary);
}
.message-content :deep(img) {
display: block;
max-width: 100%;
border-radius: 8px;
}
.message-content :deep(pre) {
overflow-x: auto;
padding: 10px 12px;
border-radius: 8px;
background: var(--theme-primary-soft);
}
.message-image {
display: block;
width: 100%;
max-height: 420px;
margin-top: 14px;
object-fit: contain;
border-radius: 8px;
background: var(--theme-primary-soft);
}
.notifications-page {
padding: 18px 18px 34px;
background:
radial-gradient(circle at 84% 0%, color-mix(in srgb, var(--theme-primary) 28%, transparent), transparent 30%),
linear-gradient(180deg, color-mix(in srgb, var(--theme-card-bg) 74%, transparent), var(--theme-page-bg));
}
.page-header {
margin-bottom: 22px;
}
.page-header h1 {
font-size: 21px;
font-weight: 860;
}
.page-header p {
color: var(--theme-secondary);
font-weight: 700;
}
.back-btn {
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-card-bg) 82%, transparent);
box-shadow: 0 12px 24px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
}
.message-list {
gap: 12px;
}
.message-item {
align-items: flex-start;
padding: 17px;
border-radius: 22px;
background: color-mix(in srgb, var(--theme-card-bg) 90%, transparent);
box-shadow: 0 18px 38px color-mix(in srgb, var(--theme-neutral) 7%, transparent);
}
.message-item.unread {
border-color: color-mix(in srgb, var(--theme-primary) 36%, var(--theme-border));
}
.message-item.unread .dot {
background: var(--theme-primary-action);
}
.message-main strong {
color: var(--text-primary);
font-size: 15px;
}
.message-main em {
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-primary) 18%, var(--theme-card-bg));
}
.message-content :deep(a) {
color: var(--theme-primary-action);
}
</style>
@@ -0,0 +1,429 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { LeftOutlined } from '@ant-design/icons-vue'
import { message, Modal } from 'ant-design-vue'
import { afterSaleApi, orderApi, paymentApi } from '../api/order'
import type { AfterSaleVO, OrderArtistChangeRequestVO, OrderArtistReviewVO } from '../api/order'
import { userApi, type ContactInfoVO } from '@/api/user'
import type { IdType } from '@/utils/id'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { extractLegacyFileId, getCachedSignedImageUrl, getCachedSignedImageUrlSync } from '@/utils/signed-image-cache'
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const order = ref<any | null>(null)
const reviews = ref<OrderArtistReviewVO[]>([])
const changeRequests = ref<OrderArtistChangeRequestVO[]>([])
const afterSales = ref<AfterSaleVO[]>([])
const contact = ref<ContactInfoVO | null>(null)
const quoteReply = ref('')
const quoteSubmitting = ref(false)
const quoteConfirming = ref(false)
const orderId = computed(() => String(route.params.id || route.query.orderId || ''))
const items = computed(() => Array.isArray(order.value?.items) ? order.value.items : [])
const formatMoney = (value?: number | string) => {
const amount = Number(value)
return Number.isFinite(amount) ? `¥${amount.toFixed(2)}` : '¥0.00'
}
const formatDateTime = (value?: string) => value ? String(value).replace('T', ' ').slice(0, 16) : '--'
const isQuoteStatus = (status?: unknown) => Number(status) === 0
const isQuoteConfirming = computed(() => isQuoteStatus(order.value?.status))
const statusClass = (status?: number) => isQuoteStatus(status) ? 'quote' : status === 2 ? 'done' : status === 3 ? 'cancelled' : 'pending'
const isOrderPaid = (target: any) => String(target?.paymentStatus || '').toUpperCase() === 'PAID'
const canPreparePayment = computed(() => !isQuoteConfirming.value && Number(order.value?.status) === 1 && !isOrderPaid(order.value))
const canMockPay = computed(() => !isQuoteConfirming.value && Number(order.value?.status) === 1 && String(order.value?.paymentStatus || '').toUpperCase() === 'PAYING')
const canApplyAfterSale = computed(() => !isQuoteConfirming.value && (Number(order.value?.status) === 2 || isOrderPaid(order.value)))
const timeline = computed(() => {
const current = order.value || {}
const firstAppointment = items.value.map((item: any) => item.appointmentTime).find(Boolean)
const status = Number(current.status)
if (status === 0) {
return [
{ key: 'created', title: '已创建', text: formatDateTime(current.createTime), done: true, active: false },
{ key: 'quote', title: '确认价格', text: current.quoteStatusText || '等待双方确认', done: Boolean(current.quoteUserConfirmed && current.quoteShopConfirmed), active: true },
{ key: 'appointment', title: '预约时间', text: firstAppointment ? formatDateTime(firstAppointment) : '价格确认后安排', done: Boolean(firstAppointment), active: false },
{ key: 'service', title: '服务完成', text: '待服务', done: false, active: false },
{ key: 'review', title: '评价', text: '完成后可评价', done: false, active: false }
]
}
return [
{ key: 'created', title: '已创建', text: formatDateTime(current.createTime), done: true, active: false },
{ key: 'appointment', title: '预约时间', text: formatDateTime(firstAppointment), done: Boolean(firstAppointment), active: status === 1 },
{ key: 'service', title: status === 3 ? '已取消' : '服务完成', text: formatDateTime(current.completeTime || current.cancelTime || current.updateTime), done: status === 2 || status === 3, active: status === 2 || status === 3 },
{ key: 'review', title: '评价', text: reviews.value.length ? `${reviews.value.length} 条记录` : '完成后可评价', done: reviews.value.some(item => Number(item.status) === 1 || item.rating), active: reviews.value.some(item => Number(item.status) !== 1 && !item.rating) },
{ key: 'after-sale', title: '售后', text: afterSales.value.length ? `${afterSales.value.length} 条记录` : '暂无售后', done: afterSales.value.length > 0, active: afterSales.value.some(item => item.status === 'PENDING') }
]
})
const hasAmount = (value: unknown) => value !== undefined && value !== null && value !== '' && Number.isFinite(Number(value))
const formatQuoteAmount = (value: unknown, fallback = '--') => hasAmount(value) ? formatMoney(value as number | string) : fallback
const quoteReferencePrice = (item: any) => item?.referencePrice ?? item?.price
const quoteMessages = computed(() => Array.isArray(order.value?.quoteMessages) ? order.value.quoteMessages : [])
const quoteStatusText = computed(() => order.value?.quoteStatusText || order.value?.statusText || '确认价格中')
const quoteExpireText = computed(() => {
const expireTime = formatDateTime(order.value?.quoteExpireTime)
return expireTime !== '--' ? `有效期至 ${expireTime}` : '等待门店报价'
})
const quoteMessageItems = (quoteMessage: any) => Array.isArray(quoteMessage?.items) ? quoteMessage.items : []
const quoteActorText = (quoteMessage: any) => {
if (quoteMessage?.actorTypeText) return quoteMessage.actorTypeText
if (String(quoteMessage?.actorType || '').toUpperCase() === 'USER') return '用户'
if (String(quoteMessage?.actorType || '').toUpperCase() === 'SHOP') return '门店'
return '系统'
}
const quoteActionText = (quoteMessage: any) => quoteMessage?.actionText || quoteMessage?.action || '报价更新'
const quoteMessageKey = (quoteMessage: any, index: string | number) => {
return String(quoteMessage?.id ?? `${quoteMessage?.createTime || 'quote'}-${quoteMessage?.action || index}`)
}
const quoteMessageItemKey = (quoteItem: any) => {
return String(quoteItem?.orderItemId ?? quoteItem?.productId ?? quoteItem?.id ?? JSON.stringify(quoteItem))
}
const quoteMessageItemText = (quoteItem: any) => {
const sourceItem = items.value.find((item: any) => String(item.id) === String(quoteItem?.orderItemId) || String(item.productId) === String(quoteItem?.productId))
const title = quoteItem?.productTitle || sourceItem?.productTitle || '预约项目'
const amount = quoteItem?.confirmedPrice ?? quoteItem?.quotedPrice ?? quoteItem?.price
return hasAmount(amount) ? `${title}:${formatMoney(amount)}` : title
}
const orderHasCurrentQuote = computed(() => {
return items.value.some((item: any) => hasAmount(item?.quotedPrice ?? item?.confirmedPrice))
})
const resolveOrderImages = async () => {
for (const item of items.value) {
const imageId = extractLegacyFileId(item.productImage)
if (!imageId) continue
const cachedUrl = getCachedSignedImageUrlSync(imageId)
if (cachedUrl) item.productImage = cachedUrl
item.productImage = await getCachedSignedImageUrl(imageId)
}
}
const loadRelated = async () => {
if (!orderId.value) return
const [reviewList, changeList, afterSalePage, contactInfo] = await Promise.all([
orderApi.getOrderReviews(orderId.value).catch(() => []),
orderApi.getOrderArtistChangeRequests(orderId.value).catch(() => []),
afterSaleApi.listMy({ page: 1, size: 50 }).catch(() => ({ list: [] })),
userApi.getOrderArtistContact(orderId.value).catch(() => null)
])
reviews.value = reviewList || []
changeRequests.value = changeList || []
afterSales.value = ((afterSalePage as any)?.list || []).filter((item: AfterSaleVO) => String(item.orderId) === orderId.value)
contact.value = contactInfo
}
const loadOrder = async () => {
if (!orderId.value) {
order.value = null
return
}
loading.value = true
try {
order.value = await orderApi.getOrderDetail(orderId.value)
await resolveOrderImages()
await loadRelated()
} catch (error: any) {
order.value = null
message.error(error?.message || '订单详情加载失败')
} finally {
loading.value = false
}
}
const submitQuoteReply = async () => {
if (!order.value?.id) return
const remark = quoteReply.value.trim()
if (!remark) {
message.warning('请先填写回复内容')
return
}
quoteSubmitting.value = true
try {
await runWithGlobalLoading(async () => {
await orderApi.replyQuote(order.value.id, { remark })
await loadOrder()
})
quoteReply.value = ''
message.success('报价回复已发送')
} catch (error: any) {
message.error(error?.message || '发送报价回复失败')
} finally {
quoteSubmitting.value = false
}
}
const confirmQuote = () => {
if (!order.value?.id) return
if (!orderHasCurrentQuote.value) {
message.warning('当前暂无可确认报价')
return
}
Modal.confirm({
title: '确认当前报价',
content: '确认后门店会继续处理预约,请确认当前报价无误。',
onOk: async () => {
quoteConfirming.value = true
try {
await runWithGlobalLoading(async () => {
await orderApi.confirmUserQuote(order.value.id)
await loadOrder()
})
message.success('已确认当前报价')
} catch (error: any) {
message.error(error?.message || '确认报价失败')
} finally {
quoteConfirming.value = false
}
}
})
}
const preparePayment = async () => {
if (!order.value?.id) return
await runWithGlobalLoading(async () => {
await paymentApi.prepareOrderPayment(order.value.id)
await loadOrder()
})
message.success('支付单已准备')
}
const mockPay = async () => {
if (!order.value?.id) return
await runWithGlobalLoading(async () => {
await paymentApi.mockSuccess(order.value.id)
await loadOrder()
})
message.success('模拟支付成功')
}
const cancelOrder = () => {
if (!order.value?.id) return
Modal.confirm({
title: '取消订单',
content: '确认取消这笔订单吗?',
onOk: async () => {
await runWithGlobalLoading(() => orderApi.cancelOrder(order.value.id as IdType))
message.success('订单已取消')
await loadOrder()
}
})
}
onMounted(loadOrder)
</script>
<template>
<div class="detail-page">
<header class="header">
<a-button type="text" @click="router.back()">
<LeftOutlined />
</a-button>
<h1>订单详情</h1>
<a-button type="link" @click="router.push('/orders')">列表</a-button>
</header>
<main class="content">
<a-spin :spinning="loading">
<a-empty v-if="!order" description="未找到订单">
<a-button type="primary" @click="router.push('/orders')">查看订单中心</a-button>
</a-empty>
<template v-else>
<section class="hero-card">
<span class="eyebrow">{{ isQuoteConfirming ? '询价预约' : '预约订单' }}</span>
<h2>{{ order.orderNo || `订单 ${order.id}` }}</h2>
<p>{{ order.shopName || '当前门店' }}</p>
<div class="hero-meta">
<strong>{{ formatMoney(order.actualAmount || order.totalAmount) }}</strong>
<span :class="['status-pill', statusClass(order.status)]">{{ isQuoteConfirming ? quoteStatusText : (order.statusText || '处理中') }}</span>
</div>
</section>
<section class="timeline-card">
<article v-for="node in timeline" :key="node.key" :class="{ done: node.done, active: node.active }">
<strong>{{ node.title }}</strong>
<span>{{ node.text }}</span>
</article>
</section>
<section v-if="isQuoteConfirming" class="section-card quote-detail-panel">
<div class="section-head">
<div>
<h3>报价确认</h3>
<p>{{ quoteStatusText }} · {{ quoteExpireText }}</p>
</div>
</div>
<p>客户备注:{{ order.customerRemark || '暂无备注' }}</p>
<div class="quote-flags">
<span :class="{ active: order.quoteUserConfirmed }">用户{{ order.quoteUserConfirmed ? '已确认' : '待确认' }}</span>
<span :class="{ active: order.quoteShopConfirmed }">门店{{ order.quoteShopConfirmed ? '已确认' : '待确认' }}</span>
</div>
<div class="quote-items">
<article v-for="item in items" :key="item.id || item.productId" class="quote-item">
<strong>{{ item.productTitle || '预约项目' }}</strong>
<span>参考价 {{ formatQuoteAmount(quoteReferencePrice(item), '待确认') }}</span>
<span>当前报价 {{ formatQuoteAmount(item.quotedPrice, '待报价') }}</span>
<span>最终价 {{ formatQuoteAmount(item.confirmedPrice, '待确认') }}</span>
</article>
</div>
<div class="quote-history">
<strong>报价历史</strong>
<div v-if="quoteMessages.length" class="quote-history__list">
<article v-for="(quoteMessage, index) in quoteMessages" :key="quoteMessageKey(quoteMessage, index)" class="quote-history__item">
<div>
<span>{{ quoteActorText(quoteMessage) }}</span>
<em>{{ quoteActionText(quoteMessage) }}</em>
<small>{{ formatDateTime(quoteMessage.createTime) }}</small>
</div>
<p v-if="quoteMessage.remark">{{ quoteMessage.remark }}</p>
<div v-if="quoteMessageItems(quoteMessage).length" class="quote-history__prices">
<span v-for="quoteItem in quoteMessageItems(quoteMessage)" :key="quoteMessageItemKey(quoteItem)">
{{ quoteMessageItemText(quoteItem) }}
</span>
</div>
</article>
</div>
<p v-else>暂无报价历史</p>
</div>
<div class="quote-reply">
<a-textarea v-model:value="quoteReply" :rows="3" :maxlength="300" placeholder="给门店补充说明或回复当前报价" />
<div class="quote-reply__actions">
<a-button :loading="quoteSubmitting" @click="submitQuoteReply">发送回复</a-button>
<a-button
v-if="!order.quoteUserConfirmed"
type="primary"
:loading="quoteConfirming"
:disabled="!orderHasCurrentQuote"
@click="confirmQuote"
>
确认当前报价
</a-button>
<span v-else class="quote-confirmed">你已确认当前报价</span>
</div>
</div>
</section>
<section class="section-card">
<div class="section-head">
<h3>预约项目</h3>
<a-button type="link" @click="router.push({ path: '/service-progress', query: { orderId } })">服务进度</a-button>
</div>
<article v-for="item in items" :key="item.id" class="item-row">
<div class="thumb">
<img v-if="item.productImage" :src="item.productImage" :alt="item.productTitle" loading="lazy" decoding="async" />
<span v-else>{{ String(item.productTitle || '项').slice(0, 1) }}</span>
</div>
<div class="item-main">
<strong>{{ item.productTitle || '预约项目' }}</strong>
<span>{{ isQuoteConfirming ? '参考价 ' : '' }}{{ formatMoney(item.price) }} x {{ item.quantity || 1 }}</span>
<span v-if="item.artistName">美甲师:{{ item.artistName }}</span>
<span v-if="item.appointmentTime">预约:{{ formatDateTime(item.appointmentTime) }}</span>
</div>
</article>
</section>
<section v-if="contact" class="section-card">
<h3>联系信息</h3>
<p>{{ contact.contactName || contact.roleLabel || '服务联系人' }}</p>
<p v-if="contact.phoneAvailable && contact.phone">电话:{{ contact.phone }}</p>
<p v-if="contact.wechatAvailable && contact.wechatId">微信:{{ contact.wechatId }}</p>
<p v-if="contact.platformContactText">{{ contact.platformContactText }}</p>
</section>
<section v-if="afterSales.length || changeRequests.length || reviews.length" class="section-card">
<h3>关联记录</h3>
<p v-for="item in afterSales" :key="`as-${item.id}`">售后 {{ item.afterSaleNo || item.id }}:{{ item.status || '-' }}</p>
<p v-for="item in changeRequests" :key="`change-${item.id}`">改派:{{ item.statusText || item.status || '-' }}</p>
<p v-for="item in reviews" :key="`review-${item.id}`">评价:{{ item.statusText || item.rating || '待评价' }}</p>
</section>
<section class="action-bar">
<a-button v-if="canPreparePayment" @click="preparePayment">准备支付</a-button>
<a-button v-if="canMockPay" type="primary" @click="mockPay">模拟支付</a-button>
<a-button v-if="canApplyAfterSale" @click="router.push({ path: '/after-sale/apply', query: { orderId } })">申请售后</a-button>
<a-button v-if="order.status === 1" danger @click="cancelOrder">取消订单</a-button>
</section>
</template>
</a-spin>
</main>
</div>
</template>
<style scoped>
.detail-page { min-height: 100vh; padding-top: 60px; background: var(--theme-page-bg); color: var(--text-primary); }
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 9px 14px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
.header h1 { margin: 0; font-size: 18px; }
.content { padding: 16px 14px 28px; }
.hero-card, .section-card, .timeline-card { border: 1px solid var(--theme-border); border-radius: 20px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); box-shadow: 0 18px 44px rgba(74, 68, 63, 0.08); }
.hero-card { padding: 22px; background: var(--theme-gradient-soft); }
.eyebrow { display: block; color: var(--theme-primary); font-size: 12px; font-weight: 700; letter-spacing: .05em; }
.hero-card h2 { margin: 10px 0 6px; font-size: 21px; }
.hero-card p { margin: 0; color: var(--text-secondary); }
.hero-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.hero-meta strong { font-size: 20px; }
.status-pill { padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--theme-primary-soft); color: var(--theme-primary); }
.status-pill.quote { color: #6b4600; background: #fff2cc; }
.status-pill.cancelled { color: var(--theme-accent); }
.timeline-card { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; overflow: hidden; margin-top: 14px; background: var(--theme-border); }
.timeline-card article { min-width: 0; padding: 12px 8px; background: var(--theme-card-bg); color: var(--text-secondary); }
.timeline-card article.active { color: var(--theme-primary); }
.timeline-card article.done strong { color: var(--theme-primary); }
.timeline-card strong, .timeline-card span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-card strong { font-size: 12px; }
.timeline-card span { margin-top: 4px; font-size: 11px; }
.section-card { margin-top: 14px; padding: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-card h3 { margin: 0 0 12px; font-size: 17px; }
.section-card p { margin: 8px 0 0; color: var(--text-secondary); line-height: 1.6; }
.section-head p { margin: 4px 0 0; font-size: 13px; }
.quote-detail-panel { display: grid; gap: 12px; }
.quote-flags { display: flex; flex-wrap: wrap; gap: 8px; }
.quote-flags span { padding: 4px 9px; border-radius: 999px; color: var(--text-secondary); background: var(--theme-primary-soft); font-size: 12px; }
.quote-flags span.active { color: var(--theme-primary); font-weight: 700; }
.quote-items, .quote-history, .quote-history__list, .quote-reply { display: grid; gap: 8px; }
.quote-item { display: grid; grid-template-columns: minmax(0, 1.35fr) repeat(3, minmax(82px, auto)); gap: 8px; align-items: center; min-width: 0; padding: 10px; border-radius: 12px; background: color-mix(in srgb, var(--theme-primary-soft) 48%, var(--theme-card-bg)); }
.quote-item strong { min-width: 0; overflow-wrap: anywhere; color: var(--text-primary); font-size: 13px; }
.quote-item span, .quote-history__item small, .quote-confirmed { color: var(--text-secondary); font-size: 12px; }
.quote-history > strong { color: var(--text-primary); font-size: 13px; }
.quote-history__item { display: grid; gap: 6px; padding: 10px; border-radius: 12px; background: color-mix(in srgb, var(--theme-primary-soft) 42%, var(--theme-card-bg)); }
.quote-history__item div { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.quote-history__item span, .quote-history__item em { color: var(--theme-primary); font-size: 12px; font-style: normal; font-weight: 700; }
.quote-history__item p { margin: 0; overflow-wrap: anywhere; font-size: 13px; }
.quote-history__prices { display: flex; flex-wrap: wrap; gap: 6px; }
.quote-history__prices span { padding: 3px 7px; border-radius: 8px; color: var(--text-secondary); background: var(--theme-card-bg); font-size: 12px; }
.quote-reply__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.quote-confirmed { display: inline-flex; align-items: center; min-height: 32px; color: var(--theme-primary); font-weight: 700; }
.item-row { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--theme-border); }
.item-row:first-of-type { border-top: 0; padding-top: 0; }
.thumb { width: 64px; height: 64px; flex: 0 0 auto; border-radius: 14px; overflow: hidden; display: grid; place-items: center; background: var(--theme-primary-soft); color: var(--theme-primary); font-weight: 700; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-main { display: grid; gap: 5px; min-width: 0; color: var(--text-secondary); font-size: 13px; }
.item-main strong { color: var(--text-primary); font-size: 15px; }
.action-bar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }
:deep(.ant-btn-primary) { background: var(--theme-primary); border-color: var(--theme-primary); }
:deep(.ant-btn-link) { color: var(--theme-primary); }
@media (max-width: 640px) {
.quote-item { grid-template-columns: 1fr; }
.quote-reply__actions { justify-content: stretch; }
.quote-reply__actions :deep(.ant-btn) { flex: 1 1 140px; }
}
</style>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,343 @@
<template>
<div class="mobile-container">
<header class="header">
<a-button class="back-btn" type="text" @click="handleBackClick">
<LeftOutlined :style="{ fontSize: '20px' }" />
</a-button>
<h1>设置密码</h1>
<div class="empty"></div>
</header>
<div class="password-form">
<a-card :bordered="false" class="form-card">
<DraftActions
:saved-at="draftSavedAt"
@save="handleSaveDraft"
@clear="handleClearDraft"
/>
<a-form
ref="formRef"
:model="formState"
:rules="formRules"
layout="vertical"
@finish="handleSubmit"
>
<a-form-item label="手机号">
<a-input :value="userPhone || '未绑定手机号'" disabled size="large" />
</a-form-item>
<a-form-item label="验证码" name="verificationCode">
<a-input
v-model:value="formState.verificationCode"
placeholder="请输入验证码"
size="large"
>
<template #suffix>
<a-button
type="link"
:disabled="countdown > 0 || !userPhone"
@click="handleSendVerificationCode"
>
{{ countdown > 0 ? `${countdown}秒后重发` : '发送验证码' }}
</a-button>
</template>
</a-input>
</a-form-item>
<a-form-item label="新密码" name="password">
<a-input-password
v-model:value="formState.password"
placeholder="请输入新密码"
size="large"
@pressEnter="handleSubmit"
>
<template #prefix>
<LockOutlined style="color: var(--text-secondary)" />
</template>
</a-input-password>
<div class="password-tip">
密码长度至少 8 位,且需包含字母和数字
</div>
</a-form-item>
<a-form-item label="确认密码" name="confirmPassword">
<a-input-password
v-model:value="formState.confirmPassword"
placeholder="请再次输入新密码"
size="large"
@pressEnter="handleSubmit"
>
<template #prefix>
<LockOutlined style="color: var(--text-secondary)" />
</template>
</a-input-password>
</a-form-item>
<a-form-item>
<a-button
type="primary"
html-type="submit"
size="large"
block
:loading="loading"
>
确认设置
</a-button>
</a-form-item>
</a-form>
</a-card>
</div>
</div>
</template>
<script setup lang="ts">
/**
* PasswordSettingsView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { LeftOutlined, LockOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue'
import type { Rule } from 'ant-design-vue/es/form'
import DraftActions from '@/components/DraftActions.vue'
import { userApi } from '@/api/user'
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
import { runWithGlobalLoading } from '@/utils/action-loading'
/**
* Purpose: router supports PasswordSettingsView.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.
*/
const router = useRouter()
/**
* Purpose: formRef supports PasswordSettingsView.vue by holding or executing the form ref 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.
*/
const formRef = ref<FormInstance>()
/** loading is a reactive state variable used by the template and event handlers. */
const loading = ref(false)
/** countdown is a reactive state variable used by the template and event handlers. */
const countdown = ref(0)
/**
* Purpose: userInfo supports PasswordSettingsView.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.
*/
const userInfo = ref<{ phone?: string } | null>(null)
/**
* Purpose: draftSavedAt supports PasswordSettingsView.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.
*/
const draftSavedAt = ref<number | null>(null)
let countdownTimer: ReturnType<typeof setInterval> | null = null
/**
* Purpose: formState supports PasswordSettingsView.vue by holding or executing the form state 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.
*/
const formState = reactive({
verificationCode: '',
password: '',
confirmPassword: ''
})
/**
* Purpose: draftKey supports PasswordSettingsView.vue by holding or executing the draft key 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.
*/
const draftKey = buildDraftStorageKey('password-settings', 'set-password')
/** restoreDraft is a local helper used by this page script. */
const restoreDraft = () => {
const draft = loadDraftRecord<typeof formState>(draftKey, 'session')
if (!draft) {
draftSavedAt.value = null
return
}
Object.assign(formState, draft.payload)
draftSavedAt.value = draft.savedAt
message.success('已恢复暂存内容')
}
/** handleSaveDraft is a local helper used by this page script. */
const handleSaveDraft = () => {
const draft = saveDraftRecord(draftKey, { ...formState }, 'session')
draftSavedAt.value = draft.savedAt
message.success('已暂存到当前会话')
}
/** handleClearDraft is a local helper used by this page script. */
const handleClearDraft = (showMessage = true) => {
clearDraftRecord(draftKey, 'session')
draftSavedAt.value = null
if (showMessage) {
message.success('已清除暂存')
}
}
/** userPhone is a reactive state variable used by the template and event handlers. */
const userPhone = computed(() => userInfo.value?.phone || '')
/** validateConfirmPassword is a local helper used by this page script. */
const validateConfirmPassword = (_rule: any, value: string) => {
if (value !== formState.password) {
return Promise.reject(new Error('两次输入的密码不一致'))
}
return Promise.resolve()
}
const formRules: Record<string, Rule[]> = {
verificationCode: [
{ required: true, message: '请输入验证码', trigger: 'blur' },
{ pattern: /^\d{6}$/, message: '验证码必须是6位数字', trigger: 'blur' }
],
password: [
{ required: true, message: '请输入新密码', trigger: 'blur' },
{ min: 8, message: '密码长度至少8位', trigger: 'blur' },
{ pattern: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/, message: '密码必须包含字母和数字', trigger: 'blur' }
],
confirmPassword: [
{ required: true, message: '请确认新密码', trigger: 'blur' },
{ validator: validateConfirmPassword, trigger: 'blur' }
]
}
/** startCountdown is a local helper used by this page script. */
const startCountdown = () => {
countdown.value = 60
if (countdownTimer) {
clearInterval(countdownTimer)
}
countdownTimer = setInterval(() => {
countdown.value -= 1
if (countdown.value <= 0 && countdownTimer) {
clearInterval(countdownTimer)
countdownTimer = null
}
}, 1000)
}
/** fetchUserInfo is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const fetchUserInfo = async () => {
try {
const res = await userApi.getUserInfo()
userInfo.value = res as unknown as { phone?: string }
} catch (error: any) {
console.error('获取用户信息失败:', error)
message.error(error.message || '获取用户信息失败')
}
}
/** handleSendVerificationCode is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleSendVerificationCode = async () => {
if (!userPhone.value) {
message.error('请先绑定手机号')
return
}
try {
await runWithGlobalLoading(() => userApi.sendVerificationCode({
phone: userPhone.value,
sceneCode: 'USER_CHANGE_PASSWORD_SMS_CODE'
}))
message.success('验证码发送成功')
startCountdown()
} catch (error: any) {
console.error('发送验证码失败:', error)
message.error(error.message || '发送验证码失败')
}
}
/** handleSubmit is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleSubmit = async () => {
if (!formRef.value) return
try {
await formRef.value.validate()
if (!userPhone.value) {
message.error('请先绑定手机号')
return
}
loading.value = true
await runWithGlobalLoading(() => userApi.updatePassword({
password: formState.password,
verificationCode: formState.verificationCode
}))
message.success('密码设置成功')
handleClearDraft(false)
localStorage.removeItem('needSetPassword')
router.push('/profile')
} catch (error: any) {
console.error('设置密码失败:', error)
message.error(error.message || '设置密码失败')
} finally {
loading.value = false
}
}
/** handleBackClick is a local helper used by this page script. */
const handleBackClick = () => {
router.back()
}
onMounted(() => {
fetchUserInfo()
restoreDraft()
})
onUnmounted(() => {
if (countdownTimer) {
clearInterval(countdownTimer)
}
})
</script>
<style scoped>
.mobile-container {
min-height: 100vh;
background: var(--theme-page-bg);
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 15px;
background: var(--theme-card-bg);
border-bottom: 1px solid var(--theme-border);
}
.header h1 {
font-size: 18px;
font-weight: bold;
margin: 0;
}
.back-btn,
.empty {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
}
.password-form {
padding: 15px;
}
.form-card {
border-radius: 16px;
overflow: hidden;
background: var(--theme-card-bg);
}
.password-tip {
margin-top: 8px;
color: var(--text-secondary);
font-size: 12px;
}
</style>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,147 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { LeftOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { afterSaleApi, orderApi } from '../api/order'
import type { AfterSaleVO, OrderArtistChangeRequestVO, OrderArtistReviewVO } from '../api/order'
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const order = ref<any | null>(null)
const reviews = ref<OrderArtistReviewVO[]>([])
const changes = ref<OrderArtistChangeRequestVO[]>([])
const afterSales = ref<AfterSaleVO[]>([])
const orderId = computed(() => String(route.query.orderId || route.params.id || ''))
const items = computed(() => Array.isArray(order.value?.items) ? order.value.items : [])
const firstAppointment = computed(() => items.value.map((item: any) => item.appointmentTime).find(Boolean))
const formatTime = (value?: string) => value ? String(value).replace('T', ' ').slice(0, 16) : '--'
const latestChangeText = computed(() => {
const latest = changes.value.slice().sort((left: any, right: any) => String(right.updateTime || right.createTime || '').localeCompare(String(left.updateTime || left.createTime || '')))[0] as any
return latest ? (latest.statusText || latest.status || '改派记录') : '暂无改派'
})
const nodes = computed(() => {
const current = order.value || {}
const status = Number(current.status)
return [
{ key: 'created', title: '订单创建', desc: formatTime(current.createTime), done: true, active: false },
{ key: 'appointment', title: '预约确认', desc: formatTime(firstAppointment.value), done: Boolean(firstAppointment.value), active: status === 1 },
{ key: 'artist', title: '服务安排', desc: latestChangeText.value, done: changes.value.length > 0 || items.value.some((item: any) => item.artistName), active: changes.value.some(item => item.status === 'PENDING') },
{ key: 'service', title: status === 3 ? '订单取消' : '服务完成', desc: formatTime(current.completeTime || current.cancelTime || current.updateTime), done: status === 2 || status === 3, active: status === 2 || status === 3 },
{ key: 'after-sale', title: '售后/评价', desc: afterSales.value.length ? `${afterSales.value.length} 条售后` : (reviews.value.length ? `${reviews.value.length} 条评价` : '暂无记录'), done: afterSales.value.length > 0 || reviews.value.length > 0, active: afterSales.value.some(item => item.status === 'PENDING') || reviews.value.some(item => !item.rating) }
]
})
const loadProgress = async () => {
if (!orderId.value) return
loading.value = true
try {
const [detail, reviewList, changeList, afterSalePage] = await Promise.all([
orderApi.getOrderDetail(orderId.value),
orderApi.getOrderReviews(orderId.value).catch(() => []),
orderApi.getOrderArtistChangeRequests(orderId.value).catch(() => []),
afterSaleApi.listMy({ page: 1, size: 50 }).catch(() => ({ list: [] }))
])
order.value = detail
reviews.value = reviewList || []
changes.value = changeList || []
afterSales.value = ((afterSalePage as any)?.list || []).filter((item: AfterSaleVO) => String(item.orderId) === orderId.value)
} catch (error: any) {
order.value = null
message.error(error?.message || '服务进度加载失败')
} finally {
loading.value = false
}
}
onMounted(loadProgress)
</script>
<template>
<div class="progress-page">
<header class="header">
<a-button type="text" @click="router.back()">
<LeftOutlined />
</a-button>
<h1>服务进度</h1>
<a-button type="link" @click="loadProgress">刷新</a-button>
</header>
<main class="content">
<section class="hero-card">
<span>进度追踪</span>
<h2>{{ order?.orderNo || (orderId ? `订单 ${orderId}` : '选择订单') }}</h2>
<p>{{ order?.shopName || '查看预约、服务、评价与售后节点' }}</p>
</section>
<a-spin :spinning="loading">
<a-empty v-if="!orderId" description="缺少订单参数">
<a-button type="primary" @click="router.push('/orders')">选择订单</a-button>
</a-empty>
<template v-else>
<section class="progress-list">
<article v-for="node in nodes" :key="node.key" :class="{ done: node.done, active: node.active }">
<i />
<div>
<strong>{{ node.title }}</strong>
<span>{{ node.desc }}</span>
</div>
</article>
</section>
<section v-if="items.length" class="section-card">
<h3>项目进度</h3>
<p v-for="item in items" :key="item.id">
{{ item.productTitle || '预约项目' }}:{{ item.artistName || '待安排美甲师' }},{{ formatTime(item.appointmentTime) }}
</p>
</section>
<section v-if="changes.length" class="section-card">
<h3>改派记录</h3>
<p v-for="item in changes" :key="item.id">{{ item.statusText || item.status }}:{{ item.reason || item.timeImpactText || '已记录' }}</p>
</section>
<section v-if="afterSales.length" class="section-card">
<h3>售后记录</h3>
<p v-for="item in afterSales" :key="item.id">{{ item.afterSaleNo || item.id }}:{{ item.status || '-' }}</p>
</section>
<div class="actions">
<a-button @click="router.push(`/orders/${orderId}`)">订单详情</a-button>
<a-button type="primary" @click="router.push({ path: '/after-sale/apply', query: { orderId } })">申请售后</a-button>
</div>
</template>
</a-spin>
</main>
</div>
</template>
<style scoped>
.progress-page { min-height: 100vh; padding-top: 60px; background: var(--theme-page-bg); color: var(--text-primary); }
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 9px 14px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
.header h1 { margin: 0; font-size: 18px; }
.content { padding: 16px 14px 32px; }
.hero-card, .section-card, .progress-list { border: 1px solid var(--theme-border); border-radius: 20px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); box-shadow: 0 18px 44px rgba(74, 68, 63, 0.08); }
.hero-card { padding: 22px; margin-bottom: 14px; background: var(--theme-gradient-soft); }
.hero-card span { color: var(--theme-primary); font-size: 12px; font-weight: 700; letter-spacing: .05em; }
.hero-card h2 { margin: 10px 0 6px; font-size: 21px; }
.hero-card p { margin: 0; color: var(--text-secondary); line-height: 1.6; }
.progress-list { display: grid; gap: 0; overflow: hidden; }
.progress-list article { display: flex; gap: 12px; padding: 16px; border-top: 1px solid var(--theme-border); }
.progress-list article:first-child { border-top: 0; }
.progress-list i { width: 14px; height: 14px; margin-top: 3px; border-radius: 999px; background: var(--theme-border); box-shadow: 0 0 0 5px var(--theme-primary-soft); }
.progress-list article.done i, .progress-list article.active i { background: var(--theme-primary); }
.progress-list strong, .progress-list span { display: block; }
.progress-list span, .section-card p { margin-top: 6px; color: var(--text-secondary); line-height: 1.6; }
.section-card { margin-top: 14px; padding: 16px; }
.section-card h3 { margin: 0 0 10px; font-size: 17px; }
.section-card p { margin: 8px 0 0; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
:deep(.ant-btn-primary) { background: var(--theme-primary); border-color: var(--theme-primary); }
:deep(.ant-btn-link) { color: var(--theme-primary); }
</style>
@@ -0,0 +1,258 @@
<template>
<div class="mobile-container">
<header class="header">
<a-button class="back-btn" type="text" @click="handleBackClick">
<LeftOutlined :style="{ fontSize: '20px' }" />
</a-button>
<h1>设置中心</h1>
<div class="empty"></div>
</header>
<div class="settings-menu">
<a-card :bordered="false" class="settings-card">
<a-list :data-source="settingsSections" :split="false">
<template #renderItem="{ item }">
<a-list-item v-if="item.type === 'title'" class="section-title">
<span>{{ item.title }}</span>
</a-list-item>
<a-list-item v-else class="setting-item" @click="handleSettingClick(item.key)">
<template #actions>
<RightOutlined />
</template>
<a-list-item-meta>
<template #avatar>
<div class="setting-icon" :style="{ backgroundColor: item.bgColor }">
<component :is="item.icon" />
</div>
</template>
<template #title>
<span>{{ item.title }}</span>
</template>
<template #description>
<span>{{ item.desc }}</span>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</a-card>
</div>
<div class="version-info">
<a-typography-text type="secondary">版本 0.0.1</a-typography-text>
</div>
</div>
</template>
<script setup lang="ts">
/**
* SettingsView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import {
LeftOutlined,
LockOutlined,
RightOutlined,
} from '@ant-design/icons-vue'
/**
* Purpose: router supports SettingsView.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.
*/
const router = useRouter()
/** settingsSections is a reactive state variable used by the template and event handlers. */
const settingsSections = ref([
{
type: 'title',
title: '账号与安全'
},
{
key: 'account',
title: '账号设置',
desc: '管理手机号、登录密码和账号安全',
icon: LockOutlined,
bgColor: 'var(--theme-primary-soft)'
}
])
/** handleBackClick is a local helper used by this page script. */
const handleBackClick = () => {
router.back()
}
/** handleSettingClick is a local helper used by this page script. */
const handleSettingClick = (key: string) => {
if (key === 'account') {
router.push('/settings/account')
return
}
}
</script>
<style scoped>
.mobile-container {
min-height: 100vh;
padding-top: 60px;
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;
}
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
justify-content: space-between;
align-items: center;
height: 60px;
padding: 10px 15px;
background: rgba(255, 255, 255, 0.92);
border-bottom: 1px solid var(--theme-border);
backdrop-filter: blur(14px);
}
.header h1 {
font-size: 18px;
font-weight: bold;
margin: 0;
color: var(--text-primary);
}
.back-btn,
.empty {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
}
.settings-menu {
padding: 15px;
}
.settings-card {
border-radius: 16px;
overflow: hidden;
background: var(--theme-card-bg);
border: 1px solid var(--theme-border);
box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08);
}
.settings-card :deep(.ant-card-body) {
padding: 0;
}
.section-title {
padding: 12px 16px;
font-size: 13px;
color: var(--theme-accent);
background: var(--theme-primary-soft);
}
.setting-item {
padding: 16px;
cursor: pointer;
transition: background 0.3s;
border-bottom: 1px solid var(--theme-border);
}
.setting-item:hover {
background: var(--theme-primary-soft);
}
.setting-item:last-child {
border-bottom: none;
}
.setting-item :deep(.ant-list-item-action) {
margin-left: 8px;
color: var(--text-secondary);
}
.setting-icon {
width: 40px;
height: 40px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
color: var(--theme-primary);
}
.setting-item :deep(.ant-list-item-meta-title) {
font-size: 15px;
font-weight: 500;
color: var(--text-primary);
}
.setting-item :deep(.ant-list-item-meta-description) {
font-size: 12px;
color: var(--text-secondary);
}
.version-info {
padding: 20px;
text-align: center;
}
.mobile-container {
padding-top: 68px;
background:
radial-gradient(circle at 85% 0%, color-mix(in srgb, var(--theme-primary) 28%, transparent), transparent 32%),
linear-gradient(180deg, color-mix(in srgb, var(--theme-card-bg) 78%, transparent), var(--theme-page-bg));
}
.header {
height: 64px;
padding: 12px 18px 10px;
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
}
.header h1 {
font-size: 17px;
font-weight: 820;
}
.back-btn {
border-radius: 999px;
background: color-mix(in srgb, var(--theme-card-bg) 74%, transparent);
}
.settings-menu {
padding: 18px;
}
.settings-card {
border-radius: 24px;
background: color-mix(in srgb, var(--theme-card-bg) 90%, transparent);
box-shadow: 0 20px 42px color-mix(in srgb, var(--theme-neutral) 9%, transparent);
}
.section-title {
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-primary) 18%, var(--theme-card-bg));
font-weight: 800;
}
.setting-item {
padding: 18px 16px;
}
.setting-icon {
border-radius: 14px;
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-primary) 22%, var(--theme-card-bg)) !important;
}
</style>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,957 @@
<script setup lang="ts">
import { computed, onMounted, ref, shallowRef } from 'vue'
import { useRouter } from 'vue-router'
import {
CreditCardOutlined,
CrownOutlined,
GiftOutlined,
HistoryOutlined,
LeftOutlined,
PayCircleOutlined,
PercentageOutlined,
SafetyCertificateOutlined,
ScissorOutlined,
ShoppingOutlined,
StarFilled,
TrophyOutlined
} from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { userApi, type BalanceHistoryItem, type UserAssetVO, type VipRechargePlanVO } from '@/api/user'
const router = useRouter()
const loading = shallowRef(false)
const rechargeOpen = shallowRef(false)
const visibleHistoryCount = shallowRef(3)
const asset = ref<UserAssetVO | null>(null)
const history = ref<BalanceHistoryItem[]>([])
const plans = ref<VipRechargePlanVO[]>([])
const selectedPlan = ref<VipRechargePlanVO | null>(null)
const rechargeSectionRef = ref<HTMLElement | null>(null)
interface LevelStep {
name: string
amount: number
}
const levelSteps: [LevelStep, ...LevelStep[]] = [
{ name: '普通会员', amount: 0 },
{ name: '玫瑰金会员', amount: 1000 },
{ name: '钻石会员', amount: 5000 }
]
const money = (value?: number | string) => {
const amount = Number(value || 0)
return Number.isFinite(amount)
? amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
: '0.00'
}
const formatTime = (value?: string) => value ? value.replace('T', ' ').slice(0, 16) : '--'
const sceneText = (scene?: string) => {
const map: Record<string, string> = {
MANUAL_RECHARGE: '手工充值',
MANUAL_DEDUCT: '手工扣减',
ORDER_PAY: '订单消费',
ORDER_REFUND: '订单退款',
RECHARGE: '会员充值',
CONSUME: '余额消费'
}
return map[scene || ''] || scene || '余额变动'
}
const sceneIcon = (item: BalanceHistoryItem) => {
const scene = item.changeScene || item.type || ''
if (Number(item.amount) > 0 || scene.includes('RECHARGE') || scene.includes('REFUND')) {
return PayCircleOutlined
}
if (scene.includes('ORDER') || scene.includes('CONSUME')) {
return ScissorOutlined
}
return HistoryOutlined
}
const memberLevel = computed(() => asset.value?.vipLevel || '普通会员')
const totalRecharge = computed(() => Number(asset.value?.totalRechargeAmount || 0))
const balanceAmount = computed(() => Number(asset.value?.balance || 0))
const sortedPlans = computed(() => [...plans.value].sort((left, right) => {
const sortDelta = Number(left.sortOrder || 0) - Number(right.sortOrder || 0)
return sortDelta || Number(left.rechargeAmount || 0) - Number(right.rechargeAmount || 0)
}))
const visibleHistory = computed(() => history.value.slice(0, visibleHistoryCount.value))
const canLoadMoreHistory = computed(() => visibleHistoryCount.value < history.value.length)
const currentStep = computed(() => {
return [...levelSteps].reverse().find(step => totalRecharge.value >= step.amount) || levelSteps[0]
})
const nextStep = computed(() => levelSteps.find(step => step.amount > totalRecharge.value))
const levelProgress = computed(() => {
const next = nextStep.value
if (!next) return 100
const current = currentStep.value
const range = Math.max(next.amount - current.amount, 1)
return Math.min(100, Math.max(8, ((totalRecharge.value - current.amount) / range) * 100))
})
const nextLevelText = computed(() => nextStep.value ? `下一等级:${nextStep.value.name}` : '已达最高等级')
const remainingAmountText = computed(() => {
const next = nextStep.value
if (!next) return '继续保持你的专属礼遇'
return `再充值 ¥${money(Math.max(next.amount - totalRecharge.value, 0))} 可升级`
})
const validityText = computed(() => {
const start = formatTime(asset.value?.vipStartTime)
const expire = formatTime(asset.value?.vipExpireTime)
if (start === '--' && expire === '--') return '长期有效'
if (expire === '--') return `${start} 起生效`
return `${start} - ${expire}`
})
const benefitCards = computed(() => [
{
icon: GiftOutlined,
title: '生日礼遇',
desc: '生日月专属美甲套装',
tone: 'rose'
},
{
icon: SafetyCertificateOutlined,
title: '优先预约',
desc: '热门时段优先锁定档期',
tone: 'gold'
},
{
icon: PercentageOutlined,
title: '专属优惠',
desc: asset.value?.benefitInfo || '会员专属折扣权益',
tone: 'slate'
},
{
icon: CrownOutlined,
title: '护理礼遇',
desc: '精选护理权益持续更新',
tone: 'cream'
}
])
const planTag = (index: number) => {
if (index === 0) return '超值'
if (index === 1) return '最佳选择'
return '尊享'
}
const openPlan = (plan: VipRechargePlanVO) => {
selectedPlan.value = plan
rechargeOpen.value = true
}
const scrollToRecharge = () => {
rechargeSectionRef.value?.scrollIntoView({ behavior: 'smooth', block: 'start' })
}
const loadMoreHistory = () => {
visibleHistoryCount.value += 3
}
const loadData = async () => {
loading.value = true
try {
const [assetRes, historyRes] = await Promise.all([
userApi.getMyAsset(),
userApi.getMyBalanceHistory()
])
asset.value = assetRes
history.value = historyRes || []
plans.value = await userApi.listMyVipRechargePlans().catch(() => [])
} catch (error: any) {
message.error(error?.message || '获取 VIP 信息失败')
} finally {
loading.value = false
}
}
onMounted(loadData)
</script>
<template>
<div class="vip-center">
<header class="vip-topbar">
<button class="topbar-button" type="button" aria-label="返回" @click="router.back()">
<LeftOutlined />
</button>
<h1>VIP中心</h1>
<button class="topbar-button" type="button" aria-label="购物车" @click="router.push('/cart')">
<ShoppingOutlined />
</button>
</header>
<a-spin :spinning="loading">
<main class="vip-main">
<section class="vip-hero-card">
<div class="hero-glow hero-glow--top"></div>
<div class="hero-glow hero-glow--bottom"></div>
<div class="hero-content">
<div class="hero-head">
<div>
<span class="vip-kicker">当前会员等级</span>
<h2>{{ memberLevel }} <StarFilled /></h2>
</div>
<div class="fingerprint-badge">
<CrownOutlined />
</div>
</div>
<div class="hero-stats">
<div>
<span>可用余额</span>
<strong><small>¥</small>{{ money(balanceAmount) }}</strong>
</div>
<div>
<span>累计充值</span>
<strong><small>¥</small>{{ money(totalRecharge) }}</strong>
</div>
</div>
<div class="level-progress">
<div>
<span>等级进度</span>
<span>{{ nextLevelText }}</span>
</div>
<div class="progress-track">
<i :style="{ width: `${levelProgress}%` }"></i>
</div>
<p>{{ remainingAmountText }}</p>
</div>
</div>
<TrophyOutlined class="hero-watermark" />
</section>
<section class="vip-section">
<div class="section-head">
<h3>会员特权</h3>
<button type="button" @click="scrollToRecharge">查看全部</button>
</div>
<div class="benefit-grid">
<article
v-for="item in benefitCards"
:key="item.title"
class="benefit-card"
:class="`benefit-card--${item.tone}`"
>
<span class="benefit-icon">
<component :is="item.icon" />
</span>
<strong>{{ item.title }}</strong>
<p>{{ item.desc }}</p>
</article>
</div>
</section>
<section class="vip-section member-info-section">
<div class="section-head">
<h3>会员信息</h3>
</div>
<div class="info-grid">
<article>
<span>生效周期</span>
<strong>{{ validityText }}</strong>
</article>
<article>
<span>最近充值</span>
<strong>{{ formatTime(asset?.lastRechargeTime) }}</strong>
</article>
<article>
<span>等级来源</span>
<strong>{{ asset?.manualOverride ? '后台指定' : '自动计算' }}</strong>
</article>
<article>
<span>当前权益</span>
<strong>{{ asset?.benefitInfo || '暂无额外权益说明' }}</strong>
</article>
</div>
</section>
<section ref="rechargeSectionRef" class="vip-section recharge-section">
<div class="section-head">
<h3>快速充值</h3>
</div>
<div v-if="sortedPlans.length" class="plan-grid">
<article
v-for="(plan, index) in sortedPlans"
:key="String(plan.id)"
class="plan-card"
:class="{ 'plan-card--featured': index === 1 }"
>
<div class="plan-tag" :class="{ 'plan-tag--featured': index === 1 }">
{{ planTag(index) }}
</div>
<span class="plan-title">{{ plan.title || plan.vipLevel }}</span>
<div class="plan-price">
<small>¥</small>
<strong>{{ money(plan.rechargeAmount).replace('.00', '') }}</strong>
</div>
<p>赠送 <b>¥{{ money(plan.giftAmount) }}</b> 奖励金</p>
<button type="button" @click="openPlan(plan)">立即充值</button>
</article>
</div>
<a-empty v-else description="暂无可展示充值档位" />
</section>
<section class="vip-section history-section">
<div class="section-head">
<h3>最近动态</h3>
</div>
<div v-if="visibleHistory.length" class="history-card">
<article
v-for="item in visibleHistory"
:key="String(item.id)"
class="history-row"
>
<span class="history-icon" :class="{ 'history-icon--income': Number(item.amount) > 0 }">
<component :is="sceneIcon(item)" />
</span>
<div class="history-copy">
<strong>{{ sceneText(item.changeScene || item.type) }}</strong>
<span>{{ formatTime(item.changeTime) }}</span>
<em v-if="item.remark">{{ item.remark }}</em>
</div>
<div class="history-amount">
<strong :class="{ income: Number(item.amount) > 0 }">
{{ Number(item.amount) > 0 ? '+' : '' }}¥{{ money(item.amount) }}
</strong>
<span v-if="item.afterBalance !== undefined">余额: ¥{{ money(item.afterBalance) }}</span>
</div>
</article>
</div>
<a-empty v-else description="暂无余额变动" />
<button v-if="canLoadMoreHistory" class="load-more-button" type="button" @click="loadMoreHistory">
加载更多交易记录
</button>
</section>
</main>
</a-spin>
<a-modal v-model:open="rechargeOpen" title="充值档位说明" :footer="null">
<div class="plan-modal" v-if="selectedPlan">
<span class="modal-icon"><CreditCardOutlined /></span>
<h3>{{ selectedPlan.title || selectedPlan.vipLevel }}</h3>
<p>充值 ¥{{ money(selectedPlan.rechargeAmount) }},赠送 ¥{{ money(selectedPlan.giftAmount) }} 奖励金。</p>
<p>{{ selectedPlan.description || '该档位仅展示,暂不发起支付。' }}</p>
</div>
</a-modal>
</div>
</template>
<style scoped>
.vip-center {
--vip-bg: #fff8f4;
--vip-surface: rgba(255, 255, 255, 0.82);
--vip-surface-strong: rgba(255, 255, 255, 0.94);
--vip-surface-low: #fcf2ea;
--vip-surface-mid: #f6ece5;
--vip-surface-high: #f1e6df;
--vip-text: #1f1b17;
--vip-muted: #504444;
--vip-outline: #d4c2c3;
--vip-outline-soft: rgba(212, 194, 195, 0.54);
--vip-primary: #7c5357;
--vip-blush: #e8b4b8;
--vip-blush-soft: #ffdadc;
--vip-blush-dim: #eeb9bd;
--vip-gold: #775a19;
--vip-gold-soft: #fed488;
--vip-neutral: #5e5e5d;
--vip-neutral-soft: #c2c1bf;
--vip-hero-text: #fff8f4;
--vip-shadow: rgba(74, 68, 63, 0.1);
min-height: 100vh;
color: var(--vip-text);
background:
radial-gradient(circle at 84% 0%, rgba(232, 180, 184, 0.38), transparent 34%),
radial-gradient(circle at 4% 18%, rgba(254, 212, 136, 0.34), transparent 30%),
linear-gradient(180deg, var(--vip-bg) 0%, var(--vip-surface-low) 46%, var(--vip-bg) 100%);
}
.vip-topbar {
position: sticky;
top: 0;
z-index: 30;
display: grid;
grid-template-columns: 42px minmax(0, 1fr) 42px;
align-items: center;
width: min(100%, var(--app-mobile-max-width, 480px));
min-height: 64px;
margin: 0 auto;
padding: 8px 20px;
background: rgba(255, 248, 244, 0.86);
box-shadow: 0 8px 28px rgba(74, 68, 63, 0.06);
backdrop-filter: blur(18px);
}
.vip-topbar h1 {
margin: 0;
color: var(--vip-primary);
font-family: Georgia, 'Times New Roman', serif;
font-size: 24px;
font-weight: 700;
line-height: 1.15;
text-align: center;
}
.topbar-button {
display: inline-flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
padding: 0;
border: 0;
border-radius: 999px;
color: var(--vip-primary);
background: var(--vip-surface-strong);
box-shadow: 0 12px 24px rgba(74, 68, 63, 0.08);
cursor: pointer;
}
.topbar-button :deep(.anticon) {
font-size: 21px;
}
.vip-main {
display: grid;
gap: 32px;
width: min(100%, var(--app-mobile-max-width, 480px));
margin: 0 auto;
padding: 22px 20px 42px;
}
.vip-hero-card {
position: relative;
overflow: hidden;
padding: 28px;
border-radius: 32px;
color: var(--vip-hero-text);
background:
linear-gradient(135deg, var(--vip-primary) 0%, var(--vip-blush) 55%, var(--vip-gold-soft) 100%);
box-shadow: 0 26px 54px rgba(124, 83, 87, 0.22);
}
.hero-glow {
position: absolute;
width: 210px;
height: 210px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.13);
filter: blur(18px);
}
.hero-glow--top {
top: -74px;
right: -78px;
}
.hero-glow--bottom {
bottom: -118px;
left: -86px;
background: rgba(254, 212, 136, 0.24);
}
.hero-content {
position: relative;
z-index: 1;
display: grid;
gap: 22px;
}
.hero-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
}
.vip-kicker,
.section-head button,
.plan-title {
font-size: 12px;
font-weight: 800;
line-height: 1.2;
letter-spacing: 0;
text-transform: uppercase;
}
.vip-kicker {
display: block;
margin-bottom: 6px;
opacity: 0.78;
}
.hero-head h2 {
display: flex;
align-items: center;
gap: 8px;
margin: 0;
font-family: Georgia, 'Times New Roman', serif;
font-size: 28px;
font-weight: 700;
line-height: 1.15;
}
.hero-head h2 :deep(.anticon) {
color: var(--vip-gold-soft);
font-size: 18px;
}
.fingerprint-badge {
display: grid;
flex: 0 0 auto;
width: 52px;
height: 52px;
place-items: center;
border: 1px solid rgba(255, 255, 255, 0.28);
border-radius: 18px;
background: rgba(255, 255, 255, 0.18);
backdrop-filter: blur(12px);
}
.fingerprint-badge :deep(.anticon) {
font-size: 28px;
}
.hero-stats {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.hero-stats > div {
min-width: 0;
padding: 14px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 16px;
background: rgba(255, 255, 255, 0.12);
backdrop-filter: blur(10px);
}
.hero-stats span,
.level-progress span,
.level-progress p {
color: rgba(255, 255, 255, 0.74);
font-size: 12px;
line-height: 1.35;
}
.hero-stats strong {
display: flex;
align-items: baseline;
gap: 3px;
min-width: 0;
margin-top: 6px;
overflow-wrap: anywhere;
color: var(--vip-hero-text);
font-family: Georgia, 'Times New Roman', serif;
font-size: 22px;
line-height: 1.1;
}
.hero-stats small,
.plan-price small {
font-family: inherit;
font-size: 13px;
}
.level-progress {
display: grid;
gap: 8px;
}
.level-progress > div:first-child {
display: flex;
justify-content: space-between;
gap: 10px;
}
.progress-track {
height: 6px;
overflow: hidden;
border-radius: 999px;
background: rgba(255, 255, 255, 0.2);
}
.progress-track i {
display: block;
height: 100%;
border-radius: inherit;
background: var(--vip-hero-text);
box-shadow: 0 0 14px rgba(255, 255, 255, 0.5);
}
.level-progress p {
margin: 0;
}
.hero-watermark {
position: absolute;
right: 20px;
bottom: -26px;
color: rgba(255, 255, 255, 0.1);
font-size: 118px;
}
.vip-section {
display: grid;
gap: 18px;
}
.section-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.section-head h3 {
margin: 0;
color: var(--vip-text);
font-family: Georgia, 'Times New Roman', serif;
font-size: 24px;
font-weight: 700;
line-height: 1.2;
}
.section-head button {
border: 0;
color: var(--vip-primary);
background: transparent;
cursor: pointer;
}
.benefit-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
}
.benefit-card,
.member-info-section,
.plan-card,
.history-card {
border: 1px solid rgba(212, 194, 195, 0.5);
background: var(--vip-surface);
box-shadow: 0 20px 40px var(--vip-shadow);
backdrop-filter: blur(16px);
}
.benefit-card {
display: grid;
justify-items: center;
gap: 10px;
min-height: 164px;
padding: 20px 14px;
border-radius: 18px;
text-align: center;
}
.benefit-icon {
display: grid;
width: 50px;
height: 50px;
place-items: center;
border-radius: 999px;
font-size: 24px;
}
.benefit-card--rose .benefit-icon {
color: var(--vip-primary);
background: var(--vip-blush-soft);
}
.benefit-card--gold .benefit-icon {
color: var(--vip-gold);
background: rgba(254, 212, 136, 0.72);
}
.benefit-card--slate .benefit-icon {
color: var(--vip-neutral);
background: rgba(194, 193, 191, 0.48);
}
.benefit-card--cream .benefit-icon {
color: var(--vip-primary);
background: var(--vip-surface-high);
}
.benefit-card strong {
color: var(--vip-text);
font-size: 14px;
font-weight: 850;
}
.benefit-card p {
display: -webkit-box;
margin: 0;
overflow: hidden;
color: var(--vip-muted);
font-size: 12px;
line-height: 1.45;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.member-info-section {
padding: 18px;
border-radius: 24px;
}
.info-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.info-grid article {
min-width: 0;
padding: 13px;
border: 1px solid var(--vip-outline-soft);
border-radius: 16px;
background: rgba(252, 242, 234, 0.78);
}
.info-grid span,
.history-copy span,
.history-copy em,
.history-amount span {
display: block;
color: var(--vip-muted);
font-size: 12px;
line-height: 1.35;
}
.info-grid strong {
display: block;
margin-top: 6px;
overflow-wrap: anywhere;
color: var(--vip-text);
font-size: 13px;
font-weight: 800;
line-height: 1.35;
}
.plan-grid {
display: grid;
gap: 16px;
}
.plan-card {
position: relative;
display: grid;
gap: 13px;
padding: 24px;
border-radius: 24px;
}
.plan-card--featured {
border-color: rgba(119, 90, 25, 0.24);
background: linear-gradient(135deg, rgba(255, 250, 240, 0.92), rgba(254, 212, 136, 0.28));
}
.plan-tag {
justify-self: start;
padding: 5px 11px;
border-radius: 999px;
color: var(--vip-primary);
background: var(--vip-blush-soft);
font-size: 10px;
font-weight: 900;
}
.plan-tag--featured {
position: absolute;
top: -11px;
right: 22px;
color: var(--vip-hero-text);
background: var(--vip-gold);
}
.plan-title {
color: var(--vip-muted);
}
.plan-price {
display: flex;
align-items: baseline;
gap: 5px;
color: var(--vip-primary);
}
.plan-price strong {
font-family: Georgia, 'Times New Roman', serif;
font-size: 40px;
line-height: 1;
}
.plan-card p {
margin: 0;
color: var(--vip-muted);
font-size: 14px;
}
.plan-card p b {
color: var(--vip-primary);
}
.plan-card button {
width: 100%;
min-height: 46px;
border: 0;
border-radius: 999px;
color: var(--vip-hero-text);
background: var(--vip-primary);
font-size: 14px;
font-weight: 850;
cursor: pointer;
box-shadow: 0 14px 28px rgba(124, 83, 87, 0.2);
}
.plan-card--featured button {
background: var(--vip-gold);
}
.history-card {
overflow: hidden;
border-radius: 24px;
}
.history-row {
display: grid;
grid-template-columns: 42px minmax(0, 1fr) auto;
gap: 12px;
align-items: center;
padding: 16px;
border-bottom: 1px solid var(--vip-outline-soft);
}
.history-row:last-child {
border-bottom: 0;
}
.history-icon {
display: grid;
width: 40px;
height: 40px;
place-items: center;
border-radius: 999px;
color: var(--vip-muted);
background: var(--vip-surface-high);
}
.history-icon--income {
color: var(--vip-primary);
background: var(--vip-blush-soft);
}
.history-copy {
min-width: 0;
}
.history-copy strong {
display: block;
overflow: hidden;
color: var(--vip-text);
font-size: 14px;
font-weight: 850;
text-overflow: ellipsis;
white-space: nowrap;
}
.history-copy em {
margin-top: 3px;
overflow: hidden;
font-style: normal;
text-overflow: ellipsis;
white-space: nowrap;
}
.history-amount {
min-width: 88px;
text-align: right;
}
.history-amount strong {
display: block;
color: var(--vip-text);
font-size: 13px;
font-weight: 900;
white-space: nowrap;
}
.history-amount strong.income {
color: var(--vip-gold);
}
.load-more-button {
width: 100%;
min-height: 44px;
border: 0;
border-radius: 16px;
color: var(--vip-primary);
background: rgba(232, 180, 184, 0.22);
font-weight: 850;
cursor: pointer;
}
.plan-modal {
display: grid;
gap: 10px;
text-align: center;
}
.modal-icon {
display: grid;
width: 54px;
height: 54px;
margin: 0 auto;
place-items: center;
border-radius: 999px;
color: var(--vip-primary);
background: var(--vip-blush-soft);
font-size: 25px;
}
.plan-modal h3 {
margin: 4px 0 0;
font-size: 18px;
font-weight: 850;
}
.plan-modal p {
margin: 0;
color: var(--vip-muted);
line-height: 1.65;
}
@media (max-width: 370px) {
.vip-main {
padding-right: 14px;
padding-left: 14px;
}
.vip-hero-card {
padding: 22px;
}
.hero-stats,
.benefit-grid,
.info-grid {
grid-template-columns: 1fr;
}
}
@media (min-width: 768px) {
.vip-topbar {
border-top-left-radius: 32px;
border-top-right-radius: 32px;
}
.plan-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
</style>
@@ -0,0 +1,520 @@
<template>
<div class="mobile-container">
<header class="header">
<div class="back-btn" @click="handleBackClick">
<el-icon><ArrowLeft /></el-icon>
</div>
<h1>我的收藏</h1>
<div class="empty"></div>
</header>
<div v-if="groups.length" class="group-tabs">
<button
class="group-tab"
:class="{ 'group-tab--active': activeGroupId === null }"
type="button"
@click="activeGroupId = null"
>
All
</button>
<button
v-for="group in groups"
:key="String(group.id)"
class="group-tab"
:class="{ 'group-tab--active': sameId(activeGroupId, group.id) }"
type="button"
@click="activeGroupId = group.id"
>
{{ group.name }}
</button>
</div>
<div class="wishlist-items">
<div v-for="item in visibleWishlistItems" :key="item.id" class="wishlist-item">
<div class="item-image" @click="handleProductClick(item.product.id)">
<img
v-if="getProductImages(item.product).length > 0"
:src="getProductImages(item.product)[0]"
:alt="item.product.title"
loading="lazy"
decoding="async"
/>
<div v-else class="image-placeholder" :style="{ backgroundColor: getRandomColor() }">
<span>{{ item.product.title ? item.product.title[0] : '作' }}</span>
</div>
</div>
<div class="item-details">
<h3 class="item-name" @click="handleProductClick(item.product.id)">{{ item.product.title }}</h3>
<div class="item-group">{{ item.groupName || '最近想做' }}</div>
<p v-if="item.note" class="item-note">{{ item.note }}</p>
<p class="item-price">¥{{ Number(item.product.price || 0).toFixed(2) }}</p>
<div class="item-actions">
<el-button
size="small"
:type="isProductInCart(item.product.id) ? 'info' : 'primary'"
@click="handleAddToCart(item.product.id)"
>
{{ isProductInCart(item.product.id) ? '购物车已有' : '加入购物车' }}
</el-button>
<el-icon class="delete-icon" @click="handleRemoveItem(item.product.id)"><Delete /></el-icon>
</div>
</div>
</div>
</div>
<div v-if="wishlistItems.length === 0" class="empty-wishlist">
<el-icon :size="60" :style="{ color: 'var(--theme-primary)' }"><StarFilled /></el-icon>
<p>收藏列表为空</p>
<el-button type="primary" @click="handleBrowseProducts">
浏览作品
</el-button>
</div>
</div>
</template>
<script setup lang="ts">
/**
* WishlistView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, ref, onMounted, inject } from 'vue'
import { ArrowLeft, Delete, StarFilled } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import 'element-plus/es/components/message/style/css'
/**
* Purpose: WishlistItem supports WishlistView.vue by holding or executing the wishlist item 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.
*/
import { wishlistApi, type WishlistGroup, type WishlistItem } from '@/api/wishlist'
import { cartApi } from '@/api/cart'
import type { IdType } from '@/utils/id'
import { sameId } from '@/utils/id'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { fetchCartProductIdSet, hasCartProduct, withAddedCartProduct } from '@/utils/cart-state'
import { resolvePublicImageUrls, resolvePublicImageUrlsSync } from '@/utils/public-image-assets'
import type { PublicImageRecord } from '@/utils/public-image-assets'
/**
* Purpose: router supports WishlistView.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.
*/
const router = useRouter()
/**
* Purpose: updateCartCount supports WishlistView.vue by holding or executing the update cart count 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.
*/
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
/**
* Purpose: wishlistItems supports WishlistView.vue by holding or executing the wishlist 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.
*/
const wishlistItems = ref<WishlistItem[]>([])
const groups = ref<WishlistGroup[]>([])
const activeGroupId = ref<IdType | null>(null)
/**
* Purpose: imageUrls supports WishlistView.vue by holding or executing the image urls 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.
*/
const imageUrls = ref<Record<string, string[]>>({})
/** cartProductIdSet is a reactive state variable used by the template and event handlers. */
const cartProductIdSet = ref(new Set<string>())
/**
* Purpose: DEFAULT_PRODUCT_IMAGE supports WishlistView.vue by holding or executing the default product image 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.
*/
const DEFAULT_PRODUCT_IMAGE = 'data:image/svg+xml;base64,PHN2ZyB3aW0dPSJodHRwOi8vd3d3Lm9yZy8yMDAwL3N2ZyI+Pjwvc3ZnPg=='
const visibleWishlistItems = computed(() => {
if (activeGroupId.value === null) {
return wishlistItems.value
}
return wishlistItems.value.filter(item => sameId(item.groupId, activeGroupId.value))
})
/** handleBackClick is a local helper used by this page script. */
const handleBackClick = () => {
router.back()
}
/** fetchWishlist is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const fetchWishlist = async () => {
try {
const [response, nextGroups, nextCartProductIdSet] = await Promise.all([
wishlistApi.getWishlist(),
wishlistApi.getGroups(),
fetchCartProductIdSet()
])
cartProductIdSet.value = nextCartProductIdSet
groups.value = nextGroups
wishlistItems.value = response as unknown as WishlistItem[]
await loadImageUrls(response as unknown as WishlistItem[])
} catch (error: any) {
console.error('获取收藏列表失败:', error)
ElMessage.error(error?.message || '获取收藏列表失败')
}
}
/** loadImageUrls is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadImageUrls = async (items: WishlistItem[]) => {
for (const item of items) {
const productKey = String(item.product.id)
const cachedUrls = resolvePublicImageUrlsSync(item.product as PublicImageRecord, '')
if (cachedUrls.length) {
imageUrls.value[productKey] = cachedUrls
}
const urls = await resolvePublicImageUrls(item.product as PublicImageRecord, DEFAULT_PRODUCT_IMAGE)
imageUrls.value[productKey] = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE]
}
}
/** getProductImages is a local helper used by this page script. */
const getProductImages = (product: { id: IdType }): string[] => {
return imageUrls.value[String(product.id)] || [DEFAULT_PRODUCT_IMAGE]
}
/** isProductInCart is a local helper used by this page script. */
const isProductInCart = (productId: IdType) => hasCartProduct(cartProductIdSet.value, productId)
/** handleAddToCart is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleAddToCart = async (productId: IdType) => {
if (isProductInCart(productId)) {
ElMessage.info('购物车已有')
return
}
try {
await runWithGlobalLoading(() => cartApi.addToCart({ productId, quantity: 1 }))
cartProductIdSet.value = withAddedCartProduct(cartProductIdSet.value, productId)
await updateCartCount()
ElMessage.success('已添加到购物车')
} catch (error: any) {
console.error('添加到购物车失败:', error)
ElMessage.error(error?.message || '添加到购物车失败')
}
}
/** handleRemoveItem is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleRemoveItem = async (productId: IdType) => {
try {
await runWithGlobalLoading(() => wishlistApi.removeFromWishlist(productId))
wishlistItems.value = wishlistItems.value.filter(item => !sameId(item.productId, productId))
ElMessage.success('已从收藏中移除')
} catch (error: any) {
console.error('移除收藏失败:', error)
ElMessage.error(error?.message || '移除收藏失败')
}
}
/** handleBrowseProducts is a local helper used by this page script. */
const handleBrowseProducts = () => {
router.push('/products')
}
/** handleProductClick is a local helper used by this page script. */
const handleProductClick = (productId: IdType) => {
router.push(`/product/${productId}`)
}
/** getRandomColor is a local helper used by this page script. */
const getRandomColor = () => {
return 'var(--theme-primary-soft)'
}
onMounted(() => {
fetchWishlist()
})
</script>
<style scoped>
.mobile-container {
min-height: 100vh;
padding-top: 60px;
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;
}
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
justify-content: space-between;
align-items: center;
height: 60px;
padding: 10px 15px;
background: rgba(255, 255, 255, 0.92);
border-bottom: 1px solid var(--theme-border);
backdrop-filter: blur(14px);
}
.back-btn {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: var(--text-primary);
}
.header h1 {
margin: 0;
font-size: 18px;
font-weight: bold;
color: var(--text-primary);
}
.empty {
width: 40px;
}
.group-tabs {
display: flex;
gap: 8px;
overflow-x: auto;
padding: 14px 16px 0;
}
.group-tab {
flex: 0 0 auto;
height: 32px;
padding: 0 12px;
border: 1px solid var(--theme-border);
border-radius: 8px;
background: var(--theme-card-bg);
color: var(--text-secondary);
font-size: 13px;
line-height: 30px;
white-space: nowrap;
}
.group-tab--active {
border-color: var(--theme-primary);
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-weight: 600;
}
.wishlist-items {
padding: 16px;
padding-bottom: 28px;
}
.wishlist-item {
display: flex;
gap: 15px;
padding: 15px;
background: var(--theme-card-bg);
border: 1px solid var(--theme-border);
border-radius: 16px;
margin-bottom: 15px;
box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08);
}
.item-image {
width: 80px;
height: 80px;
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
cursor: pointer;
}
.item-image img {
width: 100%;
height: 100%;
object-fit: cover;
}
.image-placeholder {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 30px;
font-weight: bold;
color: rgba(0, 0, 0, 0.1);
border: 1px solid var(--theme-border);
}
.item-details {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.item-name {
font-size: 16px;
font-weight: bold;
margin: 0 0 5px 0;
color: var(--text-primary);
}
.item-group {
width: fit-content;
max-width: 100%;
margin-bottom: 6px;
padding: 2px 8px;
border-radius: 8px;
background: var(--theme-primary-soft);
color: var(--theme-accent);
font-size: 12px;
line-height: 18px;
}
.item-note {
margin: 0 0 8px;
color: var(--text-secondary);
font-size: 13px;
line-height: 18px;
word-break: break-word;
}
.item-price {
color: var(--theme-primary);
font-weight: bold;
margin: 0 0 10px 0;
}
.item-actions {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
}
.delete-icon {
color: var(--theme-accent);
cursor: pointer;
font-size: 20px;
}
.empty-wishlist {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 16px;
padding: 64px 20px;
color: var(--text-secondary);
background: var(--theme-card-bg);
border: 1px solid var(--theme-border);
border-radius: 18px;
box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08);
}
.empty-wishlist p {
margin: 20px 0;
font-size: 16px;
}
:deep(.el-button--primary) {
--el-button-bg-color: var(--theme-primary);
--el-button-border-color: var(--theme-primary);
--el-button-hover-bg-color: var(--theme-accent);
--el-button-hover-border-color: var(--theme-accent);
}
:deep(.el-button--info) {
--el-button-bg-color: var(--theme-primary-soft);
--el-button-border-color: var(--theme-border);
--el-button-text-color: var(--theme-accent);
--el-button-hover-bg-color: var(--theme-primary-soft);
--el-button-hover-border-color: var(--theme-border);
--el-button-hover-text-color: var(--theme-accent);
}
.mobile-container {
padding-top: 68px;
background:
radial-gradient(circle at 84% 0%, color-mix(in srgb, var(--theme-primary) 26%, transparent), transparent 32%),
linear-gradient(180deg, color-mix(in srgb, var(--theme-card-bg) 76%, transparent), var(--theme-page-bg));
}
.header {
height: 64px;
padding: 12px 18px 10px;
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
}
.header h1 {
font-size: 17px;
font-weight: 820;
}
.back-btn {
border-radius: 999px;
background: color-mix(in srgb, var(--theme-card-bg) 74%, transparent);
}
.group-tabs {
padding: 16px 18px 0;
}
.group-tab {
height: 34px;
border-radius: 999px;
background: color-mix(in srgb, var(--theme-card-bg) 84%, transparent);
}
.group-tab--active {
border-color: color-mix(in srgb, var(--theme-primary) 40%, var(--theme-border));
background: color-mix(in srgb, var(--theme-primary) 20%, var(--theme-card-bg));
color: var(--theme-primary-action);
}
.wishlist-items {
padding: 18px;
}
.wishlist-item {
border-radius: 24px;
background: color-mix(in srgb, var(--theme-card-bg) 90%, transparent);
box-shadow: 0 18px 42px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
}
.item-image {
width: 92px;
height: 92px;
border-radius: 18px;
}
.item-name {
font-weight: 820;
}
.item-group {
border-radius: 999px;
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-primary) 18%, var(--theme-card-bg));
}
.item-price {
color: var(--theme-primary-action);
}
.empty-wishlist {
border-radius: 24px;
background: color-mix(in srgb, var(--theme-card-bg) 90%, transparent);
box-shadow: 0 18px 42px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
}
:deep(.el-button--primary) {
--el-button-bg-color: var(--theme-primary-action);
--el-button-border-color: var(--theme-primary-action);
--el-button-hover-bg-color: var(--theme-secondary);
--el-button-hover-border-color: var(--theme-secondary);
}
</style>