杂务:整理文档并收口 YumiNail 修复
This commit is contained in:
+134
-27
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-config-provider>
|
||||
<ConfigProvider :locale="antdLocale">
|
||||
<ConfigProvider :locale="antdLocale" :theme="antdTheme">
|
||||
<div class="app-container">
|
||||
<BottomNav v-if="!isHiddenNav" />
|
||||
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
|
||||
@@ -18,18 +18,27 @@
|
||||
* App 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, h, onMounted, provide, ref, watch } from 'vue'
|
||||
import { computed, h, onMounted, onUnmounted, provide, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ConfigProvider, Modal } from 'ant-design-vue'
|
||||
import type { ButtonProps } from 'ant-design-vue/es/button/buttonTypes'
|
||||
import type { ThemeConfig } from 'ant-design-vue/es/config-provider/context'
|
||||
import { CheckOutlined } from '@ant-design/icons-vue'
|
||||
import BottomNav from './components/BottomNav.vue'
|
||||
import SystemMessageCard from './components/SystemMessageCard.vue'
|
||||
import { cartApi } from './api/cart'
|
||||
import { userApi, type SystemMessageVO } from './api/user'
|
||||
import antdLocale from './config/antdv-locale'
|
||||
import { useShopTheme } from './composables/useShopTheme'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { currentTheme, refreshShopTheme, resetShopTheme, setupShopThemeSync } = useShopTheme()
|
||||
type ButtonPropsWithClass = ButtonProps & { class?: string }
|
||||
const popupMessageOkButtonProps: ButtonPropsWithClass = { class: 'popup-message-ok-button' }
|
||||
/** routerReady is a reactive state variable used by the template and event handlers. */
|
||||
const routerReady = ref(false)
|
||||
let stopThemeSync: (() => void) | undefined
|
||||
|
||||
/** isHiddenNav is a reactive state variable used by the template and event handlers. */
|
||||
const isHiddenNav = computed(() => {
|
||||
@@ -44,6 +53,28 @@ const isHiddenNav = computed(() => {
|
||||
return route.matched.some(r => r.meta.hideNav) || route.matched.some(r => r.meta.isAdmin)
|
||||
})
|
||||
|
||||
const antdTheme = computed<ThemeConfig>(() => ({
|
||||
token: {
|
||||
colorPrimary: currentTheme.value.primaryColor,
|
||||
colorLink: currentTheme.value.primaryColor,
|
||||
borderRadius: 8
|
||||
},
|
||||
components: {
|
||||
Button: {
|
||||
colorPrimary: currentTheme.value.primaryColor,
|
||||
colorPrimaryHover: currentTheme.value.accentColor,
|
||||
colorPrimaryActive: currentTheme.value.accentColor
|
||||
},
|
||||
Radio: {
|
||||
colorPrimary: currentTheme.value.primaryColor
|
||||
},
|
||||
Input: {
|
||||
activeBorderColor: currentTheme.value.primaryColor,
|
||||
hoverBorderColor: currentTheme.value.primaryColor
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
// 全局购物车数量状态
|
||||
/** cartCount is a reactive state variable used by the template and event handlers. */
|
||||
const cartCount = ref(0)
|
||||
@@ -90,13 +121,25 @@ const showPopupMessage = (item: SystemMessageVO) => {
|
||||
await userApi.markMessagePopupShown(item.id)
|
||||
resolve()
|
||||
}
|
||||
const metaText = `${item.publisherName || '系统消息'} · ${item.publishTime || item.createTime || '刚刚'}`
|
||||
Modal.info({
|
||||
title: item.title,
|
||||
content: h('div', { class: 'popup-message-body' }, [
|
||||
item.content ? h('div', { class: 'popup-message-content' }, item.content) : null,
|
||||
item.imageUrl ? h('img', { class: 'popup-message-image', src: item.imageUrl, alt: '消息图片' }) : null
|
||||
icon: null,
|
||||
centered: true,
|
||||
width: 560,
|
||||
class: 'yumi-system-message-dialog',
|
||||
wrapClassName: 'yumi-system-message-wrap',
|
||||
content: h(SystemMessageCard, {
|
||||
title: item.title || '系统消息',
|
||||
content: item.content || '',
|
||||
imageUrl: item.imageUrl || '',
|
||||
meta: metaText,
|
||||
surface: 'modal'
|
||||
}),
|
||||
okText: h('span', { class: 'popup-message-ok-text' }, [
|
||||
h(CheckOutlined),
|
||||
h('span', '我知道了')
|
||||
]),
|
||||
okText: '我知道了',
|
||||
okButtonProps: popupMessageOkButtonProps,
|
||||
async onOk() {
|
||||
await markShownAndResolve()
|
||||
},
|
||||
@@ -134,6 +177,11 @@ provide('cartCount', cartCount)
|
||||
watch(() => route.path, async () => {
|
||||
// 检查当前是否是后台页面,如果是则不加载购物车数据
|
||||
const isAdminPage = route.matched.some(r => r.meta.isAdmin)
|
||||
if (isAdminPage) {
|
||||
resetShopTheme()
|
||||
} else {
|
||||
await refreshShopTheme()
|
||||
}
|
||||
if (!isAdminPage) {
|
||||
await loadCartCount()
|
||||
await checkPopupMessages()
|
||||
@@ -144,10 +192,20 @@ watch(() => route.path, async () => {
|
||||
loadCartCount()
|
||||
|
||||
onMounted(async () => {
|
||||
stopThemeSync = setupShopThemeSync()
|
||||
await router.isReady()
|
||||
routerReady.value = true
|
||||
if (route.matched.some(r => r.meta.isAdmin)) {
|
||||
resetShopTheme()
|
||||
} else {
|
||||
await refreshShopTheme()
|
||||
}
|
||||
await checkPopupMessages()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopThemeSync?.()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -155,7 +213,7 @@ onMounted(async () => {
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
color: #2c3e50;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.app-container {
|
||||
@@ -226,14 +284,14 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.yumi-date-picker-panel .ant-picker-cell:hover .ant-picker-cell-inner {
|
||||
background: #eef6ff;
|
||||
background: var(--theme-primary-soft);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.yumi-date-picker-panel .ant-picker-cell-selected .ant-picker-cell-inner,
|
||||
.yumi-date-picker-panel .ant-picker-cell-range-start .ant-picker-cell-inner,
|
||||
.yumi-date-picker-panel .ant-picker-cell-range-end .ant-picker-cell-inner {
|
||||
background: #1677ff;
|
||||
background: var(--theme-primary);
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -263,8 +321,8 @@ onMounted(async () => {
|
||||
|
||||
.yumi-date-time-panel .ant-picker-time-panel-cell-selected .ant-picker-time-panel-cell-inner,
|
||||
.yumi-time-panel .ant-picker-time-panel-cell-selected .ant-picker-time-panel-cell-inner {
|
||||
background: #eef6ff;
|
||||
color: #1677ff;
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@@ -274,25 +332,74 @@ onMounted(async () => {
|
||||
|
||||
.ant-picker-focused,
|
||||
.ant-picker:hover {
|
||||
border-color: #1677ff;
|
||||
box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
|
||||
border-color: var(--theme-primary);
|
||||
box-shadow: var(--theme-focus-shadow);
|
||||
}
|
||||
|
||||
.popup-message-body {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
.yumi-system-message-wrap .ant-modal {
|
||||
max-width: calc(100vw - 32px);
|
||||
}
|
||||
|
||||
.popup-message-content {
|
||||
white-space: pre-wrap;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.popup-message-image {
|
||||
width: 100%;
|
||||
max-height: 360px;
|
||||
object-fit: contain;
|
||||
.yumi-system-message-dialog .ant-modal-content {
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
border-radius: 8px;
|
||||
background: #fff7f8;
|
||||
background: var(--theme-card-bg);
|
||||
box-shadow: 0 24px 70px rgba(38, 31, 36, 0.32);
|
||||
}
|
||||
|
||||
.yumi-system-message-dialog .ant-modal-confirm-body-wrapper {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.yumi-system-message-dialog .ant-modal-confirm-body {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.yumi-system-message-dialog .ant-modal-confirm-content {
|
||||
max-width: none;
|
||||
margin: 0 !important;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.yumi-system-message-dialog .ant-modal-confirm-btns {
|
||||
display: flex;
|
||||
justify-content: stretch;
|
||||
margin: 0;
|
||||
padding: 0 30px 30px;
|
||||
background: var(--theme-card-bg);
|
||||
}
|
||||
|
||||
.yumi-system-message-dialog .popup-message-ok-button {
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
color: #ffffff;
|
||||
font-weight: 700;
|
||||
background: var(--theme-gradient);
|
||||
box-shadow: var(--theme-button-shadow);
|
||||
}
|
||||
|
||||
.yumi-system-message-dialog .popup-message-ok-button:hover,
|
||||
.yumi-system-message-dialog .popup-message-ok-button:focus {
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, var(--theme-accent) 0%, var(--theme-secondary) 100%);
|
||||
}
|
||||
|
||||
.popup-message-ok-text {
|
||||
display: inline-flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.yumi-system-message-dialog .ant-modal-content {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.yumi-system-message-dialog .popup-message-ok-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -588,7 +588,7 @@ export const adminProductApi = {
|
||||
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
||||
* @param params: { page: number; size: number; keyword?: string; shopId?: IdType } caller-supplied value for `params: { page: number; size: number; keyword?: string; shopId?: IdType }`
|
||||
*/
|
||||
listProducts: (params: { page: number; size: number; keyword?: string; shopId?: IdType }) => {
|
||||
listProducts: (params: { page: number; size: number; keyword?: string; shopId?: IdType; tagId?: IdType; minPrice?: number; maxPrice?: number; createdFrom?: string; createdTo?: string }) => {
|
||||
return adminApi.get<{ list: Product[]; total: number; page: number; size: number }>('/product/list', { params })
|
||||
},
|
||||
/**
|
||||
@@ -639,6 +639,14 @@ export interface Shop {
|
||||
coverImageUrls?: string[]
|
||||
imageFileIds?: string
|
||||
imageUrls?: string[]
|
||||
themePrimaryColor?: string
|
||||
themeSecondaryColor?: string
|
||||
themeAccentColor?: string
|
||||
themePageBgColor?: string
|
||||
themeCardBgColor?: string
|
||||
themeBackgroundImageFileId?: string
|
||||
authorizationStartDate?: string
|
||||
authorizationDays?: number
|
||||
authorizationExpireTime?: string
|
||||
authorizationExpired?: boolean
|
||||
authorizationStatusText?: string
|
||||
@@ -663,7 +671,15 @@ export interface CreateShopRequest {
|
||||
businessHours: string
|
||||
coverImageFileId?: string
|
||||
imageFileIds?: string
|
||||
themePrimaryColor?: string
|
||||
themeSecondaryColor?: string
|
||||
themeAccentColor?: string
|
||||
themePageBgColor?: string
|
||||
themeCardBgColor?: string
|
||||
themeBackgroundImageFileId?: string
|
||||
status?: number
|
||||
authorizationStartDate?: string
|
||||
authorizationDays?: number
|
||||
authorizationExpireTime?: string
|
||||
}
|
||||
|
||||
@@ -982,8 +998,24 @@ export interface OrderVO {
|
||||
artistId?: IdType
|
||||
artistName?: string
|
||||
totalAmount: number
|
||||
actualAmount?: number
|
||||
discountAmount: number
|
||||
payAmount: number
|
||||
couponName?: string
|
||||
customerName?: string
|
||||
customerPhone?: string
|
||||
customerNickname?: string
|
||||
customerPhoneMasked?: string
|
||||
items?: Array<{
|
||||
id: IdType
|
||||
productId: IdType
|
||||
productTitle?: string
|
||||
artistId?: IdType
|
||||
artistName?: string
|
||||
appointmentTime?: string
|
||||
price: number
|
||||
quantity: number
|
||||
}>
|
||||
status: number
|
||||
statusText?: string
|
||||
remark?: string
|
||||
@@ -1011,7 +1043,7 @@ export const adminOrderApi = {
|
||||
* @param status: number caller-supplied value for `status: number`
|
||||
*/
|
||||
updateOrderStatus: (id: IdType, status: number) => {
|
||||
return adminApi.put<boolean>(`/order/update-status/${id}`, { status })
|
||||
return adminApi.put<boolean>(`/order/update-status/${id}`, {}, { params: { status } })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,6 +1069,16 @@ export interface DashboardStats {
|
||||
totalProducts: number
|
||||
totalShops: number
|
||||
todayOrders: number
|
||||
totalOrderAmount?: number
|
||||
todayOrderAmount?: number
|
||||
weekOrderAmount?: number
|
||||
totalCustomers?: number
|
||||
totalArtists?: number
|
||||
newCustomersToday?: number
|
||||
newCustomers7Days?: number
|
||||
newOrders7Days?: number
|
||||
pendingOrders?: number
|
||||
completedOrders?: number
|
||||
hotProducts: HotProductVO[]
|
||||
recentActivities: RecentActivityVO[]
|
||||
}
|
||||
@@ -1306,6 +1348,15 @@ export const adminVipRechargePlanApi = {
|
||||
*/
|
||||
updateStatus: (id: IdType, status: number) => {
|
||||
return adminApi.put<boolean>(`/vip-recharge-plan/admin/${id}/status`, null, { params: { status } })
|
||||
},
|
||||
/**
|
||||
* `listVipLevelOptions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
||||
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
||||
* @param shopId?: IdType caller-supplied value for `shopId?: IdType`
|
||||
*/
|
||||
listVipLevelOptions: (shopId?: IdType) => {
|
||||
const params = shopId ? { shopId } : {}
|
||||
return adminApi.get<string[]>('/vip-recharge-plan/admin/vip-level-options', { params }) as unknown as Promise<string[]>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1410,6 +1461,9 @@ export const adminSystemParameterConfigApi = {
|
||||
},
|
||||
getTencentMapKey: () => {
|
||||
return adminApi.get<{ key: string }>('/system-parameter-config/admin/tencent-map') as unknown as Promise<{ key: string }>
|
||||
},
|
||||
getMapConfig: () => {
|
||||
return adminApi.get<{ provider: 'TENCENT' | 'AMAP'; tencentWebKey?: string; amapWebKey?: string; amapMiniKey?: string }>('/system-parameter-config/admin/map-config') as unknown as Promise<{ provider: 'TENCENT' | 'AMAP'; tencentWebKey?: string; amapWebKey?: string; amapMiniKey?: string }>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,10 +108,10 @@ const handleTokenExpired = (isAdmin = false) => {
|
||||
|
||||
api.interceptors.request.use(
|
||||
async config => {
|
||||
let token = localStorage.getItem('accessToken')
|
||||
if (!token) {
|
||||
token = sessionStorage.getItem('accessToken')
|
||||
}
|
||||
const isAdminRequest = config.url?.includes('/admin/') || config.url?.includes('/order/admin/')
|
||||
let token = isAdminRequest
|
||||
? (localStorage.getItem('adminAccessToken') || sessionStorage.getItem('adminAccessToken'))
|
||||
: (localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken'))
|
||||
|
||||
// 检查是否是后台管理的API请求
|
||||
if (!token && (config.url?.includes('/admin/') || config.url?.includes('/order/admin/'))) {
|
||||
@@ -192,9 +192,9 @@ api.interceptors.response.use(
|
||||
try {
|
||||
let refreshToken
|
||||
if (isAdminRequest) {
|
||||
refreshToken = localStorage.getItem('adminRefreshToken')
|
||||
refreshToken = localStorage.getItem('adminRefreshToken') || sessionStorage.getItem('adminRefreshToken')
|
||||
} else {
|
||||
refreshToken = localStorage.getItem('refreshToken')
|
||||
refreshToken = localStorage.getItem('refreshToken') || sessionStorage.getItem('refreshToken')
|
||||
}
|
||||
|
||||
if (!refreshToken) {
|
||||
|
||||
@@ -16,6 +16,8 @@ export interface ShopVO {
|
||||
navigationUrls?: Record<string, string>
|
||||
businessHours: string
|
||||
status?: number
|
||||
authorizationStartDate?: string
|
||||
authorizationDays?: number
|
||||
authorizationExpireTime?: string
|
||||
authorizationExpired?: boolean
|
||||
authorizationStatusText?: string
|
||||
@@ -23,6 +25,12 @@ export interface ShopVO {
|
||||
coverImageUrls?: string[]
|
||||
imageFileIds: string
|
||||
imageUrls?: string[]
|
||||
themePrimaryColor?: string
|
||||
themeSecondaryColor?: string
|
||||
themeAccentColor?: string
|
||||
themePageBgColor?: string
|
||||
themeCardBgColor?: string
|
||||
themeBackgroundImageFileId?: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
@@ -47,7 +55,15 @@ export interface CreateShopRequest {
|
||||
address: string
|
||||
businessHours: string
|
||||
status: number
|
||||
authorizationStartDate?: string
|
||||
authorizationDays?: number
|
||||
authorizationExpireTime?: string
|
||||
themePrimaryColor?: string
|
||||
themeSecondaryColor?: string
|
||||
themeAccentColor?: string
|
||||
themePageBgColor?: string
|
||||
themeCardBgColor?: string
|
||||
themeBackgroundImageFileId?: string
|
||||
}
|
||||
|
||||
export interface UpdateShopRequest {
|
||||
@@ -58,7 +74,15 @@ export interface UpdateShopRequest {
|
||||
address?: string
|
||||
businessHours?: string
|
||||
status?: number
|
||||
authorizationStartDate?: string
|
||||
authorizationDays?: number
|
||||
authorizationExpireTime?: string
|
||||
themePrimaryColor?: string
|
||||
themeSecondaryColor?: string
|
||||
themeAccentColor?: string
|
||||
themePageBgColor?: string
|
||||
themeCardBgColor?: string
|
||||
themeBackgroundImageFileId?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -109,6 +109,13 @@ export interface UserRelationVO {
|
||||
sourceTypeName?: string
|
||||
}
|
||||
|
||||
export interface NailArtistInfoVO {
|
||||
userId?: IdType
|
||||
userType?: number
|
||||
participateProduction?: number | boolean
|
||||
status?: number
|
||||
}
|
||||
|
||||
// 用户端常用接口约定:
|
||||
// - relation 表示当前用户的门店和直属上级归属;
|
||||
// - announcement 只用于首页滚动公告,不进入消息通知历史;
|
||||
@@ -334,6 +341,9 @@ export const userApi = {
|
||||
getMyRelation: async (): Promise<UserRelationVO> => {
|
||||
return await api.get<UserRelationVO>('/user/relation/me') as unknown as UserRelationVO
|
||||
},
|
||||
getNailArtistInfo: async (userId: IdType): Promise<NailArtistInfoVO | null> => {
|
||||
return await api.get<NailArtistInfoVO | null>(`/nail-artist/get/${userId}`) as unknown as NailArtistInfoVO | null
|
||||
},
|
||||
// 注册页输入邀请码时先解析,给用户展示“将归属到谁/哪个店铺”。
|
||||
resolveInviteCode: async (code: string): Promise<InviteCodeVO> => {
|
||||
return await api.get<InviteCodeVO>('/user/invite-code/resolve', { params: { code } }) as unknown as InviteCodeVO
|
||||
|
||||
+2
@@ -57,6 +57,7 @@ declare module 'vue' {
|
||||
ARadio: typeof import('ant-design-vue/es')['Radio']
|
||||
ARadioButton: typeof import('ant-design-vue/es')['RadioButton']
|
||||
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
|
||||
ARangePicker: typeof import('ant-design-vue/es')['RangePicker']
|
||||
AResult: typeof import('ant-design-vue/es')['Result']
|
||||
ARow: typeof import('ant-design-vue/es')['Row']
|
||||
ASegmented: typeof import('ant-design-vue/es')['Segmented']
|
||||
@@ -85,6 +86,7 @@ declare module 'vue' {
|
||||
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
SystemMessageCard: typeof import('./components/SystemMessageCard.vue')['default']
|
||||
TableEllipsisText: typeof import('./components/TableEllipsisText.vue')['default']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,13 +125,16 @@ const handleNavClick = (tab: string) => {
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
background: white;
|
||||
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
|
||||
background: rgba(255, 255, 255, 0.98);
|
||||
background: color-mix(in srgb, var(--theme-card-bg) 94%, transparent);
|
||||
border-top: 1px solid var(--theme-border);
|
||||
box-shadow: 0 -12px 30px rgba(122, 67, 88, 0.1);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
backdrop-filter: blur(18px);
|
||||
backface-visibility: hidden;
|
||||
will-change: transform;
|
||||
transform: translateZ(0);
|
||||
@@ -158,17 +161,22 @@ const handleNavClick = (tab: string) => {
|
||||
padding: 8px 12px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
border-radius: 12px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 14px;
|
||||
min-width: 60px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.nav-item:hover {
|
||||
background: rgba(24, 144, 255, 0.05);
|
||||
background: var(--theme-primary-soft);
|
||||
border-color: var(--theme-border);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.nav-item.active {
|
||||
color: #1890ff;
|
||||
color: var(--theme-primary);
|
||||
background: var(--theme-primary-soft);
|
||||
border-color: var(--theme-border);
|
||||
}
|
||||
|
||||
.nav-item.active .nav-icon {
|
||||
@@ -181,16 +189,34 @@ const handleNavClick = (tab: string) => {
|
||||
justify-content: center;
|
||||
margin-bottom: 4px;
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
color: var(--text-secondary);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.nav-item.active .nav-icon {
|
||||
color: var(--theme-primary);
|
||||
}
|
||||
|
||||
.nav-label {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.nav-item.active .nav-label {
|
||||
font-weight: 600;
|
||||
color: var(--theme-primary);
|
||||
}
|
||||
|
||||
.nav-item :deep(.ant-badge-count) {
|
||||
background: var(--theme-primary);
|
||||
box-shadow: 0 0 0 1px var(--theme-card-bg);
|
||||
}
|
||||
|
||||
.nav-item :deep(.ant-badge-dot) {
|
||||
background: var(--theme-accent);
|
||||
box-shadow: 0 0 0 1px var(--theme-card-bg);
|
||||
}
|
||||
|
||||
@media (max-width: 359px) {
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { BellOutlined, ClockCircleOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
title?: string
|
||||
content?: string
|
||||
imageUrl?: string
|
||||
imageAlt?: string
|
||||
meta?: string
|
||||
badge?: string
|
||||
auxiliaryBadge?: string
|
||||
surface?: 'modal' | 'preview'
|
||||
footerAlign?: 'between' | 'end'
|
||||
}>(), {
|
||||
title: '系统消息',
|
||||
content: '',
|
||||
imageUrl: '',
|
||||
imageAlt: '消息图片',
|
||||
meta: '',
|
||||
badge: '',
|
||||
auxiliaryBadge: '',
|
||||
surface: 'preview',
|
||||
footerAlign: 'between'
|
||||
})
|
||||
|
||||
const hasImage = computed(() => Boolean(props.imageUrl))
|
||||
const displayTitle = computed(() => props.title?.trim() || '系统消息')
|
||||
const displayContent = computed(() => props.content?.trim() || (hasImage.value ? '' : '你收到了一条新的系统消息。'))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article
|
||||
class="system-message-card"
|
||||
:class="[
|
||||
`system-message-card--${surface}`,
|
||||
`system-message-card--footer-${footerAlign}`,
|
||||
{ 'system-message-card--with-image': hasImage }
|
||||
]"
|
||||
>
|
||||
<div v-if="hasImage" class="system-message-card__media">
|
||||
<img :src="imageUrl" :alt="imageAlt" />
|
||||
</div>
|
||||
|
||||
<div v-else class="system-message-card__icon">
|
||||
<BellOutlined />
|
||||
</div>
|
||||
|
||||
<section class="system-message-card__main">
|
||||
<div v-if="badge || auxiliaryBadge" class="system-message-card__badges">
|
||||
<span v-if="auxiliaryBadge" class="system-message-card__badge system-message-card__badge--soft">{{ auxiliaryBadge }}</span>
|
||||
<span v-if="badge" class="system-message-card__badge">{{ badge }}</span>
|
||||
</div>
|
||||
|
||||
<h2 class="system-message-card__title">{{ displayTitle }}</h2>
|
||||
|
||||
<div v-if="meta" class="system-message-card__meta">
|
||||
<ClockCircleOutlined />
|
||||
<span>{{ meta }}</span>
|
||||
</div>
|
||||
|
||||
<p v-if="displayContent" class="system-message-card__content">{{ displayContent }}</p>
|
||||
</section>
|
||||
|
||||
<footer v-if="$slots.footer" class="system-message-card__footer">
|
||||
<slot name="footer" />
|
||||
</footer>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.system-message-card {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--theme-border);
|
||||
border-radius: 8px;
|
||||
background: var(--theme-card-bg);
|
||||
}
|
||||
|
||||
.system-message-card--preview {
|
||||
box-shadow: 0 20px 54px rgba(77, 50, 62, 0.16);
|
||||
}
|
||||
|
||||
.system-message-card--modal {
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.system-message-card__media {
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 9;
|
||||
padding: 12px 12px 0;
|
||||
background: var(--theme-gradient-soft);
|
||||
}
|
||||
|
||||
.system-message-card__media img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.system-message-card__icon {
|
||||
display: grid;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin: 28px auto 0;
|
||||
place-items: center;
|
||||
border-radius: 8px;
|
||||
color: #ffffff;
|
||||
font-size: 20px;
|
||||
background: var(--theme-gradient);
|
||||
box-shadow: var(--theme-button-shadow);
|
||||
}
|
||||
|
||||
.system-message-card__main {
|
||||
padding: 20px 30px 28px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.system-message-card--with-image .system-message-card__main {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.system-message-card__badges {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.system-message-card__badge {
|
||||
display: inline-flex;
|
||||
min-height: 24px;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
border-radius: 8px;
|
||||
color: #ffffff;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
background: var(--theme-gradient);
|
||||
}
|
||||
|
||||
.system-message-card__badge--soft {
|
||||
color: var(--theme-primary);
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.system-message-card__title {
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
font-size: 22px;
|
||||
font-weight: 800;
|
||||
line-height: 1.35;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.system-message-card__meta {
|
||||
display: inline-flex;
|
||||
max-width: 100%;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 10px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.system-message-card__content {
|
||||
margin: 20px 0 0;
|
||||
color: var(--text-primary);
|
||||
font-size: 15px;
|
||||
line-height: 1.75;
|
||||
text-align: left;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.system-message-card__footer {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 18px 30px;
|
||||
border-top: 1px solid var(--theme-border);
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
background: var(--theme-card-bg);
|
||||
}
|
||||
|
||||
.system-message-card--footer-end .system-message-card__footer {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.system-message-card {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.system-message-card__main,
|
||||
.system-message-card__footer {
|
||||
padding-left: 22px;
|
||||
padding-right: 22px;
|
||||
}
|
||||
|
||||
.system-message-card__title {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.system-message-card__footer {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,120 @@
|
||||
import { readonly, shallowRef } from 'vue'
|
||||
import { fileApi } from '@/api/file'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import {
|
||||
applyShopTheme,
|
||||
DEFAULT_SHOP_THEME,
|
||||
resolveShopTheme,
|
||||
SHOP_THEME_CHANGED_EVENT,
|
||||
type ResolvedShopTheme
|
||||
} from '@/utils/shop-theme'
|
||||
|
||||
const currentTheme = shallowRef<ResolvedShopTheme>(DEFAULT_SHOP_THEME)
|
||||
let cleanupThemeSync: (() => void) | undefined
|
||||
let refreshSequence = 0
|
||||
|
||||
export function useShopTheme() {
|
||||
return {
|
||||
currentTheme: readonly(currentTheme),
|
||||
refreshShopTheme,
|
||||
resetShopTheme,
|
||||
setupShopThemeSync
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshShopTheme() {
|
||||
const token = readToken()
|
||||
const userInfo = readStoredUserInfo()
|
||||
const shopId = userInfo?.shopId
|
||||
|
||||
if (!token || !shopId) {
|
||||
resetShopTheme()
|
||||
return
|
||||
}
|
||||
|
||||
const sequence = ++refreshSequence
|
||||
try {
|
||||
const shop = await shopApi.getShopById(shopId)
|
||||
if (sequence !== refreshSequence) {
|
||||
return
|
||||
}
|
||||
await applyThemeFromShop(shop)
|
||||
} catch {
|
||||
if (sequence === refreshSequence) {
|
||||
resetShopTheme()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetShopTheme() {
|
||||
refreshSequence += 1
|
||||
currentTheme.value = DEFAULT_SHOP_THEME
|
||||
applyShopTheme(DEFAULT_SHOP_THEME)
|
||||
}
|
||||
|
||||
function setupShopThemeSync() {
|
||||
if (cleanupThemeSync || typeof window === 'undefined') {
|
||||
return cleanupThemeSync || (() => {})
|
||||
}
|
||||
|
||||
const handleThemeEvent = () => {
|
||||
void refreshShopTheme()
|
||||
}
|
||||
const handleStorage = (event: StorageEvent) => {
|
||||
if (['accessToken', 'userInfo', 'refreshToken'].includes(event.key || '')) {
|
||||
void refreshShopTheme()
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener(SHOP_THEME_CHANGED_EVENT, handleThemeEvent)
|
||||
window.addEventListener('storage', handleStorage)
|
||||
window.addEventListener('focus', handleThemeEvent)
|
||||
|
||||
cleanupThemeSync = () => {
|
||||
window.removeEventListener(SHOP_THEME_CHANGED_EVENT, handleThemeEvent)
|
||||
window.removeEventListener('storage', handleStorage)
|
||||
window.removeEventListener('focus', handleThemeEvent)
|
||||
cleanupThemeSync = undefined
|
||||
}
|
||||
return cleanupThemeSync
|
||||
}
|
||||
|
||||
async function applyThemeFromShop(shop: ShopVO) {
|
||||
const theme = resolveShopTheme(shop)
|
||||
currentTheme.value = theme
|
||||
const backgroundImageUrl = await resolveBackgroundImageUrl(theme.backgroundImageFileId)
|
||||
applyShopTheme(theme, backgroundImageUrl)
|
||||
}
|
||||
|
||||
async function resolveBackgroundImageUrl(fileId?: string) {
|
||||
if (!fileId) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
return await fileApi.getSignedUrl(fileId, 120) as unknown as string
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function readToken() {
|
||||
if (typeof window === 'undefined') {
|
||||
return ''
|
||||
}
|
||||
return localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken') || ''
|
||||
}
|
||||
|
||||
function readStoredUserInfo(): { shopId?: string | number } | null {
|
||||
if (typeof window === 'undefined') {
|
||||
return null
|
||||
}
|
||||
const raw = localStorage.getItem('userInfo')
|
||||
if (!raw) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
return JSON.parse(raw) as { shopId?: string | number }
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
isBootstrapAdminUser,
|
||||
loadCachedAdminUserInfo,
|
||||
} from '@/utils/admin-session'
|
||||
import { isAllowedForShoplessPlatformAdmin } from '@/utils/platform-admin-permissions'
|
||||
import {
|
||||
clearStoredPermissions,
|
||||
fetchUserPermissionsStrict,
|
||||
@@ -21,11 +22,17 @@ const ADMIN_PERMISSION_ROUTE_MAP: Array<{ code: string; path: string }> = [
|
||||
{ code: 'shop:view', path: '/admin/shops' },
|
||||
{ code: 'product:view', path: '/admin/products' },
|
||||
{ code: 'coupon:view', path: '/admin/coupons' },
|
||||
{ code: 'comment:view', path: '/admin/comments' },
|
||||
{ code: 'order:view', path: '/admin/orders' },
|
||||
{ code: 'user:view', path: '/admin/users' },
|
||||
{ code: 'tag:view', path: '/admin/tags' },
|
||||
{ code: 'permission:view', path: '/admin/permissions' },
|
||||
{ code: 'nail_artist:view', path: '/admin/nail-artists' },
|
||||
{ code: 'message:view', path: '/admin/messages' },
|
||||
{ code: 'announcement:view', path: '/admin/announcements' },
|
||||
{ code: 'user:vip:manage', path: '/admin/vip-recharge-plans' },
|
||||
{ code: 'messagehub:config:manage', path: '/admin/messagehub-push-configs' },
|
||||
{ code: 'legal_agreement:manage', path: '/admin/legal-agreements' },
|
||||
]
|
||||
|
||||
export const useAdminBootstrapState = () => computed(() => adminBootstrapState.value)
|
||||
@@ -48,6 +55,7 @@ export const getAdminBootstrapSnapshot = () => {
|
||||
token: getAdminAccessToken(),
|
||||
userInfo,
|
||||
isBootstrapAdmin: isBootstrapAdminUser(userInfo),
|
||||
isPlatformAdmin: Number(userInfo?.type) === 4,
|
||||
permissions: getStoredUserPermissions() || [],
|
||||
}
|
||||
}
|
||||
@@ -58,8 +66,8 @@ export const hasAdminPermission = (permissionCode?: string) => {
|
||||
}
|
||||
|
||||
const snapshot = getAdminBootstrapSnapshot()
|
||||
if (snapshot.isBootstrapAdmin) {
|
||||
return false
|
||||
if (snapshot.isBootstrapAdmin || (snapshot.isPlatformAdmin && isAllowedForShoplessPlatformAdmin(permissionCode))) {
|
||||
return isAllowedForShoplessPlatformAdmin(permissionCode)
|
||||
}
|
||||
|
||||
return snapshot.permissions.includes(permissionCode)
|
||||
@@ -71,7 +79,7 @@ export const resolveAdminLandingPath = () => {
|
||||
return '/admin'
|
||||
}
|
||||
if (snapshot.isBootstrapAdmin) {
|
||||
return '/admin/shops'
|
||||
return '/admin'
|
||||
}
|
||||
|
||||
const matchedRoute = ADMIN_PERMISSION_ROUTE_MAP.find(item => snapshot.permissions.includes(item.code))
|
||||
@@ -84,7 +92,7 @@ export const canAccessAdminRoute = (path: string, permissionCode?: string) => {
|
||||
return path === '/admin' || path === '/admin/profile'
|
||||
}
|
||||
if (snapshot.isBootstrapAdmin) {
|
||||
return path === '/admin' || path === '/admin/shops'
|
||||
return hasAdminPermission(permissionCode)
|
||||
}
|
||||
|
||||
return hasAdminPermission(permissionCode)
|
||||
|
||||
@@ -38,6 +38,8 @@ export const loadCachedAdminUserInfo = (): AdminCachedUserInfo | null => {
|
||||
export const isBootstrapAdminUser = (userInfo?: AdminCachedUserInfo | null) =>
|
||||
userInfo?.type === 4 && !userInfo?.shopId
|
||||
|
||||
export const isPlatformOverviewAdminUser = isBootstrapAdminUser
|
||||
|
||||
export const clearAdminSessionStorage = () => {
|
||||
localStorage.removeItem('adminAccessToken')
|
||||
localStorage.removeItem('adminRefreshToken')
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
const DEFAULT_MAX_IMAGE_SIZE = 5 * 1024 * 1024
|
||||
const AUTO_COMPRESS_TYPES = new Set(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])
|
||||
|
||||
const inferImageMimeType = (file: File) => {
|
||||
if (file.type) return file.type.toLowerCase()
|
||||
const name = file.name.toLowerCase().split(/[?#]/)[0] || ''
|
||||
if (name.endsWith('.jpg') || name.endsWith('.jpeg')) return 'image/jpeg'
|
||||
if (name.endsWith('.png')) return 'image/png'
|
||||
if (name.endsWith('.webp')) return 'image/webp'
|
||||
if (name.endsWith('.gif')) return 'image/gif'
|
||||
return ''
|
||||
}
|
||||
|
||||
export interface ImageCompressionResult {
|
||||
file: File
|
||||
originalSize: number
|
||||
@@ -112,7 +122,8 @@ export const compressImageIfNeeded = async (
|
||||
file: File,
|
||||
maxSize = DEFAULT_MAX_IMAGE_SIZE
|
||||
): Promise<ImageCompressionResult> => {
|
||||
if (!file.type.startsWith('image/')) {
|
||||
const sourceType = inferImageMimeType(file)
|
||||
if (!sourceType.startsWith('image/')) {
|
||||
return {
|
||||
file,
|
||||
originalSize: file.size,
|
||||
@@ -133,7 +144,7 @@ export const compressImageIfNeeded = async (
|
||||
}
|
||||
}
|
||||
|
||||
if (!AUTO_COMPRESS_TYPES.has(file.type)) {
|
||||
if (!AUTO_COMPRESS_TYPES.has(sourceType)) {
|
||||
return {
|
||||
file,
|
||||
originalSize: file.size,
|
||||
@@ -145,9 +156,9 @@ export const compressImageIfNeeded = async (
|
||||
}
|
||||
|
||||
const image = await loadImageElement(file)
|
||||
const preferredMimeTypes = getPreferredMimeTypes(file)
|
||||
const preferredMimeTypes = getPreferredMimeTypes(new File([file], file.name, { type: sourceType || file.type }))
|
||||
let bestBlob: Blob | null = null
|
||||
let bestMimeType = file.type
|
||||
let bestMimeType = sourceType || file.type
|
||||
|
||||
for (const scale of SCALE_STEPS) {
|
||||
const width = Math.max(1, Math.round(image.naturalWidth * scale))
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { permissionApi } from '@/api/permission'
|
||||
import { computed, ref } from 'vue'
|
||||
import { isBootstrapAdminUser, loadCachedAdminUserInfo } from '@/utils/admin-session'
|
||||
import { isAllowedForShoplessPlatformAdmin } from '@/utils/platform-admin-permissions'
|
||||
|
||||
const USER_PERMISSIONS_STORAGE_KEY = 'userPermissions'
|
||||
|
||||
@@ -22,6 +24,8 @@ const readPermissionsFromStorage = () => {
|
||||
const userPermissions = ref<string[]>(readPermissionsFromStorage() || [])
|
||||
const loadingPermissions = ref(false)
|
||||
|
||||
const isPlatformAdminUser = () => Number(loadCachedAdminUserInfo()?.type) === 4
|
||||
|
||||
export const getStoredUserPermissions = () => readPermissionsFromStorage()
|
||||
|
||||
export const setStoredUserPermissions = (permissions: string[]) => {
|
||||
@@ -51,14 +55,32 @@ export const fetchUserPermissionsStrict = async () => {
|
||||
|
||||
export const usePermission = () => {
|
||||
const hasPermission = (permissionCode: string) => {
|
||||
if (isBootstrapAdminUser(loadCachedAdminUserInfo())) {
|
||||
return isAllowedForShoplessPlatformAdmin(permissionCode)
|
||||
}
|
||||
if (isPlatformAdminUser() && isAllowedForShoplessPlatformAdmin(permissionCode)) {
|
||||
return isAllowedForShoplessPlatformAdmin(permissionCode)
|
||||
}
|
||||
return userPermissions.value.includes(permissionCode)
|
||||
}
|
||||
|
||||
const hasAnyPermission = (permissionCodes: string[]) => {
|
||||
if (isBootstrapAdminUser(loadCachedAdminUserInfo())) {
|
||||
return permissionCodes.some(isAllowedForShoplessPlatformAdmin)
|
||||
}
|
||||
if (isPlatformAdminUser() && permissionCodes.some(isAllowedForShoplessPlatformAdmin)) {
|
||||
return permissionCodes.some(isAllowedForShoplessPlatformAdmin)
|
||||
}
|
||||
return permissionCodes.some(code => userPermissions.value.includes(code))
|
||||
}
|
||||
|
||||
const hasAllPermissions = (permissionCodes: string[]) => {
|
||||
if (isBootstrapAdminUser(loadCachedAdminUserInfo())) {
|
||||
return permissionCodes.every(isAllowedForShoplessPlatformAdmin)
|
||||
}
|
||||
if (isPlatformAdminUser() && permissionCodes.every(isAllowedForShoplessPlatformAdmin)) {
|
||||
return permissionCodes.every(isAllowedForShoplessPlatformAdmin)
|
||||
}
|
||||
return permissionCodes.every(code => userPermissions.value.includes(code))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
const SHOPLESS_ADMIN_ALLOWED_PREFIXES = ['user:', 'shop:', 'permission:', 'message:', 'announcement:']
|
||||
const SHOPLESS_ADMIN_ALLOWED_PERMISSIONS = [
|
||||
'messagehub:config:manage',
|
||||
'legal_agreement:manage'
|
||||
]
|
||||
|
||||
export const isAllowedForShoplessPlatformAdmin = (permissionCode: string) =>
|
||||
permissionCode === 'dashboard:view'
|
||||
|| permissionCode.endsWith(':view')
|
||||
|| SHOPLESS_ADMIN_ALLOWED_PERMISSIONS.includes(permissionCode)
|
||||
|| SHOPLESS_ADMIN_ALLOWED_PREFIXES.some(prefix => permissionCode.startsWith(prefix))
|
||||
@@ -0,0 +1,168 @@
|
||||
export const SHOP_THEME_CHANGED_EVENT = 'yumi-shop-theme-updated'
|
||||
|
||||
export interface ShopThemeSource {
|
||||
themePrimaryColor?: string | null
|
||||
themeSecondaryColor?: string | null
|
||||
themeAccentColor?: string | null
|
||||
themePageBgColor?: string | null
|
||||
themeCardBgColor?: string | null
|
||||
themeBackgroundImageFileId?: string | number | null
|
||||
}
|
||||
|
||||
export interface ResolvedShopTheme {
|
||||
primaryColor: string
|
||||
secondaryColor: string
|
||||
accentColor: string
|
||||
pageBgColor: string
|
||||
cardBgColor: string
|
||||
textPrimary: string
|
||||
textSecondary: string
|
||||
borderColor: string
|
||||
primarySoftColor: string
|
||||
gradient: string
|
||||
softGradient: string
|
||||
backgroundImageFileId?: string
|
||||
cssVars: Record<string, string>
|
||||
}
|
||||
|
||||
const HEX_COLOR_PATTERN = /^#[0-9a-fA-F]{6}$/
|
||||
|
||||
export const DEFAULT_SHOP_THEME: ResolvedShopTheme = resolveShopThemeSource()
|
||||
|
||||
export function resolveShopTheme(source?: ShopThemeSource | null): ResolvedShopTheme {
|
||||
return resolveShopThemeSource(source)
|
||||
}
|
||||
|
||||
export function applyShopTheme(theme: ResolvedShopTheme, backgroundImageUrl?: string | null) {
|
||||
if (typeof document === 'undefined') {
|
||||
return
|
||||
}
|
||||
const root = document.documentElement
|
||||
Object.entries(theme.cssVars).forEach(([key, value]) => {
|
||||
root.style.setProperty(key, value)
|
||||
})
|
||||
root.style.setProperty('--theme-background-image', backgroundImageUrl ? `url("${backgroundImageUrl}")` : 'none')
|
||||
}
|
||||
|
||||
export function notifyShopThemeChanged() {
|
||||
if (typeof window === 'undefined') {
|
||||
return
|
||||
}
|
||||
window.dispatchEvent(new Event(SHOP_THEME_CHANGED_EVENT))
|
||||
}
|
||||
|
||||
function resolveShopThemeSource(source?: ShopThemeSource | null): ResolvedShopTheme {
|
||||
const normalizedPrimaryColor = normalizeHexColor(source?.themePrimaryColor)
|
||||
const primaryColor = normalizedPrimaryColor || '#C6597D'
|
||||
const secondaryColor = normalizeHexColor(source?.themeSecondaryColor)
|
||||
|| (normalizedPrimaryColor ? mixColor(primaryColor, '#FFFFFF', 0.68) : '#E9B7C7')
|
||||
const accentColor = normalizeHexColor(source?.themeAccentColor)
|
||||
|| (normalizedPrimaryColor ? mixColor(primaryColor, '#7A3F56', 0.38) : '#9F4967')
|
||||
const pageBgColor = normalizeHexColor(source?.themePageBgColor) || '#FFF7F9'
|
||||
const cardBgColor = normalizeHexColor(source?.themeCardBgColor) || '#FFFFFF'
|
||||
const textPrimary = readableTextColor(pageBgColor, '#2D2430')
|
||||
const textSecondary = textPrimary === '#2D2430'
|
||||
? mixColor('#7A6871', primaryColor, 0.12)
|
||||
: mixColor('#FFFFFF', primaryColor, 0.3)
|
||||
const borderColor = mixColor(primaryColor, cardBgColor, 0.82)
|
||||
const primarySoftColor = mixColor(primaryColor, cardBgColor, 0.88)
|
||||
const gradient = `linear-gradient(135deg, ${primaryColor} 0%, ${secondaryColor} 100%)`
|
||||
const softGradient = `linear-gradient(145deg, ${cardBgColor} 0%, ${mixColor(secondaryColor, pageBgColor, 0.55)} 58%, ${mixColor(primaryColor, pageBgColor, 0.82)} 100%)`
|
||||
const backgroundImageFileId = source?.themeBackgroundImageFileId === undefined || source?.themeBackgroundImageFileId === null
|
||||
? undefined
|
||||
: String(source.themeBackgroundImageFileId).trim() || undefined
|
||||
|
||||
return {
|
||||
primaryColor,
|
||||
secondaryColor,
|
||||
accentColor,
|
||||
pageBgColor,
|
||||
cardBgColor,
|
||||
textPrimary,
|
||||
textSecondary,
|
||||
borderColor,
|
||||
primarySoftColor,
|
||||
gradient,
|
||||
softGradient,
|
||||
backgroundImageFileId,
|
||||
cssVars: {
|
||||
'--primary-color': primaryColor,
|
||||
'--theme-primary': primaryColor,
|
||||
'--theme-secondary': secondaryColor,
|
||||
'--theme-accent': accentColor,
|
||||
'--theme-primary-soft': primarySoftColor,
|
||||
'--theme-page-bg': pageBgColor,
|
||||
'--theme-card-bg': cardBgColor,
|
||||
'--theme-border': borderColor,
|
||||
'--theme-gradient': gradient,
|
||||
'--theme-gradient-soft': softGradient,
|
||||
'--theme-button-shadow': `0 12px 28px ${rgba(primaryColor, 0.22)}`,
|
||||
'--theme-focus-shadow': `0 0 0 3px ${rgba(primaryColor, 0.16)}`,
|
||||
'--bg-color': pageBgColor,
|
||||
'--secondary-bg-color': mixColor(secondaryColor, pageBgColor, 0.58),
|
||||
'--surface-color': cardBgColor,
|
||||
'--text-primary': textPrimary,
|
||||
'--text-secondary': textSecondary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeHexColor(value?: string | null): string | undefined {
|
||||
if (!value) {
|
||||
return undefined
|
||||
}
|
||||
const normalized = value.trim()
|
||||
return HEX_COLOR_PATTERN.test(normalized) ? normalized.toUpperCase() : undefined
|
||||
}
|
||||
|
||||
function mixColor(foreground: string, background: string, backgroundWeight: number): string {
|
||||
const fg = hexToRgb(foreground)
|
||||
const bg = hexToRgb(background)
|
||||
const weight = clamp(backgroundWeight, 0, 1)
|
||||
return rgbToHex({
|
||||
r: Math.round(fg.r * (1 - weight) + bg.r * weight),
|
||||
g: Math.round(fg.g * (1 - weight) + bg.g * weight),
|
||||
b: Math.round(fg.b * (1 - weight) + bg.b * weight)
|
||||
})
|
||||
}
|
||||
|
||||
function readableTextColor(background: string, preferred: string): string {
|
||||
return relativeLuminance(hexToRgb(background)) > 0.48 ? preferred : '#FFFFFF'
|
||||
}
|
||||
|
||||
function rgba(color: string, alpha: number): string {
|
||||
const rgb = hexToRgb(color)
|
||||
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${clamp(alpha, 0, 1)})`
|
||||
}
|
||||
|
||||
function relativeLuminance(rgb: { r: number; g: number; b: number }): number {
|
||||
const toLinearChannel = (value: number) => {
|
||||
const channel = value / 255
|
||||
return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4)
|
||||
}
|
||||
const r = toLinearChannel(rgb.r)
|
||||
const g = toLinearChannel(rgb.g)
|
||||
const b = toLinearChannel(rgb.b)
|
||||
return 0.2126 * r + 0.7152 * g + 0.0722 * b
|
||||
}
|
||||
|
||||
function hexToRgb(color: string): { r: number; g: number; b: number } {
|
||||
const value = color.replace('#', '')
|
||||
return {
|
||||
r: Number.parseInt(value.slice(0, 2), 16),
|
||||
g: Number.parseInt(value.slice(2, 4), 16),
|
||||
b: Number.parseInt(value.slice(4, 6), 16)
|
||||
}
|
||||
}
|
||||
|
||||
function rgbToHex(rgb: { r: number; g: number; b: number }): string {
|
||||
return `#${toHex(rgb.r)}${toHex(rgb.g)}${toHex(rgb.b)}`
|
||||
}
|
||||
|
||||
function toHex(value: number): string {
|
||||
return clamp(value, 0, 255).toString(16).padStart(2, '0').toUpperCase()
|
||||
}
|
||||
|
||||
function clamp(value: number, min: number, max: number): number {
|
||||
return Math.min(max, Math.max(min, value))
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
<LeftOutlined :style="{ fontSize: '20px' }" />
|
||||
</a-button>
|
||||
<h1>美甲师订单</h1>
|
||||
<a-button type="link" @click="router.push('/artist-calendar')">日历</a-button>
|
||||
<a-button v-if="showCalendarEntry" type="link" @click="router.push('/artist-calendar')">日历</a-button>
|
||||
<div v-else class="placeholder" />
|
||||
</header>
|
||||
|
||||
<main class="content">
|
||||
@@ -46,7 +47,7 @@
|
||||
<a-card
|
||||
v-for="order in filteredOrders"
|
||||
:key="order.id"
|
||||
:ref="el => setOrderRef(order.id, el)"
|
||||
:ref="(el: any) => setOrderRef(order.id, el)"
|
||||
class="order-card"
|
||||
:class="{ 'is-target': isTargetOrder(order.id) }"
|
||||
>
|
||||
@@ -97,6 +98,7 @@ import { computed, nextTick, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { LeftOutlined } from '@ant-design/icons-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { userApi } from '@/api/user'
|
||||
import { fileApi } from '../api/index'
|
||||
import { orderApi } from '../api/order'
|
||||
import type { IdType } from '@/utils/id'
|
||||
@@ -107,6 +109,7 @@ const route = useRoute()
|
||||
const orders = ref<any[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const orderRefs = ref<Record<string, any>>({})
|
||||
const showCalendarEntry = ref(false)
|
||||
const filters = reactive({
|
||||
keyword: '',
|
||||
source: 'all',
|
||||
@@ -217,6 +220,24 @@ const loadOrders = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** loadCalendarAccess is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadCalendarAccess = async () => {
|
||||
showCalendarEntry.value = false
|
||||
try {
|
||||
const currentUser = await userApi.getUserInfo()
|
||||
if (currentUser.type === 3) {
|
||||
showCalendarEntry.value = true
|
||||
return
|
||||
}
|
||||
if (currentUser.type === 2) {
|
||||
const artistInfo = await userApi.getNailArtistInfo(currentUser.id).catch(() => null)
|
||||
showCalendarEntry.value = Number(artistInfo?.participateProduction) === 1
|
||||
}
|
||||
} catch {
|
||||
showCalendarEntry.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** handleRefreshClick is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleRefreshClick = async () => {
|
||||
await runWithGlobalLoading(() => loadOrders())
|
||||
@@ -241,40 +262,45 @@ const completeOrder = (orderId: IdType) => {
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(loadOrders)
|
||||
onMounted(async () => {
|
||||
await Promise.all([loadCalendarAccess(), loadOrders()])
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page { min-height: 100vh; padding-top: 60px; background: #f5f5f5; }
|
||||
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 10px 15px; background: #fff; border-bottom: 1px solid #f0f0f0; }
|
||||
.header h1 { margin: 0; font-size: 18px; }
|
||||
.page { 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; 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: 10px 15px; background: rgba(255, 255, 255, 0.92); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
|
||||
.header h1 { margin: 0; font-size: 18px; color: var(--text-primary); }
|
||||
.placeholder { width: 40px; height: 40px; }
|
||||
.content { padding: 15px; }
|
||||
.filter-panel { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; border-radius: 8px; background: #fff; }
|
||||
.filter-panel { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; 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); }
|
||||
.filter-row { display: flex; gap: 8px; align-items: center; }
|
||||
.filter-select, .filter-date, .filter-number { flex: 1; min-width: 0; }
|
||||
.filter-actions { display: flex; align-items: center; justify-content: space-between; color: #888; font-size: 12px; }
|
||||
.order-card { margin-bottom: 12px; border-radius: 12px; }
|
||||
.order-card.is-target { border-color: #d9955d; box-shadow: 0 0 0 2px rgba(217, 149, 93, .22); }
|
||||
.filter-actions { display: flex; align-items: center; justify-content: space-between; color: var(--text-secondary); font-size: 12px; }
|
||||
.order-card { margin-bottom: 12px; border-radius: 14px; border: 1px solid var(--theme-border); background: var(--theme-card-bg); box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08); }
|
||||
.order-card.is-target { border-color: var(--theme-primary); box-shadow: 0 0 0 2px rgba(198, 89, 125, .16); }
|
||||
.order-head, .footer { display: flex; align-items: center; justify-content: space-between; }
|
||||
.order-head { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0; }
|
||||
.order-head { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--theme-border); }
|
||||
.order-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||
.source-tag { padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
|
||||
.source-service { background: #e6f4ff; color: #1677ff; }
|
||||
.source-self { background: #f9f0ff; color: #722ed1; }
|
||||
.source-both { background: #fff7e6; color: #d46b08; }
|
||||
.customer-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; color: #666; font-size: 13px; }
|
||||
.source-service { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
||||
.source-self { background: var(--theme-primary-soft); color: var(--theme-accent); }
|
||||
.source-both { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
||||
.customer-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; color: var(--text-secondary); font-size: 13px; }
|
||||
.status { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
|
||||
.pending { background: #fff7e6; color: #fa8c16; }
|
||||
.completed { background: #f6ffed; color: #52c41a; }
|
||||
.cancelled { background: #fff1f0; color: #ff4d4f; }
|
||||
.pending { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
||||
.completed { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
||||
.cancelled { background: var(--theme-primary-soft); color: var(--theme-accent); }
|
||||
.item { display: flex; gap: 12px; margin-bottom: 12px; }
|
||||
.thumb { width: 60px; height: 60px; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #eef3ff; }
|
||||
.thumb { width: 60px; height: 60px; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--theme-primary-soft); color: var(--theme-primary); }
|
||||
.thumb img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.main { flex: 1; }
|
||||
.title { font-weight: 600; }
|
||||
.line { margin-top: 4px; color: #666; font-size: 13px; }
|
||||
.appointment { color: #1890ff; }
|
||||
.title { font-weight: 600; color: var(--text-primary); }
|
||||
.line { margin-top: 4px; color: var(--text-secondary); font-size: 13px; }
|
||||
.appointment { color: var(--theme-primary); }
|
||||
|
||||
:deep(.ant-btn-primary) { background: var(--theme-primary); border-color: var(--theme-primary); }
|
||||
:deep(.ant-btn-link) { color: var(--theme-primary); }
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.content {
|
||||
|
||||
@@ -427,6 +427,7 @@ import { authApi, legalAgreementApi, type LegalAgreement } from '@/api/auth'
|
||||
import { shopApi } from '@/api/shop'
|
||||
import { ACCOUNT_REGEX, ACCOUNT_RULE_MESSAGE, sanitizeAccountInput } from '@/utils/account'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { notifyShopThemeChanged } from '@/utils/shop-theme'
|
||||
import {
|
||||
userApi,
|
||||
type AvailabilityCheckResponse,
|
||||
@@ -505,13 +506,16 @@ const verificationCodeRegex = /^\d{6}$/
|
||||
const loginShopUnsupportedMessage = '可直接登录;如账号绑定多家门店,登录后可在个人中心切换当前门店。'
|
||||
/** loginShopPlaceholder is a reactive state variable used by the template and event handlers. */
|
||||
const loginShopPlaceholder = computed(() => {
|
||||
if (allowLoginShopless.value) {
|
||||
return '当前暂无启用店铺,可直接登录'
|
||||
}
|
||||
if (loadingShops.value) {
|
||||
return '正在加载可登录店铺'
|
||||
}
|
||||
return loginShops.value.length ? '请选择登录店铺' : '请先输入账号或手机号'
|
||||
if (loginShops.value.length) {
|
||||
return allowLoginShopless.value ? '可选择本次登录店铺,留空直接登录' : '请选择登录店铺'
|
||||
}
|
||||
if (allowLoginShopless.value) {
|
||||
return '当前无需选择店铺'
|
||||
}
|
||||
return '请先输入账号或手机号'
|
||||
})
|
||||
|
||||
/** validateLoginShopRequired is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
@@ -701,11 +705,6 @@ const applyLoginShopSelection = (selection?: LoginShopSelectionResponse | null)
|
||||
allowLoginShopless.value = Boolean(selection?.allowShoplessLogin)
|
||||
loginShopMessage.value = selection?.message || ''
|
||||
|
||||
if (allowLoginShopless.value) {
|
||||
formData.shopId = undefined
|
||||
return
|
||||
}
|
||||
|
||||
if (!loginShops.value.length) {
|
||||
formData.shopId = undefined
|
||||
return
|
||||
@@ -718,7 +717,7 @@ const applyLoginShopSelection = (selection?: LoginShopSelectionResponse | null)
|
||||
return
|
||||
}
|
||||
|
||||
if (loginShops.value.length === 1) {
|
||||
if (!allowLoginShopless.value && loginShops.value.length === 1) {
|
||||
const [onlyShop] = loginShops.value
|
||||
if (onlyShop) {
|
||||
formData.shopId = normalizeShopOptionValue(onlyShop.id)
|
||||
@@ -926,6 +925,7 @@ const handleSubmit = async () => {
|
||||
localStorage.setItem('refreshToken', loginData.refreshToken)
|
||||
localStorage.setItem('userInfo', JSON.stringify(loginData.userInfo))
|
||||
sessionStorage.setItem('accessToken', loginData.accessToken)
|
||||
notifyShopThemeChanged()
|
||||
|
||||
if (loginData.needSetPassword) {
|
||||
localStorage.setItem('needSetPassword', 'true')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -145,7 +145,12 @@ onMounted(() => {
|
||||
.mobile-container {
|
||||
padding-top: 60px;
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
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 {
|
||||
@@ -157,16 +162,18 @@ onMounted(() => {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 60px;
|
||||
padding: 10px 15px;
|
||||
background: white;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
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: #1a1a2e;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
@@ -175,7 +182,7 @@ onMounted(() => {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #1a1a2e;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
@@ -187,9 +194,11 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.filter-card {
|
||||
border-radius: 12px;
|
||||
border-radius: 14px;
|
||||
margin-bottom: 15px;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
|
||||
background: var(--theme-card-bg);
|
||||
border: 1px solid var(--theme-border);
|
||||
box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08);
|
||||
}
|
||||
|
||||
.filter-segmented {
|
||||
@@ -197,8 +206,10 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.content-card {
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -209,20 +220,22 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.coupon-card {
|
||||
border-radius: 12px;
|
||||
border-radius: 14px;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, #f5f7ff 0%, #e8ecff 100%);
|
||||
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 6px 20px rgba(102, 126, 234, 0.15);
|
||||
box-shadow: 0 18px 44px rgba(122, 67, 88, 0.12);
|
||||
}
|
||||
|
||||
.coupon-card.expired {
|
||||
opacity: 0.6;
|
||||
background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
|
||||
opacity: 0.66;
|
||||
background: var(--theme-card-bg);
|
||||
}
|
||||
|
||||
.coupon-content {
|
||||
@@ -235,17 +248,17 @@ onMounted(() => {
|
||||
.coupon-value {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #667eea;
|
||||
color: var(--theme-primary);
|
||||
padding: 20px;
|
||||
background: rgba(102, 126, 234, 0.1);
|
||||
background: var(--theme-primary-soft);
|
||||
border-radius: 8px;
|
||||
min-width: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.coupon-card.expired .coupon-value {
|
||||
color: #8b8b9a;
|
||||
background: rgba(139, 139, 154, 0.1);
|
||||
color: var(--text-secondary);
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.coupon-info {
|
||||
@@ -258,17 +271,17 @@ onMounted(() => {
|
||||
.coupon-name {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1a1a2e;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.coupon-condition {
|
||||
font-size: 12px;
|
||||
color: #667eea;
|
||||
color: var(--theme-primary);
|
||||
}
|
||||
|
||||
.coupon-time {
|
||||
font-size: 12px;
|
||||
color: #8b8b9a;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.coupon-status {
|
||||
@@ -280,18 +293,32 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.coupon-status.available {
|
||||
background: #f6ffed;
|
||||
color: #52c41a;
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-primary);
|
||||
}
|
||||
|
||||
.coupon-status.used {
|
||||
background: #f5f5f5;
|
||||
color: #8b8b9a;
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.coupon-status.expired {
|
||||
background: #fff1f0;
|
||||
color: #ff4d4f;
|
||||
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);
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
|
||||
@@ -28,12 +28,33 @@
|
||||
|
||||
<div v-if="announcements.length" class="announcement-bar">
|
||||
<div class="announcement-track">
|
||||
<span v-for="item in announcementLoop" :key="`${item.id}-${item.loopKey}`">
|
||||
<button
|
||||
v-for="item in announcementLoop"
|
||||
:key="`${item.id}-${item.loopKey}`"
|
||||
class="announcement-item"
|
||||
type="button"
|
||||
@click="openAnnouncementDetail(item)"
|
||||
>
|
||||
<b>{{ item.publisherName || '平台' }}</b>:{{ item.content }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a-modal
|
||||
v-model:open="announcementDetailOpen"
|
||||
title="公告详情"
|
||||
:footer="null"
|
||||
centered
|
||||
>
|
||||
<div v-if="selectedAnnouncement" class="announcement-detail">
|
||||
<div class="announcement-detail__meta">
|
||||
<span>{{ selectedAnnouncement.publisherName || '平台' }}</span>
|
||||
<span>{{ formatAnnouncementTime(selectedAnnouncement.publishTime) }}</span>
|
||||
</div>
|
||||
<p>{{ selectedAnnouncement.content }}</p>
|
||||
</div>
|
||||
</a-modal>
|
||||
|
||||
<a-alert
|
||||
v-if="!isLoggedIn"
|
||||
class="guest-alert"
|
||||
@@ -43,7 +64,7 @@
|
||||
description="先逛作品和门店,收藏、加购、下单时再登录即可。"
|
||||
/>
|
||||
|
||||
<section class="section">
|
||||
<section v-if="!isLoggedIn" class="section">
|
||||
<div class="banner-container">
|
||||
<div class="banner-carousel">
|
||||
<a-carousel v-if="bannerImages.length" autoplay :autoplay-speed="3200" effect="fade">
|
||||
@@ -181,6 +202,8 @@ const featuredItems = ref<ProductCardItem[]>([])
|
||||
const popularSource = ref<ProductCardItem[]>([])
|
||||
const popularItems = ref<ProductCardItem[]>([])
|
||||
const announcements = ref<AnnouncementVO[]>([])
|
||||
const selectedAnnouncement = ref<AnnouncementVO | null>(null)
|
||||
const announcementDetailOpen = ref(false)
|
||||
const productImageCache = ref<Record<string, string>>({})
|
||||
/** searchQuery is a reactive state variable used by the template and event handlers. */
|
||||
const searchQuery = ref('')
|
||||
@@ -201,10 +224,20 @@ const displayName = computed(() => userInfo.value?.nickname || (isLoggedIn.value
|
||||
/** announcementLoop is a reactive state variable used by the template and event handlers. */
|
||||
const announcementLoop = computed(() => [...announcements.value, ...announcements.value].map((item, index) => ({ ...item, loopKey: index })))
|
||||
|
||||
const openAnnouncementDetail = (item: AnnouncementVO) => {
|
||||
selectedAnnouncement.value = item
|
||||
announcementDetailOpen.value = true
|
||||
}
|
||||
|
||||
const formatAnnouncementTime = (value?: string) => {
|
||||
if (!value) return ''
|
||||
return value.replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
/** getRandomColor is a local helper used by this page script. */
|
||||
const getRandomColor = (): string => {
|
||||
const colors = ['#ffe4d6', '#d6eaff', '#e2ffd6', '#fff2d6', '#d6ffe4', '#e4d6ff']
|
||||
return colors[Math.floor(Math.random() * colors.length)] ?? '#ffe4d6'
|
||||
const colors = ['var(--theme-primary-soft)', 'var(--secondary-bg-color)', 'var(--theme-page-bg)']
|
||||
return colors[Math.floor(Math.random() * colors.length)] ?? 'var(--theme-primary-soft)'
|
||||
}
|
||||
|
||||
/** getProductCoverUrl is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
@@ -400,13 +433,18 @@ const openShopById = (shopId: IdType) => {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([
|
||||
const homeTasks = [
|
||||
loadUserInfo(),
|
||||
loadAnnouncements(),
|
||||
loadPublicShops(),
|
||||
loadFeaturedProducts(),
|
||||
loadPopularProducts()
|
||||
])
|
||||
]
|
||||
|
||||
if (!isLoggedIn.value) {
|
||||
homeTasks.push(loadPublicShops())
|
||||
}
|
||||
|
||||
await Promise.all(homeTasks)
|
||||
window.addEventListener('scroll', handleScroll)
|
||||
})
|
||||
|
||||
@@ -416,6 +454,15 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mobile-container {
|
||||
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 {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -455,8 +502,8 @@ onUnmounted(() => {
|
||||
margin: 12px 20px 0;
|
||||
overflow: hidden;
|
||||
border-radius: 8px;
|
||||
background: #fff7ed;
|
||||
border: 1px solid #fed7aa;
|
||||
background: var(--theme-primary-soft);
|
||||
border: 1px solid var(--theme-border);
|
||||
}
|
||||
|
||||
.announcement-track {
|
||||
@@ -464,14 +511,43 @@ onUnmounted(() => {
|
||||
width: max-content;
|
||||
gap: 32px;
|
||||
padding: 9px 14px;
|
||||
color: #7c2d12;
|
||||
color: var(--theme-primary);
|
||||
animation: announcement-scroll 22s linear infinite;
|
||||
}
|
||||
|
||||
.announcement-track span {
|
||||
.announcement-item {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.announcement-item:hover {
|
||||
color: var(--theme-accent);
|
||||
}
|
||||
|
||||
.announcement-detail {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.announcement-detail__meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
color: #8b8b9a;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.announcement-detail p {
|
||||
margin: 0;
|
||||
color: #1f1f1f;
|
||||
line-height: 1.8;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
@keyframes announcement-scroll {
|
||||
from { transform: translateX(0); }
|
||||
to { transform: translateX(-50%); }
|
||||
@@ -492,7 +568,7 @@ onUnmounted(() => {
|
||||
overflow: hidden;
|
||||
min-height: 220px;
|
||||
box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
|
||||
background: linear-gradient(135deg, #f4f7ff 0%, #eef4ff 100%);
|
||||
background: var(--theme-gradient-soft);
|
||||
}
|
||||
|
||||
.banner-slide {
|
||||
@@ -571,7 +647,7 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
.see-all {
|
||||
color: #1677ff;
|
||||
color: var(--theme-primary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
|
||||
<a-card v-for="order in filteredOrders" :key="order.id" class="order-card">
|
||||
<div class="order-head">
|
||||
<span>订单号:{{ order.orderNo }}</span>
|
||||
<span class="order-no">订单号:{{ order.orderNo }}</span>
|
||||
<a-button size="small" type="link" @click="copyOrderNo(order.orderNo)">复制</a-button>
|
||||
<span class="status" :class="statusClass(order.status)">{{ order.statusText }}</span>
|
||||
</div>
|
||||
<div v-if="order.shopName" class="order-shop">所属店铺:{{ order.shopName }}</div>
|
||||
@@ -132,6 +133,15 @@ const resetFilters = () => {
|
||||
filters.maxAmount = undefined
|
||||
}
|
||||
|
||||
const copyOrderNo = async (orderNo: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(orderNo)
|
||||
message.success('订单号已复制')
|
||||
} catch {
|
||||
message.warning('复制失败,请手动复制订单号')
|
||||
}
|
||||
}
|
||||
|
||||
/** loadOrders is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadOrders = async () => {
|
||||
try {
|
||||
@@ -180,30 +190,34 @@ onMounted(loadOrders)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page { min-height: 100vh; padding-top: 60px; background: #f5f5f5; }
|
||||
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 10px 15px; background: #fff; border-bottom: 1px solid #f0f0f0; }
|
||||
.header h1 { margin: 0; font-size: 18px; }
|
||||
.page { 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; 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 15px; background: rgba(255, 255, 255, 0.92); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
|
||||
.header h1 { margin: 0; font-size: 18px; color: var(--text-primary); }
|
||||
.placeholder { width: 40px; height: 40px; }
|
||||
.content { padding: 15px; }
|
||||
.filter-panel { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; border-radius: 8px; background: #fff; }
|
||||
.filter-panel { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; 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); }
|
||||
.filter-row { display: flex; gap: 8px; align-items: center; }
|
||||
.filter-select, .filter-date, .filter-number { flex: 1; min-width: 0; }
|
||||
.filter-summary { color: #888; font-size: 12px; text-align: right; }
|
||||
.order-card { margin-bottom: 12px; border-radius: 12px; }
|
||||
.filter-summary { color: var(--text-secondary); font-size: 12px; text-align: right; }
|
||||
.order-card { margin-bottom: 12px; border-radius: 14px; border: 1px solid var(--theme-border); background: var(--theme-card-bg); box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08); }
|
||||
.order-card :deep(.ant-card-body) { padding: 16px; }
|
||||
.order-head, .footer { display: flex; align-items: center; justify-content: space-between; }
|
||||
.order-head { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0; }
|
||||
.order-shop { margin: -4px 0 12px; color: #7a5262; font-size: 13px; }
|
||||
.order-head { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--theme-border); }
|
||||
.order-shop { margin: -4px 0 12px; color: var(--text-secondary); font-size: 13px; }
|
||||
.status { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
|
||||
.pending { background: #fff7e6; color: #fa8c16; }
|
||||
.completed { background: #f6ffed; color: #52c41a; }
|
||||
.cancelled { background: #fff1f0; color: #ff4d4f; }
|
||||
.pending { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
||||
.completed { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
||||
.cancelled { background: var(--theme-primary-soft); color: var(--theme-accent); }
|
||||
.item { display: flex; gap: 12px; margin-bottom: 12px; }
|
||||
.thumb { width: 60px; height: 60px; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #eef3ff; }
|
||||
.thumb { width: 60px; height: 60px; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--theme-primary-soft); color: var(--theme-primary); }
|
||||
.thumb img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.main { flex: 1; }
|
||||
.title { font-weight: 600; }
|
||||
.line { margin-top: 4px; color: #666; font-size: 13px; }
|
||||
.appointment { color: #1890ff; }
|
||||
.title { font-weight: 600; color: var(--text-primary); }
|
||||
.line { margin-top: 4px; color: var(--text-secondary); font-size: 13px; }
|
||||
.appointment { color: var(--theme-primary); }
|
||||
|
||||
:deep(.ant-btn-primary) { background: var(--theme-primary); border-color: var(--theme-primary); }
|
||||
:deep(.ant-btn-link) { color: var(--theme-primary); }
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.content {
|
||||
|
||||
@@ -17,7 +17,12 @@
|
||||
|
||||
<template v-else>
|
||||
<section class="media-section">
|
||||
<img :src="productImages[0] || DEFAULT_PRODUCT_IMAGE" :alt="productTitle" />
|
||||
<a-image
|
||||
class="detail-image-preview"
|
||||
:src="productImages[0] || DEFAULT_PRODUCT_IMAGE"
|
||||
:alt="productTitle"
|
||||
:preview="{ src: productImages[0] || DEFAULT_PRODUCT_IMAGE }"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="info-section">
|
||||
@@ -62,6 +67,7 @@
|
||||
<component :is="isFavorite ? StarFilled : StarOutlined" />
|
||||
{{ product.collectCount || 0 }} 收藏
|
||||
</button>
|
||||
<button type="button" @click="copyShareLink">分享链接</button>
|
||||
</div>
|
||||
|
||||
<div class="tags">
|
||||
@@ -123,7 +129,6 @@
|
||||
import { computed, inject, onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
CalendarOutlined,
|
||||
HeartFilled,
|
||||
HeartOutlined,
|
||||
LeftOutlined,
|
||||
@@ -182,6 +187,16 @@ const artistCountText = computed(() => artistCount.value > 0 ? `${artistCount.va
|
||||
/** earliestBookableText is a reactive state variable used by the template and event handlers. */
|
||||
const earliestBookableText = computed(() => shopInfo.value?.businessHours || '以门店安排为准')
|
||||
|
||||
const copyShareLink = async () => {
|
||||
const url = `${window.location.origin}/product/${route.params.id}`
|
||||
try {
|
||||
await navigator.clipboard.writeText(url)
|
||||
message.success('分享链接已复制,未登录用户也可以查看详情')
|
||||
} catch {
|
||||
message.warning(url)
|
||||
}
|
||||
}
|
||||
|
||||
/** requireLogin is a local helper used by this page script. */
|
||||
const requireLogin = (actionText: string) => {
|
||||
if (isLoggedIn.value) return true
|
||||
@@ -335,45 +350,48 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.detail-page { min-height: 100vh; background: #f6f7f9; }
|
||||
.detail-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: rgba(255,255,255,.96); border-bottom: 1px solid #eceff3; backdrop-filter: blur(10px); }
|
||||
.detail-header h1 { flex: 1; margin: 0; font-size: 17px; text-align: center; color: #20232a; }
|
||||
.detail-header .active { color: #e65d7a; }
|
||||
.detail-page { 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; }
|
||||
.detail-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(10px); }
|
||||
.detail-header h1 { flex: 1; margin: 0; font-size: 17px; text-align: center; color: var(--text-primary); }
|
||||
.detail-header .active { color: var(--theme-accent); }
|
||||
.detail-content { max-width: 1040px; margin: 0 auto; padding: 18px 16px 118px; }
|
||||
.media-section { overflow: hidden; border-radius: 8px; background: #fff; }
|
||||
.media-section img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
|
||||
.info-section, .comment-section { margin-top: 14px; padding: 22px; border-radius: 8px; background: #fff; border: 1px solid #edf0f4; }
|
||||
.media-section { overflow: hidden; border-radius: 8px; background: var(--theme-card-bg); }
|
||||
.media-section :deep(.ant-image),
|
||||
.media-section :deep(.ant-image-img),
|
||||
.media-section img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; cursor: zoom-in; }
|
||||
.info-section, .comment-section { margin-top: 14px; padding: 22px; border-radius: 8px; background: var(--theme-card-bg); border: 1px solid var(--theme-border); }
|
||||
.title-row { display: flex; justify-content: space-between; gap: 16px; }
|
||||
.title-row h2 { margin: 0 0 8px; font-size: 24px; color: #20232a; }
|
||||
.price { margin: 0; font-size: 26px; font-weight: 700; color: #d94f69; }
|
||||
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
|
||||
.metrics > div, .metrics > button { display: grid; gap: 4px; padding: 14px; border: 1px solid #edf0f4; border-radius: 8px; background: #fbfcfe; text-align: left; }
|
||||
.metrics svg { color: #3b82f6; }
|
||||
.metrics span { font-size: 12px; color: #7b8494; }
|
||||
.metrics strong { color: #20232a; }
|
||||
.shop-panel { display: grid; gap: 6px; margin-top: 18px; padding: 16px; border-radius: 8px; background: #f7f9fc; cursor: pointer; color: #5f6876; }
|
||||
.shop-panel strong { color: #20232a; }
|
||||
.title-row h2 { margin: 0 0 8px; font-size: 24px; color: var(--text-primary); }
|
||||
.price { margin: 0; font-size: 26px; font-weight: 700; color: var(--theme-accent); }
|
||||
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
|
||||
.metrics > div:nth-of-type(2) { display: none; }
|
||||
.metrics > div, .metrics > button { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--theme-border); border-radius: 8px; background: var(--theme-primary-soft); text-align: left; }
|
||||
.metrics svg { color: var(--theme-primary); }
|
||||
.metrics span { font-size: 12px; color: var(--text-secondary); }
|
||||
.metrics strong { color: var(--text-primary); }
|
||||
.shop-panel { display: none; }
|
||||
.shop-panel strong { color: var(--text-primary); }
|
||||
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
|
||||
.actions-row button { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid #edf0f4; border-radius: 999px; background: #fff; color: #5f6876; }
|
||||
.actions-row button.active { color: #d94f69; border-color: #ffd7e0; background: #fff5f7; }
|
||||
.actions-row button { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--theme-border); border-radius: 999px; background: var(--theme-card-bg); color: var(--text-secondary); }
|
||||
.actions-row button.active { color: var(--theme-accent); border-color: var(--theme-border); background: var(--theme-primary-soft); }
|
||||
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
|
||||
.description { margin-top: 22px; }
|
||||
.description h3, .section-head h3 { margin: 0; font-size: 18px; color: #20232a; }
|
||||
.description p { margin: 10px 0 0; color: #5f6876; line-height: 1.8; }
|
||||
.description h3, .section-head h3 { margin: 0; font-size: 18px; color: var(--text-primary); }
|
||||
.description p { margin: 10px 0 0; color: var(--text-secondary); line-height: 1.8; }
|
||||
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
|
||||
.section-head span { color: #7b8494; }
|
||||
.comment-editor { padding: 14px; border: 1px solid #edf0f4; border-radius: 8px; background: #fbfcfe; }
|
||||
.section-head span { color: var(--text-secondary); }
|
||||
.comment-editor { padding: 14px; border: 1px solid var(--theme-border); border-radius: 8px; background: var(--theme-primary-soft); }
|
||||
.comment-tools { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
|
||||
.comment-item { padding: 16px 0; border-bottom: 1px solid #edf0f4; }
|
||||
.comment-item { padding: 16px 0; border-bottom: 1px solid var(--theme-border); }
|
||||
.comment-item:last-child { border-bottom: 0; }
|
||||
.comment-main { display: flex; justify-content: space-between; gap: 12px; color: #7b8494; }
|
||||
.comment-main strong { color: #20232a; }
|
||||
.comment-item p { margin: 8px 0; color: #3b4350; line-height: 1.7; }
|
||||
.comment-item button { padding: 0; border: 0; background: transparent; color: #3b82f6; cursor: pointer; }
|
||||
.reply-list { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: #f7f9fc; }
|
||||
.reply-item { display: flex; gap: 8px; padding: 6px 0; color: #5f6876; }
|
||||
.reply-item strong { color: #20232a; }
|
||||
.detail-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid #eceff3; backdrop-filter: blur(10px); }
|
||||
.comment-main { display: flex; justify-content: space-between; gap: 12px; color: var(--text-secondary); }
|
||||
.comment-main strong { color: var(--text-primary); }
|
||||
.comment-item p { margin: 8px 0; color: var(--text-primary); line-height: 1.7; }
|
||||
.comment-item button { padding: 0; border: 0; background: transparent; color: var(--theme-primary); cursor: pointer; }
|
||||
.reply-list { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--theme-primary-soft); }
|
||||
.reply-item { display: flex; gap: 8px; padding: 6px 0; color: var(--text-secondary); }
|
||||
.reply-item strong { color: var(--text-primary); }
|
||||
.detail-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--theme-border); backdrop-filter: blur(10px); }
|
||||
.detail-footer :deep(.ant-btn) { flex: 1; height: 46px; border-radius: 999px; font-weight: 700; }
|
||||
@media (max-width: 720px) { .metrics { grid-template-columns: 1fr; } .title-row { flex-direction: column; } }
|
||||
</style>
|
||||
|
||||
@@ -385,9 +385,15 @@ onMounted(async () => {
|
||||
|
||||
<style scoped>
|
||||
.mobile-container {
|
||||
padding-top: 60px;
|
||||
padding-top: 58px;
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
color: var(--text-primary);
|
||||
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 {
|
||||
@@ -399,16 +405,22 @@ onMounted(async () => {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 15px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
background: white;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
gap: 12px;
|
||||
height: 58px;
|
||||
padding: 9px 15px;
|
||||
border-bottom: 1px solid var(--theme-border);
|
||||
background: rgba(255, 255, 255, 0.94);
|
||||
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
|
||||
box-shadow: 0 10px 28px rgba(122, 67, 88, 0.08);
|
||||
backdrop-filter: blur(16px);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.back-btn,
|
||||
@@ -418,40 +430,100 @@ onMounted(async () => {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 999px;
|
||||
color: var(--theme-primary);
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.back-btn:hover,
|
||||
.search-btn:hover,
|
||||
.back-btn:focus,
|
||||
.search-btn:focus {
|
||||
color: var(--theme-accent);
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.search-input-container {
|
||||
flex: 1;
|
||||
margin: 0 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.search-input :deep(.ant-input),
|
||||
.search-input :deep(.ant-input-group-addon .ant-btn) {
|
||||
height: 38px;
|
||||
}
|
||||
|
||||
.search-input :deep(.ant-input) {
|
||||
border-color: var(--theme-border);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.search-input :deep(.ant-input:hover),
|
||||
.search-input :deep(.ant-input:focus) {
|
||||
border-color: var(--theme-primary);
|
||||
box-shadow: var(--theme-focus-shadow);
|
||||
}
|
||||
|
||||
.search-input :deep(.ant-input-group-addon .ant-btn) {
|
||||
border-color: var(--theme-primary);
|
||||
background: var(--theme-gradient);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
display: flex;
|
||||
min-height: calc(100vh - 60px);
|
||||
flex-direction: column;
|
||||
min-height: calc(100vh - 58px);
|
||||
}
|
||||
|
||||
.category-sidebar {
|
||||
width: 92px;
|
||||
background: #fafafa;
|
||||
border-right: 1px solid #ececec;
|
||||
overflow-y: auto;
|
||||
position: sticky;
|
||||
top: 58px;
|
||||
z-index: 20;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
padding: 10px 14px 11px;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
background: rgba(255, 255, 255, 0.88);
|
||||
background: color-mix(in srgb, var(--theme-card-bg) 86%, transparent);
|
||||
border-bottom: 1px solid var(--theme-border);
|
||||
box-shadow: 0 8px 22px rgba(122, 67, 88, 0.06);
|
||||
backdrop-filter: blur(16px);
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.category-sidebar::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
padding: 16px 12px;
|
||||
flex: 0 0 auto;
|
||||
padding: 8px 15px;
|
||||
border-radius: 999px;
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
font-weight: 600;
|
||||
color: var(--theme-accent);
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
border-left: 3px solid transparent;
|
||||
background: var(--theme-primary-soft);
|
||||
border: 1px solid var(--theme-border);
|
||||
}
|
||||
|
||||
.category-item:hover {
|
||||
color: var(--theme-primary);
|
||||
border-color: var(--theme-primary);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.category-item.active {
|
||||
color: #1677ff;
|
||||
background: white;
|
||||
border-left-color: #1677ff;
|
||||
color: #ffffff;
|
||||
background: var(--theme-gradient);
|
||||
border-color: transparent;
|
||||
font-weight: 700;
|
||||
box-shadow: var(--theme-button-shadow);
|
||||
}
|
||||
|
||||
.product-section {
|
||||
@@ -480,7 +552,7 @@ onMounted(async () => {
|
||||
aspect-ratio: 1;
|
||||
overflow: hidden;
|
||||
border-radius: 14px;
|
||||
background: #eef3ff;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.product-image {
|
||||
@@ -510,10 +582,15 @@ onMounted(async () => {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.shop-name {
|
||||
margin: 0 0 6px;
|
||||
font-size: 12px;
|
||||
color: #7a5262;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@@ -532,7 +609,7 @@ onMounted(async () => {
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: #f4f6fb;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.stats {
|
||||
@@ -556,7 +633,7 @@ onMounted(async () => {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #ff4d4f;
|
||||
color: var(--theme-accent);
|
||||
}
|
||||
|
||||
.cart-action {
|
||||
@@ -577,9 +654,9 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.cart-btn-in-cart {
|
||||
color: #52c41a;
|
||||
border-color: #b7eb8f;
|
||||
background: #f6ffed;
|
||||
color: var(--theme-primary);
|
||||
border-color: var(--theme-border);
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.empty-state,
|
||||
@@ -595,8 +672,8 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.category-sidebar {
|
||||
width: 128px;
|
||||
border-radius: 20px 0 0 20px;
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.product-section {
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</template>
|
||||
<a-list-item-meta>
|
||||
<template #avatar>
|
||||
<div class="menu-icon" :style="{ backgroundColor: item.bgColor }">
|
||||
<div class="menu-icon" :style="{ backgroundColor: item.bgColor, color: item.iconColor }">
|
||||
<component :is="item.icon" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -219,6 +219,7 @@ import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecor
|
||||
import { wishlistApi } from '@/api/wishlist'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { notifyShopThemeChanged } from '@/utils/shop-theme'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -249,6 +250,8 @@ const orderCount = ref(0)
|
||||
const couponCount = ref(0)
|
||||
/** wishlistCount is a reactive state variable used by the template and event handlers. */
|
||||
const wishlistCount = ref(0)
|
||||
/** artistCalendarAccessible controls whether the appointment calendar entry is shown. */
|
||||
const artistCalendarAccessible = ref(false)
|
||||
/** shopSwitchVisible is a reactive state variable used by the template and event handlers. */
|
||||
const shopSwitchVisible = ref(false)
|
||||
/** shopSwitchLoading is a reactive state variable used by the template and event handlers. */
|
||||
@@ -338,14 +341,16 @@ const coreMenuItems = [
|
||||
title: '我的订单',
|
||||
desc: '查看预约状态、取消订单',
|
||||
icon: ShoppingOutlined,
|
||||
bgColor: '#e6f7ff'
|
||||
bgColor: 'var(--theme-primary-soft)',
|
||||
iconColor: 'var(--theme-primary)'
|
||||
},
|
||||
{
|
||||
key: 'artist-calendar',
|
||||
title: '预约日历',
|
||||
desc: '查看未来 7 天属于自己的预约',
|
||||
icon: CalendarOutlined,
|
||||
bgColor: '#fff7ed',
|
||||
bgColor: 'var(--theme-primary-soft)',
|
||||
iconColor: 'var(--theme-accent)',
|
||||
serviceOnly: true
|
||||
},
|
||||
{
|
||||
@@ -353,42 +358,51 @@ const coreMenuItems = [
|
||||
title: '我的收藏',
|
||||
desc: '快速回到喜欢的作品',
|
||||
icon: HeartOutlined,
|
||||
bgColor: '#fff1f0'
|
||||
bgColor: 'var(--theme-primary-soft)',
|
||||
iconColor: 'var(--theme-primary)'
|
||||
},
|
||||
{
|
||||
key: 'coupons',
|
||||
title: '我的优惠券',
|
||||
desc: '查看可用优惠和 VIP 折扣',
|
||||
icon: CreditCardOutlined,
|
||||
bgColor: '#fff7e6'
|
||||
bgColor: 'var(--theme-primary-soft)',
|
||||
iconColor: 'var(--theme-accent)'
|
||||
},
|
||||
{
|
||||
key: 'vip',
|
||||
title: 'VIP 中心',
|
||||
desc: '查看会员等级、余额和变动记录',
|
||||
icon: CreditCardOutlined,
|
||||
bgColor: '#f6f1e8'
|
||||
bgColor: 'var(--theme-primary-soft)',
|
||||
iconColor: 'var(--theme-accent)'
|
||||
},
|
||||
{
|
||||
key: 'notifications',
|
||||
title: '消息通知',
|
||||
desc: '查看店铺通知和系统消息',
|
||||
icon: BellOutlined,
|
||||
bgColor: '#eaf6ff'
|
||||
bgColor: 'var(--theme-primary-soft)',
|
||||
iconColor: 'var(--theme-primary)'
|
||||
},
|
||||
{
|
||||
key: 'settings',
|
||||
title: '设置中心',
|
||||
desc: '统一管理账号安全和更多入口',
|
||||
icon: SettingOutlined,
|
||||
bgColor: '#f9f0ff'
|
||||
bgColor: 'var(--theme-primary-soft)',
|
||||
iconColor: 'var(--theme-accent)'
|
||||
}
|
||||
]
|
||||
|
||||
/** profileMenuItems is a reactive state variable used by the template and event handlers. */
|
||||
const profileMenuItems = computed(() => {
|
||||
const canViewArtistCalendar = computed(() => {
|
||||
const userType = userInfo.value.type
|
||||
return coreMenuItems.filter((item: any) => !item.serviceOnly || userType === 2 || userType === 3)
|
||||
return userType === 3 || (userType === 2 && artistCalendarAccessible.value)
|
||||
})
|
||||
|
||||
const profileMenuItems = computed(() => {
|
||||
return coreMenuItems.filter((item: any) => !item.serviceOnly || canViewArtistCalendar.value)
|
||||
})
|
||||
|
||||
/** isServiceUser is a reactive state variable used by the template and event handlers. */
|
||||
@@ -403,6 +417,7 @@ const persistUserSession = (payload: any) => {
|
||||
localStorage.setItem('refreshToken', payload.refreshToken)
|
||||
localStorage.setItem('userInfo', JSON.stringify(payload.userInfo))
|
||||
sessionStorage.setItem('accessToken', payload.accessToken)
|
||||
notifyShopThemeChanged()
|
||||
if (payload.needSetPassword) {
|
||||
localStorage.setItem('needSetPassword', 'true')
|
||||
} else {
|
||||
@@ -413,10 +428,16 @@ const persistUserSession = (payload: any) => {
|
||||
/** fetchUserInfo is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const fetchUserInfo = async () => {
|
||||
try {
|
||||
artistCalendarAccessible.value = false
|
||||
const response = await userApi.getUserInfo()
|
||||
userInfo.value = response
|
||||
needSetPassword.value = localStorage.getItem('needSetPassword') === 'true'
|
||||
selectedShopId.value = response.shopId ? String(response.shopId) : undefined
|
||||
artistCalendarAccessible.value = response.type === 3
|
||||
if (response.type === 2) {
|
||||
const artistInfo = await userApi.getNailArtistInfo(response.id).catch(() => null)
|
||||
artistCalendarAccessible.value = Number(artistInfo?.participateProduction) === 1
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
message.error('获取用户信息失败')
|
||||
@@ -629,6 +650,9 @@ const handleMenuClick = (key: string) => {
|
||||
if (key === 'orders') {
|
||||
openOrders()
|
||||
} else if (key === 'artist-calendar') {
|
||||
if (!canViewArtistCalendar.value) {
|
||||
return
|
||||
}
|
||||
router.push('/artist-calendar')
|
||||
} else if (key === 'wishlist') {
|
||||
router.push('/wishlist')
|
||||
@@ -662,6 +686,7 @@ const handleLogout = () => {
|
||||
localStorage.removeItem('userInfo')
|
||||
localStorage.removeItem('needSetPassword')
|
||||
sessionStorage.removeItem('accessToken')
|
||||
notifyShopThemeChanged()
|
||||
message.success('已退出登录')
|
||||
router.push('/')
|
||||
}
|
||||
@@ -690,7 +715,12 @@ onMounted(async () => {
|
||||
.mobile-container {
|
||||
padding-top: 60px;
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
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;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -700,7 +730,7 @@ onMounted(async () => {
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 200px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 45%, #f093fb 100%);
|
||||
background: var(--theme-gradient);
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
@@ -782,7 +812,7 @@ onMounted(async () => {
|
||||
margin-top: 24px;
|
||||
padding: 18px;
|
||||
border-radius: 18px;
|
||||
background: linear-gradient(135deg, #f5f7ff 0%, #e8ecff 100%);
|
||||
background: var(--theme-gradient-soft);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -793,7 +823,7 @@ onMounted(async () => {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
background: var(--theme-gradient);
|
||||
}
|
||||
|
||||
.shop-icon {
|
||||
@@ -825,7 +855,8 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.shop-arrow {
|
||||
color: #c4c4d0;
|
||||
color: #76768a;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.password-tip {
|
||||
@@ -864,15 +895,15 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.stat-icon.orders {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
background: var(--theme-gradient);
|
||||
}
|
||||
|
||||
.stat-icon.wishlist {
|
||||
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
||||
background: linear-gradient(135deg, var(--theme-accent) 0%, var(--theme-primary) 100%);
|
||||
}
|
||||
|
||||
.stat-icon.coupons {
|
||||
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
|
||||
background: linear-gradient(135deg, var(--theme-secondary) 0%, var(--theme-primary) 100%);
|
||||
}
|
||||
|
||||
.menu-card :deep(.ant-card-body) {
|
||||
@@ -897,7 +928,12 @@ onMounted(async () => {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 20px;
|
||||
color: white;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.menu-item :deep(.ant-list-item-action .anticon) {
|
||||
color: #76768a;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.logout-section :deep(.ant-btn-dangerous) {
|
||||
@@ -916,7 +952,7 @@ onMounted(async () => {
|
||||
|
||||
.upload-hint {
|
||||
font-size: 12px;
|
||||
color: #667eea;
|
||||
color: var(--theme-primary);
|
||||
}
|
||||
|
||||
.avatar-upload-progress {
|
||||
@@ -926,7 +962,7 @@ onMounted(async () => {
|
||||
|
||||
.avatar-upload-status {
|
||||
font-size: 12px;
|
||||
color: #fa8c16;
|
||||
color: var(--theme-accent);
|
||||
}
|
||||
|
||||
.shop-option-group {
|
||||
|
||||
@@ -71,7 +71,7 @@ const settingsSections = ref([
|
||||
title: '账号设置',
|
||||
desc: '管理手机号、登录密码和账号安全',
|
||||
icon: LockOutlined,
|
||||
bgColor: '#e6f7ff'
|
||||
bgColor: 'var(--theme-primary-soft)'
|
||||
}
|
||||
])
|
||||
|
||||
@@ -90,18 +90,38 @@ const handleSettingClick = (key: string) => {
|
||||
</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;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
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,
|
||||
@@ -120,6 +140,9 @@ const handleSettingClick = (key: string) => {
|
||||
.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) {
|
||||
@@ -129,19 +152,19 @@ const handleSettingClick = (key: string) => {
|
||||
.section-title {
|
||||
padding: 12px 16px;
|
||||
font-size: 13px;
|
||||
color: #999;
|
||||
background: #fafafa;
|
||||
color: var(--theme-accent);
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
padding: 16px;
|
||||
cursor: pointer;
|
||||
transition: background 0.3s;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
border-bottom: 1px solid var(--theme-border);
|
||||
}
|
||||
|
||||
.setting-item:hover {
|
||||
background: #fafafa;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.setting-item:last-child {
|
||||
@@ -161,17 +184,18 @@ const handleSettingClick = (key: string) => {
|
||||
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: #333;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.setting-item :deep(.ant-list-item-meta-description) {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.version-info {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="shop-detail">
|
||||
<div class="header-bg"></div>
|
||||
|
||||
<header class="header">
|
||||
<a-button class="back-btn" type="text" @click="handleBackClick">
|
||||
<LeftOutlined :style="{ fontSize: '20px' }" />
|
||||
@@ -8,89 +9,99 @@
|
||||
<h1>店铺详情</h1>
|
||||
<div class="header-placeholder"></div>
|
||||
</header>
|
||||
<div class="shop-content">
|
||||
|
||||
<main class="shop-content">
|
||||
<a-card :bordered="false" class="shop-card">
|
||||
<div class="shop-info">
|
||||
<div class="shop-header">
|
||||
<div class="shop-icon-wrapper">
|
||||
<ShopOutlined class="shop-icon" />
|
||||
</div>
|
||||
<div class="shop-header-content">
|
||||
<h2 class="shop-name" @click="copyToClipboard(shopInfo.shopName, '店名')" style="cursor: pointer;">
|
||||
{{ shopInfo.shopName }}
|
||||
<span class="copy-icon">📋</span>
|
||||
</h2>
|
||||
<p class="shop-address" @click="copyToClipboard(shopInfo.address, '地址')" style="cursor: pointer;">
|
||||
{{ shopInfo.address }}
|
||||
<span class="copy-icon">📋</span>
|
||||
</p>
|
||||
<p v-if="distanceText" class="shop-distance">{{ distanceText }}</p>
|
||||
</div>
|
||||
<section class="shop-header">
|
||||
<div class="shop-icon-wrapper">
|
||||
<ShopOutlined class="shop-icon" />
|
||||
</div>
|
||||
<div class="shop-details">
|
||||
<div class="detail-item">
|
||||
<div class="detail-label">营业时间</div>
|
||||
<div class="detail-value">{{ shopInfo.businessHours }}</div>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<div class="detail-label">店铺描述</div>
|
||||
<div class="detail-value">{{ shopInfo.description }}</div>
|
||||
</div>
|
||||
<div class="shop-header-content">
|
||||
<h2 class="shop-name" @click="copyToClipboard(shopInfo.shopName, '店名')">
|
||||
{{ shopInfo.shopName || '店铺' }}
|
||||
<CopyOutlined class="copy-icon" />
|
||||
</h2>
|
||||
<p class="shop-address" @click="copyToClipboard(shopInfo.address, '地址')">
|
||||
{{ shopInfo.address || '暂未设置详细地址' }}
|
||||
<CopyOutlined v-if="shopInfo.address" class="copy-icon" />
|
||||
</p>
|
||||
<p v-if="distanceText" class="shop-distance">{{ distanceText }}</p>
|
||||
</div>
|
||||
<a-button class="contact-btn" type="primary" block @click="openManagerContact">
|
||||
一键联系店长
|
||||
</a-button>
|
||||
<div v-if="hasLocation" class="map-actions">
|
||||
</section>
|
||||
|
||||
<section class="shop-details">
|
||||
<div class="detail-item">
|
||||
<div class="detail-label">营业时间</div>
|
||||
<div class="detail-value">{{ shopInfo.businessHours || '暂未设置' }}</div>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<div class="detail-label">店铺描述</div>
|
||||
<div class="detail-value">{{ shopInfo.description || '暂无描述' }}</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="action-area">
|
||||
<a-button type="primary" block @click="openManagerContact">一键联系店长</a-button>
|
||||
<template v-if="hasLocation">
|
||||
<a-button block @click="openMapPreview">查看地图位置</a-button>
|
||||
<a-button block @click="openNavigation('TENCENT')">腾讯地图导航</a-button>
|
||||
<a-button block @click="openNavigation('AMAP')">高德地图导航</a-button>
|
||||
</div>
|
||||
<!-- 店铺环境图轮播 -->
|
||||
<div class="shop-images" v-if="shopImages.length > 0">
|
||||
<h3 class="section-title">店铺环境图</h3>
|
||||
<div class="image-carousel">
|
||||
<a-carousel autoplay :autoplay-speed="3000" dots>
|
||||
<div v-for="(url, index) in shopImages" :key="index" class="carousel-item" @click="showImageModal(url)">
|
||||
<img :src="url" :alt="`店铺环境图 ${index + 1}`" class="carousel-image" />
|
||||
</div>
|
||||
</a-carousel>
|
||||
<div class="navigation-actions">
|
||||
<a-button block @click="openNavigation('TENCENT')">腾讯地图导航</a-button>
|
||||
<a-button block @click="openNavigation('AMAP')">高德地图导航</a-button>
|
||||
</div>
|
||||
</template>
|
||||
<a-alert v-else type="info" show-icon message="店铺暂未设置地图位置" />
|
||||
</section>
|
||||
|
||||
<section v-if="shopImages.length > 0" class="shop-images">
|
||||
<h3 class="section-title">店铺环境图</h3>
|
||||
<div class="image-carousel">
|
||||
<a-carousel autoplay :autoplay-speed="3000" dots>
|
||||
<div v-for="(url, index) in shopImages" :key="url" class="carousel-item" @click="showImageModal(url)">
|
||||
<img :src="url" :alt="`店铺环境图 ${index + 1}`" class="carousel-image" />
|
||||
</div>
|
||||
</a-carousel>
|
||||
</div>
|
||||
|
||||
<!-- 图片查看模态框 -->
|
||||
<a-modal
|
||||
v-model:open="imageModalVisible"
|
||||
title="店铺环境图"
|
||||
:width="800"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<img :src="selectedImage" alt="店铺环境图" class="modal-image" />
|
||||
</a-modal>
|
||||
<a-modal v-model:open="contactOpen" title="一键联系" :footer="null">
|
||||
<div class="contact-box">
|
||||
<p><strong>{{ contactInfo.contactName || contactInfo.roleLabel || '联系人' }}</strong></p>
|
||||
<p>电话联系:{{ contactInfo.phoneAvailable ? contactInfo.phone : '暂无电话' }}</p>
|
||||
<a-button v-if="contactInfo.phoneAvailable" type="primary" block :href="`tel:${contactInfo.phone}`">拨打电话</a-button>
|
||||
<a-button block disabled>{{ contactInfo.platformContactText || '平台联系暂未接入' }}</a-button>
|
||||
</div>
|
||||
</a-modal>
|
||||
</div>
|
||||
</section>
|
||||
</a-card>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<a-modal v-model:open="imageModalVisible" title="店铺环境图" :width="800" :footer="null" @cancel="handleImageCancel">
|
||||
<img :src="selectedImage" alt="店铺环境图" class="modal-image" />
|
||||
</a-modal>
|
||||
|
||||
<a-modal v-model:open="contactOpen" title="一键联系" :footer="null">
|
||||
<div class="contact-box">
|
||||
<p class="contact-name">{{ contactInfo.contactName || contactInfo.roleLabel || '联系人' }}</p>
|
||||
<p>电话联系:{{ contactInfo.phoneAvailable ? contactInfo.phone : '暂无电话' }}</p>
|
||||
<a-button v-if="contactInfo.phoneAvailable" type="primary" block :href="`tel:${contactInfo.phone}`">拨打电话</a-button>
|
||||
<a-button block disabled>{{ contactInfo.platformContactText || '平台联系暂未接入' }}</a-button>
|
||||
</div>
|
||||
</a-modal>
|
||||
|
||||
<a-modal v-model:open="mapOpen" title="店铺位置" :width="900" :footer="null" class="map-modal">
|
||||
<div class="map-panel">
|
||||
<div class="map-summary">
|
||||
<strong>{{ shopInfo.shopName }}</strong>
|
||||
<span>{{ shopInfo.address }}</span>
|
||||
<span v-if="distanceText">{{ distanceText }}</span>
|
||||
</div>
|
||||
<iframe v-if="mapPreviewUrl" class="map-frame" :src="mapPreviewUrl" title="店铺地图位置"></iframe>
|
||||
<div class="navigation-actions">
|
||||
<a-button type="primary" block @click="openNavigation('TENCENT')">腾讯地图导航</a-button>
|
||||
<a-button block @click="openNavigation('AMAP')">高德地图导航</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* ShopDetailView 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 } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { CopyOutlined, LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { fileApi } from '@/api/file'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { userApi, type ContactInfoVO } from '@/api/user'
|
||||
import { toOptionalIdString } from '@/utils/id'
|
||||
|
||||
@@ -112,38 +123,30 @@ const shopInfo = ref<ShopVO>({
|
||||
})
|
||||
|
||||
const shopImages = ref<string[]>([])
|
||||
|
||||
// 图片模态框
|
||||
/** imageModalVisible is a reactive state variable used by the template and event handlers. */
|
||||
const imageModalVisible = ref(false)
|
||||
/** selectedImage is a reactive state variable used by the template and event handlers. */
|
||||
const selectedImage = ref('')
|
||||
/** contactOpen is a reactive state variable used by the template and event handlers. */
|
||||
const contactOpen = ref(false)
|
||||
const contactInfo = ref<ContactInfoVO>({})
|
||||
const hasLocation = computed(() => Boolean(shopInfo.value.longitude && shopInfo.value.latitude))
|
||||
const mapOpen = ref(false)
|
||||
const distanceText = ref('')
|
||||
|
||||
/** handleBackClick is a local helper used by this page script. */
|
||||
const hasLocation = computed(() => Boolean(shopInfo.value.longitude && shopInfo.value.latitude))
|
||||
const mapPreviewUrl = computed(() => shopInfo.value.navigationUrls?.BROWSER || shopInfo.value.navigationUrls?.TENCENT || '')
|
||||
|
||||
const handleBackClick = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
// 显示图片模态框
|
||||
/** showImageModal is a local helper used by this page script. */
|
||||
const showImageModal = (imageUrl: string) => {
|
||||
selectedImage.value = imageUrl
|
||||
imageModalVisible.value = true
|
||||
}
|
||||
|
||||
// 关闭图片模态框
|
||||
/** handleCancel is a local helper used by this page script. */
|
||||
const handleCancel = () => {
|
||||
const handleImageCancel = () => {
|
||||
imageModalVisible.value = false
|
||||
selectedImage.value = ''
|
||||
}
|
||||
|
||||
/** openManagerContact is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const openManagerContact = async () => {
|
||||
try {
|
||||
contactInfo.value = await userApi.getShopManagerContact(shopInfo.value.id)
|
||||
@@ -154,12 +157,11 @@ const openManagerContact = async () => {
|
||||
}
|
||||
|
||||
const openMapPreview = () => {
|
||||
const url = shopInfo.value.navigationUrls?.BROWSER || shopInfo.value.navigationUrls?.TENCENT
|
||||
if (!url) {
|
||||
if (!mapPreviewUrl.value) {
|
||||
message.warning('店铺暂未设置地图位置')
|
||||
return
|
||||
}
|
||||
window.open(url, '_blank')
|
||||
mapOpen.value = true
|
||||
}
|
||||
|
||||
const openNavigation = (provider: 'TENCENT' | 'AMAP') => {
|
||||
@@ -178,6 +180,7 @@ const calculateDistanceText = (currentLat: number, currentLng: number) => {
|
||||
distanceText.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
const toRad = (value: number) => value * Math.PI / 180
|
||||
const earthRadius = 6371000
|
||||
const dLat = toRad(shopLat - currentLat)
|
||||
@@ -188,9 +191,7 @@ const calculateDistanceText = (currentLat: number, currentLng: number) => {
|
||||
}
|
||||
|
||||
const loadCurrentDistance = () => {
|
||||
if (!hasLocation.value || !navigator.geolocation) {
|
||||
return
|
||||
}
|
||||
if (!hasLocation.value || !navigator.geolocation) return
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
position => calculateDistanceText(position.coords.latitude, position.coords.longitude),
|
||||
() => {
|
||||
@@ -200,78 +201,55 @@ const loadCurrentDistance = () => {
|
||||
)
|
||||
}
|
||||
|
||||
// 复制到剪贴板
|
||||
/** copyToClipboard is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const copyToClipboard = async (text: string, type: string) => {
|
||||
if (!text) return
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
message.success(`${type}已复制到剪贴板`)
|
||||
} catch (err) {
|
||||
console.error('复制失败:', err)
|
||||
} catch {
|
||||
message.error('复制失败,请手动复制')
|
||||
}
|
||||
}
|
||||
|
||||
/** loadShopImages is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadShopImages = async () => {
|
||||
try {
|
||||
const imageFileIds = shopInfo.value.imageFileIds
|
||||
if (imageFileIds) {
|
||||
const fileIds = imageFileIds.split(',').filter(id => id.trim())
|
||||
const fileIdPromises = fileIds.map(idStr => {
|
||||
const fileId = idStr.trim()
|
||||
if (!fileId) {
|
||||
return null
|
||||
}
|
||||
return fileApi.getSignedUrl(fileId).catch(() => {
|
||||
return null
|
||||
})
|
||||
})
|
||||
|
||||
const results = await Promise.all(fileIdPromises)
|
||||
const filteredResults = results
|
||||
.filter((url): url is any => url !== null)
|
||||
.map(url => {
|
||||
const urlStr = typeof url === 'string' ? url : String(url)
|
||||
return urlStr.replace(/[`]/g, '').trim()
|
||||
})
|
||||
shopImages.value = filteredResults
|
||||
}
|
||||
} catch (error) {
|
||||
if (!imageFileIds) return
|
||||
|
||||
const fileIds = imageFileIds.split(',').map(id => id.trim()).filter(Boolean)
|
||||
const results = await Promise.all(fileIds.map(fileId => fileApi.getSignedUrl(fileId).catch(() => null)))
|
||||
shopImages.value = results
|
||||
.filter(Boolean)
|
||||
.map(url => String(url).replace(/[`]/g, '').trim())
|
||||
} catch {
|
||||
shopImages.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/** fetchShopDetail is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const fetchShopDetail = async () => {
|
||||
try {
|
||||
// 从路由参数或本地存储获取店铺ID
|
||||
const shopId = toOptionalIdString(route.params.id || localStorage.getItem('userShopId'))
|
||||
if (!shopId) {
|
||||
message.error('店铺ID不存在')
|
||||
router.back()
|
||||
return
|
||||
}
|
||||
|
||||
const response = await shopApi.getShopById(shopId) as any
|
||||
shopInfo.value = response || {}
|
||||
|
||||
// 加载店铺图片
|
||||
|
||||
shopInfo.value = await shopApi.getShopById(shopId)
|
||||
await loadShopImages()
|
||||
loadCurrentDistance()
|
||||
} catch (error) {
|
||||
message.error('获取店铺详情失败')
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '获取店铺详情失败')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchShopDetail()
|
||||
})
|
||||
onMounted(fetchShopDetail)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.shop-detail {
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
background: var(--bg-color);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -281,7 +259,7 @@ onMounted(() => {
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 120px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
background: var(--theme-gradient);
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
@@ -299,9 +277,13 @@ onMounted(() => {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
.back-btn,
|
||||
.header-placeholder {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -310,15 +292,10 @@ onMounted(() => {
|
||||
|
||||
.header h1 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.header-placeholder {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.shop-content {
|
||||
padding: 100px 15px 20px;
|
||||
position: relative;
|
||||
@@ -326,21 +303,15 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.shop-card {
|
||||
border-radius: 20px;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
|
||||
box-shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
|
||||
}
|
||||
|
||||
.shop-card :deep(.ant-card-body) {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.shop-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.shop-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -348,9 +319,9 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.shop-icon-wrapper {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
width: 76px;
|
||||
height: 76px;
|
||||
background: var(--theme-gradient);
|
||||
border-radius: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -359,111 +330,110 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.shop-icon {
|
||||
font-size: 36px;
|
||||
font-size: 34px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.shop-header-content {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.shop-name {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
margin: 0 0 8px 0;
|
||||
color: #1a1a2e;
|
||||
margin: 0 0 8px;
|
||||
color: #172033;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.shop-address {
|
||||
font-size: 14px;
|
||||
color: #8b8b9a;
|
||||
color: #667085;
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.shop-distance {
|
||||
margin: 6px 0 0;
|
||||
color: #7a5262;
|
||||
color: var(--theme-primary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.copy-icon {
|
||||
font-size: 12px;
|
||||
font-size: 13px;
|
||||
margin-left: 6px;
|
||||
opacity: 0.6;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.shop-name:hover .copy-icon,
|
||||
.shop-address:hover .copy-icon {
|
||||
opacity: 1;
|
||||
color: #667eea;
|
||||
color: #8a94a6;
|
||||
}
|
||||
|
||||
.shop-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.contact-btn {
|
||||
margin-top: 18px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.map-actions {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.contact-box {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-top: 22px;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
font-size: 13px;
|
||||
color: #8b8b9a;
|
||||
font-weight: 500;
|
||||
color: #8a94a6;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
margin-top: 6px;
|
||||
font-size: 16px;
|
||||
color: #1a1a2e;
|
||||
line-height: 1.5;
|
||||
color: #172033;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.action-area {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin-top: 22px;
|
||||
}
|
||||
|
||||
.action-area .navigation-actions {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.action-area :deep(.ant-btn) {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.action-area :deep(.ant-alert) {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.navigation-actions {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.shop-images {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1a1a2e;
|
||||
margin: 0 0 12px 0;
|
||||
font-weight: 700;
|
||||
color: #172033;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.image-carousel {
|
||||
margin: 12px 0;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 4px 12px rgba(31, 41, 55, 0.12);
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
height: 220px;
|
||||
}
|
||||
|
||||
.carousel-item {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
height: 220px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.carousel-image {
|
||||
@@ -474,29 +444,24 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.carousel-item:hover .carousel-image {
|
||||
transform: scale(1.05);
|
||||
transform: scale(1.04);
|
||||
}
|
||||
|
||||
/* 轮播指示器样式 */
|
||||
.image-carousel :deep(.slick-dots) {
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
.image-carousel :deep(.slick-dots li) {
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
.image-carousel :deep(.slick-dots li button) {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
background: rgba(255, 255, 255, 0.65);
|
||||
}
|
||||
|
||||
.image-carousel :deep(.slick-dots li.slick-active button) {
|
||||
width: 20px;
|
||||
border-radius: 4px;
|
||||
background: #667eea;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.modal-image {
|
||||
@@ -506,6 +471,59 @@ onMounted(() => {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.contact-box,
|
||||
.map-panel {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.contact-name {
|
||||
margin: 0;
|
||||
font-weight: 700;
|
||||
color: #172033;
|
||||
}
|
||||
|
||||
.map-summary {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
color: #475467;
|
||||
}
|
||||
|
||||
.map-frame {
|
||||
width: 100%;
|
||||
height: 420px;
|
||||
border: 0;
|
||||
border-radius: 10px;
|
||||
background: #eef2f7;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.shop-card :deep(.ant-card-body) {
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.shop-header {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.shop-icon-wrapper {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.shop-name {
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
.navigation-actions {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.map-frame {
|
||||
height: 320px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.shop-content {
|
||||
max-width: 1040px;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</div>
|
||||
|
||||
<div v-if="wishlistItems.length === 0" class="empty-wishlist">
|
||||
<el-icon :size="60" :style="{ color: '#fadb14' }"><StarFilled /></el-icon>
|
||||
<el-icon :size="60" :style="{ color: 'var(--theme-primary)' }"><StarFilled /></el-icon>
|
||||
<p>收藏列表为空</p>
|
||||
<el-button type="primary" @click="handleBrowseProducts">
|
||||
浏览作品
|
||||
@@ -177,8 +177,7 @@ const handleProductClick = (productId: IdType) => {
|
||||
|
||||
/** getRandomColor is a local helper used by this page script. */
|
||||
const getRandomColor = () => {
|
||||
const colors = ['#ffe4d6', '#d6eaff', '#e2ffd6', '#fff2d6', '#d6ffe4', '#e4d6ff']
|
||||
return colors[Math.floor(Math.random() * colors.length)]
|
||||
return 'var(--theme-primary-soft)'
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -189,15 +188,29 @@ onMounted(() => {
|
||||
<style scoped>
|
||||
.mobile-container {
|
||||
min-height: 100vh;
|
||||
background: #fff;
|
||||
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;
|
||||
padding: 15px 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
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 {
|
||||
@@ -205,13 +218,16 @@ onMounted(() => {
|
||||
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 {
|
||||
@@ -219,17 +235,19 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.wishlist-items {
|
||||
padding: 20px;
|
||||
padding-bottom: 20px;
|
||||
padding: 16px;
|
||||
padding-bottom: 28px;
|
||||
}
|
||||
|
||||
.wishlist-item {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
padding: 15px;
|
||||
background: #f9f9f9;
|
||||
border-radius: 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 {
|
||||
@@ -258,6 +276,7 @@ onMounted(() => {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
color: rgba(0, 0, 0, 0.1);
|
||||
border: 1px solid var(--theme-border);
|
||||
}
|
||||
|
||||
.item-details {
|
||||
@@ -271,10 +290,11 @@ onMounted(() => {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin: 0 0 5px 0;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.item-price {
|
||||
color: var(--primary-color);
|
||||
color: var(--theme-primary);
|
||||
font-weight: bold;
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
@@ -287,7 +307,7 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.delete-icon {
|
||||
color: #ff4757;
|
||||
color: var(--theme-accent);
|
||||
cursor: pointer;
|
||||
font-size: 20px;
|
||||
}
|
||||
@@ -297,12 +317,33 @@ onMounted(() => {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60px 20px;
|
||||
color: #999;
|
||||
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);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<div class="admin-layout" :class="{ 'admin-layout--mobile': isMobile }">
|
||||
<div
|
||||
class="admin-layout"
|
||||
:class="{
|
||||
'admin-layout--mobile': isMobile,
|
||||
'admin-layout--collapsed': collapsed && !isMobile
|
||||
}"
|
||||
>
|
||||
<template v-if="!isMobile">
|
||||
<a-layout>
|
||||
<a-layout-sider
|
||||
@@ -7,11 +13,12 @@
|
||||
:trigger="null"
|
||||
collapsible
|
||||
class="sider"
|
||||
width="240"
|
||||
:width="240"
|
||||
:collapsed-width="80"
|
||||
>
|
||||
<div class="logo">
|
||||
<h1 v-if="!collapsed">后台管理</h1>
|
||||
<h1 v-else>后台</h1>
|
||||
<h1 v-if="!collapsed">YumiNail 管理台</h1>
|
||||
<h1 v-else>YN</h1>
|
||||
</div>
|
||||
<a-menu
|
||||
:selectedKeys="selectedKeys"
|
||||
@@ -39,8 +46,8 @@
|
||||
<MenuFoldOutlined v-else class="trigger" @click="toggleCollapsed" />
|
||||
|
||||
<div v-if="isBootstrapAdmin" class="shop-hint">
|
||||
<span>当前暂无可用门店,请先前往店铺管理创建</span>
|
||||
<a-button type="link" @click="router.push('/admin/shops')">去创建</a-button>
|
||||
<span>平台总览模式:用户、店铺、权限、消息、公告和参数可管理,其它店铺业务仅查看</span>
|
||||
<a-button type="link" @click="router.push('/admin/shops')">店铺管理</a-button>
|
||||
</div>
|
||||
|
||||
<div v-else-if="shopOptions.length > 1" class="shop-switcher">
|
||||
@@ -229,6 +236,7 @@ import { message, Modal } from 'ant-design-vue'
|
||||
import { adminAuthApi, type UserVO } from '@/api/admin'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import { isAllowedForShoplessPlatformAdmin } from '@/utils/platform-admin-permissions'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { useAdminViewport } from '@/composables/useAdminViewport'
|
||||
import {
|
||||
@@ -294,7 +302,10 @@ const isShopAuthorizationExpired = computed(() => Boolean(userInfo.value?.shopAu
|
||||
/** shopOptions is a reactive state variable used by the template and event handlers. */
|
||||
const shopOptions = computed(() => getAdminShopOptions(userInfo.value))
|
||||
/** shopSelectOptions is a reactive state variable used by the template and event handlers. */
|
||||
const shopSelectOptions = computed(() => shopOptions.value.map(shop => ({ label: shop.name, value: shop.id })))
|
||||
const shopSelectOptions = computed(() => {
|
||||
const options = shopOptions.value.map(shop => ({ label: shop.name, value: shop.id }))
|
||||
return options
|
||||
})
|
||||
/** currentShopName is a reactive state variable used by the template and event handlers. */
|
||||
const currentShopName = computed(() => getAdminCurrentShopName(userInfo.value))
|
||||
/** roleLabel is a reactive state variable used by the template and event handlers. */
|
||||
@@ -302,7 +313,7 @@ const roleLabel = computed(() => getAdminRoleLabel(userInfo.value?.type))
|
||||
/** shopScopeText is a reactive state variable used by the template and event handlers. */
|
||||
const shopScopeText = computed(() => {
|
||||
if (!shopOptions.value.length) {
|
||||
return '游客模式'
|
||||
return isBootstrapAdmin.value ? '平台总览模式' : '游客模式'
|
||||
}
|
||||
return `可登录门店:${shopOptions.value.map(shop => shop.name).join(' / ')}`
|
||||
})
|
||||
@@ -314,14 +325,11 @@ const filteredMenuItems = computed(() => {
|
||||
if (!item.permissionCode) {
|
||||
return true
|
||||
}
|
||||
if (isBootstrapAdmin.value && item.key === '/admin/shops') {
|
||||
return true
|
||||
if (isBootstrapAdmin.value) {
|
||||
return isAllowedForShoplessPlatformAdmin(item.permissionCode)
|
||||
}
|
||||
return hasPermission(item.permissionCode)
|
||||
})
|
||||
if (isBootstrapAdmin.value) {
|
||||
visibleItems = visibleItems.filter(item => item.key === '/admin' || item.key === '/admin/shops')
|
||||
}
|
||||
if (isShopAuthorizationExpired.value && userInfo.value?.type !== 4) {
|
||||
visibleItems = visibleItems.filter(item => item.key === '/admin')
|
||||
}
|
||||
@@ -520,7 +528,6 @@ onMounted(async () => {
|
||||
await fetchUserInfo()
|
||||
if (isBootstrapAdmin.value) {
|
||||
clearPermissions()
|
||||
return
|
||||
}
|
||||
await loadUserPermissions()
|
||||
})
|
||||
@@ -529,6 +536,11 @@ onMounted(async () => {
|
||||
<style scoped>
|
||||
.admin-layout {
|
||||
min-height: 100vh;
|
||||
--admin-sider-width: 240px;
|
||||
}
|
||||
|
||||
.admin-layout--collapsed {
|
||||
--admin-sider-width: 80px;
|
||||
}
|
||||
|
||||
.sider {
|
||||
@@ -546,6 +558,7 @@ onMounted(async () => {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 1000;
|
||||
transition: width 0.2s ease;
|
||||
}
|
||||
|
||||
.logo {
|
||||
@@ -561,16 +574,22 @@ onMounted(async () => {
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
margin-left: var(--admin-sider-width);
|
||||
height: auto;
|
||||
min-height: 64px;
|
||||
padding: 0 24px;
|
||||
background: rgba(255, 249, 242, 0.96);
|
||||
box-shadow: 0 10px 24px rgba(145, 102, 82, 0.08);
|
||||
backdrop-filter: blur(14px);
|
||||
line-height: normal;
|
||||
transition: margin-left 0.2s ease;
|
||||
}
|
||||
|
||||
.header-shell {
|
||||
@@ -588,10 +607,12 @@ onMounted(async () => {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.trigger {
|
||||
flex: 0 0 auto;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
color: var(--admin-mobile-ink);
|
||||
@@ -608,10 +629,14 @@ onMounted(async () => {
|
||||
border-radius: 999px;
|
||||
background: var(--admin-mobile-surface-alt);
|
||||
color: var(--admin-mobile-ink);
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.shop-hint {
|
||||
flex-wrap: wrap;
|
||||
border-radius: 14px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.shop-switcher-label {
|
||||
@@ -620,24 +645,88 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.shop-select {
|
||||
min-width: 220px;
|
||||
min-width: 180px;
|
||||
width: min(260px, 28vw);
|
||||
}
|
||||
|
||||
.shop-pill {
|
||||
flex: 0 1 auto;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.shop-pill :deep(.anticon) {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.shop-pill span {
|
||||
display: inline-block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 0 0 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.header {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.header-shell {
|
||||
gap: 10px;
|
||||
min-height: 58px;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
flex: 1 1 0;
|
||||
gap: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
flex: 0 0 auto;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.shop-pill {
|
||||
flex: 1 1 0;
|
||||
max-width: none;
|
||||
min-height: 36px;
|
||||
padding: 0 12px;
|
||||
gap: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.shop-pill span {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 420px) {
|
||||
.header-shell {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.user-dropdown {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
min-height: 48px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 10px;
|
||||
line-height: 1.2;
|
||||
transition: background 0.2s ease;
|
||||
}
|
||||
|
||||
@@ -647,10 +736,14 @@ onMounted(async () => {
|
||||
|
||||
.username {
|
||||
color: var(--admin-mobile-ink);
|
||||
max-width: 120px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-left: 240px;
|
||||
margin-left: var(--admin-sider-width);
|
||||
min-height: calc(100vh - 64px);
|
||||
padding: 24px;
|
||||
background:
|
||||
@@ -664,8 +757,20 @@ onMounted(async () => {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.admin-layout :deep(.ant-layout-sider-collapsed) + .ant-layout .content {
|
||||
margin-left: 80px;
|
||||
@media (max-width: 960px) {
|
||||
.admin-layout,
|
||||
.admin-layout--collapsed {
|
||||
--admin-sider-width: 0px;
|
||||
}
|
||||
|
||||
.sider {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.header,
|
||||
.content {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.mobile-shell {
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="登录店铺" name="shopId">
|
||||
<a-form-item v-if="hasAvailableShops || !allowShoplessLogin" label="登录店铺" name="shopId">
|
||||
<a-select
|
||||
v-model:value="formState.shopId"
|
||||
size="large"
|
||||
@@ -138,14 +138,14 @@ const hasAvailableShops = computed(() => shopOptions.value.length > 0)
|
||||
const shouldRequireShop = computed(() => hasAvailableShops.value && !allowShoplessLogin.value)
|
||||
/** shopPlaceholder is a reactive state variable used by the template and event handlers. */
|
||||
const shopPlaceholder = computed(() => {
|
||||
if (allowShoplessLogin.value) {
|
||||
return '当前无需选择店铺'
|
||||
}
|
||||
if (shopLoading.value) {
|
||||
return '正在加载可登录店铺'
|
||||
}
|
||||
if (hasAvailableShops.value) {
|
||||
return '请选择登录店铺'
|
||||
return allowShoplessLogin.value ? '可选择本次登录店铺,留空进入平台总览' : '请选择登录店铺'
|
||||
}
|
||||
if (allowShoplessLogin.value) {
|
||||
return '当前无需选择店铺'
|
||||
}
|
||||
return '请先输入账号'
|
||||
})
|
||||
@@ -193,6 +193,9 @@ const restoreLoginShop = () => {
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(cached)
|
||||
if (parsed?.type === 4) {
|
||||
return
|
||||
}
|
||||
if (parsed?.shopId) {
|
||||
formState.shopId = String(parsed.shopId)
|
||||
}
|
||||
@@ -207,11 +210,6 @@ const applyLoginShopSelection = (selection?: LoginShopSelectionResponse | null)
|
||||
allowShoplessLogin.value = Boolean(selection?.allowShoplessLogin)
|
||||
loginShopMessage.value = selection?.message || ''
|
||||
|
||||
if (allowShoplessLogin.value) {
|
||||
formState.shopId = undefined
|
||||
return
|
||||
}
|
||||
|
||||
if (!shops.value.length) {
|
||||
formState.shopId = undefined
|
||||
return
|
||||
@@ -222,7 +220,7 @@ const applyLoginShopSelection = (selection?: LoginShopSelectionResponse | null)
|
||||
return
|
||||
}
|
||||
|
||||
if (shops.value.length === 1) {
|
||||
if (!allowShoplessLogin.value && shops.value.length === 1) {
|
||||
formState.shopId = getShopIdValue(shops.value[0]!)
|
||||
return
|
||||
}
|
||||
@@ -284,6 +282,7 @@ const handleLogin = async () => {
|
||||
localStorage.setItem('adminRefreshToken', refreshToken)
|
||||
localStorage.setItem('adminUserInfo', JSON.stringify(userInfo))
|
||||
sessionStorage.setItem('adminAccessToken', accessToken)
|
||||
sessionStorage.setItem('adminRefreshToken', refreshToken)
|
||||
|
||||
|
||||
message.success('登录成功')
|
||||
@@ -331,12 +330,9 @@ const goToFrontend = () => {
|
||||
localStorage.removeItem('adminAccessToken')
|
||||
localStorage.removeItem('adminRefreshToken')
|
||||
localStorage.removeItem('adminUserInfo')
|
||||
localStorage.removeItem('accessToken')
|
||||
localStorage.removeItem('refreshToken')
|
||||
localStorage.removeItem('userInfo')
|
||||
localStorage.removeItem('userPermissions')
|
||||
sessionStorage.removeItem('adminAccessToken')
|
||||
sessionStorage.removeItem('accessToken')
|
||||
sessionStorage.removeItem('adminRefreshToken')
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.href = '/'
|
||||
@@ -399,14 +395,23 @@ const goToFrontend = () => {
|
||||
}
|
||||
|
||||
.login-footer a {
|
||||
color: #fff3ea;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 36px;
|
||||
padding: 0 14px;
|
||||
border-radius: 999px;
|
||||
color: #7a4058;
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
font-weight: 700;
|
||||
box-shadow: 0 8px 20px rgba(122, 64, 88, 0.14);
|
||||
}
|
||||
|
||||
.login-footer a:hover {
|
||||
text-decoration: underline;
|
||||
color: #c6597d;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.login-card :deep(.ant-card-body) {
|
||||
|
||||
@@ -8,9 +8,17 @@
|
||||
<a-input-search v-model:value="keyword" class="search" allow-clear placeholder="搜索评论内容" @search="loadComments" />
|
||||
</header>
|
||||
|
||||
<div class="admin-filter-bar">
|
||||
<a-input v-model:value="shopKeyword" allow-clear placeholder="店铺" style="width: 160px" @pressEnter="loadComments" />
|
||||
<a-input v-model:value="productKeyword" allow-clear placeholder="作品" style="width: 160px" @pressEnter="loadComments" />
|
||||
<a-input v-model:value="userKeyword" allow-clear placeholder="用户" style="width: 160px" @pressEnter="loadComments" />
|
||||
<a-range-picker v-model:value="createdRange" value-format="YYYY-MM-DD HH:mm:ss" show-time />
|
||||
<a-button @click="resetFilters">重置筛选</a-button>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="comments"
|
||||
:data-source="filteredComments"
|
||||
:loading="loading"
|
||||
:pagination="{ pageSize: 10 }"
|
||||
row-key="id"
|
||||
@@ -33,31 +41,48 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* CommentsView 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 { onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { adminCommentApi, type AdminCommentVO } from '@/api/admin'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
const loading = ref(false)
|
||||
/** keyword is a reactive state variable used by the template and event handlers. */
|
||||
const keyword = ref('')
|
||||
const shopKeyword = ref('')
|
||||
const productKeyword = ref('')
|
||||
const userKeyword = ref('')
|
||||
const createdRange = ref<[string, string] | undefined>()
|
||||
const comments = ref<AdminCommentVO[]>([])
|
||||
|
||||
const columns = [
|
||||
{ title: '评论内容', dataIndex: 'commentContent', key: 'commentContent' },
|
||||
{ title: '用户', dataIndex: 'userNickname', key: 'userNickname', width: 140 },
|
||||
{ title: '作品', dataIndex: 'productTitle', key: 'productTitle', width: 180 },
|
||||
{ title: '门店', dataIndex: 'shopName', key: 'shopName', width: 160 },
|
||||
{ title: '店铺', dataIndex: 'shopName', key: 'shopName', width: 160 },
|
||||
{ title: '时间', dataIndex: 'createTime', key: 'createTime', width: 180 },
|
||||
{ title: '操作', key: 'action', width: 100 }
|
||||
]
|
||||
|
||||
/** loadComments is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const filteredComments = computed(() => comments.value.filter(comment => {
|
||||
if (!matchText(shopKeyword.value, [comment.shopName, comment.shopId])) return false
|
||||
if (!matchText(productKeyword.value, [comment.productTitle, comment.productId])) return false
|
||||
if (!matchText(userKeyword.value, [comment.userNickname, comment.userId])) return false
|
||||
return matchRange(comment.createTime, createdRange.value)
|
||||
}))
|
||||
|
||||
const matchText = (needle: string, values: any[]) => {
|
||||
const normalized = needle.trim().toLowerCase()
|
||||
if (!normalized) return true
|
||||
return values.some(value => String(value ?? '').toLowerCase().includes(normalized))
|
||||
}
|
||||
|
||||
const matchRange = (value?: string, range?: [string, string]) => {
|
||||
if (!range?.length) return true
|
||||
if (!value) return false
|
||||
const time = new Date(value).getTime()
|
||||
return time >= new Date(range[0]).getTime() && time <= new Date(range[1]).getTime()
|
||||
}
|
||||
|
||||
const loadComments = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -69,13 +94,21 @@ const loadComments = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** deleteComment is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const deleteComment = async (id: IdType) => {
|
||||
await adminCommentApi.deleteComment(id)
|
||||
message.success('评论已删除')
|
||||
await loadComments()
|
||||
}
|
||||
|
||||
const resetFilters = () => {
|
||||
keyword.value = ''
|
||||
shopKeyword.value = ''
|
||||
productKeyword.value = ''
|
||||
userKeyword.value = ''
|
||||
createdRange.value = undefined
|
||||
loadComments()
|
||||
}
|
||||
|
||||
onMounted(loadComments)
|
||||
</script>
|
||||
|
||||
@@ -107,6 +140,12 @@ onMounted(loadComments)
|
||||
width: min(360px, 100%);
|
||||
}
|
||||
|
||||
.admin-filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.comment-cell {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
|
||||
@@ -217,9 +217,7 @@
|
||||
|
||||
<a-form-item v-if="isVipAutoForm" label="所需 VIP 等级" name="requiredVipLevel">
|
||||
<a-select v-model:value="formState.requiredVipLevel" placeholder="请选择 VIP 等级">
|
||||
<a-select-option value="青铜">青铜</a-select-option>
|
||||
<a-select-option value="白银">白银</a-select-option>
|
||||
<a-select-option value="黄金">黄金</a-select-option>
|
||||
<a-select-option v-for="level in vipLevelOptions" :key="level" :value="level">{{ level }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
@@ -249,7 +247,7 @@
|
||||
|
||||
<a-form-item label="可用标签" name="availableTagIds">
|
||||
<a-select v-model:value="formState.availableTagIds" mode="multiple" placeholder="请选择可用标签">
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id">
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id" :disabled="formState.unavailableTagIds.includes(Number(tag.id))">
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
@@ -257,7 +255,7 @@
|
||||
|
||||
<a-form-item label="不可用标签" name="unavailableTagIds">
|
||||
<a-select v-model:value="formState.unavailableTagIds" mode="multiple" placeholder="请选择不可用标签">
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id">
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id" :disabled="formState.availableTagIds.includes(Number(tag.id))">
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
@@ -343,6 +341,7 @@ import DraftActions from '@/components/DraftActions.vue'
|
||||
import dayjs, { type Dayjs } from 'dayjs'
|
||||
import {
|
||||
adminCouponApi,
|
||||
adminVipRechargePlanApi,
|
||||
adminShopApi,
|
||||
adminTagApi,
|
||||
adminUserApi,
|
||||
@@ -413,6 +412,7 @@ const couponList = ref<Coupon[]>([])
|
||||
const tagList = ref<Tag[]>([])
|
||||
const userList = ref<UserVO[]>([])
|
||||
const shops = ref<Shop[]>([])
|
||||
const vipLevelOptions = ref<string[]>(['普通', '青铜', '白银', '黄金'])
|
||||
|
||||
/** distributeModalVisible is a reactive state variable used by the template and event handlers. */
|
||||
const distributeModalVisible = ref(false)
|
||||
@@ -554,8 +554,8 @@ const buildDraftPayload = () => ({
|
||||
minAmount: formState.minAmount,
|
||||
reduceAmount: formState.reduceAmount,
|
||||
totalCount: formState.totalCount,
|
||||
startTime: formState.startTime?.format('YYYY-MM-DD HH:mm:ss'),
|
||||
endTime: formState.endTime?.format('YYYY-MM-DD HH:mm:ss'),
|
||||
startTime: formState.startTime?.format('YYYY-MM-DDTHH:mm:ss'),
|
||||
endTime: formState.endTime?.format('YYYY-MM-DDTHH:mm:ss'),
|
||||
availableTagIds: [...formState.availableTagIds],
|
||||
unavailableTagIds: [...formState.unavailableTagIds],
|
||||
shopId: formState.shopId,
|
||||
@@ -597,13 +597,21 @@ const handleClearDraft = (showMessage = true) => {
|
||||
}
|
||||
}
|
||||
|
||||
const isSameTagSelection = (left: number[], right: number[]) =>
|
||||
left.length === right.length && left.every((id, index) => Number(id) === Number(right[index]))
|
||||
|
||||
const removeSelectedTags = (target: number[], selected: number[]) => {
|
||||
const selectedIds = new Set(selected.map(Number))
|
||||
return target.filter(id => !selectedIds.has(Number(id)))
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formState.couponScene,
|
||||
value => {
|
||||
if (value === 'VIP_AUTO') {
|
||||
formState.autoMatch = 1
|
||||
if (!formState.requiredVipLevel) {
|
||||
formState.requiredVipLevel = '青铜'
|
||||
formState.requiredVipLevel = vipLevelOptions.value.find(level => level !== '普通') || vipLevelOptions.value[0]
|
||||
}
|
||||
} else {
|
||||
formState.autoMatch = 0
|
||||
@@ -612,6 +620,26 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => formState.availableTagIds.slice(),
|
||||
value => {
|
||||
const nextUnavailableTagIds = removeSelectedTags(formState.unavailableTagIds, value)
|
||||
if (!isSameTagSelection(formState.unavailableTagIds, nextUnavailableTagIds)) {
|
||||
formState.unavailableTagIds = nextUnavailableTagIds
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => formState.unavailableTagIds.slice(),
|
||||
value => {
|
||||
const nextAvailableTagIds = removeSelectedTags(formState.availableTagIds, value)
|
||||
if (!isSameTagSelection(formState.availableTagIds, nextAvailableTagIds)) {
|
||||
formState.availableTagIds = nextAvailableTagIds
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/** handleAutoMatchChange is a local helper used by this page script. */
|
||||
const handleAutoMatchChange = (checked: boolean) => {
|
||||
formState.autoMatch = checked ? 1 : 0
|
||||
@@ -737,8 +765,8 @@ const buildCouponPayload = () => ({
|
||||
minAmount: formState.couponType === 2 ? formState.minAmount : undefined,
|
||||
reduceAmount: formState.couponType === 2 ? formState.reduceAmount : undefined,
|
||||
totalCount: formState.totalCount,
|
||||
startTime: formState.startTime?.format('YYYY-MM-DD HH:mm:ss'),
|
||||
endTime: formState.endTime?.format('YYYY-MM-DD HH:mm:ss'),
|
||||
startTime: formState.startTime?.format('YYYY-MM-DDTHH:mm:ss'),
|
||||
endTime: formState.endTime?.format('YYYY-MM-DDTHH:mm:ss'),
|
||||
availableTagIds: formState.availableTagIds,
|
||||
unavailableTagIds: formState.unavailableTagIds,
|
||||
shopId: formState.shopId,
|
||||
@@ -850,9 +878,20 @@ const handleDistributeCancel = () => {
|
||||
distributeFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const fetchVipLevelOptions = async () => {
|
||||
try {
|
||||
const levels = await adminVipRechargePlanApi.listVipLevelOptions(currentUserInfo?.shopId)
|
||||
if (Array.isArray(levels) && levels.length) {
|
||||
vipLevelOptions.value = ['普通', ...levels.filter(level => level !== '普通')]
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('VIP 等级选项加载失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadUserPermissions()
|
||||
await Promise.all([fetchTags(), fetchShops(), fetchCoupons()])
|
||||
await Promise.all([fetchTags(), fetchShops(), fetchCoupons(), fetchVipLevelOptions()])
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
<template>
|
||||
<div class="dashboard">
|
||||
<a-page-header
|
||||
v-if="!isMobile"
|
||||
title="仪表盘"
|
||||
:sub-title="pageSubtitle"
|
||||
/>
|
||||
<a-page-header v-if="!isMobile" title="仪表盘" :sub-title="pageSubtitle" />
|
||||
|
||||
<section v-else class="admin-page-intro">
|
||||
<span class="admin-page-intro__eyebrow">工作台</span>
|
||||
@@ -12,66 +8,61 @@
|
||||
<p class="admin-page-intro__subtitle">{{ pageSubtitle }}</p>
|
||||
</section>
|
||||
|
||||
<a-alert
|
||||
v-if="currentUser?.shopAuthorizationExpired && currentUser?.type !== 4"
|
||||
class="auth-alert"
|
||||
type="warning"
|
||||
show-icon
|
||||
message="授权已到期,请联系管理员"
|
||||
description="当前店铺业务功能已被临时禁用,后台仅保留首页、账号信息和退出登录等基础能力。"
|
||||
/>
|
||||
|
||||
<a-row :gutter="[16, 16]" class="stat-cards">
|
||||
<a-col :xs="24" :sm="12" :xl="6">
|
||||
<a-card>
|
||||
<a-statistic title="用户数" :value="stats.totalUsers" :loading="loading">
|
||||
<a-col v-for="item in primaryStats" :key="item.key" :xs="24" :sm="12" :xl="6">
|
||||
<a-card class="metric-card">
|
||||
<a-statistic :title="item.title" :value="item.value" :precision="item.precision || 0" :loading="loading">
|
||||
<template #prefix>
|
||||
<UserOutlined />
|
||||
</template>
|
||||
</a-statistic>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-col :xs="24" :sm="12" :xl="6">
|
||||
<a-card>
|
||||
<a-statistic title="作品数" :value="stats.totalProducts" :loading="loading">
|
||||
<template #prefix>
|
||||
<ShopOutlined />
|
||||
</template>
|
||||
</a-statistic>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-col v-if="isAdmin" :xs="24" :sm="12" :xl="6">
|
||||
<a-card>
|
||||
<a-statistic title="门店数" :value="stats.totalShops" :loading="loading">
|
||||
<template #prefix>
|
||||
<HomeOutlined />
|
||||
</template>
|
||||
</a-statistic>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-col :xs="24" :sm="12" :xl="6">
|
||||
<a-card>
|
||||
<a-statistic title="今日订单" :value="stats.todayOrders" :loading="loading">
|
||||
<template #prefix>
|
||||
<ShoppingOutlined />
|
||||
<component :is="item.icon" />
|
||||
</template>
|
||||
<template v-if="item.suffix" #suffix>{{ item.suffix }}</template>
|
||||
</a-statistic>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-row :gutter="[16, 16]">
|
||||
<a-col :xs="24" :xl="14">
|
||||
<a-card title="经营提醒" class="insight-card">
|
||||
<a-col :xs="24" :xl="15">
|
||||
<a-card title="经营概览" class="panel-card">
|
||||
<a-spin :spinning="loading">
|
||||
<div class="insight-list">
|
||||
<div v-for="item in insightItems" :key="item.title" class="insight-item">
|
||||
<div class="insight-title">{{ item.title }}</div>
|
||||
<div class="insight-description">{{ item.description }}</div>
|
||||
<div class="overview-grid">
|
||||
<div v-for="item in overviewItems" :key="item.label" class="overview-item">
|
||||
<span>{{ item.label }}</span>
|
||||
<strong>{{ item.value }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-col :xs="24" :xl="10">
|
||||
<a-card title="热门作品" class="side-card">
|
||||
<a-col :xs="24" :xl="9">
|
||||
<a-card title="快捷跳转" class="panel-card">
|
||||
<div class="quick-grid">
|
||||
<a-button v-for="item in quickLinks" :key="item.path" @click="router.push(item.path)">
|
||||
<template #icon>
|
||||
<component :is="item.icon" />
|
||||
</template>
|
||||
{{ item.label }}
|
||||
</a-button>
|
||||
</div>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-row :gutter="[16, 16]">
|
||||
<a-col :xs="24" :xl="12">
|
||||
<a-card title="热门作品" class="panel-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-empty v-if="!stats.hotProducts.length" description="暂时还没有热门作品数据" />
|
||||
<a-empty v-if="!stats.hotProducts.length" description="暂无热门作品数据" />
|
||||
<div v-else class="hot-list">
|
||||
<div v-for="item in stats.hotProducts" :key="item.id" class="hot-item">
|
||||
<div>
|
||||
@@ -84,51 +75,68 @@
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-card title="最近动态" class="activity-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-empty v-if="!stats.recentActivities.length" description="暂时没有最近动态" />
|
||||
<a-timeline v-else>
|
||||
<a-timeline-item
|
||||
v-for="activity in stats.recentActivities"
|
||||
:key="activity.id"
|
||||
:color="activity.color || 'blue'"
|
||||
>
|
||||
<p class="activity-title">{{ activity.title || '系统动态' }}</p>
|
||||
<p class="activity-description">{{ activity.description }}</p>
|
||||
<p class="activity-time">{{ formatTime(activity.time) }}</p>
|
||||
</a-timeline-item>
|
||||
</a-timeline>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
<a-col :xs="24" :xl="12">
|
||||
<a-card title="最近动态" class="panel-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-empty v-if="!stats.recentActivities.length" description="暂无最近动态" />
|
||||
<a-timeline v-else>
|
||||
<a-timeline-item
|
||||
v-for="activity in stats.recentActivities"
|
||||
:key="activity.id"
|
||||
:color="activity.color || 'blue'"
|
||||
>
|
||||
<p class="activity-title">{{ activity.title || '系统动态' }}</p>
|
||||
<p class="activity-description">{{ activity.description }}</p>
|
||||
<p class="activity-time">{{ formatTime(activity.time) }}</p>
|
||||
</a-timeline-item>
|
||||
</a-timeline>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* DashboardView 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, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { HomeOutlined, ShopOutlined, ShoppingOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
import {
|
||||
GiftOutlined,
|
||||
HomeOutlined,
|
||||
MessageOutlined,
|
||||
ShopOutlined,
|
||||
ShoppingOutlined,
|
||||
TeamOutlined,
|
||||
UserOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import { adminDashboardApi, type DashboardStats } from '@/api/admin'
|
||||
import { useAdminViewport } from '@/composables/useAdminViewport'
|
||||
|
||||
const router = useRouter()
|
||||
const { isMobile } = useAdminViewport()
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
const loading = ref(false)
|
||||
|
||||
const stats = reactive<DashboardStats>({
|
||||
totalUsers: 0,
|
||||
totalProducts: 0,
|
||||
totalShops: 0,
|
||||
todayOrders: 0,
|
||||
totalOrderAmount: 0,
|
||||
todayOrderAmount: 0,
|
||||
weekOrderAmount: 0,
|
||||
totalCustomers: 0,
|
||||
totalArtists: 0,
|
||||
newCustomersToday: 0,
|
||||
newCustomers7Days: 0,
|
||||
newOrders7Days: 0,
|
||||
pendingOrders: 0,
|
||||
completedOrders: 0,
|
||||
hotProducts: [],
|
||||
recentActivities: []
|
||||
})
|
||||
|
||||
/** getCurrentUserInfo is a local helper used by this page script. */
|
||||
const getCurrentUserInfo = () => {
|
||||
try {
|
||||
const cache = localStorage.getItem('adminUserInfo')
|
||||
@@ -139,69 +147,53 @@ const getCurrentUserInfo = () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** currentUser is a reactive state variable used by the template and event handlers. */
|
||||
const currentUser = computed(() => getCurrentUserInfo())
|
||||
/** isAdmin is a reactive state variable used by the template and event handlers. */
|
||||
const isAdmin = computed(() => currentUser.value?.type === 4)
|
||||
/** pageSubtitle is a reactive state variable used by the template and event handlers. */
|
||||
const pageSubtitle = computed(() => {
|
||||
if (isAdmin.value) {
|
||||
return stats.totalShops > 0 ? '查看整体经营情况与各门店动态' : '当前还没有门店,先去店铺管理创建第一家门店'
|
||||
return '查看全平台经营情况、订单增长与待处理事项'
|
||||
}
|
||||
return currentUser.value?.shopName ? `当前门店:${currentUser.value.shopName}` : '当前还没有选中门店'
|
||||
return currentUser.value?.shopName ? `当前店铺:${currentUser.value.shopName}` : '查看当前账号可管理范围内的经营情况'
|
||||
})
|
||||
|
||||
/** insightItems is a reactive state variable used by the template and event handlers. */
|
||||
const insightItems = computed(() => {
|
||||
const items = []
|
||||
if (isAdmin.value && stats.totalShops === 0) {
|
||||
items.push({
|
||||
title: '先创建门店',
|
||||
description: '系统目前还没有门店,建议先在店铺管理里创建第一家门店,再继续配置作品、优惠券和员工。'
|
||||
})
|
||||
}
|
||||
if (stats.totalProducts === 0) {
|
||||
items.push({
|
||||
title: '还没有可售作品',
|
||||
description: '先补充基础作品,首页和作品页会更完整,顾客也能更顺畅地下单。'
|
||||
})
|
||||
} else {
|
||||
items.push({
|
||||
title: '作品库已准备好',
|
||||
description: `当前共有 ${stats.totalProducts} 个作品,建议继续关注热门作品的收藏和点赞表现。`
|
||||
})
|
||||
}
|
||||
if (stats.todayOrders === 0) {
|
||||
items.push({
|
||||
title: '今日订单较安静',
|
||||
description: '可以检查首页推荐、优惠券配置或门店营业时间是否完整,减少用户下单前的犹豫。'
|
||||
})
|
||||
} else {
|
||||
items.push({
|
||||
title: '今日已有订单流入',
|
||||
description: `今天已产生 ${stats.todayOrders} 笔订单,建议优先关注订单状态推进和美甲师排期。`
|
||||
})
|
||||
}
|
||||
if (stats.totalUsers > 0) {
|
||||
items.push({
|
||||
title: '用户池正在积累',
|
||||
description: `当前共有 ${stats.totalUsers} 个用户,可继续结合收藏、优惠券和 VIP 规则提升复购。`
|
||||
})
|
||||
}
|
||||
return items
|
||||
})
|
||||
const money = (value?: number) => Number(value || 0)
|
||||
const numberText = (value?: number) => String(Number(value || 0))
|
||||
|
||||
const primaryStats = computed(() => [
|
||||
{ key: 'amount', title: '订单总额', value: money(stats.totalOrderAmount), precision: 2, suffix: '元', icon: ShoppingOutlined },
|
||||
{ key: 'todayAmount', title: '今日订单额', value: money(stats.todayOrderAmount), precision: 2, suffix: '元', icon: ShoppingOutlined },
|
||||
{ key: 'customers', title: '客户数量', value: stats.totalCustomers || stats.totalUsers || 0, icon: UserOutlined },
|
||||
{ key: 'artists', title: '美甲师数量', value: stats.totalArtists || 0, icon: TeamOutlined }
|
||||
])
|
||||
|
||||
const overviewItems = computed(() => [
|
||||
{ label: '近 7 日订单额', value: `¥${money(stats.weekOrderAmount).toFixed(2)}` },
|
||||
{ label: '今日订单数', value: numberText(stats.todayOrders) },
|
||||
{ label: '近 7 日新增订单', value: numberText(stats.newOrders7Days) },
|
||||
{ label: '待处理订单', value: numberText(stats.pendingOrders) },
|
||||
{ label: '已完成订单', value: numberText(stats.completedOrders) },
|
||||
{ label: '今日新增客户', value: numberText(stats.newCustomersToday) },
|
||||
{ label: '近 7 日新增客户', value: numberText(stats.newCustomers7Days) },
|
||||
{ label: isAdmin.value ? '店铺数量' : '作品数量', value: numberText(isAdmin.value ? stats.totalShops : stats.totalProducts) }
|
||||
])
|
||||
|
||||
const quickLinks = computed(() => [
|
||||
{ label: '订单管理', path: '/admin/orders', icon: ShoppingOutlined },
|
||||
{ label: '用户管理', path: '/admin/users', icon: UserOutlined },
|
||||
{ label: '作品管理', path: '/admin/products', icon: ShopOutlined },
|
||||
{ label: '优惠券管理', path: '/admin/coupons', icon: GiftOutlined },
|
||||
{ label: '消息发布', path: '/admin/messages', icon: MessageOutlined },
|
||||
{ label: isAdmin.value ? '店铺管理' : '美甲师管理', path: isAdmin.value ? '/admin/shops' : '/admin/nail-artists', icon: HomeOutlined }
|
||||
])
|
||||
|
||||
/** formatTime is a local helper used by this page script. */
|
||||
const formatTime = (timeStr: string) => {
|
||||
if (!timeStr) return ''
|
||||
const time = new Date(timeStr)
|
||||
const now = new Date()
|
||||
const diff = now.getTime() - time.getTime()
|
||||
|
||||
const minutes = Math.floor(diff / 60000)
|
||||
const hours = Math.floor(diff / 3600000)
|
||||
const days = Math.floor(diff / 86400000)
|
||||
|
||||
if (minutes < 1) return '刚刚'
|
||||
if (minutes < 60) return `${minutes} 分钟前`
|
||||
if (hours < 24) return `${hours} 小时前`
|
||||
@@ -209,7 +201,6 @@ const formatTime = (timeStr: string) => {
|
||||
return time.toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
/** fetchStats is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const fetchStats = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -233,38 +224,48 @@ onMounted(() => {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.auth-alert {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.stat-cards {
|
||||
margin-bottom: 24px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.insight-card,
|
||||
.side-card,
|
||||
.activity-card {
|
||||
border-radius: 18px;
|
||||
.metric-card,
|
||||
.panel-card {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.insight-list {
|
||||
.overview-grid {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.insight-item {
|
||||
padding: 16px 18px;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(135deg, #fff8f1 0%, #f8ede1 100%);
|
||||
border: 1px solid #edd9ca;
|
||||
.overview-item {
|
||||
padding: 14px;
|
||||
border: 1px solid #f0e1d5;
|
||||
border-radius: 8px;
|
||||
background: #fffaf5;
|
||||
}
|
||||
|
||||
.insight-title {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #1f2937;
|
||||
.overview-item span {
|
||||
display: block;
|
||||
color: #8a6b5f;
|
||||
font-size: 13px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.insight-description {
|
||||
margin-top: 6px;
|
||||
line-height: 1.7;
|
||||
color: #64748b;
|
||||
.overview-item strong {
|
||||
color: #2f211b;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.quick-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.hot-list {
|
||||
@@ -276,50 +277,52 @@ onMounted(() => {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 14px 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid #f1e6dd;
|
||||
}
|
||||
|
||||
.hot-item:last-child {
|
||||
border-bottom: none;
|
||||
padding-bottom: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.hot-name {
|
||||
font-weight: 700;
|
||||
color: #1f2937;
|
||||
color: #2f211b;
|
||||
}
|
||||
|
||||
.hot-meta,
|
||||
.activity-description,
|
||||
.activity-time {
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.hot-meta,
|
||||
.activity-time {
|
||||
font-size: 12px;
|
||||
color: #8a6b5f;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.hot-price {
|
||||
white-space: nowrap;
|
||||
color: #c05d3b;
|
||||
font-weight: 700;
|
||||
color: #c4684b;
|
||||
}
|
||||
|
||||
.activity-card {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.activity-title {
|
||||
margin: 0 0 4px;
|
||||
font-weight: 700;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.activity-description,
|
||||
.activity-time {
|
||||
margin: 0;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.overview-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.overview-grid,
|
||||
.quick-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
<a-alert
|
||||
v-if="isBootstrapAdmin"
|
||||
class="bootstrap-alert"
|
||||
type="warning"
|
||||
type="info"
|
||||
show-icon
|
||||
message="当前处于建店引导状态"
|
||||
description="系统里还没有可用店铺。当前账号已允许登录后台先创建第一家店铺,其他后台模块会保持不可用,创建完成后请重新登录并选择店铺。"
|
||||
message="当前处于平台总览模式"
|
||||
description="可以查看总览、店铺列表和权限入口;用户、作品、订单、优惠券等店铺业务默认仅可查看,编辑操作已关闭。"
|
||||
/>
|
||||
|
||||
<a-alert
|
||||
@@ -86,16 +86,16 @@
|
||||
<template v-else>
|
||||
<section class="admin-page-intro">
|
||||
<span class="admin-page-intro__eyebrow">{{ userInfo?.nickname || userInfo?.account || '后台账号' }}</span>
|
||||
<h1 class="admin-page-intro__title">{{ userInfo?.shopName || (isBootstrapAdmin ? '无门店工作台' : '游客模式') }}</h1>
|
||||
<h1 class="admin-page-intro__title">{{ userInfo?.shopName || (isBootstrapAdmin ? '平台总览模式' : '游客模式') }}</h1>
|
||||
<div class="admin-page-intro__meta">
|
||||
<span class="admin-page-chip">{{ currentTime }}</span>
|
||||
<span class="admin-page-chip">{{ getUserTypeText(userInfo?.type) }}</span>
|
||||
<span v-if="isBootstrapAdmin" class="admin-page-chip">游客模式</span>
|
||||
<span v-if="isBootstrapAdmin" class="admin-page-chip">平台总览</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="isBootstrapAdmin" class="admin-mobile-section-card">
|
||||
<div class="admin-mobile-section-card__title">先创建第一家店铺</div>
|
||||
<div class="admin-mobile-section-card__title">平台总览模式</div>
|
||||
<a-button type="primary" size="large" block @click="navigateTo('/admin/shops', 'shop:view')">进入店铺管理</a-button>
|
||||
</section>
|
||||
|
||||
@@ -155,13 +155,27 @@
|
||||
*/
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { DashboardOutlined, HomeOutlined, SafetyCertificateOutlined, ShopOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
import {
|
||||
DashboardOutlined,
|
||||
FileProtectOutlined,
|
||||
GiftOutlined,
|
||||
HomeOutlined,
|
||||
MessageOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
SettingOutlined,
|
||||
ShopOutlined,
|
||||
ShoppingOutlined,
|
||||
TagOutlined,
|
||||
TeamOutlined,
|
||||
UserOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import { userApi, type UserVO } from '@/api/admin'
|
||||
import { permissionApi, type PermissionVO } from '@/api/permission'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useAdminViewport } from '@/composables/useAdminViewport'
|
||||
import { isBootstrapAdminUser } from './admin-helpers'
|
||||
import { isAllowedForShoplessPlatformAdmin } from '@/utils/platform-admin-permissions'
|
||||
|
||||
const router = useRouter()
|
||||
const { isMobile } = useAdminViewport()
|
||||
@@ -228,6 +242,34 @@ const quickActions = computed(() => {
|
||||
icon: ShopOutlined,
|
||||
permissionCode: 'product:view'
|
||||
},
|
||||
{
|
||||
key: 'coupons',
|
||||
title: '优惠券',
|
||||
path: '/admin/coupons',
|
||||
icon: GiftOutlined,
|
||||
permissionCode: 'coupon:view'
|
||||
},
|
||||
{
|
||||
key: 'orders',
|
||||
title: '订单管理',
|
||||
path: '/admin/orders',
|
||||
icon: ShoppingOutlined,
|
||||
permissionCode: 'order:view'
|
||||
},
|
||||
{
|
||||
key: 'tags',
|
||||
title: '标签管理',
|
||||
path: '/admin/tags',
|
||||
icon: TagOutlined,
|
||||
permissionCode: 'tag:view'
|
||||
},
|
||||
{
|
||||
key: 'artists',
|
||||
title: '美甲师管理',
|
||||
path: '/admin/nail-artists',
|
||||
icon: TeamOutlined,
|
||||
permissionCode: 'nail_artist:view'
|
||||
},
|
||||
{
|
||||
key: 'shops',
|
||||
title: '店铺管理',
|
||||
@@ -241,10 +283,48 @@ const quickActions = computed(() => {
|
||||
path: '/admin/permissions',
|
||||
icon: SafetyCertificateOutlined,
|
||||
permissionCode: 'permission:view'
|
||||
},
|
||||
{
|
||||
key: 'messages',
|
||||
title: '消息发布',
|
||||
path: '/admin/messages',
|
||||
icon: MessageOutlined,
|
||||
permissionCode: 'message:view'
|
||||
},
|
||||
{
|
||||
key: 'announcements',
|
||||
title: '公告管理',
|
||||
path: '/admin/announcements',
|
||||
icon: MessageOutlined,
|
||||
permissionCode: 'announcement:view'
|
||||
},
|
||||
{
|
||||
key: 'vip-plans',
|
||||
title: 'VIP充值配置',
|
||||
path: '/admin/vip-recharge-plans',
|
||||
icon: GiftOutlined,
|
||||
permissionCode: 'user:vip:manage'
|
||||
},
|
||||
{
|
||||
key: 'parameters',
|
||||
title: '参数管理',
|
||||
path: '/admin/messagehub-push-configs',
|
||||
icon: SettingOutlined,
|
||||
permissionCode: 'messagehub:config:manage'
|
||||
},
|
||||
{
|
||||
key: 'agreements',
|
||||
title: '协议管理',
|
||||
path: '/admin/legal-agreements',
|
||||
icon: FileProtectOutlined,
|
||||
permissionCode: 'legal_agreement:manage'
|
||||
}
|
||||
]
|
||||
|
||||
const grantedPermissions = new Set(userPermissions.value.map(permission => permission.permissionCode))
|
||||
if (isBootstrapAdmin.value) {
|
||||
return actions.filter(item => isAllowedForShoplessPlatformAdmin(item.permissionCode))
|
||||
}
|
||||
return actions.filter(item => grantedPermissions.has(item.permissionCode))
|
||||
})
|
||||
|
||||
@@ -303,6 +383,10 @@ const fetchUserPermissions = async () => {
|
||||
/** navigateTo is a local helper used by this page script. */
|
||||
const navigateTo = (path: string, permissionCode?: string) => {
|
||||
if (permissionCode) {
|
||||
if (isBootstrapAdmin.value && isAllowedForShoplessPlatformAdmin(permissionCode)) {
|
||||
router.push(path)
|
||||
return
|
||||
}
|
||||
const hasPermission = userPermissions.value.some(p => p.permissionCode === permissionCode)
|
||||
if (!hasPermission) {
|
||||
message.warning('您没有该操作的权限')
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="admin-page-intro__meta">
|
||||
<span class="admin-page-chip">{{ roleLabel }}</span>
|
||||
<span class="admin-page-chip">可见模块 {{ visibleModules.length }}</span>
|
||||
<span v-if="isBootstrapAdmin" class="admin-page-chip">游客模式</span>
|
||||
<span v-if="isBootstrapAdmin" class="admin-page-chip">平台总览</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<div class="module-card__head">
|
||||
<div class="module-card__title">{{ module.title }}</div>
|
||||
<span class="module-card__badge">
|
||||
{{ module.allowed ? '进入' : '受限' }}
|
||||
{{ module.readonly ? '仅查看' : (module.allowed ? '进入' : '受限') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="module-card__subtitle">{{ module.description }}</div>
|
||||
@@ -48,10 +48,13 @@ import { computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import {
|
||||
DashboardOutlined,
|
||||
FileProtectOutlined,
|
||||
GiftOutlined,
|
||||
HomeOutlined,
|
||||
MessageOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
ShopOutlined,
|
||||
SettingOutlined,
|
||||
TagOutlined,
|
||||
TeamOutlined,
|
||||
UserOutlined
|
||||
@@ -95,7 +98,8 @@ const visibleModules = computed(() => {
|
||||
path: '/admin/users',
|
||||
icon: UserOutlined,
|
||||
permissionCode: 'user:view',
|
||||
requireShopContext: true
|
||||
requireShopContext: true,
|
||||
allowPlatformOverviewManage: true
|
||||
},
|
||||
{
|
||||
key: 'products',
|
||||
@@ -148,22 +152,65 @@ const visibleModules = computed(() => {
|
||||
path: '/admin/permissions',
|
||||
icon: SafetyCertificateOutlined,
|
||||
permissionCode: 'permission:view'
|
||||
},
|
||||
{
|
||||
key: 'messages',
|
||||
title: '消息发布',
|
||||
description: '发布站内消息,可面向全平台或指定范围。',
|
||||
path: '/admin/messages',
|
||||
icon: MessageOutlined,
|
||||
permissionCode: 'message:view'
|
||||
},
|
||||
{
|
||||
key: 'announcements',
|
||||
title: '公告管理',
|
||||
description: '维护首页滚动公告,支持平台和门店范围。',
|
||||
path: '/admin/announcements',
|
||||
icon: MessageOutlined,
|
||||
permissionCode: 'announcement:view'
|
||||
},
|
||||
{
|
||||
key: 'vip-plans',
|
||||
title: 'VIP充值配置',
|
||||
description: '维护充值档位和 VIP 等级来源。',
|
||||
path: '/admin/vip-recharge-plans',
|
||||
icon: GiftOutlined,
|
||||
permissionCode: 'user:vip:manage',
|
||||
requireShopContext: true
|
||||
},
|
||||
{
|
||||
key: 'parameters',
|
||||
title: '参数管理',
|
||||
description: '维护地图 Key、短信 MessageHub 等系统参数。',
|
||||
path: '/admin/messagehub-push-configs',
|
||||
icon: SettingOutlined,
|
||||
permissionCode: 'messagehub:config:manage'
|
||||
},
|
||||
{
|
||||
key: 'agreements',
|
||||
title: '协议管理',
|
||||
description: '维护用户协议和隐私政策版本。',
|
||||
path: '/admin/legal-agreements',
|
||||
icon: FileProtectOutlined,
|
||||
permissionCode: 'legal_agreement:manage'
|
||||
}
|
||||
]
|
||||
|
||||
return definitions
|
||||
.filter(module => !module.permissionCode || hasPermission(module.permissionCode))
|
||||
.map(module => {
|
||||
if (module.requireShopContext && isBootstrapAdmin.value) {
|
||||
if (module.requireShopContext && isBootstrapAdmin.value && !module.allowPlatformOverviewManage) {
|
||||
return {
|
||||
...module,
|
||||
allowed: false,
|
||||
disabledReason: '当前没有门店上下文,先进入店铺管理完成初始化或切换门店。'
|
||||
allowed: true,
|
||||
readonly: true,
|
||||
disabledReason: '平台总览模式下该模块仅可查看,编辑操作已关闭。'
|
||||
}
|
||||
}
|
||||
return {
|
||||
...module,
|
||||
allowed: true,
|
||||
readonly: false,
|
||||
disabledReason: ''
|
||||
}
|
||||
})
|
||||
|
||||
@@ -10,11 +10,23 @@
|
||||
|
||||
<a-card title="地图服务配置" :bordered="false">
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="腾讯位置服务 Key">
|
||||
<a-input-password v-model:value="mapForm.configValue" placeholder="请输入腾讯位置服务 Key" />
|
||||
<a-form-item label="当前地图渠道">
|
||||
<a-radio-group v-model:value="mapProvider">
|
||||
<a-radio-button value="TENCENT">腾讯地图</a-radio-button>
|
||||
<a-radio-button value="AMAP">高德地图</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="腾讯 Web Key">
|
||||
<a-input-password v-model:value="mapForms.tencentWeb.configValue" placeholder="用于后台腾讯地图选点和 Web 展示" />
|
||||
</a-form-item>
|
||||
<a-form-item label="高德 Web Key">
|
||||
<a-input-password v-model:value="mapForms.amapWeb.configValue" placeholder="用于后台高德地图选点和 Web 展示" />
|
||||
</a-form-item>
|
||||
<a-form-item label="高德小程序 Key">
|
||||
<a-input-password v-model:value="mapForms.amapMini.configValue" placeholder="用于后续小程序端高德 SDK / API 调用" />
|
||||
</a-form-item>
|
||||
<a-form-item label="备注">
|
||||
<a-textarea v-model:value="mapForm.remark" :rows="2" placeholder="例如:用于后台店铺选点和腾讯地图展示" />
|
||||
<a-textarea v-model:value="mapRemark" :rows="2" placeholder="例如:默认使用腾讯地图,高德小程序 Key 单独申请填写" />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
@@ -46,7 +58,7 @@
|
||||
<div class="muted">通道ID:{{ record.channelId || '由 MessageHub 自动选择' }}</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'enabled'">
|
||||
<a-switch :checked="record.enabled === 1" @change="checked => toggleStatus(record as MessageHubPushConfigVO, Boolean(checked))" />
|
||||
<a-switch :checked="record.enabled === 1" @change="(checked: any) => toggleStatus(record as MessageHubPushConfigVO, Boolean(checked))" />
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-space>
|
||||
@@ -122,13 +134,21 @@ const testPhone = ref('')
|
||||
const configs = ref<MessageHubPushConfigVO[]>([])
|
||||
const savingMap = ref(false)
|
||||
const mapEnabled = ref(true)
|
||||
const mapForm = reactive({
|
||||
const mapProvider = ref<'TENCENT' | 'AMAP'>('TENCENT')
|
||||
const mapRemark = ref('地图渠道由平台管理员选择;高德 Web Key 与高德小程序 Key 分开填写。')
|
||||
const createMapForm = (configKey: string, configName: string, remark: string) => ({
|
||||
configGroup: 'MAP',
|
||||
configKey: 'TENCENT_MAP_KEY',
|
||||
configName: '腾讯位置服务 Key',
|
||||
configKey,
|
||||
configName,
|
||||
configValue: '',
|
||||
enabled: 1,
|
||||
remark: '用于后台店铺选点和腾讯地图展示'
|
||||
remark
|
||||
})
|
||||
const mapForms = reactive({
|
||||
provider: createMapForm('MAP_PROVIDER', '当前地图渠道', 'TENCENT 或 AMAP;决定后台店铺选点默认使用哪个地图渠道'),
|
||||
tencentWeb: createMapForm('TENCENT_MAP_KEY', '腾讯 Web Key', '用于后台腾讯地图选点和 Web 展示'),
|
||||
amapWeb: createMapForm('AMAP_WEB_KEY', '高德 Web Key', '用于后台高德地图选点和 Web 展示'),
|
||||
amapMini: createMapForm('AMAP_MINI_KEY', '高德小程序 Key', '用于后续小程序端高德 SDK / API 调用')
|
||||
})
|
||||
|
||||
const sceneOptions = [
|
||||
@@ -177,11 +197,18 @@ const load = async () => {
|
||||
adminSystemParameterConfigApi.listConfigs('MAP')
|
||||
])
|
||||
configs.value = messageConfigs
|
||||
const providerConfig = mapConfigs.find(item => item.configKey === 'MAP_PROVIDER')
|
||||
const tencentMapConfig = mapConfigs.find(item => item.configKey === 'TENCENT_MAP_KEY')
|
||||
if (tencentMapConfig) {
|
||||
Object.assign(mapForm, tencentMapConfig)
|
||||
mapEnabled.value = tencentMapConfig.enabled === 1
|
||||
const amapWebConfig = mapConfigs.find(item => item.configKey === 'AMAP_WEB_KEY')
|
||||
const amapMiniConfig = mapConfigs.find(item => item.configKey === 'AMAP_MINI_KEY')
|
||||
if (providerConfig?.configValue) {
|
||||
mapProvider.value = providerConfig.configValue === 'AMAP' ? 'AMAP' : 'TENCENT'
|
||||
mapEnabled.value = providerConfig.enabled === 1
|
||||
Object.assign(mapForms.provider, providerConfig)
|
||||
}
|
||||
if (tencentMapConfig) Object.assign(mapForms.tencentWeb, tencentMapConfig)
|
||||
if (amapWebConfig) Object.assign(mapForms.amapWeb, amapWebConfig)
|
||||
if (amapMiniConfig) Object.assign(mapForms.amapMini, amapMiniConfig)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -191,7 +218,20 @@ const saveMapConfig = async () => {
|
||||
savingMap.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...mapForm,
|
||||
...mapForms.provider,
|
||||
configValue: mapProvider.value,
|
||||
enabled: mapEnabled.value ? 1 : 0
|
||||
})
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...mapForms.tencentWeb,
|
||||
enabled: mapEnabled.value ? 1 : 0
|
||||
})
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...mapForms.amapWeb,
|
||||
enabled: mapEnabled.value ? 1 : 0
|
||||
})
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...mapForms.amapMini,
|
||||
enabled: mapEnabled.value ? 1 : 0
|
||||
})
|
||||
message.success('地图配置已保存')
|
||||
|
||||
@@ -24,16 +24,44 @@
|
||||
v-model:value="keyword"
|
||||
class="admin-toolbar__grow"
|
||||
placeholder="搜索订单号、用户 ID 或优惠券"
|
||||
@search="noop"
|
||||
@search="loadOrders"
|
||||
/>
|
||||
<a-select
|
||||
v-model:value="statusFilter"
|
||||
:options="statusOptions"
|
||||
:style="isMobile ? { width: '100%' } : { width: '160px' }"
|
||||
@change="loadOrders"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="admin-filter-bar">
|
||||
<a-select
|
||||
v-model:value="shopFilter"
|
||||
:allow-clear="currentUserType === 4"
|
||||
placeholder="所属店铺"
|
||||
style="width: 180px"
|
||||
:loading="shopLoading"
|
||||
:disabled="currentUserType !== 4 && !!currentUserInfo?.shopId"
|
||||
@change="loadOrders"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="shop in shopList"
|
||||
:key="shop.id"
|
||||
:value="getShopOptionValue(shop)"
|
||||
>
|
||||
{{ shop.shopName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
<a-input v-model:value="artistKeyword" allow-clear placeholder="美甲师" style="width: 160px" @pressEnter="noop" />
|
||||
<a-input v-model:value="userKeyword" allow-clear placeholder="用户ID/客户" style="width: 160px" @pressEnter="noop" />
|
||||
<a-range-picker v-model:value="createRange" value-format="YYYY-MM-DD HH:mm:ss" show-time />
|
||||
<a-range-picker v-model:value="appointmentRange" value-format="YYYY-MM-DD HH:mm:ss" show-time />
|
||||
<a-input-number v-model:value="minAmount" :min="0" placeholder="最低金额" style="width: 120px" />
|
||||
<a-input-number v-model:value="maxAmount" :min="0" placeholder="最高金额" style="width: 120px" />
|
||||
<a-button @click="resetFilters">重置筛选</a-button>
|
||||
</div>
|
||||
|
||||
<a-table v-if="!isMobile" :columns="columns" :data-source="filteredOrders" :loading="loading" row-key="id">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'status'">
|
||||
@@ -191,7 +219,7 @@
|
||||
*/
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { orderApi } from '../../api/order'
|
||||
import { adminOrderApi, adminShopApi, type Shop } from '@/api/admin'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { sameId } from '@/utils/id'
|
||||
@@ -204,11 +232,29 @@ const { isMobile } = useAdminViewport()
|
||||
const orders = ref<any[]>([])
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
const loading = ref(false)
|
||||
const shopLoading = ref(false)
|
||||
const currentOrder = ref<any | null>(null)
|
||||
const currentUserType = ref<number | null>(null)
|
||||
const currentUserInfo = (() => {
|
||||
try {
|
||||
const cached = localStorage.getItem('adminUserInfo') || sessionStorage.getItem('adminUserInfo')
|
||||
return cached ? JSON.parse(cached) : null
|
||||
} catch (error) {
|
||||
console.error('获取当前用户信息失败', error)
|
||||
return null
|
||||
}
|
||||
})()
|
||||
/** keyword is a reactive state variable used by the template and event handlers. */
|
||||
const keyword = ref('')
|
||||
const statusFilter = ref<'all' | string>('all')
|
||||
const shopList = ref<Shop[]>([])
|
||||
const shopFilter = ref<string | undefined>()
|
||||
const artistKeyword = ref('')
|
||||
const userKeyword = ref('')
|
||||
const createRange = ref<[string, string] | undefined>()
|
||||
const appointmentRange = ref<[string, string] | undefined>()
|
||||
const minAmount = ref<number | undefined>()
|
||||
const maxAmount = ref<number | undefined>()
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
|
||||
/** detailVisible is a reactive state variable used by the template and event handlers. */
|
||||
@@ -235,6 +281,13 @@ const filteredOrders = computed(() => {
|
||||
if (!matchStatus) {
|
||||
return false
|
||||
}
|
||||
const actualAmount = Number(order.actualAmount ?? order.totalAmount ?? 0)
|
||||
if (minAmount.value !== undefined && actualAmount < minAmount.value) return false
|
||||
if (maxAmount.value !== undefined && actualAmount > maxAmount.value) return false
|
||||
if (!matchText(userKeyword.value, [order.userId, order.userNickname, order.customerName, order.customerPhone])) return false
|
||||
if (!matchText(artistKeyword.value, (order.items || []).map((item: any) => item.artistName || item.artistId))) return false
|
||||
if (!matchRange(order.createTime, createRange.value)) return false
|
||||
if (!matchRange((order.items || [])[0]?.appointmentTime, appointmentRange.value, (order.items || []).map((item: any) => item.appointmentTime))) return false
|
||||
if (!keywordValue) {
|
||||
return true
|
||||
}
|
||||
@@ -248,6 +301,37 @@ const filteredOrders = computed(() => {
|
||||
})
|
||||
})
|
||||
|
||||
const matchText = (needle: string, values: any[]) => {
|
||||
const normalized = needle.trim().toLowerCase()
|
||||
if (!normalized) return true
|
||||
return values.some(value => String(value ?? '').toLowerCase().includes(normalized))
|
||||
}
|
||||
|
||||
const matchRange = (value: string | undefined, range?: [string, string], candidates?: string[]) => {
|
||||
if (!range?.length) return true
|
||||
const values = candidates?.length ? candidates : [value]
|
||||
const start = new Date(range[0]).getTime()
|
||||
const end = new Date(range[1]).getTime()
|
||||
return values.some(item => {
|
||||
if (!item) return false
|
||||
const time = new Date(item).getTime()
|
||||
return time >= start && time <= end
|
||||
})
|
||||
}
|
||||
|
||||
const resetFilters = () => {
|
||||
keyword.value = ''
|
||||
statusFilter.value = 'all'
|
||||
shopFilter.value = currentUserType.value !== 4 ? normalizeShopId(currentUserInfo?.shopId) : undefined
|
||||
artistKeyword.value = ''
|
||||
userKeyword.value = ''
|
||||
createRange.value = undefined
|
||||
appointmentRange.value = undefined
|
||||
minAmount.value = undefined
|
||||
maxAmount.value = undefined
|
||||
void loadOrders()
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{ title: '订单编号', dataIndex: 'orderNo', key: 'orderNo' },
|
||||
{ title: '用户ID', dataIndex: 'userId', key: 'userId', width: 100 },
|
||||
@@ -277,17 +361,36 @@ const statusColor = (status: number) => {
|
||||
return 'default'
|
||||
}
|
||||
|
||||
const normalizeUserType = (value: unknown) => {
|
||||
const type = Number(value)
|
||||
return Number.isFinite(type) ? type : null
|
||||
}
|
||||
|
||||
/** resolveCurrentUserType is a local helper used by this page script. */
|
||||
const resolveCurrentUserType = () => {
|
||||
const cached = localStorage.getItem('adminUserInfo') || sessionStorage.getItem('adminUserInfo')
|
||||
if (!cached) {
|
||||
currentUserType.value = null
|
||||
return
|
||||
currentUserType.value = normalizeUserType(currentUserInfo?.type)
|
||||
}
|
||||
|
||||
const normalizeShopId = (value: unknown) => {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
return undefined
|
||||
}
|
||||
return String(value)
|
||||
}
|
||||
|
||||
const getShopOptionValue = (shop: Shop) => normalizeShopId((shop as any).id) || ''
|
||||
|
||||
const loadShopOptions = async () => {
|
||||
shopLoading.value = true
|
||||
try {
|
||||
currentUserType.value = JSON.parse(cached)?.type ?? null
|
||||
} catch {
|
||||
currentUserType.value = null
|
||||
shopList.value = await adminShopApi.listAllShops() as unknown as Shop[]
|
||||
if (currentUserType.value !== 4 && currentUserInfo?.shopId) {
|
||||
shopFilter.value = normalizeShopId(currentUserInfo.shopId)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败:', error)
|
||||
} finally {
|
||||
shopLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +398,15 @@ const resolveCurrentUserType = () => {
|
||||
const loadOrders = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
orders.value = await orderApi.getAllOrders() as unknown as any[]
|
||||
const scopedShopId = shopFilter.value || (currentUserType.value !== 4 ? normalizeShopId(currentUserInfo?.shopId) : undefined)
|
||||
const result = await adminOrderApi.listOrders({
|
||||
page: 1,
|
||||
size: 1000,
|
||||
keyword: keyword.value || undefined,
|
||||
status: statusFilter.value === 'all' ? undefined : Number(statusFilter.value),
|
||||
shopId: scopedShopId
|
||||
}) as unknown as { list?: any[] }
|
||||
orders.value = result.list || []
|
||||
} catch {
|
||||
message.error('获取订单列表失败')
|
||||
} finally {
|
||||
@@ -307,7 +418,7 @@ const loadOrders = async () => {
|
||||
const process = async (orderId: IdType, status: number) => {
|
||||
try {
|
||||
await runWithGlobalLoading(async () => {
|
||||
await orderApi.processOrder(orderId, status)
|
||||
await adminOrderApi.updateOrderStatus(orderId, status)
|
||||
await loadOrders()
|
||||
})
|
||||
message.success('操作成功')
|
||||
@@ -325,6 +436,7 @@ const noop = () => {}
|
||||
onMounted(async () => {
|
||||
resolveCurrentUserType()
|
||||
await loadUserPermissions()
|
||||
await loadShopOptions()
|
||||
await loadOrders()
|
||||
})
|
||||
</script>
|
||||
@@ -338,4 +450,11 @@ onMounted(async () => {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.admin-filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -31,6 +31,23 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="admin-filter-bar">
|
||||
<a-select v-model:value="shopFilter" allow-clear placeholder="所属店铺" style="width: 180px" @change="handleSearch">
|
||||
<a-select-option v-for="shop in shops" :key="shop.id" :value="shop.id">
|
||||
{{ shop.shopName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
<a-select v-model:value="tagFilter" allow-clear placeholder="标签" style="width: 160px" @change="handleSearch">
|
||||
<a-select-option v-for="tag in tags" :key="tag.id" :value="tag.id">
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
<a-input-number v-model:value="minPriceFilter" :min="0" placeholder="最低价" style="width: 120px" @pressEnter="handleSearch" />
|
||||
<a-input-number v-model:value="maxPriceFilter" :min="0" placeholder="最高价" style="width: 120px" @pressEnter="handleSearch" />
|
||||
<a-range-picker v-model:value="createdRange" value-format="YYYY-MM-DD HH:mm:ss" show-time @change="handleSearch" />
|
||||
<a-button @click="resetFilters">重置筛选</a-button>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
v-if="!isMobile"
|
||||
:columns="columns"
|
||||
@@ -514,6 +531,11 @@ const { isMobile } = useAdminViewport()
|
||||
const loading = ref(false)
|
||||
/** searchText is a reactive state variable used by the template and event handlers. */
|
||||
const searchText = ref('')
|
||||
const shopFilter = ref<IdType | undefined>()
|
||||
const tagFilter = ref<IdType | undefined>()
|
||||
const minPriceFilter = ref<number | undefined>()
|
||||
const maxPriceFilter = ref<number | undefined>()
|
||||
const createdRange = ref<[string, string] | undefined>()
|
||||
const productList = ref<Product[]>([])
|
||||
/** modalVisible is a reactive state variable used by the template and event handlers. */
|
||||
const modalVisible = ref(false)
|
||||
@@ -836,7 +858,13 @@ const fetchProductList = async () => {
|
||||
const params: any = {
|
||||
page: pagination.current,
|
||||
size: pagination.pageSize,
|
||||
keyword: searchText.value
|
||||
keyword: searchText.value,
|
||||
shopId: shopFilter.value,
|
||||
tagId: tagFilter.value,
|
||||
minPrice: minPriceFilter.value,
|
||||
maxPrice: maxPriceFilter.value,
|
||||
createdFrom: createdRange.value?.[0],
|
||||
createdTo: createdRange.value?.[1]
|
||||
}
|
||||
|
||||
if (currentUser && currentUser.type !== 4 && currentUser.shopId) {
|
||||
@@ -864,6 +892,16 @@ const fetchProductList = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const resetFilters = () => {
|
||||
searchText.value = ''
|
||||
shopFilter.value = undefined
|
||||
tagFilter.value = undefined
|
||||
minPriceFilter.value = undefined
|
||||
maxPriceFilter.value = undefined
|
||||
createdRange.value = undefined
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
/** loadImageUrls is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadImageUrls = async (products: Product[], requestToken?: number) => {
|
||||
const nextImageUrls: Record<string, string[]> = {}
|
||||
@@ -1495,4 +1533,11 @@ watch(() => formState.shopId, (newShopId) => {
|
||||
.coupon-actions {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.admin-filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<span class="admin-page-chip">权限 {{ permissionCount }}</span>
|
||||
<span class="admin-page-chip">门店 {{ shopOptions.length || 0 }}</span>
|
||||
<span class="admin-page-chip">{{ roleLabel }}</span>
|
||||
<span v-if="currentShopName === '游客模式'" class="admin-page-chip">游客模式</span>
|
||||
<span v-if="isPlatformOverview" class="admin-page-chip">平台总览</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -45,9 +45,12 @@
|
||||
</section>
|
||||
|
||||
<section class="admin-mobile-section-card">
|
||||
<div class="admin-mobile-section-card__title">门店切换</div>
|
||||
<div class="admin-mobile-section-card__title">{{ isPlatformOverview ? '管理范围' : '门店切换' }}</div>
|
||||
<div v-if="isPlatformOverview" class="profile-static-shop">
|
||||
平台总览模式,店铺业务仅可查看
|
||||
</div>
|
||||
<a-select
|
||||
v-if="shopOptions.length > 1"
|
||||
v-else-if="shopOptions.length > 1"
|
||||
v-model:value="selectedShopId"
|
||||
class="profile-shop-select"
|
||||
:options="shopSelectOptions"
|
||||
@@ -89,6 +92,7 @@ import {
|
||||
getAdminCurrentShopName,
|
||||
getAdminRoleLabel,
|
||||
getAdminShopOptions,
|
||||
isBootstrapAdminUser,
|
||||
loadCachedAdminUserInfo
|
||||
} from './admin-helpers'
|
||||
|
||||
@@ -104,18 +108,22 @@ const shopSwitchLoading = ref(false)
|
||||
|
||||
/** currentShopName is a reactive state variable used by the template and event handlers. */
|
||||
const currentShopName = computed(() => getAdminCurrentShopName(userInfo.value))
|
||||
const isPlatformOverview = computed(() => isBootstrapAdminUser(userInfo.value))
|
||||
/** roleLabel is a reactive state variable used by the template and event handlers. */
|
||||
const roleLabel = computed(() => getAdminRoleLabel(userInfo.value?.type))
|
||||
/** shopOptions is a reactive state variable used by the template and event handlers. */
|
||||
const shopOptions = computed(() => getAdminShopOptions(userInfo.value))
|
||||
/** shopSelectOptions is a reactive state variable used by the template and event handlers. */
|
||||
const shopSelectOptions = computed(() => shopOptions.value.map(shop => ({ label: shop.name, value: shop.id })))
|
||||
const shopSelectOptions = computed(() => {
|
||||
const options = shopOptions.value.map(shop => ({ label: shop.name, value: shop.id }))
|
||||
return options
|
||||
})
|
||||
/** permissionCount is a reactive state variable used by the template and event handlers. */
|
||||
const permissionCount = computed(() => userPermissions.value.length)
|
||||
/** shopScopeText is a reactive state variable used by the template and event handlers. */
|
||||
const shopScopeText = computed(() => {
|
||||
if (!shopOptions.value.length) {
|
||||
return '游客模式'
|
||||
return isPlatformOverview.value ? '平台总览模式' : '游客模式'
|
||||
}
|
||||
return shopOptions.value.map(item => item.name).join(' / ')
|
||||
})
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,74 +1,111 @@
|
||||
<template>
|
||||
<div class="system-messages admin-page">
|
||||
<a-page-header title="消息发布" sub-title="发布站内消息,支持文本和单张图片" />
|
||||
<section class="message-page-head">
|
||||
<a-page-header title="消息发布" sub-title="发布站内消息,支持文本和单张图片" />
|
||||
</section>
|
||||
|
||||
<a-card :bordered="false" class="admin-section-card">
|
||||
<template #title>发布消息</template>
|
||||
<a-form layout="vertical" :model="form">
|
||||
<a-form-item label="标题" required>
|
||||
<a-input v-model:value="form.title" :maxlength="100" placeholder="请输入消息标题" />
|
||||
</a-form-item>
|
||||
<a-form-item label="内容">
|
||||
<a-textarea v-model:value="form.content" :rows="5" :maxlength="2000" placeholder="请输入消息内容,可配合图片展示" />
|
||||
</a-form-item>
|
||||
<a-form-item label="消息图片">
|
||||
<div class="image-upload-row">
|
||||
<a-upload
|
||||
accept="image/*"
|
||||
list-type="picture-card"
|
||||
:show-upload-list="false"
|
||||
:custom-request="handleImageUpload"
|
||||
>
|
||||
<div v-if="!imagePreviewUrl" class="upload-placeholder">
|
||||
<span class="upload-plus">+</span>
|
||||
<span>上传图片</span>
|
||||
</div>
|
||||
<img v-else class="message-image-preview" :src="imagePreviewUrl" alt="消息图片预览" />
|
||||
</a-upload>
|
||||
<div class="image-upload-copy">
|
||||
<div>每条消息最多上传一张图片。</div>
|
||||
<small>建议使用 JPG/PNG/WebP,图片会在弹窗和通知详情中展示。</small>
|
||||
<a-button v-if="form.imageFileId" type="link" danger size="small" @click="removeImage">移除图片</a-button>
|
||||
<section class="message-composer-shell">
|
||||
<div class="message-composer-grid">
|
||||
<article class="message-editor-panel">
|
||||
<div class="panel-heading">
|
||||
<div class="panel-heading__icon">
|
||||
<SendOutlined />
|
||||
</div>
|
||||
<div>
|
||||
<p class="panel-eyebrow">站内消息</p>
|
||||
<h2>发布消息</h2>
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-row :gutter="16">
|
||||
<a-col :xs="24" :md="10">
|
||||
<a-form-item label="接收范围" required>
|
||||
<a-select v-model:value="form.targetType" @change="handleTargetTypeChange">
|
||||
<a-select-option v-for="item in targetTypes" :key="item.value" :value="item.value">
|
||||
{{ item.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
|
||||
<a-form layout="vertical" :model="form" class="message-form">
|
||||
<a-form-item label="标题" required>
|
||||
<a-input v-model:value="form.title" :maxlength="100" placeholder="请输入消息标题" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="needsShopSelection" :xs="24" :md="14">
|
||||
<a-form-item label="接收店铺" required>
|
||||
<a-select v-model:value="form.shopIds" mode="multiple" :options="shopOptions" placeholder="请选择店铺" />
|
||||
<a-form-item label="内容">
|
||||
<a-textarea v-model:value="form.content" :rows="6" :maxlength="2000" placeholder="请输入消息内容,可配合图片展示" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="form.targetType === 'SELECTED_USERS'" :xs="24" :md="14">
|
||||
<a-form-item label="接收用户" required>
|
||||
<a-select
|
||||
v-model:value="form.userIds"
|
||||
mode="multiple"
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
:options="userOptions"
|
||||
placeholder="请选择用户"
|
||||
/>
|
||||
<a-form-item label="消息图片">
|
||||
<div class="image-upload-row">
|
||||
<a-upload accept="image/*" list-type="picture-card" :show-upload-list="false" :custom-request="handleImageUpload">
|
||||
<div v-if="!imagePreviewUrl" class="upload-placeholder">
|
||||
<PictureOutlined />
|
||||
<span>上传图片</span>
|
||||
</div>
|
||||
<img v-else class="message-image-preview" :src="imagePreviewUrl" alt="消息图片预览" />
|
||||
</a-upload>
|
||||
<div class="image-upload-copy">
|
||||
<div>每条消息最多上传一张图片。</div>
|
||||
<small>建议使用 JPG/PNG/WebP,图片会在弹窗和通知详情中展示。</small>
|
||||
<a-button v-if="form.imageFileId" type="link" danger size="small" @click="removeImage">移除图片</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-form-item>
|
||||
<a-checkbox v-model:checked="popupEnabled">弹窗显示一次</a-checkbox>
|
||||
</a-form-item>
|
||||
<a-space>
|
||||
<a-button type="primary" :loading="saving" @click="handlePublish">发布</a-button>
|
||||
<a-button @click="resetForm">清空</a-button>
|
||||
</a-space>
|
||||
</a-form>
|
||||
</a-card>
|
||||
|
||||
<div class="scope-panel">
|
||||
<a-row :gutter="16">
|
||||
<a-col :xs="24" :md="10">
|
||||
<a-form-item label="接收范围" required>
|
||||
<a-select v-model:value="form.targetType" @change="handleTargetTypeChange">
|
||||
<a-select-option v-for="item in targetTypes" :key="item.value" :value="item.value">
|
||||
{{ item.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="needsShopSelection" :xs="24" :md="14">
|
||||
<a-form-item label="接收店铺" required>
|
||||
<a-select v-model:value="form.shopIds" mode="multiple" :options="shopOptions" placeholder="请选择店铺" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="form.targetType === 'SELECTED_USERS'" :xs="24" :md="14">
|
||||
<a-form-item label="接收用户" required>
|
||||
<a-select
|
||||
v-model:value="form.userIds"
|
||||
mode="multiple"
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
:options="userOptions"
|
||||
placeholder="请选择用户"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<div class="publish-footer">
|
||||
<a-checkbox v-model:checked="popupEnabled" class="popup-checkbox">弹窗显示一次</a-checkbox>
|
||||
<a-space>
|
||||
<a-button @click="resetForm">清空</a-button>
|
||||
<a-button type="primary" :loading="saving" @click="handlePublish">
|
||||
<template #icon>
|
||||
<SendOutlined />
|
||||
</template>
|
||||
发布
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</a-form>
|
||||
</article>
|
||||
|
||||
<aside class="message-preview-panel">
|
||||
<SystemMessageCard
|
||||
:title="previewTitle"
|
||||
:content="previewContent"
|
||||
:image-url="imagePreviewUrl"
|
||||
:meta="previewMeta"
|
||||
surface="preview"
|
||||
footer-align="end"
|
||||
>
|
||||
<template #footer>
|
||||
<button class="preview-read-button" type="button" tabindex="-1">
|
||||
<CheckOutlined />
|
||||
我知道了
|
||||
</button>
|
||||
</template>
|
||||
</SystemMessageCard>
|
||||
</aside>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<a-card :bordered="false" class="admin-section-card">
|
||||
<template #title>发布记录</template>
|
||||
@@ -96,40 +133,48 @@
|
||||
</a-table>
|
||||
</a-card>
|
||||
|
||||
<a-modal v-model:open="previewVisible" title="消息详情" :footer="null" width="620px">
|
||||
<h3>{{ currentMessage?.title }}</h3>
|
||||
<p class="message-meta">{{ currentMessage?.publisherName }} · {{ currentMessage?.targetTypeName }} · {{ currentMessage?.publishTime }}</p>
|
||||
<div v-if="currentMessage?.content" class="message-content">{{ currentMessage?.content }}</div>
|
||||
<img v-if="currentMessage?.imageUrl" class="detail-image" :src="currentMessage.imageUrl" alt="消息图片" />
|
||||
<a-modal v-model:open="previewVisible" :footer="null" width="560px" wrap-class-name="message-detail-modal-wrap">
|
||||
<SystemMessageCard
|
||||
:title="currentMessage?.title || '消息详情'"
|
||||
:content="currentMessage?.content || ''"
|
||||
:image-url="currentMessage?.imageUrl || ''"
|
||||
:meta="currentMessageMeta"
|
||||
surface="modal"
|
||||
footer-align="end"
|
||||
>
|
||||
<template #footer>
|
||||
<a-button type="primary" class="message-detail-close-button" @click="previewVisible = false">
|
||||
<template #icon>
|
||||
<CheckOutlined />
|
||||
</template>
|
||||
我知道了
|
||||
</a-button>
|
||||
</template>
|
||||
</SystemMessageCard>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* SystemMessagesView 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, reactive, ref } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { adminFileApi, adminSystemMessageApi, type SystemMessageVO, type SystemMessageCreateRequest } from '@/api/admin'
|
||||
import {
|
||||
CheckOutlined,
|
||||
PictureOutlined,
|
||||
SendOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import SystemMessageCard from '@/components/SystemMessageCard.vue'
|
||||
import { adminFileApi, adminSystemMessageApi, type SystemMessageCreateRequest, type SystemMessageVO } from '@/api/admin'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
const loading = ref(false)
|
||||
/** saving is a reactive state variable used by the template and event handlers. */
|
||||
const saving = ref(false)
|
||||
/** imageUploading is a reactive state variable used by the template and event handlers. */
|
||||
const imageUploading = ref(false)
|
||||
const messages = ref<SystemMessageVO[]>([])
|
||||
/** targetOptions is a reactive state variable used by the template and event handlers. */
|
||||
const targetOptions = ref({ shops: [] as any[], users: [] as any[] })
|
||||
/** popupEnabled is a reactive state variable used by the template and event handlers. */
|
||||
const popupEnabled = ref(true)
|
||||
/** previewVisible is a reactive state variable used by the template and event handlers. */
|
||||
const previewVisible = ref(false)
|
||||
const currentMessage = ref<SystemMessageVO | null>(null)
|
||||
/** imagePreviewUrl is a reactive state variable used by the template and event handlers. */
|
||||
const imagePreviewUrl = ref('')
|
||||
|
||||
const form = reactive<SystemMessageCreateRequest>({
|
||||
@@ -142,26 +187,36 @@ const form = reactive<SystemMessageCreateRequest>({
|
||||
popupEnabled: 1
|
||||
})
|
||||
|
||||
/** targetTypes is a reactive state variable used by the template and event handlers. */
|
||||
const targetTypes = computed(() => {
|
||||
const shopCount = targetOptions.value.shops.length
|
||||
const hasPlatformScope = shopCount > 1
|
||||
return [
|
||||
...(hasPlatformScope ? [{ label: '全平台', value: 'PLATFORM_ALL' }] : []),
|
||||
{ label: hasPlatformScope ? '指定店铺全员' : '本店全员', value: hasPlatformScope ? 'SELECTED_SHOPS' : 'CURRENT_SHOP_ALL' },
|
||||
{ label: '指定用户', value: 'SELECTED_USERS' }
|
||||
]
|
||||
const currentAdminUser = computed(() => {
|
||||
try {
|
||||
const cache = localStorage.getItem('adminUserInfo') || sessionStorage.getItem('adminUserInfo')
|
||||
return cache ? JSON.parse(cache) : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
})
|
||||
|
||||
/** needsShopSelection is a reactive state variable used by the template and event handlers. */
|
||||
const isPlatformAdmin = computed(() => Number(currentAdminUser.value?.type) === 4)
|
||||
const targetTypes = computed(() => [
|
||||
...(isPlatformAdmin.value ? [{ label: '全平台', value: 'PLATFORM_ALL' }] : []),
|
||||
{ label: isPlatformAdmin.value ? '指定店铺全员' : '本店全员', value: isPlatformAdmin.value ? 'SELECTED_SHOPS' : 'CURRENT_SHOP_ALL' },
|
||||
{ label: '指定用户', value: 'SELECTED_USERS' }
|
||||
])
|
||||
const needsShopSelection = computed(() => form.targetType === 'SELECTED_SHOPS' || form.targetType === 'SHOP_ALL')
|
||||
/** shopOptions is a reactive state variable used by the template and event handlers. */
|
||||
const shopOptions = computed(() => targetOptions.value.shops.map(shop => ({ label: shop.shopName, value: shop.id })))
|
||||
/** userOptions is a reactive state variable used by the template and event handlers. */
|
||||
const userOptions = computed(() => targetOptions.value.users.map(user => ({
|
||||
label: `${user.nickname || user.account} ${user.shopName ? `(${user.shopName})` : ''}`,
|
||||
value: user.id
|
||||
})))
|
||||
const previewTitle = computed(() => form.title.trim() || '消息标题预览')
|
||||
const previewContent = computed(() => form.content.trim() || (imagePreviewUrl.value ? '' : '这里会显示消息正文。支持纯文本,也可以配合一张图片展示给用户。'))
|
||||
const previewMeta = computed(() => `系统消息 · ${popupEnabled.value ? '弹窗预览' : '列表预览'}`)
|
||||
const currentMessageMeta = computed(() => {
|
||||
if (!currentMessage.value) return ''
|
||||
return [
|
||||
currentMessage.value.publisherName || '系统消息',
|
||||
currentMessage.value.publishTime || currentMessage.value.createTime
|
||||
].filter(Boolean).join(' · ')
|
||||
})
|
||||
|
||||
const columns = [
|
||||
{ title: '标题', dataIndex: 'title', key: 'title' },
|
||||
@@ -174,7 +229,15 @@ const columns = [
|
||||
{ title: '操作', key: 'action', width: 120 }
|
||||
]
|
||||
|
||||
/** loadData is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const syncDefaultTargetType = () => {
|
||||
if (isPlatformAdmin.value && form.targetType === 'CURRENT_SHOP_ALL') {
|
||||
form.targetType = 'PLATFORM_ALL'
|
||||
}
|
||||
if (!isPlatformAdmin.value && form.targetType === 'PLATFORM_ALL') {
|
||||
form.targetType = 'CURRENT_SHOP_ALL'
|
||||
}
|
||||
}
|
||||
|
||||
const loadData = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -184,9 +247,7 @@ const loadData = async () => {
|
||||
])
|
||||
messages.value = messageList || []
|
||||
targetOptions.value = options || { shops: [], users: [] }
|
||||
if (targetOptions.value.shops.length > 1 && form.targetType === 'CURRENT_SHOP_ALL') {
|
||||
form.targetType = 'PLATFORM_ALL'
|
||||
}
|
||||
syncDefaultTargetType()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '消息数据加载失败')
|
||||
} finally {
|
||||
@@ -194,31 +255,27 @@ const loadData = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** handleTargetTypeChange is a local helper used by this page script. */
|
||||
const handleTargetTypeChange = () => {
|
||||
form.shopIds = []
|
||||
form.userIds = []
|
||||
}
|
||||
|
||||
/** removeImage is a local helper used by this page script. */
|
||||
const removeImage = () => {
|
||||
form.imageFileId = undefined
|
||||
imagePreviewUrl.value = ''
|
||||
}
|
||||
|
||||
/** resetForm is a local helper used by this page script. */
|
||||
const resetForm = () => {
|
||||
form.title = ''
|
||||
form.content = ''
|
||||
form.imageFileId = undefined
|
||||
form.targetType = targetOptions.value.shops.length > 1 ? 'PLATFORM_ALL' : 'CURRENT_SHOP_ALL'
|
||||
form.targetType = isPlatformAdmin.value ? 'PLATFORM_ALL' : 'CURRENT_SHOP_ALL'
|
||||
form.shopIds = []
|
||||
form.userIds = []
|
||||
popupEnabled.value = true
|
||||
imagePreviewUrl.value = ''
|
||||
}
|
||||
|
||||
/** handleImageUpload is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleImageUpload = async (options: any) => {
|
||||
const file = options.file as File
|
||||
if (!file?.type?.startsWith('image/')) {
|
||||
@@ -245,7 +302,6 @@ const handleImageUpload = async (options: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
/** handlePublish is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handlePublish = async () => {
|
||||
if (!form.title.trim()) return message.warning('请填写消息标题')
|
||||
if (!form.content.trim() && !form.imageFileId) return message.warning('请填写消息内容或上传消息图片')
|
||||
@@ -265,14 +321,12 @@ const handlePublish = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** handleRevoke is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleRevoke = async (id: IdType) => {
|
||||
await adminSystemMessageApi.revokeMessage(id)
|
||||
message.success('消息已撤回')
|
||||
await loadData()
|
||||
}
|
||||
|
||||
/** previewMessage is a local helper used by this page script. */
|
||||
const previewMessage = (record: SystemMessageVO) => {
|
||||
currentMessage.value = record
|
||||
previewVisible.value = true
|
||||
@@ -283,11 +337,177 @@ onMounted(loadData)
|
||||
|
||||
<style scoped>
|
||||
.system-messages {
|
||||
padding: 16px;
|
||||
padding: 18px;
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.message-page-head {
|
||||
max-width: 1120px;
|
||||
margin: 0 auto 12px;
|
||||
}
|
||||
|
||||
.message-page-head :deep(.ant-page-header) {
|
||||
padding: 0 0 12px;
|
||||
}
|
||||
|
||||
.message-page-head :deep(.ant-page-header-heading-title) {
|
||||
color: #33232d;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.message-composer-shell {
|
||||
max-width: 1120px;
|
||||
margin: 0 auto 24px;
|
||||
}
|
||||
|
||||
.message-composer-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
|
||||
gap: 22px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.message-editor-panel,
|
||||
.message-preview-panel {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.message-editor-panel {
|
||||
padding: 24px;
|
||||
border: 1px solid rgba(245, 203, 218, 0.9);
|
||||
border-radius: 22px;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
box-shadow: 0 18px 48px rgba(198, 89, 125, 0.12);
|
||||
}
|
||||
|
||||
.panel-heading {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: center;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
.panel-heading__icon {
|
||||
display: grid;
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
flex: 0 0 auto;
|
||||
place-items: center;
|
||||
border-radius: 14px;
|
||||
color: #ffffff;
|
||||
font-size: 20px;
|
||||
background: linear-gradient(135deg, #c6597d 0%, #e9b7c7 100%);
|
||||
box-shadow: 0 12px 24px rgba(198, 89, 125, 0.24);
|
||||
}
|
||||
|
||||
.panel-eyebrow {
|
||||
margin: 0 0 4px;
|
||||
color: #a45771;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.panel-heading h2 {
|
||||
margin: 0;
|
||||
color: #312330;
|
||||
font-size: 22px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.message-form :deep(.ant-form-item-label > label) {
|
||||
color: #4a3a44;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.message-form :deep(.ant-input),
|
||||
.message-form :deep(.ant-input-number),
|
||||
.message-form :deep(.ant-select-selector),
|
||||
.message-form :deep(.ant-input-affix-wrapper) {
|
||||
border-color: #f1d6df;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.message-form :deep(.ant-input:focus),
|
||||
.message-form :deep(.ant-input-focused),
|
||||
.message-form :deep(.ant-select-focused .ant-select-selector),
|
||||
.message-form :deep(.ant-input-affix-wrapper-focused) {
|
||||
border-color: #c6597d;
|
||||
box-shadow: 0 0 0 3px rgba(198, 89, 125, 0.12);
|
||||
}
|
||||
|
||||
.scope-panel {
|
||||
padding: 16px 16px 0;
|
||||
margin-bottom: 18px;
|
||||
border: 1px solid rgba(246, 205, 219, 0.9);
|
||||
border-radius: 16px;
|
||||
background: #fff8fa;
|
||||
}
|
||||
|
||||
.publish-footer {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-top: 18px;
|
||||
border-top: 1px solid #f5dbe4;
|
||||
}
|
||||
|
||||
.popup-checkbox {
|
||||
color: #5c4b55;
|
||||
}
|
||||
|
||||
.message-preview-panel {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
--theme-primary: #c6597d;
|
||||
--theme-secondary: #e9b7c7;
|
||||
--theme-accent: #9f4967;
|
||||
--theme-primary-soft: #f8edf1;
|
||||
--theme-card-bg: #ffffff;
|
||||
--theme-border: #efd4dd;
|
||||
--theme-gradient: linear-gradient(135deg, #c6597d 0%, #e9b7c7 100%);
|
||||
--theme-gradient-soft: linear-gradient(145deg, #ffffff 0%, #fff7f9 58%, #f8edf1 100%);
|
||||
--theme-button-shadow: 0 12px 28px rgba(198, 89, 125, 0.22);
|
||||
--text-primary: #2d2430;
|
||||
--text-secondary: #7a6871;
|
||||
}
|
||||
|
||||
.message-preview-panel :deep(.system-message-card) {
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.preview-read-button {
|
||||
display: inline-flex;
|
||||
min-height: 40px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 0 18px;
|
||||
border: 0;
|
||||
border-radius: 12px;
|
||||
color: #ffffff;
|
||||
font-weight: 700;
|
||||
background: var(--theme-gradient);
|
||||
box-shadow: var(--theme-button-shadow);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.admin-section-card {
|
||||
max-width: 1120px;
|
||||
margin-bottom: 16px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
border: 1px solid rgba(246, 205, 219, 0.75);
|
||||
border-radius: 18px;
|
||||
box-shadow: 0 18px 42px rgba(198, 89, 125, 0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin-section-card :deep(.ant-card-head) {
|
||||
color: #7a4058;
|
||||
background: linear-gradient(135deg, #fff7f9 0%, #ffe8ef 100%);
|
||||
}
|
||||
|
||||
.image-upload-row {
|
||||
@@ -299,15 +519,11 @@ onMounted(loadData)
|
||||
.upload-placeholder {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
place-items: center;
|
||||
color: #8a7b83;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.upload-plus {
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.message-image-preview {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -321,30 +537,92 @@ onMounted(loadData)
|
||||
}
|
||||
|
||||
.image-upload-copy small,
|
||||
.message-meta,
|
||||
.muted {
|
||||
color: #7f7781;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
white-space: pre-wrap;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.detail-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: 420px;
|
||||
margin-top: 14px;
|
||||
object-fit: contain;
|
||||
border-radius: 8px;
|
||||
background: #f7f2f4;
|
||||
}
|
||||
|
||||
.table-image {
|
||||
overflow: hidden;
|
||||
border-radius: 6px;
|
||||
object-fit: cover;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
:global(.message-detail-modal-wrap .ant-modal-content) {
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:global(.message-detail-modal-wrap .ant-modal-body) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
:global(.message-detail-modal-wrap .system-message-card) {
|
||||
--theme-primary: #c6597d;
|
||||
--theme-secondary: #e9b7c7;
|
||||
--theme-accent: #9f4967;
|
||||
--theme-primary-soft: #f8edf1;
|
||||
--theme-card-bg: #ffffff;
|
||||
--theme-border: #efd4dd;
|
||||
--theme-gradient: linear-gradient(135deg, #c6597d 0%, #e9b7c7 100%);
|
||||
--theme-gradient-soft: linear-gradient(145deg, #ffffff 0%, #fff7f9 58%, #f8edf1 100%);
|
||||
--theme-button-shadow: 0 12px 28px rgba(198, 89, 125, 0.22);
|
||||
--text-primary: #2d2430;
|
||||
--text-secondary: #7a6871;
|
||||
}
|
||||
|
||||
:global(.message-detail-modal-wrap .ant-modal-close) {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
:global(.message-detail-modal-wrap .message-detail-close-button) {
|
||||
border: 0;
|
||||
border-radius: 12px;
|
||||
color: #ffffff;
|
||||
font-weight: 700;
|
||||
background: var(--theme-gradient);
|
||||
box-shadow: var(--theme-button-shadow);
|
||||
}
|
||||
|
||||
:global(.message-detail-modal-wrap .message-detail-close-button:hover),
|
||||
:global(.message-detail-modal-wrap .message-detail-close-button:focus) {
|
||||
color: #ffffff;
|
||||
background: var(--theme-gradient);
|
||||
filter: brightness(0.98);
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.message-composer-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.message-preview-panel :deep(.system-message-card) {
|
||||
max-width: 640px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.system-messages {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.message-editor-panel {
|
||||
border-radius: 18px;
|
||||
}
|
||||
|
||||
.image-upload-row,
|
||||
.publish-footer {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.publish-footer :deep(.ant-space) {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.preview-read-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -31,6 +31,49 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="admin-filter-bar">
|
||||
<a-select
|
||||
v-model:value="shopFilter"
|
||||
:allow-clear="currentUserType === 4"
|
||||
placeholder="所属店铺"
|
||||
style="width: 180px"
|
||||
:loading="shopLoading"
|
||||
:disabled="currentUserType !== 4 && !!currentUserInfo?.shopId"
|
||||
@change="handleSearch"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="shop in shopList"
|
||||
:key="shop.id"
|
||||
:value="getShopOptionValue(shop)"
|
||||
>
|
||||
{{ shop.shopName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
<a-select v-model:value="typeFilter" allow-clear placeholder="用户类型" style="width: 140px" @change="handleSearch">
|
||||
<a-select-option :value="0">普通用户</a-select-option>
|
||||
<a-select-option :value="2">店长</a-select-option>
|
||||
<a-select-option :value="3">美甲师</a-select-option>
|
||||
<a-select-option :value="4">管理员</a-select-option>
|
||||
</a-select>
|
||||
<a-select v-model:value="vipLevelFilter" allow-clear placeholder="VIP等级" style="width: 140px" @change="handleSearch">
|
||||
<a-select-option v-for="level in vipLevelOptions" :key="level" :value="level">{{ level }}</a-select-option>
|
||||
</a-select>
|
||||
<a-select v-model:value="statusFilter" allow-clear placeholder="账号状态" style="width: 140px" @change="handleSearch">
|
||||
<a-select-option :value="1">启用</a-select-option>
|
||||
<a-select-option :value="0">停用</a-select-option>
|
||||
</a-select>
|
||||
<a-range-picker v-model:value="createdRange" value-format="YYYY-MM-DD HH:mm:ss" show-time @change="handleSearch" />
|
||||
<a-select v-model:value="hasPhoneFilter" allow-clear placeholder="手机号" style="width: 130px" @change="handleSearch">
|
||||
<a-select-option value="true">有手机号</a-select-option>
|
||||
<a-select-option value="false">无手机号</a-select-option>
|
||||
</a-select>
|
||||
<a-select v-model:value="hasOrderFilter" allow-clear placeholder="订单情况" style="width: 130px" @change="handleSearch">
|
||||
<a-select-option value="true">有订单</a-select-option>
|
||||
<a-select-option value="false">无订单</a-select-option>
|
||||
</a-select>
|
||||
<a-button @click="resetFilters">重置筛选</a-button>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
v-if="!isMobile"
|
||||
:columns="columns"
|
||||
@@ -206,9 +249,9 @@
|
||||
<a-select
|
||||
v-model:value="formState.shopIds"
|
||||
mode="multiple"
|
||||
:placeholder="currentUserType === 4 ? '请选择一个或多个店铺' : '请选择店铺'"
|
||||
:placeholder="Number(formState.type) === 4 ? '平台管理员无需绑定店铺' : (currentUserType === 4 ? '请选择一个或多个店铺' : '请选择店铺')"
|
||||
:loading="shopLoading"
|
||||
:disabled="currentUserType !== 4 && !!currentUserInfo?.shopId"
|
||||
:disabled="Number(formState.type) === 4 || (currentUserType !== 4 && !!currentUserInfo?.shopId)"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="shop in shopList"
|
||||
@@ -364,10 +407,7 @@
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="目标等级">
|
||||
<a-select v-model:value="vipForm.vipLevel">
|
||||
<a-select-option value="普通">普通</a-select-option>
|
||||
<a-select-option value="青铜">青铜</a-select-option>
|
||||
<a-select-option value="白银">白银</a-select-option>
|
||||
<a-select-option value="黄金">黄金</a-select-option>
|
||||
<a-select-option v-for="level in vipLevelOptions" :key="level" :value="level">{{ level }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注">
|
||||
@@ -461,6 +501,7 @@ import { userApi, type AvailabilityCheckResponse } from '@/api/user'
|
||||
import {
|
||||
adminShopApi,
|
||||
adminUserApi,
|
||||
adminVipRechargePlanApi,
|
||||
type AdminUserBalanceChangeRequest,
|
||||
type AdminUserVipOverrideRequest,
|
||||
type Shop,
|
||||
@@ -511,9 +552,17 @@ const viewModalVisible = ref(false)
|
||||
const isEdit = ref(false)
|
||||
/** searchText is a reactive state variable used by the template and event handlers. */
|
||||
const searchText = ref('')
|
||||
const shopFilter = ref<string | undefined>()
|
||||
const typeFilter = ref<number | undefined>()
|
||||
const vipLevelFilter = ref<string | undefined>()
|
||||
const statusFilter = ref<number | undefined>()
|
||||
const createdRange = ref<[string, string] | undefined>()
|
||||
const hasPhoneFilter = ref<'true' | 'false' | undefined>()
|
||||
const hasOrderFilter = ref<'true' | 'false' | undefined>()
|
||||
const formRef = ref<FormInstance>()
|
||||
const userList = ref<UserVO[]>([])
|
||||
const shopList = ref<Shop[]>([])
|
||||
const vipLevelOptions = ref<string[]>(['普通', '青铜', '白银', '黄金'])
|
||||
const currentUser = ref<UserVO | null>(null)
|
||||
const viewRecord = ref<UserVO | null>(null)
|
||||
const draftSavedAt = ref<number | null>(null)
|
||||
@@ -743,9 +792,15 @@ const formRules = {
|
||||
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
||||
shopIds: [{
|
||||
validator: async (_rule: unknown, value: string[]) => {
|
||||
if (Number(formState.type) === 4) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
if (Array.isArray(value) && value.length > 0) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
if (currentUserType.value === 4 && shopList.value.length === 0) {
|
||||
return Promise.reject('请先新增店铺后再创建店铺用户')
|
||||
}
|
||||
return Promise.reject('请选择至少一个店铺')
|
||||
},
|
||||
trigger: 'change'
|
||||
@@ -933,6 +988,7 @@ const fetchShopList = async () => {
|
||||
const shops = await adminShopApi.listAllShops() as unknown as Shop[]
|
||||
shopList.value = shops || []
|
||||
if (currentUserType.value !== 4 && currentUserInfo?.shopId) {
|
||||
shopFilter.value = normalizeShopId(currentUserInfo.shopId)
|
||||
formState.shopIds = [normalizeShopId(currentUserInfo.shopId)!]
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -949,11 +1005,19 @@ const fetchUserList = async () => {
|
||||
const params: Record<string, unknown> = {
|
||||
page: pagination.current,
|
||||
size: pagination.pageSize,
|
||||
keyword: searchText.value || undefined
|
||||
keyword: searchText.value || undefined,
|
||||
type: typeFilter.value,
|
||||
vipLevel: vipLevelFilter.value,
|
||||
status: statusFilter.value,
|
||||
createdFrom: createdRange.value?.[0],
|
||||
createdTo: createdRange.value?.[1],
|
||||
hasPhone: hasPhoneFilter.value === undefined ? undefined : hasPhoneFilter.value === 'true',
|
||||
hasOrder: hasOrderFilter.value === undefined ? undefined : hasOrderFilter.value === 'true'
|
||||
}
|
||||
|
||||
if (currentUserInfo?.shopId) {
|
||||
params.shopId = currentUserInfo.shopId
|
||||
const scopedShopId = shopFilter.value || (currentUserType.value !== 4 ? normalizeShopId(currentUserInfo?.shopId) : undefined)
|
||||
if (scopedShopId) {
|
||||
params.shopId = scopedShopId
|
||||
}
|
||||
|
||||
const res = await adminUserApi.listUsers(params as any)
|
||||
@@ -968,14 +1032,30 @@ const fetchUserList = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const resetFilters = () => {
|
||||
searchText.value = ''
|
||||
shopFilter.value = currentUserType.value !== 4 ? normalizeShopId(currentUserInfo?.shopId) : undefined
|
||||
typeFilter.value = undefined
|
||||
vipLevelFilter.value = undefined
|
||||
statusFilter.value = undefined
|
||||
createdRange.value = undefined
|
||||
hasPhoneFilter.value = undefined
|
||||
hasOrderFilter.value = undefined
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
/** resetFormState is a local helper used by this page script. */
|
||||
const resetFormState = () => {
|
||||
const defaultUserType = currentUserType.value === 4 && shopList.value.length === 0
|
||||
? availableUserTypeOptions.value.find(option => option.value === 4)?.value
|
||||
: availableUserTypeOptions.value[0]?.value
|
||||
|
||||
Object.assign(formState, {
|
||||
account: '',
|
||||
nickname: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
type: availableUserTypeOptions.value[0]?.value ?? 0,
|
||||
type: defaultUserType ?? 0,
|
||||
shopIds: currentUserType.value !== 4 && currentUserInfo?.shopId
|
||||
? [normalizeShopId(currentUserInfo.shopId)!]
|
||||
: []
|
||||
@@ -1130,13 +1210,14 @@ const handleModalOk = async () => {
|
||||
await formRef.value?.validate()
|
||||
modalLoading.value = true
|
||||
await runWithGlobalLoading(async () => {
|
||||
const requestShopIds = Number(formState.type) === 4 ? [] : formState.shopIds
|
||||
const requestData: Record<string, unknown> = {
|
||||
account: formState.account.trim(),
|
||||
nickname: formState.nickname.trim(),
|
||||
phone: formState.phone.trim(),
|
||||
type: formState.type,
|
||||
shopIds: formState.shopIds,
|
||||
shopId: formState.shopIds.length ? formState.shopIds[0] : undefined,
|
||||
shopIds: requestShopIds,
|
||||
shopId: requestShopIds.length ? requestShopIds[0] : undefined,
|
||||
...(formState.password.trim() ? { password: formState.password.trim() } : {})
|
||||
}
|
||||
|
||||
@@ -1384,9 +1465,27 @@ const handleVipRecalculate = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const fetchVipLevelOptions = async () => {
|
||||
try {
|
||||
const levels = await adminVipRechargePlanApi.listVipLevelOptions(currentUserInfo?.shopId)
|
||||
if (Array.isArray(levels) && levels.length) {
|
||||
vipLevelOptions.value = ['普通', ...levels.filter(level => level !== '普通')]
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('VIP 等级选项加载失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => formState.type, type => {
|
||||
if (Number(type) === 4) {
|
||||
formState.shopIds = []
|
||||
formRef.value?.clearValidate?.(['shopIds'])
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
await loadUserPermissions()
|
||||
await fetchShopList()
|
||||
await Promise.all([fetchShopList(), fetchVipLevelOptions()])
|
||||
await fetchUserList()
|
||||
})
|
||||
</script>
|
||||
@@ -1402,6 +1501,13 @@ onMounted(async () => {
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.admin-filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.mobile-user-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
充 {{ money(record.rechargeAmount) }} 送 {{ money(record.giftAmount) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'status'">
|
||||
<a-switch :checked="record.status === 1" @change="checked => toggleStatus(record as VipRechargePlanVO, Boolean(checked))" />
|
||||
<a-switch :checked="record.status === 1" @change="(checked: any) => toggleStatus(record as VipRechargePlanVO, Boolean(checked))" />
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-button size="small" @click="openEdit(record as VipRechargePlanVO)">编辑</a-button>
|
||||
@@ -37,7 +37,10 @@
|
||||
<a-input-number v-model:value="form.giftAmount" :min="0" :precision="2" style="width: 100%" />
|
||||
</a-form-item>
|
||||
<a-form-item label="对应 VIP 等级">
|
||||
<a-input v-model:value="form.vipLevel" placeholder="如 青铜VIP / 白银VIP / 黄金VIP" />
|
||||
<a-input v-model:value="form.vipLevel" placeholder="如 青铜 / 白银 / 黄金,也可以输入自定义等级" />
|
||||
<div class="level-shortcuts">
|
||||
<a-tag v-for="level in vipLevelOptions" :key="level" @click="form.vipLevel = level">{{ level }}</a-tag>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="展示说明">
|
||||
<a-textarea v-model:value="form.description" :rows="3" />
|
||||
@@ -68,6 +71,7 @@ const formOpen = ref(false)
|
||||
const editingId = ref<any>()
|
||||
const plans = ref<VipRechargePlanVO[]>([])
|
||||
const shops = ref<Shop[]>([])
|
||||
const vipLevelOptions = ref<string[]>(['普通', '青铜', '白银', '黄金'])
|
||||
const form = reactive<any>({ shopId: undefined, title: '', rechargeAmount: 0, giftAmount: 0, vipLevel: '', description: '', sortOrder: 0, status: 1 })
|
||||
|
||||
const columns = [
|
||||
@@ -93,6 +97,8 @@ const load = async () => {
|
||||
adminShopApi.listAllShops().catch(() => [])
|
||||
])
|
||||
plans.value = planList || []
|
||||
const configuredLevels = Array.from(new Set(plans.value.map(item => item.vipLevel).filter(Boolean)))
|
||||
vipLevelOptions.value = Array.from(new Set(['普通', '青铜', '白银', '黄金', ...configuredLevels]))
|
||||
shops.value = shopList || []
|
||||
shopOptions.value = shops.value.map(item => ({ label: item.shopName, value: item.id }))
|
||||
} finally {
|
||||
@@ -146,4 +152,6 @@ onMounted(load)
|
||||
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
|
||||
.page-head h2 { margin: 0 0 4px; }
|
||||
.page-head p { margin: 0; color: #7a6f68; }
|
||||
.level-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
|
||||
.level-shortcuts :deep(.ant-tag) { cursor: pointer; }
|
||||
</style>
|
||||
|
||||
@@ -26,4 +26,4 @@ export const getAdminShopOptions = (userInfo?: AdminCachedUserInfo | null) => {
|
||||
}
|
||||
|
||||
export const getAdminCurrentShopName = (userInfo?: AdminCachedUserInfo | null) =>
|
||||
userInfo?.shopName || '游客模式'
|
||||
userInfo?.shopName || (isBootstrapAdminUser(userInfo) ? '平台总览模式' : '游客模式')
|
||||
|
||||
Reference in New Issue
Block a user