功能(网页):新增客户体验流程
This commit is contained in:
@@ -491,6 +491,10 @@ export interface Tag {
|
||||
textColor?: string
|
||||
bgColor?: string
|
||||
borderColor?: string
|
||||
sceneGroup?: string
|
||||
displayName?: string
|
||||
sortOrder?: number
|
||||
frontVisible?: number
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
type?: number
|
||||
@@ -524,7 +528,7 @@ export const adminTagApi = {
|
||||
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
||||
* @param data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType } caller-supplied value for `data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }`
|
||||
*/
|
||||
createTag: (data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }) => {
|
||||
createTag: (data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; sceneGroup?: string; displayName?: string; sortOrder?: number; frontVisible?: number; shopId?: IdType }) => {
|
||||
return adminApi.post<IdType>('/tag/create', data)
|
||||
},
|
||||
/**
|
||||
@@ -533,7 +537,7 @@ export const adminTagApi = {
|
||||
* @param id: IdType caller-supplied value for `id: IdType`
|
||||
* @param data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType } caller-supplied value for `data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }`
|
||||
*/
|
||||
updateTag: (id: IdType, data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }) => {
|
||||
updateTag: (id: IdType, data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; sceneGroup?: string; displayName?: string; sortOrder?: number; frontVisible?: number; shopId?: IdType }) => {
|
||||
return adminApi.put<boolean>(`/tag/update/${id}`, data)
|
||||
},
|
||||
/**
|
||||
@@ -711,6 +715,8 @@ export interface Product {
|
||||
shopName?: string
|
||||
title: string
|
||||
description: string
|
||||
targetAudience?: string
|
||||
precautions?: string
|
||||
price: number
|
||||
approximateDuration?: string
|
||||
tags?: string
|
||||
|
||||
@@ -16,10 +16,13 @@ export const WEB_API_AUTH_FREE_PATHS = [
|
||||
'/product/get/',
|
||||
'/product/list/',
|
||||
'/comment/list/product/',
|
||||
'/nail-artist/',
|
||||
'/shop/get/',
|
||||
'/shop/trust-profile/',
|
||||
'/shop/list/public',
|
||||
'/shop/list/simple',
|
||||
'/tag/list/all',
|
||||
'/tag/list/filter-options',
|
||||
'/file/get-signed-url/',
|
||||
'/admin/auth/login',
|
||||
'/admin/auth/login-shops/',
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface NailArtistAvailabilityVO {
|
||||
startTime: string
|
||||
endTime: string
|
||||
dateText: string
|
||||
timeText: string
|
||||
available: boolean
|
||||
}
|
||||
|
||||
export interface NailArtistWorkVO {
|
||||
id: IdType
|
||||
title?: string
|
||||
description?: string
|
||||
price?: number | string
|
||||
coverImageUrl?: string
|
||||
imageUrls?: string[]
|
||||
tags?: string[]
|
||||
likeCount?: number
|
||||
collectCount?: number
|
||||
}
|
||||
|
||||
export interface NailArtistReviewVO {
|
||||
id: IdType
|
||||
artistId: IdType
|
||||
customerId?: IdType
|
||||
customerName?: string
|
||||
customerAvatar?: string
|
||||
productId?: IdType
|
||||
productTitle?: string
|
||||
rating?: number | string
|
||||
content?: string
|
||||
imageFileIds?: IdType[]
|
||||
imageUrls?: string[]
|
||||
submittedAt?: string
|
||||
}
|
||||
|
||||
export interface NailArtistProfileVO {
|
||||
artistId: IdType
|
||||
artistName?: string
|
||||
avatar?: string
|
||||
identity?: string
|
||||
signature?: string
|
||||
experience?: number
|
||||
status?: number
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
rating?: number | string
|
||||
serviceCount?: number | string
|
||||
workStartTime?: string
|
||||
workEndTime?: string
|
||||
styleTags?: string[]
|
||||
works?: NailArtistWorkVO[]
|
||||
reviews?: NailArtistReviewVO[]
|
||||
availability?: NailArtistAvailabilityVO[]
|
||||
}
|
||||
|
||||
export const nailArtistApi = {
|
||||
getPublicProfile: async (artistId: IdType): Promise<NailArtistProfileVO> => {
|
||||
return await api.get<NailArtistProfileVO>(`/nail-artist/profile/${artistId}`) as unknown as NailArtistProfileVO
|
||||
},
|
||||
getAvailability: async (artistId: IdType): Promise<NailArtistAvailabilityVO[]> => {
|
||||
return await api.get<NailArtistAvailabilityVO[]>(`/nail-artist/${artistId}/availability`) as unknown as NailArtistAvailabilityVO[]
|
||||
},
|
||||
listReviews: async (artistId: IdType): Promise<NailArtistReviewVO[]> => {
|
||||
return await api.get<NailArtistReviewVO[]>(`/nail-artist/${artistId}/reviews`) as unknown as NailArtistReviewVO[]
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import type { IdType } from '@/utils/id'
|
||||
* Purpose: OrderItem supports order.ts by holding or executing the order item page or API role.
|
||||
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
interface OrderItem {
|
||||
export interface OrderItem {
|
||||
productId: IdType
|
||||
quantity: number
|
||||
artistId?: IdType
|
||||
@@ -20,12 +20,47 @@ interface OrderItem {
|
||||
* Purpose: CreateOrderRequest supports order.ts by holding or executing the create order request page or API role.
|
||||
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
interface CreateOrderRequest {
|
||||
export interface CreateOrderRequest {
|
||||
couponId?: IdType
|
||||
couponSourceType?: string
|
||||
items: OrderItem[]
|
||||
}
|
||||
|
||||
export type CheckoutPreviewRequest = CreateOrderRequest
|
||||
|
||||
export interface CheckoutCouponPreview {
|
||||
id: IdType
|
||||
couponId?: IdType
|
||||
userCouponId?: IdType
|
||||
sourceType?: string
|
||||
couponName: string
|
||||
couponType: number
|
||||
couponTypeName?: string
|
||||
discountValue?: number
|
||||
minAmount?: number
|
||||
reduceAmount?: number
|
||||
discountAmount?: number
|
||||
available?: boolean
|
||||
best?: boolean
|
||||
vipAuto?: boolean
|
||||
displayText?: string
|
||||
savingText?: string
|
||||
unavailableReason?: string
|
||||
startTime?: string
|
||||
endTime?: string
|
||||
}
|
||||
|
||||
export interface CheckoutPreview {
|
||||
subtotalAmount: number
|
||||
savedAmount: number
|
||||
payableAmount: number
|
||||
bestCoupon?: CheckoutCouponPreview
|
||||
availableCoupons: CheckoutCouponPreview[]
|
||||
unavailableCoupons: CheckoutCouponPreview[]
|
||||
vipTip?: string
|
||||
summaryText?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: ArtistCalendarAppointment supports order.ts by holding or executing the artist calendar appointment page or API role.
|
||||
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -72,6 +107,7 @@ export interface OrderArtistReviewVO {
|
||||
status?: number
|
||||
statusText?: string
|
||||
submitTime?: string
|
||||
reviewTime?: string
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
@@ -115,16 +151,34 @@ export interface OrderArtistChangeRequestVO {
|
||||
productTitle?: string
|
||||
shopId?: IdType
|
||||
userId?: IdType
|
||||
customerId?: IdType
|
||||
originalArtistId?: IdType
|
||||
originalArtistName?: string
|
||||
requestedArtistId?: IdType
|
||||
requestedArtistName?: string
|
||||
fromArtistId?: IdType
|
||||
fromArtistName?: string
|
||||
toArtistId?: IdType
|
||||
toArtistName?: string
|
||||
requesterId?: IdType
|
||||
requesterName?: string
|
||||
status?: string
|
||||
statusText?: string
|
||||
reason?: string
|
||||
rejectReason?: string
|
||||
appointmentTime?: string
|
||||
timeAffected?: boolean
|
||||
timeImpactText?: string
|
||||
originalPrice?: number | string
|
||||
newPrice?: number | string
|
||||
priceAffected?: boolean
|
||||
priceImpactText?: string
|
||||
reviewerId?: IdType
|
||||
messageId?: IdType
|
||||
reviewTime?: string
|
||||
approvedTime?: string
|
||||
rejectedTime?: string
|
||||
expireTime?: string
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
@@ -161,6 +215,10 @@ export const orderApi = {
|
||||
createOrder: (data: CreateOrderRequest) => {
|
||||
return api.post('/order/create', data)
|
||||
},
|
||||
|
||||
checkoutPreview: async (data: CheckoutPreviewRequest): Promise<CheckoutPreview> => {
|
||||
return await api.post<CheckoutPreview>('/order/checkout-preview', data) as unknown as CheckoutPreview
|
||||
},
|
||||
|
||||
// 获取订单列表
|
||||
getOrderList: async (): Promise<any[]> => {
|
||||
@@ -193,6 +251,10 @@ export const orderApi = {
|
||||
return await api.get<OrderArtistChangeRequestVO[]>('/order/artist-change/my-pending') as unknown as OrderArtistChangeRequestVO[]
|
||||
},
|
||||
|
||||
getOrderArtistChangeRequests: async (orderId: IdType): Promise<OrderArtistChangeRequestVO[]> => {
|
||||
return await api.get<OrderArtistChangeRequestVO[]>(`/order/${orderId}/artist-change/requests`) as unknown as OrderArtistChangeRequestVO[]
|
||||
},
|
||||
|
||||
approveArtistChange: async (requestId: IdType): Promise<OrderArtistChangeRequestVO> => {
|
||||
return await api.put<OrderArtistChangeRequestVO>(`/order/artist-change/${requestId}/approve`) as unknown as OrderArtistChangeRequestVO
|
||||
},
|
||||
|
||||
@@ -16,6 +16,8 @@ export interface ProductVO {
|
||||
name: string
|
||||
title?: string
|
||||
description: string
|
||||
targetAudience?: string
|
||||
precautions?: string
|
||||
image: string
|
||||
imageFileIds?: string
|
||||
imageUrls?: string[]
|
||||
@@ -57,6 +59,8 @@ export interface ListProductsParams {
|
||||
page: number
|
||||
size: number
|
||||
keyword?: string
|
||||
tag?: string
|
||||
tagIds?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,5 +124,9 @@ export const productApi = {
|
||||
keyword: keyword
|
||||
}
|
||||
}) as unknown as ProductVO[]
|
||||
},
|
||||
|
||||
getProductPage: async (params: ListProductsParams): Promise<{ list: ProductVO[]; total: number; page: number; size: number }> => {
|
||||
return await api.get('/product/list/page', { params }) as unknown as { list: ProductVO[]; total: number; page: number; size: number }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,56 @@ export interface ShopSimpleVO {
|
||||
name?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: ShopTrustProfileVO carries public trust signals for a shop detail page.
|
||||
* Usage: fetch it with getTrustProfile and render ratings, recent reviews, environment images, and booking hints.
|
||||
*/
|
||||
export interface ShopTrustProfileVO {
|
||||
shopId: IdType
|
||||
shopName?: string
|
||||
businessHoursText?: string
|
||||
businessStatusText?: string
|
||||
locationAvailable?: boolean
|
||||
distanceCapabilityText?: string
|
||||
navigationAvailable?: boolean
|
||||
stats?: {
|
||||
averageRating?: number
|
||||
reviewCount?: number
|
||||
productCount?: number
|
||||
recentReviewCount?: number
|
||||
}
|
||||
environmentImages?: string[]
|
||||
featuredProducts?: Array<{
|
||||
id: IdType
|
||||
title?: string
|
||||
imageUrl?: string
|
||||
price?: number
|
||||
likeCount?: number
|
||||
collectCount?: number
|
||||
availableBookableArtistCount?: number
|
||||
bookingHint?: string
|
||||
}>
|
||||
recentReviews?: Array<{
|
||||
id: IdType
|
||||
productId?: IdType
|
||||
productTitle?: string
|
||||
ratingScore?: number
|
||||
content?: string
|
||||
imageUrls?: string[]
|
||||
submittedAt?: string
|
||||
}>
|
||||
availabilitySummary?: {
|
||||
available?: boolean
|
||||
summaryText?: string
|
||||
nextSlots?: string[]
|
||||
}
|
||||
contactSummary?: {
|
||||
actionText?: string
|
||||
phoneExposed?: boolean
|
||||
phone?: string
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: ListShopsParams supports shop.ts by holding or executing the list shops params page or API role.
|
||||
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -124,5 +174,9 @@ export const shopApi = {
|
||||
|
||||
getShopById: async (id: IdType): Promise<ShopVO> => {
|
||||
return await api.get<ShopVO>(`/shop/get/${id}`) as unknown as ShopVO
|
||||
},
|
||||
|
||||
getTrustProfile: async (id: IdType): Promise<ShopTrustProfileVO> => {
|
||||
return await api.get<ShopTrustProfileVO>(`/shop/trust-profile/${id}`) as unknown as ShopTrustProfileVO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,23 @@ export interface TagVO {
|
||||
textColor: string
|
||||
bgColor: string
|
||||
borderColor: string
|
||||
sceneGroup?: string
|
||||
displayName?: string
|
||||
sortOrder?: number
|
||||
frontVisible?: number
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: TagFilterGroupVO groups public tags for scene filters.
|
||||
* Usage: render each group as one filter row and pass selected tag ids to product list APIs.
|
||||
*/
|
||||
export interface TagFilterGroupVO {
|
||||
groupName: string
|
||||
tags: TagVO[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: TagDTO supports tag.ts by holding or executing the tag dto page or API role.
|
||||
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -28,6 +41,10 @@ export interface TagDTO {
|
||||
textColor: string
|
||||
bgColor: string
|
||||
borderColor: string
|
||||
sceneGroup?: string
|
||||
displayName?: string
|
||||
sortOrder?: number
|
||||
frontVisible?: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +60,16 @@ export const tagApi = {
|
||||
return api.get<TagVO[]>('/tag/list/all')
|
||||
},
|
||||
|
||||
/**
|
||||
* `getFilterOptions` API call. Use this method to load customer-facing scene filters.
|
||||
* Call guide: optionally pass shopId, await the grouped tags, then query products with tagIds.
|
||||
*/
|
||||
getFilterOptions: (shopId?: IdType | null) => {
|
||||
return api.get<TagFilterGroupVO[]>('/tag/list/filter-options', {
|
||||
params: shopId ? { shopId } : undefined
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `getTagById` 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.
|
||||
|
||||
@@ -13,6 +13,10 @@ export interface WishlistItem {
|
||||
id: IdType
|
||||
userId: IdType
|
||||
productId: IdType
|
||||
groupId?: IdType | null
|
||||
groupName?: string | null
|
||||
note?: string | null
|
||||
sortOrder?: number | null
|
||||
product: {
|
||||
id: IdType
|
||||
shopId: IdType | null
|
||||
@@ -35,6 +39,39 @@ export interface WishlistItem {
|
||||
}
|
||||
}
|
||||
|
||||
export interface WishlistGroup {
|
||||
id: IdType
|
||||
name: string
|
||||
sortOrder: number
|
||||
itemCount: number
|
||||
items?: WishlistItem[]
|
||||
}
|
||||
|
||||
export interface WishlistInspiration {
|
||||
total: number
|
||||
groups: WishlistGroup[]
|
||||
}
|
||||
|
||||
export interface WishlistGroupPayload {
|
||||
name: string
|
||||
sortOrder?: number
|
||||
}
|
||||
|
||||
export interface WishlistAddWithGroupPayload {
|
||||
productId: IdType
|
||||
groupId?: IdType | null
|
||||
note?: string
|
||||
sortOrder?: number
|
||||
}
|
||||
|
||||
export interface WishlistMovePayload {
|
||||
wishlistId?: IdType
|
||||
productId?: IdType
|
||||
groupId?: IdType | null
|
||||
note?: string
|
||||
sortOrder?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* wishlistApi groups all API calls for this page domain.
|
||||
* Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script.
|
||||
@@ -54,5 +91,33 @@ export const wishlistApi = {
|
||||
|
||||
getWishlist: async (): Promise<WishlistItem[]> => {
|
||||
return await api.get<WishlistItem[]>('/wishlist/list') as unknown as WishlistItem[]
|
||||
},
|
||||
|
||||
getGroups: async (): Promise<WishlistGroup[]> => {
|
||||
return await api.get<WishlistGroup[]>('/wishlist/groups') as unknown as WishlistGroup[]
|
||||
},
|
||||
|
||||
createGroup: async (payload: WishlistGroupPayload): Promise<IdType> => {
|
||||
return await api.post<IdType>('/wishlist/groups', payload) as unknown as IdType
|
||||
},
|
||||
|
||||
updateGroup: async (id: IdType, payload: WishlistGroupPayload): Promise<boolean> => {
|
||||
return await api.put<boolean>(`/wishlist/groups/${id}`, payload) as unknown as boolean
|
||||
},
|
||||
|
||||
deleteGroup: async (id: IdType): Promise<boolean> => {
|
||||
return await api.delete<boolean>(`/wishlist/groups/${id}`) as unknown as boolean
|
||||
},
|
||||
|
||||
addWithGroup: async (payload: WishlistAddWithGroupPayload): Promise<boolean> => {
|
||||
return await api.post<boolean>('/wishlist/add-with-group', payload) as unknown as boolean
|
||||
},
|
||||
|
||||
moveWishlist: async (payload: WishlistMovePayload): Promise<boolean> => {
|
||||
return await api.post<boolean>('/wishlist/move', payload) as unknown as boolean
|
||||
},
|
||||
|
||||
getInspiration: async (): Promise<WishlistInspiration> => {
|
||||
return await api.get<WishlistInspiration>('/wishlist/inspiration') as unknown as WishlistInspiration
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,12 @@ const router = createRouter({
|
||||
component: () => import('../views/ShopDetailView.vue'),
|
||||
meta: { requiresAuth: false, hideNav: true, isAdmin: false }
|
||||
},
|
||||
{
|
||||
path: '/artist/:id',
|
||||
name: 'artist-profile',
|
||||
component: () => import('../views/ArtistProfileView.vue'),
|
||||
meta: { requiresAuth: false, hideNav: true, isAdmin: false }
|
||||
},
|
||||
{
|
||||
path: '/wishlist',
|
||||
name: 'wishlist',
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { BUY_NOW_MODE, getBuyNowProductIdFromQuery, isBuyNowCartItem } from './buy-now'
|
||||
|
||||
describe('buy-now checkout mode', () => {
|
||||
it('reads the target product id only when cart query is in buyNow mode', () => {
|
||||
expect(getBuyNowProductIdFromQuery({ mode: BUY_NOW_MODE, productId: '1001' })).toBe('1001')
|
||||
expect(getBuyNowProductIdFromQuery({ mode: 'cart', productId: '1001' })).toBe('')
|
||||
})
|
||||
|
||||
it('uses the first query value when vue-router provides array values', () => {
|
||||
expect(getBuyNowProductIdFromQuery({ mode: [BUY_NOW_MODE], productId: ['2002', '3003'] })).toBe('2002')
|
||||
})
|
||||
|
||||
it('matches numeric and string product ids for cart selection', () => {
|
||||
expect(isBuyNowCartItem(1001, '1001')).toBe(true)
|
||||
expect(isBuyNowCartItem('1002', '1001')).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
export const BUY_NOW_MODE = 'buyNow'
|
||||
|
||||
type QueryValue = string | string[] | null | undefined
|
||||
|
||||
const firstQueryValue = (value: QueryValue) => Array.isArray(value) ? value[0] : value
|
||||
|
||||
export const getBuyNowProductIdFromQuery = (query: Record<string, unknown>) => {
|
||||
const mode = firstQueryValue(query.mode as QueryValue)
|
||||
const productId = firstQueryValue(query.productId as QueryValue)
|
||||
return mode === BUY_NOW_MODE && productId ? String(productId) : ''
|
||||
}
|
||||
|
||||
export const isBuyNowCartItem = (itemProductId: unknown, buyNowProductId: string) => {
|
||||
return Boolean(buyNowProductId) && String(itemProductId || '') === String(buyNowProductId)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { resolveOrderReviewFocus } from './order-review-focus'
|
||||
|
||||
const orders = [
|
||||
{
|
||||
id: 10,
|
||||
items: [
|
||||
{ id: 1001, productTitle: '猫眼款' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
items: [
|
||||
{ id: 1101, productTitle: '法式款' }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
describe('resolveOrderReviewFocus', () => {
|
||||
it('focuses the exact pending review from message query parameters', () => {
|
||||
const result = resolveOrderReviewFocus({
|
||||
orders,
|
||||
pendingReviews: [{ id: 99, orderId: 10, orderItemId: 1001 }],
|
||||
orderReviews: {},
|
||||
query: { reviewId: 99 }
|
||||
})
|
||||
|
||||
expect(result.status).toBe('pending')
|
||||
expect(result.focusOrderId).toBe('10')
|
||||
expect(result.focusOrderItemId).toBe('1001')
|
||||
expect(result.focusReviewId).toBe('99')
|
||||
})
|
||||
|
||||
it('reports a friendly submitted state when the reminder was already handled', () => {
|
||||
const result = resolveOrderReviewFocus({
|
||||
orders,
|
||||
pendingReviews: [],
|
||||
orderReviews: {
|
||||
10: [{ id: 99, orderId: 10, orderItemId: 1001, status: 1 }]
|
||||
},
|
||||
query: { reviewId: 99 }
|
||||
})
|
||||
|
||||
expect(result.status).toBe('submitted')
|
||||
expect(result.focusOrderId).toBe('10')
|
||||
expect(result.focusOrderItemId).toBe('1001')
|
||||
expect(result.message).toContain('已处理')
|
||||
})
|
||||
|
||||
it('chooses the first pending review for profile pending-review entry', () => {
|
||||
const result = resolveOrderReviewFocus({
|
||||
orders,
|
||||
pendingReviews: [{ id: 88, orderId: 11, orderItemId: 1101 }],
|
||||
orderReviews: {},
|
||||
query: { review: 'pending' }
|
||||
})
|
||||
|
||||
expect(result.status).toBe('pending')
|
||||
expect(result.focusOrderId).toBe('11')
|
||||
expect(result.focusOrderItemId).toBe('1101')
|
||||
expect(result.focusReviewId).toBe('88')
|
||||
})
|
||||
|
||||
it('keeps an order-level focus when only orderId is provided', () => {
|
||||
const result = resolveOrderReviewFocus({
|
||||
orders,
|
||||
pendingReviews: [],
|
||||
orderReviews: {},
|
||||
query: { orderId: 10 }
|
||||
})
|
||||
|
||||
expect(result.status).toBe('order')
|
||||
expect(result.focusOrderId).toBe('10')
|
||||
expect(result.focusOrderItemId).toBe('')
|
||||
})
|
||||
|
||||
it('keeps the order visible when a review id is stale but orderId still exists', () => {
|
||||
const result = resolveOrderReviewFocus({
|
||||
orders,
|
||||
pendingReviews: [],
|
||||
orderReviews: {},
|
||||
query: { orderId: 10, reviewId: 404 }
|
||||
})
|
||||
|
||||
expect(result.status).toBe('missing')
|
||||
expect(result.focusOrderId).toBe('10')
|
||||
expect(result.message).toContain('失效')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,120 @@
|
||||
import type { OrderArtistReviewVO } from '@/api/order'
|
||||
|
||||
type QueryValue = string | number | null | undefined | Array<string | number | null | undefined>
|
||||
|
||||
interface OrderLike {
|
||||
id?: unknown
|
||||
items?: Array<{ id?: unknown }>
|
||||
}
|
||||
|
||||
interface ResolveOrderReviewFocusOptions {
|
||||
orders: OrderLike[]
|
||||
pendingReviews: OrderArtistReviewVO[]
|
||||
orderReviews: Record<string, OrderArtistReviewVO[]>
|
||||
query: Record<string, QueryValue>
|
||||
}
|
||||
|
||||
export interface OrderReviewFocusResult {
|
||||
status: 'none' | 'pending' | 'submitted' | 'missing' | 'order'
|
||||
focusOrderId: string
|
||||
focusOrderItemId: string
|
||||
focusReviewId: string
|
||||
message: string
|
||||
}
|
||||
|
||||
const toText = (value: QueryValue | unknown) => {
|
||||
if (Array.isArray(value)) {
|
||||
return value[0] === undefined || value[0] === null ? '' : String(value[0])
|
||||
}
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
}
|
||||
|
||||
const sameId = (left: unknown, right: unknown) => {
|
||||
const leftText = toText(left)
|
||||
const rightText = toText(right)
|
||||
return leftText !== '' && leftText === rightText
|
||||
}
|
||||
|
||||
const flattenSubmittedReviews = (orderReviews: Record<string, OrderArtistReviewVO[]>) => {
|
||||
return Object.values(orderReviews).flat().filter(review => Number(review.status) === 1 || Boolean(review.rating))
|
||||
}
|
||||
|
||||
const findOrder = (orders: OrderLike[], orderId: string) => {
|
||||
return orders.find(order => sameId(order.id, orderId))
|
||||
}
|
||||
|
||||
const buildResult = (
|
||||
status: OrderReviewFocusResult['status'],
|
||||
review?: OrderArtistReviewVO,
|
||||
fallbackOrderId = '',
|
||||
message = ''
|
||||
): OrderReviewFocusResult => ({
|
||||
status,
|
||||
focusOrderId: toText(review?.orderId) || fallbackOrderId,
|
||||
focusOrderItemId: toText(review?.orderItemId),
|
||||
focusReviewId: toText(review?.id),
|
||||
message
|
||||
})
|
||||
|
||||
export const resolveOrderReviewFocus = ({
|
||||
orders,
|
||||
pendingReviews,
|
||||
orderReviews,
|
||||
query
|
||||
}: ResolveOrderReviewFocusOptions): OrderReviewFocusResult => {
|
||||
const reviewId = toText(query.reviewId)
|
||||
const orderId = toText(query.orderId)
|
||||
const orderItemId = toText(query.orderItemId)
|
||||
const reviewMode = toText(query.review)
|
||||
const submittedReviews = flattenSubmittedReviews(orderReviews)
|
||||
|
||||
if (reviewId) {
|
||||
const pending = pendingReviews.find(review => sameId(review.id, reviewId))
|
||||
if (pending) {
|
||||
return buildResult('pending', pending, '', '已为你定位到待评价订单。')
|
||||
}
|
||||
const submitted = submittedReviews.find(review => sameId(review.id, reviewId))
|
||||
if (submitted) {
|
||||
return buildResult('submitted', submitted, '', '这条评价提醒已处理,可查看已评价内容。')
|
||||
}
|
||||
return {
|
||||
status: 'missing',
|
||||
focusOrderId: findOrder(orders, orderId) ? orderId : '',
|
||||
focusOrderItemId: orderItemId,
|
||||
focusReviewId: reviewId,
|
||||
message: '这条评价提醒已失效,可在订单页查看最新状态。'
|
||||
}
|
||||
}
|
||||
|
||||
if (reviewMode === 'pending') {
|
||||
const firstPending = pendingReviews[0]
|
||||
if (firstPending) {
|
||||
return buildResult('pending', firstPending, '', '已为你定位到待评价订单。')
|
||||
}
|
||||
return {
|
||||
status: 'missing',
|
||||
focusOrderId: '',
|
||||
focusOrderItemId: '',
|
||||
focusReviewId: '',
|
||||
message: '暂无待评价订单。'
|
||||
}
|
||||
}
|
||||
|
||||
if (orderId && findOrder(orders, orderId)) {
|
||||
return {
|
||||
status: 'order',
|
||||
focusOrderId: orderId,
|
||||
focusOrderItemId: orderItemId,
|
||||
focusReviewId: '',
|
||||
message: ''
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
status: 'none',
|
||||
focusOrderId: '',
|
||||
focusOrderItemId: '',
|
||||
focusReviewId: '',
|
||||
message: ''
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildRecoveryActions, getRecoveryMessage, recoveryRouteFor } from './recovery'
|
||||
|
||||
describe('recovery utils', () => {
|
||||
it('normalizes error messages with fallback text', () => {
|
||||
expect(getRecoveryMessage(new Error('网络开小差了'), '请求失败')).toBe('网络开小差了')
|
||||
expect(getRecoveryMessage('', '请求失败')).toBe('请求失败')
|
||||
})
|
||||
|
||||
it('adds default routes and primary action state', () => {
|
||||
const actions = buildRecoveryActions([
|
||||
{ key: 'retry', text: '重试' },
|
||||
{ key: 'orders', text: '查看订单' },
|
||||
{ key: 'cart', text: '返回购物车' }
|
||||
])
|
||||
const retryAction = actions[0]
|
||||
const ordersAction = actions[1]
|
||||
const cartAction = actions[2]
|
||||
|
||||
expect(retryAction?.primary).toBe(true)
|
||||
expect(ordersAction?.route).toBe('/orders')
|
||||
expect(cartAction?.route).toBe('/cart')
|
||||
expect(recoveryRouteFor('products')).toBe('/products')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,43 @@
|
||||
export type RecoveryActionKey = 'retry' | 'orders' | 'cart' | 'products' | 'profile' | 'contact'
|
||||
|
||||
export interface RecoveryAction {
|
||||
key: RecoveryActionKey
|
||||
text: string
|
||||
route?: string
|
||||
primary?: boolean
|
||||
}
|
||||
|
||||
const DEFAULT_ROUTES: Record<string, string> = {
|
||||
orders: '/orders',
|
||||
cart: '/cart',
|
||||
products: '/products',
|
||||
profile: '/profile'
|
||||
}
|
||||
|
||||
export const getRecoveryMessage = (error: unknown, fallbackMessage: string): string => {
|
||||
if (error instanceof Error && error.message.trim()) {
|
||||
return error.message.trim()
|
||||
}
|
||||
if (typeof error === 'string' && error.trim()) {
|
||||
return error.trim()
|
||||
}
|
||||
if (error && typeof error === 'object' && 'message' in error) {
|
||||
const message = String((error as { message?: unknown }).message || '').trim()
|
||||
if (message) {
|
||||
return message
|
||||
}
|
||||
}
|
||||
return fallbackMessage
|
||||
}
|
||||
|
||||
export const recoveryRouteFor = (key: RecoveryActionKey): string => DEFAULT_ROUTES[key] || ''
|
||||
|
||||
export const buildRecoveryActions = (actions: RecoveryAction[]): RecoveryAction[] => (
|
||||
actions
|
||||
.filter(action => action.key && action.text)
|
||||
.map((action, index) => ({
|
||||
...action,
|
||||
route: action.route || recoveryRouteFor(action.key),
|
||||
primary: action.primary ?? index === 0
|
||||
}))
|
||||
)
|
||||
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildSystemMessageActionPath } from './system-message-action'
|
||||
|
||||
describe('buildSystemMessageActionPath', () => {
|
||||
it('keeps safe review action paths with order and review query parameters', () => {
|
||||
expect(buildSystemMessageActionPath({
|
||||
actionPath: '/orders?orderId=10&reviewId=99&orderItemId=1001',
|
||||
businessType: 'ORDER_ARTIST_REVIEW',
|
||||
businessId: 99
|
||||
})).toBe('/orders?orderId=10&reviewId=99&orderItemId=1001')
|
||||
})
|
||||
|
||||
it('uses reviewId fallback for review reminder messages when actionPath is absent', () => {
|
||||
expect(buildSystemMessageActionPath({
|
||||
businessType: 'ORDER_ARTIST_REVIEW',
|
||||
businessId: 99
|
||||
})).toBe('/orders?reviewId=99&source=message')
|
||||
})
|
||||
|
||||
it('opens pending reviews when a review reminder has no business id', () => {
|
||||
expect(buildSystemMessageActionPath({
|
||||
businessType: 'ORDER_ARTIST_REVIEW'
|
||||
})).toBe('/orders?review=pending&source=message')
|
||||
})
|
||||
|
||||
it('uses orderId fallback for generic order messages', () => {
|
||||
expect(buildSystemMessageActionPath({
|
||||
businessType: 'ORDER',
|
||||
businessId: 10
|
||||
})).toBe('/orders?orderId=10&source=message')
|
||||
})
|
||||
|
||||
it('rejects unsafe or backend-only action paths', () => {
|
||||
expect(buildSystemMessageActionPath({ actionPath: '//evil.example/orders' })).toBe('')
|
||||
expect(buildSystemMessageActionPath({ actionPath: 'https://evil.example/orders' })).toBe('')
|
||||
expect(buildSystemMessageActionPath({ actionPath: '/admin/users' })).toBe('')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,72 @@
|
||||
import type { SystemMessageVO } from '@/api/user'
|
||||
|
||||
type MessageLike = Pick<SystemMessageVO, 'actionPath' | 'businessType' | 'businessId'>
|
||||
|
||||
const USER_ACTION_PREFIXES = [
|
||||
'/orders',
|
||||
'/product/',
|
||||
'/shop/',
|
||||
'/coupons',
|
||||
'/vip-center',
|
||||
'/cart',
|
||||
'/notifications',
|
||||
'/wishlist',
|
||||
'/profile',
|
||||
'/settings'
|
||||
]
|
||||
|
||||
const appendQuery = (path: string, query: Record<string, string | number | undefined>) => {
|
||||
const params = new URLSearchParams()
|
||||
Object.entries(query).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== '') {
|
||||
params.set(key, String(value))
|
||||
}
|
||||
})
|
||||
const queryString = params.toString()
|
||||
return queryString ? `${path}?${queryString}` : path
|
||||
}
|
||||
|
||||
export const normalizeSystemMessageActionPath = (value?: string) => {
|
||||
const actionPath = String(value || '').trim()
|
||||
if (!actionPath || !actionPath.startsWith('/') || actionPath.startsWith('//') || actionPath.includes('\\')) {
|
||||
return ''
|
||||
}
|
||||
return USER_ACTION_PREFIXES.some(prefix => actionPath === prefix || actionPath.startsWith(prefix))
|
||||
? actionPath
|
||||
: ''
|
||||
}
|
||||
|
||||
export const buildSystemMessageActionPath = (message: MessageLike) => {
|
||||
const actionPath = normalizeSystemMessageActionPath(message.actionPath)
|
||||
if (actionPath) {
|
||||
return actionPath
|
||||
}
|
||||
|
||||
const businessType = String(message.businessType || '').toUpperCase()
|
||||
const businessId = message.businessId === undefined || message.businessId === null ? '' : String(message.businessId)
|
||||
if (businessType === 'ORDER_ARTIST_REVIEW') {
|
||||
return businessId
|
||||
? appendQuery('/orders', { reviewId: businessId, source: 'message' })
|
||||
: appendQuery('/orders', { review: 'pending', source: 'message' })
|
||||
}
|
||||
if (businessType === 'ORDER_ARTIST_CHANGE' || businessType === 'ORDER') {
|
||||
return appendQuery('/orders', { orderId: businessId || undefined, source: 'message' })
|
||||
}
|
||||
if (businessType === 'PRODUCT' && businessId) {
|
||||
return `/product/${encodeURIComponent(businessId)}`
|
||||
}
|
||||
if (businessType === 'SHOP' && businessId) {
|
||||
return `/shop/${encodeURIComponent(businessId)}`
|
||||
}
|
||||
if (businessType === 'VIP') {
|
||||
return '/vip-center'
|
||||
}
|
||||
if (businessType === 'COUPON') {
|
||||
return '/coupons'
|
||||
}
|
||||
if (businessType === 'CART') {
|
||||
return '/cart'
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
@@ -0,0 +1,552 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, shallowRef } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
CalendarOutlined,
|
||||
LeftOutlined,
|
||||
PictureOutlined,
|
||||
ShopOutlined,
|
||||
StarFilled,
|
||||
UserOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
|
||||
import {
|
||||
nailArtistApi,
|
||||
type NailArtistAvailabilityVO,
|
||||
type NailArtistProfileVO,
|
||||
type NailArtistReviewVO,
|
||||
type NailArtistWorkVO
|
||||
} from '@/api/nail-artist'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const profile = shallowRef<NailArtistProfileVO | null>(null)
|
||||
const reviews = ref<NailArtistReviewVO[]>([])
|
||||
const availability = ref<NailArtistAvailabilityVO[]>([])
|
||||
const loading = ref(false)
|
||||
const loadError = ref('')
|
||||
|
||||
const artistId = computed(() => String(route.params.id || ''))
|
||||
const artistName = computed(() => profile.value?.artistName || '美甲师')
|
||||
const ratingText = computed(() => Number(profile.value?.rating || 0).toFixed(1))
|
||||
const serviceCountText = computed(() => String(profile.value?.serviceCount || 0))
|
||||
const works = computed<NailArtistWorkVO[]>(() => profile.value?.works || [])
|
||||
const styleTags = computed(() => profile.value?.styleTags?.filter(Boolean) || [])
|
||||
const firstWorkImage = computed(() => works.value.find(work => work.coverImageUrl)?.coverImageUrl || DEFAULT_PRODUCT_IMAGE)
|
||||
const workTimeText = computed(() => {
|
||||
const start = profile.value?.workStartTime?.slice(0, 5)
|
||||
const end = profile.value?.workEndTime?.slice(0, 5)
|
||||
return start && end ? `${start}-${end}` : '到店确认'
|
||||
})
|
||||
|
||||
const formatPrice = (price?: number | string) => {
|
||||
const value = Number(price || 0)
|
||||
return value > 0 ? `¥${value.toFixed(2)}` : '到店确认'
|
||||
}
|
||||
|
||||
const formatDateTime = (value?: string) => {
|
||||
if (!value) {
|
||||
return ''
|
||||
}
|
||||
return value.replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
const openProduct = (work: NailArtistWorkVO) => {
|
||||
if (!work.id) {
|
||||
return
|
||||
}
|
||||
router.push(`/product/${work.id}`)
|
||||
}
|
||||
|
||||
const openShop = () => {
|
||||
if (!profile.value?.shopId) {
|
||||
return
|
||||
}
|
||||
router.push(`/shop/${profile.value.shopId}`)
|
||||
}
|
||||
|
||||
const loadProfile = async () => {
|
||||
if (!artistId.value) {
|
||||
loadError.value = '缺少美甲师信息'
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
const [profileData, availabilityData, reviewData] = await Promise.all([
|
||||
nailArtistApi.getPublicProfile(artistId.value),
|
||||
nailArtistApi.getAvailability(artistId.value),
|
||||
nailArtistApi.listReviews(artistId.value)
|
||||
])
|
||||
profile.value = profileData
|
||||
availability.value = availabilityData || profileData.availability || []
|
||||
reviews.value = reviewData || profileData.reviews || []
|
||||
} catch (error) {
|
||||
loadError.value = error instanceof Error ? error.message : '美甲师个人页加载失败'
|
||||
message.error(loadError.value)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadProfile)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="artist-profile">
|
||||
<header class="page-header">
|
||||
<a-button type="text" class="icon-btn" @click="router.back()">
|
||||
<LeftOutlined />
|
||||
</a-button>
|
||||
<h1>{{ artistName }}</h1>
|
||||
<div class="header-spacer"></div>
|
||||
</header>
|
||||
|
||||
<main class="page-body">
|
||||
<a-spin :spinning="loading">
|
||||
<a-result v-if="loadError" status="warning" title="暂时无法查看个人页" :sub-title="loadError">
|
||||
<template #extra>
|
||||
<a-button type="primary" @click="loadProfile">重试</a-button>
|
||||
</template>
|
||||
</a-result>
|
||||
|
||||
<template v-else-if="profile">
|
||||
<section class="hero-section">
|
||||
<img class="hero-image" :src="firstWorkImage" alt="美甲作品" />
|
||||
<div class="hero-overlay"></div>
|
||||
<div class="artist-card">
|
||||
<a-avatar :size="72" :src="profile.avatar">
|
||||
<UserOutlined />
|
||||
</a-avatar>
|
||||
<div class="artist-main">
|
||||
<h2>{{ artistName }}</h2>
|
||||
<p>{{ profile.identity || profile.signature || '专注细节与稳定出品' }}</p>
|
||||
<button type="button" class="shop-link" @click="openShop">
|
||||
<ShopOutlined />
|
||||
<span>{{ profile.shopName || '门店待确认' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="metrics-grid">
|
||||
<div class="metric-item">
|
||||
<StarFilled />
|
||||
<span>评分</span>
|
||||
<strong>{{ ratingText }}</strong>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<PictureOutlined />
|
||||
<span>服务</span>
|
||||
<strong>{{ serviceCountText }}</strong>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<CalendarOutlined />
|
||||
<span>工时</span>
|
||||
<strong>{{ workTimeText }}</strong>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="content-section">
|
||||
<div class="section-head">
|
||||
<h3>擅长风格</h3>
|
||||
</div>
|
||||
<div class="tag-list">
|
||||
<a-tag v-for="tag in styleTags" :key="tag">{{ tag }}</a-tag>
|
||||
<span v-if="!styleTags.length" class="muted">暂未设置风格标签</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="content-section">
|
||||
<div class="section-head">
|
||||
<h3>近期可预约</h3>
|
||||
</div>
|
||||
<div v-if="availability.length" class="slot-grid">
|
||||
<button v-for="slot in availability" :key="slot.startTime" type="button" class="slot-chip">
|
||||
<span>{{ slot.dateText }}</span>
|
||||
<strong>{{ slot.timeText }}</strong>
|
||||
</button>
|
||||
</div>
|
||||
<a-empty v-else description="近期暂未放出可预约时间" />
|
||||
</section>
|
||||
|
||||
<section class="content-section">
|
||||
<div class="section-head">
|
||||
<h3>作品</h3>
|
||||
</div>
|
||||
<div v-if="works.length" class="work-grid">
|
||||
<button v-for="work in works" :key="work.id" type="button" class="work-card" @click="openProduct(work)">
|
||||
<img :src="work.coverImageUrl || DEFAULT_PRODUCT_IMAGE" :alt="work.title || '作品'" />
|
||||
<span>{{ work.title || '美甲作品' }}</span>
|
||||
<strong>{{ formatPrice(work.price) }}</strong>
|
||||
</button>
|
||||
</div>
|
||||
<a-empty v-else description="作品正在整理中" />
|
||||
</section>
|
||||
|
||||
<section class="content-section">
|
||||
<div class="section-head">
|
||||
<h3>评价</h3>
|
||||
<span>{{ reviews.length }} 条</span>
|
||||
</div>
|
||||
<div v-if="reviews.length" class="review-list">
|
||||
<article v-for="review in reviews" :key="review.id" class="review-item">
|
||||
<div class="review-top">
|
||||
<a-avatar :size="36" :src="review.customerAvatar">
|
||||
<UserOutlined />
|
||||
</a-avatar>
|
||||
<div>
|
||||
<strong>{{ review.customerName || '匿名用户' }}</strong>
|
||||
<span>{{ formatDateTime(review.submittedAt) }}</span>
|
||||
</div>
|
||||
<em>{{ Number(review.rating || 0).toFixed(1) }}</em>
|
||||
</div>
|
||||
<p>{{ review.content || '这位用户没有填写文字评价' }}</p>
|
||||
<div v-if="review.imageUrls?.length" class="review-images">
|
||||
<img v-for="url in review.imageUrls" :key="url" :src="url" alt="评价图片" />
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<a-empty v-else description="还没有公开评价" />
|
||||
</section>
|
||||
</template>
|
||||
</a-spin>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.artist-profile {
|
||||
min-height: 100vh;
|
||||
background: #f6f7fb;
|
||||
color: #1f2933;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
display: grid;
|
||||
grid-template-columns: 44px 1fr 44px;
|
||||
align-items: center;
|
||||
height: 56px;
|
||||
padding: 0 14px;
|
||||
background: rgba(255, 255, 255, 0.94);
|
||||
border-bottom: 1px solid #e6e9ef;
|
||||
backdrop-filter: blur(14px);
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.icon-btn,
|
||||
.header-spacer {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.page-body {
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
padding: 16px 14px 32px;
|
||||
}
|
||||
|
||||
.hero-section {
|
||||
position: relative;
|
||||
min-height: 300px;
|
||||
overflow: hidden;
|
||||
border-radius: 8px;
|
||||
background: #222831;
|
||||
}
|
||||
|
||||
.hero-image {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.hero-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(180deg, rgba(10, 14, 20, 0.08), rgba(10, 14, 20, 0.72));
|
||||
}
|
||||
|
||||
.artist-card {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
bottom: 20px;
|
||||
left: 20px;
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: flex-end;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.artist-main {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.artist-main h2 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 30px;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.artist-main p {
|
||||
max-width: 640px;
|
||||
margin: 0 0 12px;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.shop-link {
|
||||
display: inline-flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
max-width: 100%;
|
||||
padding: 7px 10px;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
border: 1px solid rgba(255, 255, 255, 0.28);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.shop-link span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.metrics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin: 14px 0;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
min-height: 98px;
|
||||
padding: 16px;
|
||||
background: #fff;
|
||||
border: 1px solid #e6e9ef;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.metric-item svg {
|
||||
color: #c6597d;
|
||||
}
|
||||
|
||||
.metric-item span {
|
||||
color: #65717f;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.metric-item strong {
|
||||
overflow-wrap: anywhere;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.content-section {
|
||||
margin-top: 14px;
|
||||
padding: 18px;
|
||||
background: #fff;
|
||||
border: 1px solid #e6e9ef;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.section-head h3 {
|
||||
margin: 0;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.section-head span,
|
||||
.muted {
|
||||
color: #7b8794;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.tag-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.slot-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.slot-chip {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
min-height: 64px;
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
cursor: default;
|
||||
background: #f6f7fb;
|
||||
border: 1px solid #dfe4ea;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.slot-chip span {
|
||||
color: #65717f;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.slot-chip strong {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.work-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.work-card {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
background: #fff;
|
||||
border: 1px solid #e6e9ef;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.work-card img {
|
||||
width: 100%;
|
||||
aspect-ratio: 4 / 3;
|
||||
object-fit: cover;
|
||||
background: #eef1f5;
|
||||
}
|
||||
|
||||
.work-card span,
|
||||
.work-card strong {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.work-card span {
|
||||
overflow: hidden;
|
||||
color: #29333d;
|
||||
font-weight: 600;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.work-card strong {
|
||||
padding-bottom: 10px;
|
||||
color: #c6597d;
|
||||
}
|
||||
|
||||
.review-list {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.review-item {
|
||||
padding: 14px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e6e9ef;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.review-top {
|
||||
display: grid;
|
||||
grid-template-columns: 36px minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.review-top strong,
|
||||
.review-top span {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.review-top span {
|
||||
color: #7b8794;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.review-top em {
|
||||
color: #c6597d;
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.review-item p {
|
||||
margin: 12px 0 0;
|
||||
color: #3f4a56;
|
||||
line-height: 1.7;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.review-images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.review-images img {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
object-fit: cover;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.page-body {
|
||||
padding: 12px 10px 24px;
|
||||
}
|
||||
|
||||
.hero-section {
|
||||
min-height: 280px;
|
||||
}
|
||||
|
||||
.artist-card {
|
||||
right: 14px;
|
||||
bottom: 14px;
|
||||
left: 14px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.artist-main h2 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.metrics-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.work-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -8,8 +8,8 @@
|
||||
<template v-else>
|
||||
<section class="checkout-hero" :class="{ 'has-issues': selectedCount && checkoutIssueCount }">
|
||||
<div class="hero-main">
|
||||
<p class="hero-eyebrow">购物车</p>
|
||||
<h1>{{ selectedCount ? '准备结算' : '选择要结算的作品' }}</h1>
|
||||
<p class="hero-eyebrow">{{ isBuyNowMode ? '确认订单' : '购物车' }}</p>
|
||||
<h1>{{ cartHeroTitle }}</h1>
|
||||
<p>{{ checkoutStatusText }}</p>
|
||||
</div>
|
||||
<div class="hero-total">
|
||||
@@ -128,11 +128,16 @@
|
||||
<RightOutlined />
|
||||
</button>
|
||||
|
||||
<section v-if="checkoutPreview" class="preview-panel">
|
||||
<div class="preview-line">{{ checkoutPreview.summaryText }}</div>
|
||||
<div v-if="checkoutPreview.vipTip" class="preview-line vip">{{ checkoutPreview.vipTip }}</div>
|
||||
</section>
|
||||
|
||||
<section class="summary-panel">
|
||||
<div class="summary-row"><span>选中项目</span><strong>{{ selectedCount }} 项</strong></div>
|
||||
<div class="summary-row"><span>作品数量</span><strong>{{ totalQuantity }} 件</strong></div>
|
||||
<div class="summary-row"><span>小计</span><strong>¥{{ subtotal.toFixed(2) }}</strong></div>
|
||||
<div v-if="selectedCoupon" class="summary-row discount"><span>优惠</span><strong>-¥{{ discountAmount.toFixed(2) }}</strong></div>
|
||||
<div class="summary-row"><span>商品小计</span><strong>¥{{ subtotal.toFixed(2) }}</strong></div>
|
||||
<div v-if="discountAmount > 0" class="summary-row discount"><span>已省</span><strong>-¥{{ discountAmount.toFixed(2) }}</strong></div>
|
||||
<div class="summary-row total"><span>合计</span><strong>¥{{ totalAmount.toFixed(2) }}</strong></div>
|
||||
</section>
|
||||
</aside>
|
||||
@@ -172,11 +177,20 @@
|
||||
<a-radio-group v-model:value="couponSelectionKey" class="coupon-options">
|
||||
<a-radio :value="NO_COUPON_KEY">不使用优惠</a-radio>
|
||||
<a-radio v-for="coupon in availableCoupons" :key="getCouponKey(coupon)" :value="getCouponKey(coupon)">
|
||||
{{ formatCouponDisplay(coupon) }}
|
||||
<span class="coupon-option-copy">
|
||||
<strong>{{ formatCouponDisplay(coupon) }}</strong>
|
||||
<em>{{ coupon.savingText || `本单可省 ¥${Number(coupon.discountAmount || 0).toFixed(2)}` }}</em>
|
||||
</span>
|
||||
</a-radio>
|
||||
</a-radio-group>
|
||||
<div v-if="unavailableCoupons.length" class="coupon-unavailable">
|
||||
<div v-for="coupon in unavailableCoupons" :key="getCouponKey(coupon)" class="coupon-unavailable-item">
|
||||
<span>{{ formatCouponDisplay(coupon) }}</span>
|
||||
<em>{{ coupon.unavailableReason || '本单暂不可用' }}</em>
|
||||
</div>
|
||||
</div>
|
||||
<div class="coupon-tip">
|
||||
系统会按本次订单金额自动预选减免最高的一张券,也可以手动选择不使用优惠。
|
||||
{{ checkoutPreview?.vipTip || '系统会按本次订单金额自动预选减免最高的一张券,也可以手动选择不使用优惠。' }}
|
||||
</div>
|
||||
</a-modal>
|
||||
|
||||
@@ -240,28 +254,32 @@
|
||||
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
||||
*/
|
||||
import { computed, inject, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { DeleteOutlined, RightOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import type { ButtonProps } from 'ant-design-vue/es/button/buttonTypes'
|
||||
import { cartApi } from '../api/cart'
|
||||
/**
|
||||
* Purpose: UserCoupon supports CartView.vue by holding or executing the user coupon page or API role.
|
||||
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
import { couponApi, type UserCoupon } from '../api/coupon'
|
||||
import { fileApi } from '../api/index'
|
||||
import { orderApi } from '../api/order'
|
||||
import type { CheckoutCouponPreview, CheckoutPreview } from '../api/order'
|
||||
import { shopApi } from '../api/shop'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { sameId, toOptionalIdString } from '@/utils/id'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { getBuyNowProductIdFromQuery, isBuyNowCartItem } from '@/utils/buy-now'
|
||||
import { buildRecoveryActions, getRecoveryMessage } from '@/utils/recovery'
|
||||
|
||||
/**
|
||||
* Purpose: router supports CartView.vue by holding or executing the router page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const router = useRouter()
|
||||
/** route exposes cart query parameters, including the one-shot buyNow checkout target. */
|
||||
const route = useRoute()
|
||||
/**
|
||||
* Purpose: updateCartCount supports CartView.vue by holding or executing the update cart count page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -350,12 +368,14 @@ const itemRefs = ref<Record<string, HTMLElement>>({})
|
||||
* Purpose: availableCoupons supports CartView.vue by holding or executing the available coupons page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const availableCoupons = ref<UserCoupon[]>([])
|
||||
const availableCoupons = ref<CheckoutCouponPreview[]>([])
|
||||
const unavailableCoupons = ref<CheckoutCouponPreview[]>([])
|
||||
const checkoutPreview = ref<CheckoutPreview | null>(null)
|
||||
/**
|
||||
* Purpose: selectedCoupon supports CartView.vue by holding or executing the selected coupon page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const selectedCoupon = ref<UserCoupon | null>(null)
|
||||
const selectedCoupon = ref<CheckoutCouponPreview | null>(null)
|
||||
/** couponSelectionKey is a reactive state variable used by the template and event handlers. */
|
||||
const couponSelectionKey = ref(NO_COUPON_KEY)
|
||||
/** couponSelectionTouched is a reactive state variable used by the template and event handlers. */
|
||||
@@ -385,6 +405,10 @@ const draftAppointmentTime = ref('')
|
||||
const currentShopHours = ref('')
|
||||
/** submittingOrder is a reactive state variable used by the template and event handlers. */
|
||||
const submittingOrder = ref(false)
|
||||
/** buyNowProductId limits checkout selection to the product that opened cart from "立即预约". */
|
||||
const buyNowProductId = computed(() => getBuyNowProductIdFromQuery(route.query))
|
||||
/** isBuyNowMode switches cart copy into a focused order-confirmation experience. */
|
||||
const isBuyNowMode = computed(() => Boolean(buyNowProductId.value))
|
||||
|
||||
/** selectedItems is a reactive state variable used by the template and event handlers. */
|
||||
const selectedItems = computed(() => cartItems.value.filter(item => item.selected))
|
||||
@@ -393,11 +417,19 @@ const selectedCount = computed(() => selectedItems.value.length)
|
||||
/** totalQuantity is a reactive state variable used by the template and event handlers. */
|
||||
const totalQuantity = computed(() => selectedItems.value.reduce((sum, item) => sum + item.quantity, 0))
|
||||
/** subtotal is a reactive state variable used by the template and event handlers. */
|
||||
const subtotal = computed(() => selectedItems.value.reduce((sum, item) => sum + Number(item.price || 0) * item.quantity, 0))
|
||||
const localSubtotal = computed(() => selectedItems.value.reduce((sum, item) => sum + Number(item.price || 0) * item.quantity, 0))
|
||||
const subtotal = computed(() => Number(checkoutPreview.value?.subtotalAmount ?? localSubtotal.value))
|
||||
/** discountAmount is a reactive state variable used by the template and event handlers. */
|
||||
const discountAmount = computed(() => calculateCouponDiscount(selectedCoupon.value, subtotal.value))
|
||||
const discountAmount = computed(() => Number(checkoutPreview.value?.savedAmount ?? calculateCouponDiscount(selectedCoupon.value, subtotal.value)))
|
||||
/** totalAmount is a reactive state variable used by the template and event handlers. */
|
||||
const totalAmount = computed(() => Math.max(0, subtotal.value - discountAmount.value))
|
||||
const totalAmount = computed(() => Number(checkoutPreview.value?.payableAmount ?? Math.max(0, subtotal.value - discountAmount.value)))
|
||||
/** cartHeroTitle names the current checkout mode for the first screen. */
|
||||
const cartHeroTitle = computed(() => {
|
||||
if (isBuyNowMode.value) {
|
||||
return selectedCount.value ? '确认本次预约订单' : '请选择本次预约项目'
|
||||
}
|
||||
return selectedCount.value ? '确认订单' : '选择要结算的作品'
|
||||
})
|
||||
/** bookingTitle is a reactive state variable used by the template and event handlers. */
|
||||
const bookingTitle = computed(() => currentItem.value ? `为 ${currentItem.value.productTitle} 选择预约信息` : '选择预约信息')
|
||||
/** bookingHelperText is a reactive state variable used by the template and event handlers. */
|
||||
@@ -483,7 +515,7 @@ const quickDateLabel = (date: Date) => {
|
||||
}
|
||||
|
||||
/** getCouponKey is a local helper used by this page script. */
|
||||
const getCouponKey = (coupon: UserCoupon) => `${coupon.sourceType || 'USER_COUPON'}:${coupon.id}`
|
||||
const getCouponKey = (coupon: CheckoutCouponPreview) => `${coupon.sourceType || 'USER_COUPON'}:${coupon.id}`
|
||||
|
||||
/** setItemRef is a local helper used by this page script. */
|
||||
const setItemRef = (itemId: IdType, element: unknown) => {
|
||||
@@ -503,7 +535,10 @@ const setItemRef = (itemId: IdType, element: unknown) => {
|
||||
}
|
||||
|
||||
/** formatCouponDisplay is a local helper used by this page script. */
|
||||
const formatCouponDisplay = (coupon: UserCoupon) => {
|
||||
const formatCouponDisplay = (coupon: CheckoutCouponPreview) => {
|
||||
if (coupon.displayText) {
|
||||
return coupon.displayText
|
||||
}
|
||||
const badge = coupon.sourceType === 'SYSTEM_VIP' ? '[VIP 自动券]' : '[用户券]'
|
||||
const benefit = coupon.couponType === 1
|
||||
? `${coupon.discountValue} 折`
|
||||
@@ -512,10 +547,13 @@ const formatCouponDisplay = (coupon: UserCoupon) => {
|
||||
}
|
||||
|
||||
/** calculateCouponDiscount is a local helper used by this page script. */
|
||||
const calculateCouponDiscount = (coupon: UserCoupon | null, amount: number) => {
|
||||
const calculateCouponDiscount = (coupon: CheckoutCouponPreview | null, amount: number) => {
|
||||
if (!coupon || amount <= 0) {
|
||||
return 0
|
||||
}
|
||||
if (coupon.discountAmount !== undefined && coupon.discountAmount !== null) {
|
||||
return Number(coupon.discountAmount || 0)
|
||||
}
|
||||
if (coupon.couponType === 1) {
|
||||
const discountValue = Number(coupon.discountValue || 0)
|
||||
return discountValue ? amount - amount * discountValue / 10 : 0
|
||||
@@ -527,7 +565,7 @@ const calculateCouponDiscount = (coupon: UserCoupon | null, amount: number) => {
|
||||
}
|
||||
|
||||
/** findBestCoupon is a local helper used by this page script. */
|
||||
const findBestCoupon = (coupons: UserCoupon[]) => {
|
||||
const findBestCoupon = (coupons: CheckoutCouponPreview[]) => {
|
||||
return coupons
|
||||
.sort((left, right) => calculateCouponDiscount(right, subtotal.value) - calculateCouponDiscount(left, subtotal.value))[0] || null
|
||||
}
|
||||
@@ -604,12 +642,12 @@ const firstCheckoutIssue = computed(() => checkoutIssues.value[0])
|
||||
/** checkoutStatusText is a reactive state variable used by the template and event handlers. */
|
||||
const checkoutStatusText = computed(() => {
|
||||
if (!selectedCount.value) {
|
||||
return '勾选需要结算的作品,完善预约信息后即可提交订单'
|
||||
return isBuyNowMode.value ? '本次预约只会提交刚刚选择的作品,不会混入购物车其他项目' : '勾选需要结算的作品,完善预约信息后即可提交订单'
|
||||
}
|
||||
if (checkoutIssueCount.value) {
|
||||
return `还有 ${checkoutIssueCount.value} 项预约信息待完善`
|
||||
}
|
||||
return selectedCoupon.value ? '预约信息已完成,优惠已计算' : '预约信息已完成,可以提交订单'
|
||||
return selectedCoupon.value ? '订单信息已确认,优惠已计算' : '订单信息已确认,可以提交订单'
|
||||
})
|
||||
/** checkoutActionText is a reactive state variable used by the template and event handlers. */
|
||||
const checkoutActionText = computed(() => {
|
||||
@@ -641,7 +679,7 @@ const loadCartItems = async () => {
|
||||
const response = await cartApi.getCartList() as unknown as any[]
|
||||
cartItems.value = (response || []).map(item => ({
|
||||
...item,
|
||||
selected: true,
|
||||
selected: isBuyNowMode.value ? isBuyNowCartItem(item.productId, buyNowProductId.value) : true,
|
||||
originalProductImage: item.productImage,
|
||||
productImage: '',
|
||||
appointmentTime: item.appointmentTime
|
||||
@@ -673,28 +711,30 @@ const loadProductImages = async () => {
|
||||
/** loadAvailableCoupons is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadAvailableCoupons = async () => {
|
||||
const currentSelectedKey = selectedCoupon.value ? getCouponKey(selectedCoupon.value) : couponSelectionKey.value
|
||||
const selectedShopId = selectedItems.value[0]?.shopId
|
||||
|
||||
if (!selectedItems.value.length || subtotal.value <= 0) {
|
||||
if (!selectedItems.value.length || localSubtotal.value <= 0) {
|
||||
checkoutPreview.value = null
|
||||
availableCoupons.value = []
|
||||
unavailableCoupons.value = []
|
||||
selectedCoupon.value = null
|
||||
couponSelectionKey.value = NO_COUPON_KEY
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// 这里只做“最佳 VIP 自动券”兜底预选,普通用户券必须显式点选后才会消耗。
|
||||
const tags = new Set<string>()
|
||||
selectedItems.value.forEach(item => {
|
||||
item.tagNames?.split(',').map(tag => tag.trim()).forEach(tag => {
|
||||
if (tag) {
|
||||
tags.add(tag)
|
||||
}
|
||||
})
|
||||
const preview = await orderApi.checkoutPreview({
|
||||
couponId: selectedCoupon.value?.id,
|
||||
couponSourceType: selectedCoupon.value?.sourceType || (couponSelectionTouched.value && currentSelectedKey === NO_COUPON_KEY ? NO_COUPON_KEY : undefined),
|
||||
items: selectedItems.value.map(item => ({
|
||||
productId: item.productId,
|
||||
quantity: item.quantity,
|
||||
artistId: item.artistId,
|
||||
appointmentTime: item.appointmentTime
|
||||
}))
|
||||
})
|
||||
|
||||
const data = await couponApi.getAvailableCoupons(Array.from(tags).join(','), subtotal.value, selectedShopId) as unknown as UserCoupon[]
|
||||
availableCoupons.value = Array.isArray(data) ? data : []
|
||||
checkoutPreview.value = preview
|
||||
availableCoupons.value = Array.isArray(preview.availableCoupons) ? preview.availableCoupons : []
|
||||
unavailableCoupons.value = Array.isArray(preview.unavailableCoupons) ? preview.unavailableCoupons : []
|
||||
|
||||
const matchedCoupon = availableCoupons.value.find(coupon => getCouponKey(coupon) === currentSelectedKey) || null
|
||||
if (matchedCoupon) {
|
||||
@@ -720,7 +760,9 @@ const loadAvailableCoupons = async () => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取可用优惠失败:', error)
|
||||
checkoutPreview.value = null
|
||||
availableCoupons.value = []
|
||||
unavailableCoupons.value = []
|
||||
selectedCoupon.value = null
|
||||
couponSelectionKey.value = NO_COUPON_KEY
|
||||
}
|
||||
@@ -852,7 +894,7 @@ const closeBookingModal = () => {
|
||||
}
|
||||
|
||||
/** confirmBooking is a local helper used by this page script. */
|
||||
const confirmBooking = () => {
|
||||
const confirmBooking = async () => {
|
||||
if (!currentItem.value) return closeBookingModal()
|
||||
if (!draftArtistId.value) return message.warning('请先选择美甲师')
|
||||
if (!draftAppointmentTime.value) return message.warning('请选择预约时间')
|
||||
@@ -861,6 +903,7 @@ const confirmBooking = () => {
|
||||
currentItem.value.artist = availableArtists.value.find(artist => sameId(artist.id, draftArtistId.value))
|
||||
currentItem.value.appointmentTime = draftAppointmentTime.value
|
||||
closeBookingModal()
|
||||
await loadAvailableCoupons()
|
||||
}
|
||||
|
||||
/** openCouponModal is a local helper used by this page script. */
|
||||
@@ -870,7 +913,7 @@ const openCouponModal = () => {
|
||||
}
|
||||
|
||||
/** applyCouponSelection is a local helper used by this page script. */
|
||||
const applyCouponSelection = () => {
|
||||
const applyCouponSelection = async () => {
|
||||
couponSelectionTouched.value = true
|
||||
if (couponSelectionKey.value === NO_COUPON_KEY) {
|
||||
selectedCoupon.value = null
|
||||
@@ -878,6 +921,24 @@ const applyCouponSelection = () => {
|
||||
selectedCoupon.value = availableCoupons.value.find(coupon => getCouponKey(coupon) === couponSelectionKey.value) || null
|
||||
}
|
||||
showCouponModal.value = false
|
||||
await runWithGlobalLoading(() => loadAvailableCoupons())
|
||||
}
|
||||
|
||||
const openCheckoutRecovery = (error: unknown) => {
|
||||
const actions = buildRecoveryActions([
|
||||
{ key: 'retry', text: '重试下单' },
|
||||
{ key: 'orders', text: '查看订单' }
|
||||
])
|
||||
const retryAction = actions[0]
|
||||
const ordersAction = actions[1]
|
||||
Modal.confirm({
|
||||
title: '下单失败',
|
||||
content: `${getRecoveryMessage(error, '订单创建失败')}。如果担心重复下单,请先查看订单;仍失败时请联系客服。`,
|
||||
okText: retryAction?.text || '重试下单',
|
||||
cancelText: ordersAction?.text || '查看订单',
|
||||
onOk: () => checkout(),
|
||||
onCancel: () => router.push(ordersAction?.route || '/orders')
|
||||
})
|
||||
}
|
||||
|
||||
/** checkout is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
@@ -931,7 +992,7 @@ const checkout = async () => {
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('创建订单失败:', error)
|
||||
message.error(error?.message || '创建订单失败')
|
||||
openCheckoutRecovery(error)
|
||||
} finally {
|
||||
submittingOrder.value = false
|
||||
}
|
||||
@@ -1320,6 +1381,7 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.coupon-panel,
|
||||
.preview-panel,
|
||||
.summary-panel {
|
||||
border: 1px solid var(--theme-border);
|
||||
border-radius: 8px;
|
||||
@@ -1363,6 +1425,23 @@ onMounted(async () => {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.preview-panel {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
padding: 13px;
|
||||
}
|
||||
|
||||
.preview-line {
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.preview-line.vip {
|
||||
color: var(--theme-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.summary-panel {
|
||||
padding: 13px;
|
||||
}
|
||||
@@ -1441,6 +1520,58 @@ onMounted(async () => {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.coupon-option-copy {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.coupon-option-copy strong,
|
||||
.coupon-option-copy em {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.coupon-option-copy strong {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.coupon-option-copy em {
|
||||
color: var(--theme-accent);
|
||||
font-size: 12px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.coupon-unavailable {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin-top: 14px;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid var(--theme-border);
|
||||
}
|
||||
|
||||
.coupon-unavailable-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.coupon-unavailable-item span {
|
||||
min-width: 0;
|
||||
color: var(--text-primary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.coupon-unavailable-item em {
|
||||
max-width: 180px;
|
||||
color: var(--text-secondary);
|
||||
font-style: normal;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
:global(.cart-coupon-modal-wrap .ant-modal) {
|
||||
max-width: calc(100vw - 24px);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import { message } from 'ant-design-vue'
|
||||
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
import { userApi, type SystemMessageVO } from '@/api/user'
|
||||
import { buildSystemMessageActionPath } from '@/utils/system-message-action'
|
||||
|
||||
/**
|
||||
* Purpose: router supports NotificationsView.vue by holding or executing the router page or API role.
|
||||
@@ -76,13 +77,7 @@ const unreadCount = computed(() => messages.value.filter(item => item.readStatus
|
||||
* Purpose: resolveSystemMessageActionPath supports NotificationsView.vue by holding or executing the resolve system message action path page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const resolveSystemMessageActionPath = (item: SystemMessageVO) => {
|
||||
const actionPath = String(item.actionPath || '').trim()
|
||||
if (!actionPath || !actionPath.startsWith('/') || actionPath.startsWith('//')) {
|
||||
return ''
|
||||
}
|
||||
return actionPath
|
||||
}
|
||||
const resolveSystemMessageActionPath = (item: SystemMessageVO) => buildSystemMessageActionPath(item)
|
||||
|
||||
/**
|
||||
* Purpose: markMessageReadIfNeeded supports NotificationsView.vue by holding or executing the mark message read if needed page or API role.
|
||||
|
||||
@@ -35,15 +35,35 @@
|
||||
<a-button @click="resetFilters">清空筛选</a-button>
|
||||
</a-empty>
|
||||
|
||||
<a-card v-for="order in filteredOrders" :key="order.id" class="order-card">
|
||||
<a-card
|
||||
v-for="order in filteredOrders"
|
||||
:key="order.id"
|
||||
class="order-card"
|
||||
:class="{ focused: sameId(focusedOrderId, order.id) }"
|
||||
>
|
||||
<div class="order-head">
|
||||
<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>
|
||||
<ol class="order-timeline">
|
||||
<li
|
||||
v-for="node in buildOrderTimeline(order)"
|
||||
:key="`${order.id}-${node.key}`"
|
||||
:class="{ active: node.active, done: node.done }"
|
||||
>
|
||||
<strong>{{ node.title }}</strong>
|
||||
<span>{{ node.time || node.desc }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<div v-for="item in order.items" :key="item.id" class="item">
|
||||
<div
|
||||
v-for="item in order.items"
|
||||
:key="item.id"
|
||||
class="item"
|
||||
:class="{ focused: sameId(focusedOrderItemId, item.id) }"
|
||||
>
|
||||
<div class="thumb">
|
||||
<img v-if="item.productImage" :src="item.productImage" :alt="item.productTitle" />
|
||||
<span v-else>{{ item.productTitle[0] }}</span>
|
||||
@@ -64,11 +84,12 @@
|
||||
<div v-if="pendingChangeRequestForItem(order, item)" class="change-request">
|
||||
<div class="change-info">
|
||||
<strong>待处理改派申请</strong>
|
||||
<span>
|
||||
{{ pendingChangeRequestForItem(order, item)?.originalArtistName || item.artistName || '原美甲师' }}
|
||||
→ {{ pendingChangeRequestForItem(order, item)?.requestedArtistName || '新美甲师' }}
|
||||
</span>
|
||||
<span>原美甲师:{{ artistChangeDisplay(pendingChangeRequestForItem(order, item), item).originalArtistName }}</span>
|
||||
<span>新美甲师:{{ artistChangeDisplay(pendingChangeRequestForItem(order, item), item).requestedArtistName }}</span>
|
||||
<span v-if="pendingChangeRequestForItem(order, item)?.reason">原因:{{ pendingChangeRequestForItem(order, item)?.reason }}</span>
|
||||
<div class="impact-list">
|
||||
<span v-for="line in artistChangeDisplay(pendingChangeRequestForItem(order, item), item).impactLines" :key="line">{{ line }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="change-actions">
|
||||
<a-button size="small" type="primary" @click="approveArtistChange(pendingChangeRequestForItem(order, item))">同意</a-button>
|
||||
@@ -80,7 +101,10 @@
|
||||
|
||||
<div class="footer">
|
||||
<span>总计:¥{{ order.actualAmount.toFixed(2) }}</span>
|
||||
<a-button v-if="order.status === 1" size="small" danger @click="cancelOrder(order.id)">取消订单</a-button>
|
||||
<div class="footer-actions">
|
||||
<a-button v-if="hasRebookableItems(order)" size="small" type="primary" @click="rebookOrder(order)">复刻同款</a-button>
|
||||
<a-button v-if="order.status === 1" size="small" danger @click="cancelOrder(order.id)">取消订单</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</a-card>
|
||||
</main>
|
||||
@@ -117,6 +141,12 @@
|
||||
@cancel="closeRejectArtistChange"
|
||||
>
|
||||
<a-form layout="vertical">
|
||||
<div v-if="activeChangeRequest" class="reject-change-summary">
|
||||
<span>原美甲师:{{ artistChangeDisplay(activeChangeRequest).originalArtistName }}</span>
|
||||
<span>新美甲师:{{ artistChangeDisplay(activeChangeRequest).requestedArtistName }}</span>
|
||||
<span v-if="activeChangeRequest.reason">原因:{{ activeChangeRequest.reason }}</span>
|
||||
<span v-for="line in artistChangeDisplay(activeChangeRequest).impactLines" :key="line">{{ line }}</span>
|
||||
</div>
|
||||
<a-form-item label="拒绝原因">
|
||||
<a-textarea v-model:value="rejectForm.rejectReason" :rows="3" :maxlength="300" placeholder="可选,请填写拒绝原因" />
|
||||
</a-form-item>
|
||||
@@ -130,22 +160,27 @@
|
||||
* OrderView 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 { computed, inject, 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 { fileApi } from '../api/index'
|
||||
import { cartApi } from '../api/cart'
|
||||
import { orderApi } from '../api/order'
|
||||
import type { OrderArtistChangeRequestVO, OrderArtistReviewVO } from '../api/order'
|
||||
import { userApi } from '@/api/user'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { buildRecoveryActions, getRecoveryMessage } from '@/utils/recovery'
|
||||
import { resolveOrderReviewFocus } from '@/utils/order-review-focus'
|
||||
|
||||
/**
|
||||
* Purpose: router supports OrderView.vue by holding or executing the router page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
|
||||
/**
|
||||
* Purpose: orders supports OrderView.vue by holding or executing the orders page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -171,6 +206,8 @@ const orderReviews = ref<Record<string, OrderArtistReviewVO[]>>({})
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const pendingChangeRequests = ref<OrderArtistChangeRequestVO[]>([])
|
||||
/** historicalChangeRequests stores handled change requests for order timelines. */
|
||||
const historicalChangeRequests = ref<Record<string, OrderArtistChangeRequestVO[]>>({})
|
||||
/**
|
||||
* Purpose: reviewModalOpen supports OrderView.vue by holding or executing the review modal open page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -254,6 +291,13 @@ const filteredOrders = computed(() => {
|
||||
})
|
||||
})
|
||||
|
||||
/** focusedOrderId stores message/deep-link focus for reviews or artist-change cards. */
|
||||
const focusedOrderId = ref('')
|
||||
/** focusedOrderItemId stores message/deep-link item focus. */
|
||||
const focusedOrderItemId = ref('')
|
||||
/** focusedReviewId stores message/deep-link review focus. */
|
||||
const focusedReviewId = ref('')
|
||||
|
||||
/** statusClass is a local helper used by this page script. */
|
||||
const statusClass = (status: number) => {
|
||||
if (status === 1) return 'pending'
|
||||
@@ -311,6 +355,108 @@ const pendingChangeRequestForItem = (order: any, item: any): OrderArtistChangeRe
|
||||
return pendingChangeRequests.value.find(request => sameId(request.orderId, order.id) && sameId(request.orderItemId, item.id))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatChangePrice supports OrderView.vue by turning optional impact prices into stable customer-facing copy.
|
||||
* Usage: call it when rendering artist-change impact cards and confirmation dialogs.
|
||||
*/
|
||||
const formatChangePrice = (price?: number | string) => {
|
||||
const value = Number(price)
|
||||
return Number.isFinite(value) ? `¥${value.toFixed(2)}` : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatChangeTime supports OrderView.vue by normalizing backend or order-item appointment values for impact copy.
|
||||
* Usage: call it when rendering artist-change impact cards and confirmation dialogs.
|
||||
*/
|
||||
const formatChangeTime = (time?: string) => {
|
||||
return String(time || '').replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: artistChangeDisplay supports OrderView.vue by deriving visible impact text from a pending artist-change request.
|
||||
* Usage: use it in cards and confirmation dialogs so the user sees the same time and price impact.
|
||||
*/
|
||||
const artistChangeDisplay = (request?: OrderArtistChangeRequestVO, item?: any) => {
|
||||
const originalArtistName = request?.originalArtistName || request?.fromArtistName || item?.artistName || '原美甲师'
|
||||
const requestedArtistName = request?.requestedArtistName || request?.toArtistName || '新美甲师'
|
||||
const appointmentTime = formatChangeTime(request?.appointmentTime || item?.appointmentTime)
|
||||
const timeImpactText = request?.timeImpactText || (request?.timeAffected ? '预约时间可能调整' : '预约时间不变')
|
||||
const priceImpactText = request?.priceImpactText || (request?.priceAffected ? '订单价格可能调整' : '价格不变')
|
||||
const priceValue = request?.priceAffected ? request?.newPrice : (request?.newPrice ?? request?.originalPrice ?? item?.price)
|
||||
const priceText = formatChangePrice(priceValue)
|
||||
const impactLines = [
|
||||
appointmentTime ? `${timeImpactText}:${appointmentTime}` : timeImpactText,
|
||||
priceText ? `${priceImpactText}:${priceText}` : priceImpactText
|
||||
].filter(Boolean)
|
||||
|
||||
return {
|
||||
originalArtistName,
|
||||
requestedArtistName,
|
||||
impactLines
|
||||
}
|
||||
}
|
||||
|
||||
/** formatTimelineTime normalizes backend timestamps for the compact order timeline. */
|
||||
const formatTimelineTime = (value?: string) => {
|
||||
return String(value || '').replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
/** buildOrderTimeline creates a customer-facing status path for one order. */
|
||||
const buildOrderTimeline = (order: any) => {
|
||||
const items = order.items || []
|
||||
const firstAppointment = items.map((item: any) => item.appointmentTime).find(Boolean)
|
||||
const changes = historicalChangeRequests.value[String(order.id)] || []
|
||||
const latestHandledChange = changes.find(request => String(request.status || '').toUpperCase() !== 'PENDING')
|
||||
const nodes = [
|
||||
{
|
||||
key: 'created',
|
||||
title: '已下单',
|
||||
time: formatTimelineTime(order.createTime),
|
||||
desc: '订单已创建',
|
||||
done: true,
|
||||
active: Number(order.status) === 1
|
||||
},
|
||||
{
|
||||
key: 'appointment',
|
||||
title: '预约时间',
|
||||
time: formatTimelineTime(firstAppointment),
|
||||
desc: firstAppointment ? '' : '待确认',
|
||||
done: Boolean(firstAppointment),
|
||||
active: Number(order.status) === 1
|
||||
}
|
||||
]
|
||||
if (changes.length) {
|
||||
nodes.push({
|
||||
key: 'artist-change',
|
||||
title: '改派记录',
|
||||
time: formatTimelineTime(latestHandledChange?.approvedTime || latestHandledChange?.rejectedTime || changes[0]?.createTime),
|
||||
desc: `${changes.length} 次申请`,
|
||||
done: String(latestHandledChange?.status || '').toUpperCase() !== 'PENDING',
|
||||
active: changes.some(request => String(request.status || '').toUpperCase() === 'PENDING')
|
||||
})
|
||||
}
|
||||
nodes.push({
|
||||
key: Number(order.status) === 3 ? 'cancelled' : 'completed',
|
||||
title: Number(order.status) === 3 ? '已取消' : '已完成',
|
||||
time: formatTimelineTime(order.completeTime || order.cancelTime || order.updateTime),
|
||||
desc: Number(order.status) === 2 ? '服务已完成' : (Number(order.status) === 3 ? '订单已取消' : '等待服务完成'),
|
||||
done: Number(order.status) === 2 || Number(order.status) === 3,
|
||||
active: Number(order.status) === 2 || Number(order.status) === 3
|
||||
})
|
||||
const orderReviewsForTimeline = orderReviews.value[String(order.id)] || []
|
||||
nodes.push({
|
||||
key: 'review',
|
||||
title: '评价',
|
||||
time: formatTimelineTime(orderReviewsForTimeline.find(review => Number(review.status) === 1)?.reviewTime),
|
||||
desc: orderReviewsForTimeline.some(review => Number(review.status) === 1)
|
||||
? '已评价'
|
||||
: (pendingReviews.value.some(review => sameId(review.orderId, order.id)) ? '待评价' : '服务完成后可评价'),
|
||||
done: orderReviewsForTimeline.some(review => Number(review.status) === 1),
|
||||
active: pendingReviews.value.some(review => sameId(review.orderId, order.id))
|
||||
})
|
||||
return nodes
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatRating supports OrderView.vue by holding or executing the format rating page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -328,6 +474,47 @@ const resetFilters = () => {
|
||||
filters.maxAmount = undefined
|
||||
}
|
||||
|
||||
const normalizeRebookQuantity = (quantity: unknown) => {
|
||||
const value = Number(quantity)
|
||||
return Number.isFinite(value) && value > 0 ? Math.max(1, Math.floor(value)) : 1
|
||||
}
|
||||
|
||||
const getRebookableOrderItems = (order: any) => {
|
||||
return (order.items || []).filter((item: any) => item?.productId !== undefined && item?.productId !== null)
|
||||
}
|
||||
|
||||
const hasRebookableItems = (order: any) => {
|
||||
return Number(order.status) === 2 && getRebookableOrderItems(order).length > 0
|
||||
}
|
||||
|
||||
const rebookOrder = async (order: any) => {
|
||||
if (Number(order.status) !== 2) {
|
||||
message.warning('仅已完成订单支持再次预约')
|
||||
return
|
||||
}
|
||||
const items = getRebookableOrderItems(order)
|
||||
if (!items.length) {
|
||||
message.warning('这笔订单暂无可复刻作品')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await runWithGlobalLoading(async () => {
|
||||
for (const item of items) {
|
||||
await cartApi.addToCart({
|
||||
productId: item.productId,
|
||||
quantity: normalizeRebookQuantity(item.quantity)
|
||||
})
|
||||
}
|
||||
await updateCartCount()
|
||||
})
|
||||
message.success('已加入购物车,请重新选择美甲师和时间')
|
||||
router.push('/cart')
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '复刻同款失败,请稍后重试')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: copyOrderNo supports OrderView.vue by holding or executing the copy order no page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -391,6 +578,54 @@ const refreshOrderExtensions = async () => {
|
||||
loadOrderReviews(),
|
||||
loadPendingArtistChangeRequests()
|
||||
])
|
||||
await loadHistoricalArtistChangeRequests()
|
||||
resolveRouteFocus()
|
||||
}
|
||||
|
||||
/** loadHistoricalArtistChangeRequests loads handled and pending changes for the order timeline. */
|
||||
const loadHistoricalArtistChangeRequests = async () => {
|
||||
const orderIds = orders.value.map(order => order.id).filter(Boolean)
|
||||
const entries = await Promise.all(orderIds.map(async (orderId) => {
|
||||
try {
|
||||
return [String(orderId), await orderApi.getOrderArtistChangeRequests(orderId)] as const
|
||||
} catch {
|
||||
return [String(orderId), []] as const
|
||||
}
|
||||
}))
|
||||
historicalChangeRequests.value = Object.fromEntries(entries)
|
||||
}
|
||||
|
||||
/** resolveRouteFocus handles message jumps for review or order focus. */
|
||||
const resolveRouteFocus = () => {
|
||||
const focus = resolveOrderReviewFocus({
|
||||
orders: orders.value,
|
||||
pendingReviews: pendingReviews.value,
|
||||
orderReviews: orderReviews.value,
|
||||
query: route.query
|
||||
})
|
||||
focusedOrderId.value = focus.focusOrderId
|
||||
focusedOrderItemId.value = focus.focusOrderItemId
|
||||
focusedReviewId.value = focus.focusReviewId
|
||||
if (focus.message) {
|
||||
message.info(focus.message)
|
||||
}
|
||||
}
|
||||
|
||||
const openOrdersRecovery = (error: unknown) => {
|
||||
const actions = buildRecoveryActions([
|
||||
{ key: 'retry', text: '重试' },
|
||||
{ key: 'products', text: '去逛作品' }
|
||||
])
|
||||
const retryAction = actions[0]
|
||||
const productsAction = actions[1]
|
||||
Modal.confirm({
|
||||
title: '订单列表加载失败',
|
||||
content: `${getRecoveryMessage(error, '订单暂时没有加载出来,请重试或稍后再查看。')}。你可以重试,或先去浏览作品。`,
|
||||
okText: retryAction?.text || '重试',
|
||||
cancelText: productsAction?.text || '去逛作品',
|
||||
onOk: () => loadOrders(),
|
||||
onCancel: () => router.push(productsAction?.route || '/products')
|
||||
})
|
||||
}
|
||||
|
||||
/** loadOrders is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
@@ -417,8 +652,9 @@ const loadOrders = async () => {
|
||||
}
|
||||
await refreshOrderExtensions()
|
||||
return true
|
||||
} catch {
|
||||
message.error('获取订单列表失败')
|
||||
} catch (error) {
|
||||
orders.value = []
|
||||
openOrdersRecovery(error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -485,9 +721,15 @@ const submitReview = async () => {
|
||||
*/
|
||||
const approveArtistChange = (request?: OrderArtistChangeRequestVO) => {
|
||||
if (!request) return
|
||||
const display = artistChangeDisplay(request)
|
||||
Modal.confirm({
|
||||
title: '同意改派申请',
|
||||
content: `确定同意改派给「${request.requestedArtistName || '新美甲师'}」吗?`,
|
||||
content: [
|
||||
`原美甲师:${display.originalArtistName}`,
|
||||
`新美甲师:${display.requestedArtistName}`,
|
||||
request.reason ? `原因:${request.reason}` : '',
|
||||
...display.impactLines
|
||||
].filter(Boolean).join('\n'),
|
||||
onOk: async () => {
|
||||
try {
|
||||
await runWithGlobalLoading(async () => {
|
||||
@@ -575,15 +817,24 @@ onMounted(loadOrders)
|
||||
.filter-select, .filter-date, .filter-number { flex: 1; min-width: 0; }
|
||||
.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.focused { border-color: var(--theme-primary); box-shadow: 0 18px 40px rgba(186, 110, 132, 0.2); }
|
||||
.order-card :deep(.ant-card-body) { padding: 16px; }
|
||||
.order-head, .footer { display: flex; align-items: center; justify-content: space-between; }
|
||||
.order-head, .footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.footer-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
|
||||
.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; }
|
||||
.order-timeline { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
|
||||
.order-timeline li { display: grid; gap: 3px; min-width: 0; padding: 8px; border-radius: 8px; background: var(--theme-primary-soft); color: var(--text-secondary); }
|
||||
.order-timeline li.done { color: var(--theme-primary); }
|
||||
.order-timeline li.active { outline: 1px solid var(--theme-primary); }
|
||||
.order-timeline strong { font-size: 12px; color: var(--text-primary); }
|
||||
.order-timeline span { min-width: 0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.status { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
|
||||
.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; }
|
||||
.item.focused { padding: 8px; border-radius: 10px; background: var(--theme-primary-soft); }
|
||||
.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; }
|
||||
@@ -595,6 +846,9 @@ onMounted(loadOrders)
|
||||
.change-request { display: grid; gap: 8px; margin-top: 8px; padding: 10px; border: 1px solid var(--theme-border); border-radius: 8px; background: rgba(255, 255, 255, 0.72); }
|
||||
.change-info { display: grid; gap: 4px; color: var(--text-secondary); font-size: 13px; }
|
||||
.change-info strong { color: var(--text-primary); }
|
||||
.impact-list, .reject-change-summary { display: grid; gap: 4px; }
|
||||
.impact-list { margin-top: 2px; color: var(--theme-primary); }
|
||||
.reject-change-summary { margin-bottom: 14px; padding: 10px 12px; border-radius: 8px; background: var(--theme-primary-soft); color: var(--text-secondary); font-size: 13px; }
|
||||
.change-actions { display: flex; gap: 8px; justify-content: flex-end; }
|
||||
.rating-input { width: 100%; }
|
||||
|
||||
|
||||
@@ -79,6 +79,17 @@
|
||||
<h3>款式说明</h3>
|
||||
<p>{{ product.description || '店家暂未补充作品说明。' }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="product.targetAudience || product.precautions" class="guidance-grid">
|
||||
<section v-if="product.targetAudience" class="guidance-panel">
|
||||
<h3>适合人群</h3>
|
||||
<p>{{ product.targetAudience }}</p>
|
||||
</section>
|
||||
<section v-if="product.precautions" class="guidance-panel">
|
||||
<h3>注意事项</h3>
|
||||
<p>{{ product.precautions }}</p>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="comment-section">
|
||||
@@ -365,8 +376,10 @@ const handleAddToCart = async () => {
|
||||
/** handleBuyNow is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleBuyNow = async () => {
|
||||
if (!product.value.id || !requireLogin('预约下单')) return
|
||||
await handleAddToCart()
|
||||
router.push('/cart')
|
||||
await runWithGlobalLoading(() => cartApi.addToCart({ productId: product.value.id, quantity: 1 }))
|
||||
await updateCartCount()
|
||||
message.success('已加入确认订单')
|
||||
router.push({ path: '/cart', query: { mode: 'buyNow', productId: String(product.value.id) } })
|
||||
}
|
||||
|
||||
/** submitComment is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
@@ -428,8 +441,10 @@ onMounted(() => {
|
||||
.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: var(--text-primary); }
|
||||
.description p { margin: 10px 0 0; color: var(--text-secondary); line-height: 1.8; }
|
||||
.description h3, .guidance-panel h3, .section-head h3 { margin: 0; font-size: 18px; color: var(--text-primary); }
|
||||
.description p, .guidance-panel p { margin: 10px 0 0; color: var(--text-secondary); line-height: 1.8; white-space: pre-wrap; }
|
||||
.guidance-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
|
||||
.guidance-panel { padding: 14px; border-radius: 8px; border: 1px solid var(--theme-border); background: var(--theme-primary-soft); }
|
||||
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
|
||||
.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); }
|
||||
@@ -445,5 +460,5 @@ onMounted(() => {
|
||||
.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; } }
|
||||
@media (max-width: 720px) { .metrics, .guidance-grid { grid-template-columns: 1fr; } .title-row { flex-direction: column; } }
|
||||
</style>
|
||||
|
||||
@@ -21,14 +21,26 @@
|
||||
|
||||
<div class="main-content">
|
||||
<div class="category-sidebar">
|
||||
<div
|
||||
v-for="category in categories"
|
||||
:key="category"
|
||||
<button
|
||||
class="category-item"
|
||||
:class="{ active: selectedCategory === category }"
|
||||
@click="handleCategoryClick(category)"
|
||||
:class="{ active: selectedCategory === '全部' }"
|
||||
type="button"
|
||||
@click="handleCategoryClick('全部')"
|
||||
>
|
||||
{{ category }}
|
||||
全部
|
||||
</button>
|
||||
<div v-for="group in filterGroups" :key="group.groupName" class="filter-group">
|
||||
<span class="filter-group__title">{{ group.groupName }}</span>
|
||||
<button
|
||||
v-for="tag in group.tags"
|
||||
:key="tag.id"
|
||||
class="category-item"
|
||||
:class="{ active: selectedTagId === String(tag.id) }"
|
||||
type="button"
|
||||
@click="handleTagClick(tag)"
|
||||
>
|
||||
{{ tag.displayName || tag.tagName }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -146,7 +158,7 @@ import { productApi, type ProductVO } from '@/api/product'
|
||||
* Purpose: TagVO supports ProductListView.vue by holding or executing the tag vo page or API role.
|
||||
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
import { tagApi, type TagVO } from '@/api/tag'
|
||||
import { tagApi, type TagFilterGroupVO, type TagVO } from '@/api/tag'
|
||||
import { cartApi } from '@/api/cart'
|
||||
import { fileApi } from '@/api/file'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
@@ -176,18 +188,14 @@ const route = useRoute()
|
||||
*/
|
||||
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
|
||||
|
||||
/**
|
||||
* Purpose: allTags supports ProductListView.vue by holding or executing the all tags page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const allTags = ref<TagVO[]>([])
|
||||
/**
|
||||
* Purpose: categories supports ProductListView.vue by holding or executing the categories page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const categories = ref<string[]>(['全部'])
|
||||
/** filterGroups stores scene-based tag filters shown above the product grid. */
|
||||
const filterGroups = ref<TagFilterGroupVO[]>([])
|
||||
/** allTags flattens filter groups for route/query lookup. */
|
||||
const allTags = computed(() => filterGroups.value.flatMap(group => group.tags || []))
|
||||
/** selectedCategory is a reactive state variable used by the template and event handlers. */
|
||||
const selectedCategory = ref('全部')
|
||||
/** selectedTagId tracks the grouped filter id sent to the backend. */
|
||||
const selectedTagId = ref('')
|
||||
/**
|
||||
* Purpose: products supports ProductListView.vue by holding or executing the products page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -225,7 +233,7 @@ const activeBannerText = computed(() => {
|
||||
return `当前显示“${searchKeyword.value.trim()}”的匹配结果`
|
||||
}
|
||||
if (selectedCategory.value !== '全部') {
|
||||
return `当前按标签“${selectedCategory.value}”筛选`
|
||||
return `当前按场景“${selectedCategory.value}”筛选`
|
||||
}
|
||||
return ''
|
||||
})
|
||||
@@ -297,12 +305,11 @@ const syncCartProductState = async () => {
|
||||
/** fetchTags is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const fetchTags = async () => {
|
||||
try {
|
||||
const response = await tagApi.getAllTags() as unknown as TagVO[]
|
||||
allTags.value = Array.isArray(response) ? response : []
|
||||
categories.value = ['全部', ...allTags.value.map(tag => tag.tagName)]
|
||||
const response = await tagApi.getFilterOptions() as unknown as TagFilterGroupVO[]
|
||||
filterGroups.value = Array.isArray(response) ? response : []
|
||||
} catch (error: any) {
|
||||
console.error('获取标签失败:', error)
|
||||
categories.value = ['全部']
|
||||
filterGroups.value = []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,10 +322,15 @@ const fetchProducts = async () => {
|
||||
|
||||
if (keyword) {
|
||||
response = await productApi.searchProducts(keyword)
|
||||
} else if (selectedCategory.value === '全部') {
|
||||
} else if (!selectedTagId.value) {
|
||||
response = await productApi.getAllProducts()
|
||||
} else {
|
||||
response = await productApi.getProductsByTag(selectedCategory.value)
|
||||
const pageResult = await productApi.getProductPage({
|
||||
page: 1,
|
||||
size: 200,
|
||||
tagIds: selectedTagId.value
|
||||
})
|
||||
response = pageResult.list || []
|
||||
}
|
||||
|
||||
products.value = markProductsInCart(Array.isArray(response) ? response : [])
|
||||
@@ -337,10 +349,15 @@ const syncRouteFilters = async () => {
|
||||
await syncCartProductState()
|
||||
const keyword = typeof route.query.keyword === 'string' ? route.query.keyword.trim() : ''
|
||||
const tag = typeof route.query.tag === 'string' ? route.query.tag.trim() : ''
|
||||
const tagId = typeof route.query.tagId === 'string' ? route.query.tagId.trim() : ''
|
||||
const matchedTag = tagId
|
||||
? allTags.value.find(item => String(item.id) === tagId)
|
||||
: allTags.value.find(item => item.tagName === tag || item.displayName === tag)
|
||||
|
||||
searchKeyword.value = keyword
|
||||
showSearch.value = Boolean(keyword)
|
||||
selectedCategory.value = tag && categories.value.includes(tag) ? tag : '全部'
|
||||
selectedTagId.value = matchedTag ? String(matchedTag.id) : ''
|
||||
selectedCategory.value = matchedTag ? (matchedTag.displayName || matchedTag.tagName) : '全部'
|
||||
if (useGlobalLoadingForNextRouteSync) {
|
||||
useGlobalLoadingForNextRouteSync = false
|
||||
await runWithGlobalLoading(() => fetchProducts())
|
||||
@@ -357,12 +374,23 @@ const handleBackClick = () => {
|
||||
/** handleCategoryClick is a local helper used by this page script. */
|
||||
const handleCategoryClick = (category: string) => {
|
||||
selectedCategory.value = category
|
||||
selectedTagId.value = ''
|
||||
searchKeyword.value = ''
|
||||
showSearch.value = false
|
||||
useGlobalLoadingForNextRouteSync = true
|
||||
router.replace({ path: '/products', query: {} })
|
||||
}
|
||||
|
||||
/** handleTagClick is a local helper used by grouped scene-filter chips. */
|
||||
const handleTagClick = (tag: TagVO) => {
|
||||
selectedCategory.value = tag.displayName || tag.tagName
|
||||
selectedTagId.value = String(tag.id)
|
||||
searchKeyword.value = ''
|
||||
showSearch.value = false
|
||||
useGlobalLoadingForNextRouteSync = true
|
||||
router.replace({
|
||||
path: '/products',
|
||||
query: category === '全部' ? {} : { tag: category }
|
||||
query: { tag: tag.displayName || tag.tagName, tagId: String(tag.id) }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -408,13 +436,17 @@ const toggleSearch = () => {
|
||||
if (!showSearch.value) {
|
||||
searchKeyword.value = ''
|
||||
useGlobalLoadingForNextRouteSync = true
|
||||
router.replace({ path: '/products', query: selectedCategory.value === '全部' ? {} : { tag: selectedCategory.value } })
|
||||
router.replace({
|
||||
path: '/products',
|
||||
query: selectedTagId.value ? { tag: selectedCategory.value, tagId: selectedTagId.value } : {}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/** resetFilters is a local helper used by this page script. */
|
||||
const resetFilters = () => {
|
||||
selectedCategory.value = '全部'
|
||||
selectedTagId.value = ''
|
||||
searchKeyword.value = ''
|
||||
showSearch.value = false
|
||||
useGlobalLoadingForNextRouteSync = true
|
||||
@@ -564,6 +596,20 @@ onMounted(async () => {
|
||||
border: 1px solid var(--theme-border);
|
||||
}
|
||||
|
||||
.filter-group {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.filter-group__title {
|
||||
flex: 0 0 auto;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.category-item:hover {
|
||||
color: var(--theme-primary);
|
||||
border-color: var(--theme-primary);
|
||||
|
||||
@@ -83,6 +83,10 @@
|
||||
</div>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<button v-if="pendingReviewCount > 0" class="pending-review-card" type="button" @click="openPendingReviews">
|
||||
<span>待评价 {{ pendingReviewCount }}</span>
|
||||
<small>给服务过你的美甲师一点反馈</small>
|
||||
</button>
|
||||
</a-card>
|
||||
</div>
|
||||
|
||||
@@ -260,6 +264,8 @@ const needSetPassword = ref(false)
|
||||
const hasNotification = ref(false)
|
||||
/** unreadMessageCount is a reactive state variable used by the template and event handlers. */
|
||||
const unreadMessageCount = ref(0)
|
||||
/** pendingReviewCount is the number of completed services waiting for customer review. */
|
||||
const pendingReviewCount = ref(0)
|
||||
/** orderCount is a reactive state variable used by the template and event handlers. */
|
||||
const orderCount = ref(0)
|
||||
/** couponCount is a reactive state variable used by the template and event handlers. */
|
||||
@@ -484,16 +490,18 @@ const fetchUserInfo = async () => {
|
||||
const loadCounts = async () => {
|
||||
try {
|
||||
const orderListRequest = isServiceUser.value ? orderApi.getArtistOrders() : orderApi.getOrderList()
|
||||
const [orders, coupons, wishlist, unreadMessages] = await Promise.all([
|
||||
const [orders, coupons, wishlist, unreadMessages, pendingReviews] = await Promise.all([
|
||||
orderListRequest,
|
||||
couponApi.listUserCoupons(),
|
||||
wishlistApi.getWishlist(),
|
||||
userApi.getMyUnreadMessageCount()
|
||||
userApi.getMyUnreadMessageCount(),
|
||||
isServiceUser.value ? Promise.resolve([]) : orderApi.getMyPendingReviews().catch(() => [])
|
||||
])
|
||||
orderCount.value = Array.isArray(orders) ? orders.length : 0
|
||||
couponCount.value = Array.isArray(coupons) ? coupons.length : 0
|
||||
wishlistCount.value = Array.isArray(wishlist) ? wishlist.length : 0
|
||||
unreadMessageCount.value = Number(unreadMessages?.unreadCount || 0)
|
||||
pendingReviewCount.value = Array.isArray(pendingReviews) ? pendingReviews.length : 0
|
||||
hasNotification.value = unreadMessageCount.value > 0
|
||||
} catch (error) {
|
||||
console.error('加载个人中心统计失败:', error)
|
||||
@@ -505,6 +513,11 @@ const openOrders = () => {
|
||||
router.push(isServiceUser.value ? '/artist-orders' : '/orders')
|
||||
}
|
||||
|
||||
/** openPendingReviews jumps directly to the first pending review on the order page. */
|
||||
const openPendingReviews = () => {
|
||||
router.push('/orders?review=pending&source=profile')
|
||||
}
|
||||
|
||||
/** handleEditProfile is a local helper used by this page script. */
|
||||
const handleEditProfile = () => {
|
||||
avatarUploadTask?.cancel()
|
||||
@@ -911,6 +924,29 @@ onMounted(async () => {
|
||||
padding: 20px 16px;
|
||||
}
|
||||
|
||||
.pending-review-card {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
margin-top: 18px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid var(--theme-border);
|
||||
border-radius: 8px;
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--text-primary);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pending-review-card span {
|
||||
color: var(--theme-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.pending-review-card small {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -30,9 +30,23 @@
|
||||
</section>
|
||||
|
||||
<section class="shop-details">
|
||||
<div v-if="trustProfile" class="trust-grid">
|
||||
<div class="trust-card">
|
||||
<strong>{{ formatRating(trustProfile.stats?.averageRating) }}</strong>
|
||||
<span>{{ Number(trustProfile.stats?.reviewCount || 0) }} 条评价</span>
|
||||
</div>
|
||||
<div class="trust-card">
|
||||
<strong>{{ Number(trustProfile.stats?.productCount || 0) }}</strong>
|
||||
<span>在售作品</span>
|
||||
</div>
|
||||
<div class="trust-card">
|
||||
<strong>{{ trustProfile.businessStatusText || '可浏览' }}</strong>
|
||||
<span>{{ trustProfile.availabilitySummary?.summaryText || '预约前会再次确认档期' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<div class="detail-label">营业时间</div>
|
||||
<div class="detail-value">{{ shopInfo.businessHours || '暂未设置' }}</div>
|
||||
<div class="detail-value">{{ trustProfile?.businessHoursText || shopInfo.businessHours || '暂未设置' }}</div>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<div class="detail-label">店铺描述</div>
|
||||
@@ -62,6 +76,41 @@
|
||||
</a-carousel>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="trustProfile?.featuredProducts?.length" class="shop-trust-section">
|
||||
<h3 class="section-title">可预约作品</h3>
|
||||
<div class="featured-products">
|
||||
<button
|
||||
v-for="product in trustProfile.featuredProducts"
|
||||
:key="product.id"
|
||||
type="button"
|
||||
class="featured-product"
|
||||
@click="openProduct(product.id)"
|
||||
>
|
||||
<img v-if="product.imageUrl" :src="product.imageUrl" :alt="product.title || '作品'" />
|
||||
<div v-else class="featured-product__placeholder">作</div>
|
||||
<div>
|
||||
<strong>{{ product.title || '美甲作品' }}</strong>
|
||||
<span>¥{{ Number(product.price || 0).toFixed(2) }}</span>
|
||||
<small>{{ product.bookingHint || '下单前选择美甲师和时间' }}</small>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="trustProfile?.recentReviews?.length" class="shop-trust-section">
|
||||
<h3 class="section-title">近期评价</h3>
|
||||
<div class="recent-reviews">
|
||||
<article v-for="review in trustProfile.recentReviews" :key="review.id" class="recent-review">
|
||||
<div class="recent-review__head">
|
||||
<strong>{{ review.productTitle || '订单评价' }}</strong>
|
||||
<span>{{ formatRating(review.ratingScore) }}</span>
|
||||
</div>
|
||||
<p>{{ review.content || '用户已完成评价' }}</p>
|
||||
<small>{{ formatTime(review.submittedAt) }}</small>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</a-card>
|
||||
</main>
|
||||
|
||||
@@ -105,7 +154,7 @@ import { fileApi } from '@/api/file'
|
||||
* Purpose: ShopVO supports ShopDetailView.vue by holding or executing the shop vo page or API role.
|
||||
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { shopApi, type ShopTrustProfileVO, type ShopVO } from '@/api/shop'
|
||||
/**
|
||||
* Purpose: ContactInfoVO supports ShopDetailView.vue by holding or executing the contact info vo page or API role.
|
||||
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -177,6 +226,8 @@ const mapOpen = ref(false)
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const distanceText = ref('')
|
||||
/** trustProfile stores public confidence signals for this shop. */
|
||||
const trustProfile = ref<ShopTrustProfileVO | null>(null)
|
||||
|
||||
/**
|
||||
* Purpose: hasLocation supports ShopDetailView.vue by holding or executing the has location page or API role.
|
||||
@@ -253,6 +304,23 @@ const openNavigation = (provider: 'TENCENT' | 'AMAP') => {
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
||||
/** openProduct routes from shop trust cards to the product detail page. */
|
||||
const openProduct = (productId: string | number) => {
|
||||
router.push(`/product/${productId}`)
|
||||
}
|
||||
|
||||
/** formatRating renders trust scores without exposing backend numeric details. */
|
||||
const formatRating = (value: unknown) => {
|
||||
const rating = Number(value || 0)
|
||||
return rating > 0 ? rating.toFixed(1) : '暂无'
|
||||
}
|
||||
|
||||
/** formatTime renders review timestamps for the trust section. */
|
||||
const formatTime = (value?: string) => {
|
||||
if (!value) return ''
|
||||
return String(value).replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: calculateDistanceText supports ShopDetailView.vue by holding or executing the calculate distance text page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -311,6 +379,7 @@ const loadShopImages = async () => {
|
||||
try {
|
||||
const imageFileIds = shopInfo.value.imageFileIds
|
||||
if (!imageFileIds) return
|
||||
if (shopImages.value.length > 0) return
|
||||
|
||||
const fileIds = imageFileIds.split(',').map(id => id.trim()).filter(Boolean)
|
||||
const results = await Promise.all(fileIds.map(fileId => fileApi.getSignedUrl(fileId).catch(() => null)))
|
||||
@@ -336,6 +405,10 @@ const fetchShopDetail = async () => {
|
||||
}
|
||||
|
||||
shopInfo.value = await shopApi.getShopById(shopId)
|
||||
trustProfile.value = await shopApi.getTrustProfile(shopId).catch(() => null)
|
||||
if (trustProfile.value?.environmentImages?.length) {
|
||||
shopImages.value = trustProfile.value.environmentImages.filter(Boolean)
|
||||
}
|
||||
await loadShopImages()
|
||||
loadCurrentDistance()
|
||||
} catch (error: any) {
|
||||
@@ -473,6 +546,33 @@ onMounted(fetchShopDetail)
|
||||
margin-top: 22px;
|
||||
}
|
||||
|
||||
.trust-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.trust-card {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
min-height: 74px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--theme-border);
|
||||
border-radius: 8px;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.trust-card strong {
|
||||
color: var(--theme-primary);
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.trust-card span {
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
font-size: 13px;
|
||||
color: #8a94a6;
|
||||
@@ -515,6 +615,101 @@ onMounted(fetchShopDetail)
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.shop-trust-section {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.featured-products {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.featured-product {
|
||||
display: grid;
|
||||
grid-template-columns: 84px minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
border: 1px solid var(--theme-border);
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.featured-product img,
|
||||
.featured-product__placeholder {
|
||||
width: 84px;
|
||||
height: 84px;
|
||||
border-radius: 8px;
|
||||
object-fit: cover;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.featured-product__placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--theme-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.featured-product strong,
|
||||
.featured-product span,
|
||||
.featured-product small {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.featured-product strong {
|
||||
color: #172033;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.featured-product span {
|
||||
margin-top: 4px;
|
||||
color: var(--theme-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.featured-product small {
|
||||
margin-top: 6px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.recent-reviews {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.recent-review {
|
||||
padding: 12px;
|
||||
border: 1px solid var(--theme-border);
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.recent-review__head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
color: #172033;
|
||||
}
|
||||
|
||||
.recent-review__head span {
|
||||
color: var(--theme-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.recent-review p {
|
||||
margin: 8px 0 6px;
|
||||
color: #475467;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.recent-review small {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
@@ -619,6 +814,10 @@ onMounted(fetchShopDetail)
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.trust-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.map-frame {
|
||||
height: 320px;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,29 @@
|
||||
<div class="empty"></div>
|
||||
</header>
|
||||
|
||||
<div v-if="groups.length" class="group-tabs">
|
||||
<button
|
||||
class="group-tab"
|
||||
:class="{ 'group-tab--active': activeGroupId === null }"
|
||||
type="button"
|
||||
@click="activeGroupId = null"
|
||||
>
|
||||
All
|
||||
</button>
|
||||
<button
|
||||
v-for="group in groups"
|
||||
:key="String(group.id)"
|
||||
class="group-tab"
|
||||
:class="{ 'group-tab--active': sameId(activeGroupId, group.id) }"
|
||||
type="button"
|
||||
@click="activeGroupId = group.id"
|
||||
>
|
||||
{{ group.name }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="wishlist-items">
|
||||
<div v-for="item in wishlistItems" :key="item.id" class="wishlist-item">
|
||||
<div v-for="item in visibleWishlistItems" :key="item.id" class="wishlist-item">
|
||||
<div class="item-image" @click="handleProductClick(item.product.id)">
|
||||
<img
|
||||
v-if="getProductImages(item.product).length > 0"
|
||||
@@ -22,6 +43,8 @@
|
||||
</div>
|
||||
<div class="item-details">
|
||||
<h3 class="item-name" @click="handleProductClick(item.product.id)">{{ item.product.title }}</h3>
|
||||
<div class="item-group">{{ item.groupName || '最近想做' }}</div>
|
||||
<p v-if="item.note" class="item-note">{{ item.note }}</p>
|
||||
<p class="item-price">¥{{ Number(item.product.price || 0).toFixed(2) }}</p>
|
||||
<div class="item-actions">
|
||||
<el-button
|
||||
@@ -52,7 +75,7 @@
|
||||
* WishlistView page script.
|
||||
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
||||
*/
|
||||
import { ref, onMounted, inject } from 'vue'
|
||||
import { computed, ref, onMounted, inject } from 'vue'
|
||||
import { ArrowLeft, Delete, StarFilled } from '@element-plus/icons-vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
@@ -61,7 +84,7 @@ import 'element-plus/es/components/message/style/css'
|
||||
* Purpose: WishlistItem supports WishlistView.vue by holding or executing the wishlist item page or API role.
|
||||
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
import { wishlistApi, type WishlistItem } from '@/api/wishlist'
|
||||
import { wishlistApi, type WishlistGroup, type WishlistItem } from '@/api/wishlist'
|
||||
import { cartApi } from '@/api/cart'
|
||||
import { fileApi } from '@/api/file'
|
||||
import type { IdType } from '@/utils/id'
|
||||
@@ -85,6 +108,8 @@ const updateCartCount = inject<() => Promise<void>>('updateCartCount', async ()
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const wishlistItems = ref<WishlistItem[]>([])
|
||||
const groups = ref<WishlistGroup[]>([])
|
||||
const activeGroupId = ref<IdType | null>(null)
|
||||
/**
|
||||
* Purpose: imageIdCache supports WishlistView.vue by holding or executing the image id cache page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -103,6 +128,13 @@ const cartProductIdSet = ref(new Set<string>())
|
||||
*/
|
||||
const DEFAULT_PRODUCT_IMAGE = 'data:image/svg+xml;base64,PHN2ZyB3aW0dPSJodHRwOi8vd3d3Lm9yZy8yMDAwL3N2ZyI+Pjwvc3ZnPg=='
|
||||
|
||||
const visibleWishlistItems = computed(() => {
|
||||
if (activeGroupId.value === null) {
|
||||
return wishlistItems.value
|
||||
}
|
||||
return wishlistItems.value.filter(item => sameId(item.groupId, activeGroupId.value))
|
||||
})
|
||||
|
||||
/** handleBackClick is a local helper used by this page script. */
|
||||
const handleBackClick = () => {
|
||||
router.back()
|
||||
@@ -111,11 +143,13 @@ const handleBackClick = () => {
|
||||
/** fetchWishlist is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const fetchWishlist = async () => {
|
||||
try {
|
||||
const [response, nextCartProductIdSet] = await Promise.all([
|
||||
const [response, nextGroups, nextCartProductIdSet] = await Promise.all([
|
||||
wishlistApi.getWishlist(),
|
||||
wishlistApi.getGroups(),
|
||||
fetchCartProductIdSet()
|
||||
])
|
||||
cartProductIdSet.value = nextCartProductIdSet
|
||||
groups.value = nextGroups
|
||||
wishlistItems.value = response as unknown as WishlistItem[]
|
||||
await loadImageUrls(response as unknown as WishlistItem[])
|
||||
} catch (error: any) {
|
||||
@@ -262,6 +296,33 @@ onMounted(() => {
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.group-tabs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
overflow-x: auto;
|
||||
padding: 14px 16px 0;
|
||||
}
|
||||
|
||||
.group-tab {
|
||||
flex: 0 0 auto;
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid var(--theme-border);
|
||||
border-radius: 8px;
|
||||
background: var(--theme-card-bg);
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 30px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.group-tab--active {
|
||||
border-color: var(--theme-primary);
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wishlist-items {
|
||||
padding: 16px;
|
||||
padding-bottom: 28px;
|
||||
@@ -321,6 +382,26 @@ onMounted(() => {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.item-group {
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
margin-bottom: 6px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 8px;
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-accent);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.item-note {
|
||||
margin: 0 0 8px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.item-price {
|
||||
color: var(--theme-primary);
|
||||
font-weight: bold;
|
||||
|
||||
@@ -189,6 +189,20 @@
|
||||
:rows="3"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="适合人群" name="targetAudience">
|
||||
<a-textarea
|
||||
v-model:value="formState.targetAudience"
|
||||
placeholder="例如:短甲、通勤、婚礼跟妆、敏感肌需提前沟通"
|
||||
:rows="3"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="注意事项" name="precautions">
|
||||
<a-textarea
|
||||
v-model:value="formState.precautions"
|
||||
placeholder="例如:完成后 24 小时内避免长时间热水浸泡"
|
||||
:rows="3"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="店铺" name="shopId">
|
||||
<a-select
|
||||
v-model:value="formState.shopId"
|
||||
@@ -390,6 +404,20 @@
|
||||
:disabled="true"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="适合人群">
|
||||
<a-textarea
|
||||
v-model:value="viewFormState.targetAudience"
|
||||
:rows="3"
|
||||
:disabled="true"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="注意事项">
|
||||
<a-textarea
|
||||
v-model:value="viewFormState.precautions"
|
||||
:rows="3"
|
||||
:disabled="true"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="店铺">
|
||||
<a-select v-model:value="viewFormState.shopId" :disabled="true">
|
||||
<a-select-option
|
||||
@@ -698,6 +726,8 @@ const viewFormState = reactive({
|
||||
shopId: undefined,
|
||||
title: '',
|
||||
description: '',
|
||||
targetAudience: '',
|
||||
precautions: '',
|
||||
imageFileIds: '',
|
||||
price: 0,
|
||||
likeCount: 0,
|
||||
@@ -729,6 +759,8 @@ const formState = reactive({
|
||||
shopId: undefined,
|
||||
title: '',
|
||||
description: '',
|
||||
targetAudience: '',
|
||||
precautions: '',
|
||||
imageFileIds: '',
|
||||
price: 0,
|
||||
likeCount: 0,
|
||||
@@ -1084,6 +1116,8 @@ const showAddModal = async () => {
|
||||
shopId: shopId,
|
||||
title: '',
|
||||
description: '',
|
||||
targetAudience: '',
|
||||
precautions: '',
|
||||
imageFileIds: '',
|
||||
price: 0,
|
||||
likeCount: 0,
|
||||
@@ -1112,6 +1146,8 @@ const showEditModal = async (record: Product | Record<string, any>) => {
|
||||
const recordShopId = 'shopId' in record ? record.shopId : (record as any).shopId
|
||||
const recordTitle = 'title' in record ? record.title : (record as any).title
|
||||
const recordDescription = 'description' in record ? record.description : (record as any).description
|
||||
const recordTargetAudience = 'targetAudience' in record ? record.targetAudience : (record as any).targetAudience
|
||||
const recordPrecautions = 'precautions' in record ? record.precautions : (record as any).precautions
|
||||
const recordImageFileIds = 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||||
const recordPrice = 'price' in record ? record.price : (record as any).price
|
||||
const recordLikeCount = 'likeCount' in record ? record.likeCount : (record as any).likeCount
|
||||
@@ -1134,6 +1170,8 @@ const showEditModal = async (record: Product | Record<string, any>) => {
|
||||
shopId: recordShopId,
|
||||
title: recordTitle,
|
||||
description: recordDescription,
|
||||
targetAudience: recordTargetAudience || '',
|
||||
precautions: recordPrecautions || '',
|
||||
imageFileIds: recordImageFileIds,
|
||||
price: recordPrice,
|
||||
likeCount: normalizeInteractionCount(recordLikeCount),
|
||||
@@ -1168,6 +1206,8 @@ const showViewModal = async (record: Product | Record<string, any>) => {
|
||||
const recordShopId = 'shopId' in record ? record.shopId : (record as any).shopId
|
||||
const recordTitle = 'title' in record ? record.title : (record as any).title
|
||||
const recordDescription = 'description' in record ? record.description : (record as any).description
|
||||
const recordTargetAudience = 'targetAudience' in record ? record.targetAudience : (record as any).targetAudience
|
||||
const recordPrecautions = 'precautions' in record ? record.precautions : (record as any).precautions
|
||||
const recordImageFileIds = 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||||
const recordPrice = 'price' in record ? record.price : (record as any).price
|
||||
const recordLikeCount = 'likeCount' in record ? record.likeCount : (record as any).likeCount
|
||||
@@ -1190,6 +1230,8 @@ const showViewModal = async (record: Product | Record<string, any>) => {
|
||||
shopId: recordShopId,
|
||||
title: recordTitle,
|
||||
description: recordDescription,
|
||||
targetAudience: recordTargetAudience || '',
|
||||
precautions: recordPrecautions || '',
|
||||
imageFileIds: recordImageFileIds,
|
||||
price: recordPrice,
|
||||
likeCount: normalizeInteractionCount(recordLikeCount),
|
||||
@@ -1252,6 +1294,8 @@ const buildDraftPayload = () => ({
|
||||
shopId: formState.shopId,
|
||||
title: formState.title,
|
||||
description: formState.description,
|
||||
targetAudience: formState.targetAudience,
|
||||
precautions: formState.precautions,
|
||||
imageFileIds: formState.imageFileIds,
|
||||
price: formState.price,
|
||||
likeCount: formState.likeCount,
|
||||
|
||||
@@ -159,6 +159,18 @@
|
||||
<a-form-item label="边框颜色" name="borderColor">
|
||||
<el-color-picker v-model="formState.borderColor" />
|
||||
</a-form-item>
|
||||
<a-form-item label="场景分组" name="sceneGroup">
|
||||
<a-input v-model:value="formState.sceneGroup" placeholder="如:风格、场合、季节" />
|
||||
</a-form-item>
|
||||
<a-form-item label="前台名称" name="displayName">
|
||||
<a-input v-model:value="formState.displayName" placeholder="留空则使用标签名称" />
|
||||
</a-form-item>
|
||||
<a-form-item label="前台排序" name="sortOrder">
|
||||
<a-input-number v-model:value="formState.sortOrder" :min="0" style="width: 100%" />
|
||||
</a-form-item>
|
||||
<a-form-item label="前台展示" name="frontVisible">
|
||||
<a-switch v-model:checked="formState.frontVisible" :checked-value="1" :un-checked-value="0" />
|
||||
</a-form-item>
|
||||
<a-form-item label="预览">
|
||||
<span
|
||||
class="tag-preview"
|
||||
@@ -210,6 +222,18 @@
|
||||
<a-form-item label="边框颜色">
|
||||
<el-color-picker v-model="viewFormState.borderColor" disabled />
|
||||
</a-form-item>
|
||||
<a-form-item label="场景分组">
|
||||
<a-input v-model:value="viewFormState.sceneGroup" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="前台名称">
|
||||
<a-input v-model:value="viewFormState.displayName" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="前台排序">
|
||||
<a-input-number v-model:value="viewFormState.sortOrder" :disabled="true" style="width: 100%" />
|
||||
</a-form-item>
|
||||
<a-form-item label="前台展示">
|
||||
<a-switch v-model:checked="viewFormState.frontVisible" :checked-value="1" :un-checked-value="0" disabled />
|
||||
</a-form-item>
|
||||
<a-form-item label="预览">
|
||||
<span
|
||||
class="tag-preview"
|
||||
@@ -308,7 +332,11 @@ const viewFormState = reactive({
|
||||
shopId: undefined as number | undefined,
|
||||
textColor: '#333333',
|
||||
bgColor: '#FFFFFF',
|
||||
borderColor: '#E5E5E5'
|
||||
borderColor: '#E5E5E5',
|
||||
sceneGroup: '',
|
||||
displayName: '',
|
||||
sortOrder: 100,
|
||||
frontVisible: 1
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -346,7 +374,11 @@ const formState = reactive({
|
||||
shopId: undefined as number | undefined,
|
||||
textColor: '#333333',
|
||||
bgColor: '#FFFFFF',
|
||||
borderColor: '#E5E5E5'
|
||||
borderColor: '#E5E5E5',
|
||||
sceneGroup: '',
|
||||
displayName: '',
|
||||
sortOrder: 100,
|
||||
frontVisible: 1
|
||||
})
|
||||
|
||||
/** getDraftKey is a local helper used by this page script. */
|
||||
@@ -358,7 +390,11 @@ const buildDraftPayload = () => ({
|
||||
shopId: formState.shopId,
|
||||
textColor: formState.textColor,
|
||||
bgColor: formState.bgColor,
|
||||
borderColor: formState.borderColor
|
||||
borderColor: formState.borderColor,
|
||||
sceneGroup: formState.sceneGroup,
|
||||
displayName: formState.displayName,
|
||||
sortOrder: formState.sortOrder,
|
||||
frontVisible: formState.frontVisible
|
||||
})
|
||||
|
||||
/** restoreDraft is a local helper used by this page script. */
|
||||
@@ -409,6 +445,8 @@ const columns = [
|
||||
{ title: '文字颜色', dataIndex: 'textColor', key: 'textColor', width: 120 },
|
||||
{ title: '背景颜色', dataIndex: 'bgColor', key: 'bgColor', width: 120 },
|
||||
{ title: '边框颜色', dataIndex: 'borderColor', key: 'borderColor', width: 120 },
|
||||
{ title: '场景分组', dataIndex: 'sceneGroup', key: 'sceneGroup', width: 120 },
|
||||
{ title: '前台名称', dataIndex: 'displayName', key: 'displayName', width: 120 },
|
||||
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
|
||||
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
|
||||
]
|
||||
@@ -487,7 +525,11 @@ const showAddModal = () => {
|
||||
shopId: shopId,
|
||||
textColor: '#333333',
|
||||
bgColor: '#FFFFFF',
|
||||
borderColor: '#E5E5E5'
|
||||
borderColor: '#E5E5E5',
|
||||
sceneGroup: '',
|
||||
displayName: '',
|
||||
sortOrder: 100,
|
||||
frontVisible: 1
|
||||
})
|
||||
restoreDraft()
|
||||
modalVisible.value = true
|
||||
@@ -502,7 +544,11 @@ const showEditModal = (record: any) => {
|
||||
shopId: record.shopId,
|
||||
textColor: record.textColor,
|
||||
bgColor: record.bgColor,
|
||||
borderColor: record.borderColor
|
||||
borderColor: record.borderColor,
|
||||
sceneGroup: record.sceneGroup || '',
|
||||
displayName: record.displayName || '',
|
||||
sortOrder: record.sortOrder ?? 100,
|
||||
frontVisible: record.frontVisible ?? 1
|
||||
})
|
||||
restoreDraft()
|
||||
modalVisible.value = true
|
||||
@@ -515,7 +561,11 @@ const showViewModal = (record: any) => {
|
||||
shopId: record.shopId,
|
||||
textColor: record.textColor,
|
||||
bgColor: record.bgColor,
|
||||
borderColor: record.borderColor
|
||||
borderColor: record.borderColor,
|
||||
sceneGroup: record.sceneGroup || '',
|
||||
displayName: record.displayName || '',
|
||||
sortOrder: record.sortOrder ?? 100,
|
||||
frontVisible: record.frontVisible ?? 1
|
||||
})
|
||||
viewModalVisible.value = true
|
||||
}
|
||||
@@ -537,7 +587,11 @@ const handleModalOk = async () => {
|
||||
shopId: formState.shopId,
|
||||
textColor: formState.textColor,
|
||||
bgColor: formState.bgColor,
|
||||
borderColor: formState.borderColor
|
||||
borderColor: formState.borderColor,
|
||||
sceneGroup: formState.sceneGroup,
|
||||
displayName: formState.displayName,
|
||||
sortOrder: formState.sortOrder,
|
||||
frontVisible: formState.frontVisible
|
||||
}
|
||||
|
||||
if (isEdit.value && currentTag.value) {
|
||||
|
||||
Reference in New Issue
Block a user