重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,565 @@
|
||||
/**
|
||||
* Purpose: cartApi supports index.js by holding or executing the cart api 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 cartApi = require('../../api/cart')
|
||||
/**
|
||||
* Purpose: productApi supports index.js by holding or executing the product api 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 productApi = require('../../api/product')
|
||||
/**
|
||||
* Purpose: productLikeApi supports index.js by holding or executing the product like api 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 productLikeApi = require('../../api/product-like')
|
||||
/**
|
||||
* Purpose: commentApi supports index.js by holding or executing the comment api 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 commentApi = require('../../api/comment')
|
||||
/**
|
||||
* Purpose: shopApi supports index.js by holding or executing the shop api 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 shopApi = require('../../api/shop')
|
||||
/**
|
||||
* Purpose: wishlistApi supports index.js by holding or executing the wishlist api 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 wishlistApi = require('../../api/wishlist')
|
||||
/**
|
||||
* Purpose: actionGuard supports index.js by holding or executing the action guard 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 actionGuard = require('../../utils/action-guard')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth 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 auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation 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 navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme 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 theme = require('../../utils/theme')
|
||||
const { getSignedUrl, resolveImageList, previewImagesSafely } = require('../../utils/file')
|
||||
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
|
||||
const { formatPrice, getProductTitle, splitCsv } = require('../../utils/format')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
const { saveBuyNowContext } = require('../../utils/buy-now')
|
||||
|
||||
/**
|
||||
* Purpose: parseTimeRange supports index.js by holding or executing the parse time range page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function parseTimeRange(businessHours) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!businessHours) {
|
||||
return null
|
||||
}
|
||||
|
||||
const matched = String(businessHours).replace(/\s+/g, '').match(/(\d{1,2}:\d{2}).*?(\d{1,2}:\d{2})/)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!matched) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
start: matched[1],
|
||||
end: matched[2]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: estimateEarliestBookable supports index.js by holding or executing the estimate earliest bookable page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function estimateEarliestBookable(businessHours) {
|
||||
const range = parseTimeRange(businessHours)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!range) {
|
||||
return businessHours || '以门店安排为准'
|
||||
}
|
||||
|
||||
const next = new Date(Date.now() + 30 * 60 * 1000)
|
||||
const openTime = new Date(next)
|
||||
const closeTime = new Date(next)
|
||||
const startParts = range.start.split(':').map(Number)
|
||||
const endParts = range.end.split(':').map(Number)
|
||||
|
||||
openTime.setHours(startParts[0], startParts[1], 0, 0)
|
||||
closeTime.setHours(endParts[0], endParts[1], 0, 0)
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (next <= openTime) {
|
||||
return `今天 ${range.start}`
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (next >= closeTime) {
|
||||
return `明天 ${range.start}`
|
||||
}
|
||||
|
||||
const month = String(next.getMonth() + 1).padStart(2, '0')
|
||||
const date = String(next.getDate()).padStart(2, '0')
|
||||
const hour = String(next.getHours()).padStart(2, '0')
|
||||
const minute = String(next.getMinutes()).padStart(2, '0')
|
||||
return `${month}-${date} ${hour}:${minute}`
|
||||
}
|
||||
|
||||
/**
|
||||
* product-detail page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
||||
loading: true,
|
||||
loadError: '',
|
||||
productId: '',
|
||||
product: null,
|
||||
productImages: [],
|
||||
shopInfo: null,
|
||||
comments: [],
|
||||
commentText: '',
|
||||
replyTarget: null,
|
||||
isFavorite: false,
|
||||
isLiked: false,
|
||||
artistCountText: '门店安排',
|
||||
earliestBookableText: '以门店安排为准'
|
||||
}),
|
||||
|
||||
/**
|
||||
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
productId: options && options.id ? options.id : ''
|
||||
})
|
||||
|
||||
this.loadProductDetail()
|
||||
},
|
||||
|
||||
async onPullDownRefresh() {
|
||||
await this.loadProductDetail()
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
async loadProductDetail() {
|
||||
const productId = this.data.productId
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!productId) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
loadError: '作品 ID 不存在'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.setData({
|
||||
loading: true,
|
||||
loadError: ''
|
||||
})
|
||||
|
||||
try {
|
||||
const product = await productApi.getProductById(productId)
|
||||
const productImages = await resolveImageList(product.imageFileIds, DEFAULT_PRODUCT_IMAGE)
|
||||
const shopInfo = product.shopId ? await shopApi.getShopById(product.shopId) : null
|
||||
if (shopInfo) {
|
||||
const shopTheme = theme.resolveShopTheme(shopInfo)
|
||||
this.setData(theme.pageThemeData(shopTheme))
|
||||
if (shopTheme.backgroundImageFileId) {
|
||||
try {
|
||||
const backgroundImageUrl = await getSignedUrl(shopTheme.backgroundImageFileId)
|
||||
if (backgroundImageUrl) {
|
||||
this.setData(theme.pageThemeData(shopTheme, backgroundImageUrl))
|
||||
}
|
||||
} catch (error) {}
|
||||
}
|
||||
}
|
||||
const artistCount = typeof product.availableBookableArtistCount === 'number'
|
||||
? product.availableBookableArtistCount
|
||||
: splitCsv(product.bookableArtists).length
|
||||
|
||||
const formattedProduct = {
|
||||
...product,
|
||||
displayTitle: getProductTitle(product),
|
||||
priceText: `¥${formatPrice(product.price)}`,
|
||||
descriptionText: product.description || '商家还没有补充作品说明。',
|
||||
targetAudienceText: product.targetAudience || '',
|
||||
precautionsText: product.precautions || ''
|
||||
}
|
||||
|
||||
this.setData({
|
||||
product: formattedProduct,
|
||||
productImages,
|
||||
shopInfo,
|
||||
artistCountText: artistCount > 0 ? `${artistCount} 位可预约` : (product.bookableArtistRestricted ? '暂时没有' : '门店安排'),
|
||||
earliestBookableText: estimateEarliestBookable(shopInfo && shopInfo.businessHours)
|
||||
})
|
||||
|
||||
await this.loadComments()
|
||||
if (auth.isLoggedIn()) {
|
||||
await this.loadInteractionStatus()
|
||||
} else {
|
||||
this.setData({
|
||||
isFavorite: false,
|
||||
isLiked: false
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
loadError: error.message || '作品详情加载失败'
|
||||
})
|
||||
} finally {
|
||||
this.setData({
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async loadInteractionStatus() {
|
||||
const product = this.data.product
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!product || !product.id) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const [isFavorite, isLiked] = await Promise.all([
|
||||
wishlistApi.checkWishlist(product.id),
|
||||
productLikeApi.checkLikeStatus(product.id)
|
||||
])
|
||||
this.setData({
|
||||
isFavorite: Boolean(isFavorite),
|
||||
isLiked: Boolean(isLiked)
|
||||
})
|
||||
} catch (error) {}
|
||||
},
|
||||
|
||||
async loadComments() {
|
||||
const product = this.data.product
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!product || !product.id) {
|
||||
this.setData({ comments: [] })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const comments = await commentApi.listByProduct(product.id)
|
||||
this.setData({
|
||||
comments: Array.isArray(comments) ? comments : []
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ comments: [] })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/products/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handlePreviewImage` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handlePreviewImage(event) {
|
||||
const current = event.currentTarget.dataset.url
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!current) {
|
||||
return
|
||||
}
|
||||
|
||||
previewImagesSafely(current, this.data.productImages, {
|
||||
failMessage: '图片可能已过期,请重试;仍失败时可以返回作品列表重新进入。',
|
||||
emptyMessage: '这件作品暂时没有可预览图片,可以返回作品列表查看其他款式。'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShareAppMessage exposes the product detail as a native mini-program share target.
|
||||
* Usage: WeChat calls it from the share menu; keep title and path aligned with the current product id.
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
const product = this.data.product || {}
|
||||
return {
|
||||
title: product.displayTitle || 'Fingertip Designer 美甲款式',
|
||||
path: `/pages/product-detail/index?id=${product.id || this.data.productId}`,
|
||||
imageUrl: this.data.productImages[0] || DEFAULT_PRODUCT_IMAGE
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCopyShareLink copies a mini-program route for users who cannot invoke native share.
|
||||
* Usage: bind it to the visible share action in the product info card.
|
||||
*/
|
||||
handleCopyShareLink() {
|
||||
const product = this.data.product || {}
|
||||
const path = `/pages/product-detail/index?id=${product.id || this.data.productId}`
|
||||
wx.setClipboardData({
|
||||
data: path,
|
||||
success: () => {
|
||||
wx.showToast({
|
||||
title: '分享路径已复制',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenShop` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenShop() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shopInfo || !shopInfo.id) {
|
||||
return
|
||||
}
|
||||
|
||||
navigation.navigate('/pages/shop-detail/index', {
|
||||
id: shopInfo.id,
|
||||
returnTo: navigation.getCurrentPageUrl()
|
||||
})
|
||||
},
|
||||
|
||||
async handleToggleFavorite() {
|
||||
const product = this.data.product
|
||||
if (!product || !product.id || !navigation.ensureLogin('收藏作品')) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await actionGuard.run(this, `wishlist:toggle:${product.id}`, async () => {
|
||||
const nextFavorite = !this.data.isFavorite
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.isFavorite) {
|
||||
await runWithLoading(() => wishlistApi.removeFromWishlist(product.id))
|
||||
product.collectCount = Math.max(0, Number(product.collectCount || 0) - 1)
|
||||
} else {
|
||||
await runWithLoading(() => wishlistApi.addToWishlist(product.id))
|
||||
product.collectCount = Number(product.collectCount || 0) + 1
|
||||
}
|
||||
|
||||
this.setData({
|
||||
isFavorite: nextFavorite,
|
||||
product
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title: nextFavorite ? '已加入收藏' : '已取消收藏',
|
||||
icon: 'none'
|
||||
})
|
||||
}, {
|
||||
message: '操作进行中,请勿重复点击'
|
||||
})
|
||||
} catch (error) {
|
||||
if (actionGuard.isGuardError(error)) {
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: error.message || '收藏操作失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async handleToggleLike() {
|
||||
const product = this.data.product
|
||||
if (!product || !product.id || !navigation.ensureLogin('点赞作品')) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await actionGuard.run(this, `like:toggle:${product.id}`, async () => {
|
||||
const nextLiked = !this.data.isLiked
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.isLiked) {
|
||||
await runWithLoading(() => productLikeApi.unlikeProduct(product.id))
|
||||
product.likeCount = Math.max(0, Number(product.likeCount || 0) - 1)
|
||||
} else {
|
||||
await runWithLoading(() => productLikeApi.likeProduct(product.id))
|
||||
product.likeCount = Number(product.likeCount || 0) + 1
|
||||
}
|
||||
|
||||
this.setData({
|
||||
isLiked: nextLiked,
|
||||
product
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title: nextLiked ? '已点赞' : '已取消点赞',
|
||||
icon: 'none'
|
||||
})
|
||||
}, {
|
||||
message: '操作进行中,请勿重复点击'
|
||||
})
|
||||
} catch (error) {
|
||||
if (actionGuard.isGuardError(error)) {
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: error.message || '点赞操作失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async handleAddToCart() {
|
||||
const product = this.data.product
|
||||
if (!product || !product.id || !navigation.ensureLogin('加购')) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await actionGuard.run(this, `cart:add:${product.id}`, () => runWithLoading(() => cartApi.addToCart({
|
||||
productId: product.id,
|
||||
quantity: 1
|
||||
})), {
|
||||
message: '购物车处理中,请勿重复操作'
|
||||
})
|
||||
await getApp().updateCartBadge()
|
||||
wx.showToast({
|
||||
title: '已加入购物车',
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (error) {
|
||||
if (actionGuard.isGuardError(error)) {
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: error.message || '加入购物车失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async handleBuyNow() {
|
||||
const product = this.data.product
|
||||
if (!product || !product.id || !navigation.ensureLogin('预约下单')) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await actionGuard.run(this, `cart:buy-now:${product.id}`, () => runWithLoading(() => cartApi.addToCart({
|
||||
productId: product.id,
|
||||
quantity: 1
|
||||
})), {
|
||||
message: '操作进行中,请勿重复点击'
|
||||
})
|
||||
await getApp().updateCartBadge()
|
||||
saveBuyNowContext(product.id)
|
||||
wx.switchTab({
|
||||
url: '/pages/cart/index'
|
||||
})
|
||||
} catch (error) {
|
||||
if (actionGuard.isGuardError(error)) {
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: error.message || '操作失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
,
|
||||
|
||||
/**
|
||||
* `handleCommentInput` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleCommentInput(event) {
|
||||
this.setData({
|
||||
commentText: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleReply` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleReply(event) {
|
||||
const comment = event.currentTarget.dataset.comment
|
||||
this.setData({
|
||||
replyTarget: comment || null
|
||||
})
|
||||
},
|
||||
|
||||
async handleSubmitComment() {
|
||||
const product = this.data.product
|
||||
const content = String(this.data.commentText || '').trim()
|
||||
if (!product || !product.id || !navigation.ensureLogin('发表评论')) {
|
||||
return
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!content) {
|
||||
wx.showToast({ title: '请输入评论内容', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
await commentApi.create({
|
||||
productId: product.id,
|
||||
shopId: product.shopId,
|
||||
parentCommentId: this.data.replyTarget ? this.data.replyTarget.id : null,
|
||||
commentContent: content
|
||||
})
|
||||
this.setData({
|
||||
commentText: '',
|
||||
replyTarget: null
|
||||
})
|
||||
await this.loadComments()
|
||||
wx.showToast({ title: '评论已发布', icon: 'none' })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '评论发布失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<navigation-bar title="{{product ? product.displayTitle : '作品详情'}}" showBack="{{true}}" fallbackPath="/pages/products/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
|
||||
|
||||
<view class="page-shell detail-page" style="{{themeVars}}">
|
||||
<view wx:if="{{loadError}}" class="page-content">
|
||||
<view class="page-card empty-card">
|
||||
<text class="empty-title">暂时无法查看作品详情</text>
|
||||
<text class="empty-desc">{{loadError}}</text>
|
||||
<view class="ghost-btn" bindtap="handleBack">返回上一页</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<block wx:elif="{{product}}">
|
||||
<view class="media-box">
|
||||
<swiper class="media-swiper" indicator-dots autoplay circular>
|
||||
<swiper-item wx:for="{{productImages}}" wx:key="*this">
|
||||
<image class="media-image" src="{{item}}" mode="aspectFill" data-url="{{item}}" bindtap="handlePreviewImage" lazy-load="{{true}}"></image>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view class="media-mask">
|
||||
<view class="media-badges">
|
||||
<view class="chip">{{product.approximateDuration || '时长待确认'}}</view>
|
||||
<view class="soft-chip">{{artistCountText}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="page-content detail-content">
|
||||
<view class="page-card info-card">
|
||||
<view class="detail-head">
|
||||
<text class="section-kicker">作品详情</text>
|
||||
<view class="product-title">{{product.displayTitle}}</view>
|
||||
<view class="product-price">{{product.priceText}}</view>
|
||||
<view class="product-brief">查看作品、门店和可预约信息。</view>
|
||||
</view>
|
||||
|
||||
<view class="summary-strip detail-summary">
|
||||
<view class="summary-metric" bindtap="handleOpenShop">
|
||||
<text class="summary-label">所属门店</text>
|
||||
<text class="summary-value detail-summary-value">{{shopInfo ? shopInfo.shopName : '待绑定'}}</text>
|
||||
<text class="summary-note">查看门店</text>
|
||||
</view>
|
||||
<view class="summary-metric">
|
||||
<text class="summary-label">可约美甲师</text>
|
||||
<text class="summary-value detail-summary-value">{{artistCountText}}</text>
|
||||
<text class="summary-note">可继续选择</text>
|
||||
</view>
|
||||
<view class="summary-metric">
|
||||
<text class="summary-label">最早可约</text>
|
||||
<text class="summary-value detail-summary-value">{{earliestBookableText}}</text>
|
||||
<text class="summary-note">以营业时间为准</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{shopInfo}}" class="shop-box" bindtap="handleOpenShop">
|
||||
<view class="shop-box-head">
|
||||
<view class="shop-name">{{shopInfo.shopName}}</view>
|
||||
<view class="shop-link">查看门店</view>
|
||||
</view>
|
||||
<view class="shop-meta">{{shopInfo.address || '门店地址待补充'}}</view>
|
||||
<view class="shop-meta">{{shopInfo.businessHours || '营业时间待补充'}}</view>
|
||||
</view>
|
||||
|
||||
<view class="actions-row">
|
||||
<view class="action-pill {{isLiked ? 'active' : ''}}" bindtap="handleToggleLike">
|
||||
点赞 {{product.likeCount || 0}}
|
||||
</view>
|
||||
<view class="action-pill {{isFavorite ? 'active' : ''}}" bindtap="handleToggleFavorite">
|
||||
收藏 {{product.collectCount || 0}}
|
||||
</view>
|
||||
<button class="action-pill share-pill" open-type="share">分享</button>
|
||||
<view class="action-pill" bindtap="handleCopyShareLink">复制路径</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{product.tagInfos && product.tagInfos.length}}" class="tags-wrap">
|
||||
<view wx:for="{{product.tagInfos}}" wx:key="id" class="tag-chip">{{item.tagName}}</view>
|
||||
</view>
|
||||
|
||||
<view class="desc-block">
|
||||
<view class="section-title">款式说明</view>
|
||||
<view class="desc-text">{{product.descriptionText}}</view>
|
||||
</view>
|
||||
<view wx:if="{{product.targetAudienceText || product.precautionsText}}" class="guidance-grid">
|
||||
<view wx:if="{{product.targetAudienceText}}" class="guidance-block">
|
||||
<view class="section-title">适合人群</view>
|
||||
<view class="desc-text">{{product.targetAudienceText}}</view>
|
||||
</view>
|
||||
<view wx:if="{{product.precautionsText}}" class="guidance-block">
|
||||
<view class="section-title">注意事项</view>
|
||||
<view class="desc-text">{{product.precautionsText}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="page-card comment-card">
|
||||
<view class="comment-head">
|
||||
<view class="section-title">作品评论</view>
|
||||
<text class="comment-count">{{comments.length}} 条</text>
|
||||
</view>
|
||||
<view class="comment-editor">
|
||||
<textarea class="comment-input" maxlength="300" auto-height placeholder="{{replyTarget ? '回复 ' + (replyTarget.userNickname || '用户') : '说说你的看法'}}" value="{{commentText}}" bindinput="handleCommentInput"></textarea>
|
||||
<view class="comment-actions">
|
||||
<view wx:if="{{replyTarget}}" class="comment-cancel" bindtap="handleReply">取消回复</view>
|
||||
<view class="comment-submit" bindtap="handleSubmitComment">发布</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{!comments.length}}" class="comment-empty">还没有评论,来写第一条吧</view>
|
||||
<view wx:for="{{comments}}" wx:key="id" class="comment-item">
|
||||
<view class="comment-main">
|
||||
<text class="comment-name">{{item.userNickname || '用户'}}</text>
|
||||
<text class="comment-time">{{item.createTime}}</text>
|
||||
</view>
|
||||
<view class="comment-text">{{item.commentContent}}</view>
|
||||
<view class="comment-reply-btn" data-comment="{{item}}" bindtap="handleReply">回复</view>
|
||||
<view wx:if="{{item.replies && item.replies.length}}" class="reply-list">
|
||||
<view wx:for="{{item.replies}}" wx:for-item="reply" wx:key="id" class="reply-item">
|
||||
<text class="reply-name">{{reply.userNickname || '用户'}}:</text>
|
||||
<text>{{reply.commentContent}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="footer-bar">
|
||||
<view class="footer-btn secondary" bindtap="handleAddToCart">加入购物车</view>
|
||||
<view class="footer-btn primary" bindtap="handleBuyNow">立即预约</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
@@ -0,0 +1,325 @@
|
||||
.detail-page {
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 160rpx);
|
||||
background: var(--theme-page-bg);
|
||||
}
|
||||
|
||||
.media-box {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-radius: 0 0 40rpx 40rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.media-swiper,
|
||||
.media-image {
|
||||
width: 100%;
|
||||
height: 640rpx;
|
||||
}
|
||||
|
||||
.media-mask {
|
||||
position: absolute;
|
||||
left: 24rpx;
|
||||
right: 24rpx;
|
||||
bottom: 28rpx;
|
||||
}
|
||||
|
||||
.media-badges {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.detail-content {
|
||||
margin-top: -48rpx;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
padding: 32rpx 30rpx;
|
||||
}
|
||||
|
||||
.detail-head {
|
||||
padding-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.product-title {
|
||||
margin-top: 16rpx;
|
||||
font-size: 42rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.product-price {
|
||||
margin-top: 12rpx;
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
color: var(--theme-accent);
|
||||
}
|
||||
|
||||
.product-brief {
|
||||
margin-top: 14rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.8;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.detail-summary {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.detail-summary-value {
|
||||
font-size: 26rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.shop-box {
|
||||
margin-top: 28rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background: var(--theme-gradient-soft);
|
||||
}
|
||||
|
||||
.shop-box-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.shop-name {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.shop-link {
|
||||
font-size: 24rpx;
|
||||
color: var(--theme-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.shop-meta {
|
||||
margin-top: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.actions-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
|
||||
.action-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 180rpx;
|
||||
height: 68rpx;
|
||||
padding: 0 24rpx;
|
||||
border-radius: 999rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-accent);
|
||||
font-size: 24rpx;
|
||||
font-weight: 600;
|
||||
border: 0;
|
||||
line-height: 68rpx;
|
||||
}
|
||||
|
||||
.share-pill::after {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.action-pill.active {
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-primary);
|
||||
}
|
||||
|
||||
.tags-wrap {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.tag-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 10rpx 18rpx;
|
||||
border-radius: 999rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-primary);
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.desc-block {
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
|
||||
.desc-text {
|
||||
margin-top: 16rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.8;
|
||||
color: #5d4b55;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.guidance-grid {
|
||||
display: grid;
|
||||
gap: 18rpx;
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
.guidance-block {
|
||||
padding: 22rpx;
|
||||
border-radius: 22rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.comment-card {
|
||||
margin-top: 24rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.comment-head,
|
||||
.comment-main,
|
||||
.comment-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.comment-count,
|
||||
.comment-time {
|
||||
font-size: 22rpx;
|
||||
color: #9b8d94;
|
||||
}
|
||||
|
||||
.comment-editor {
|
||||
margin-top: 20rpx;
|
||||
padding: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.comment-input {
|
||||
width: 100%;
|
||||
min-height: 120rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.7;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.comment-actions {
|
||||
margin-top: 16rpx;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.comment-cancel,
|
||||
.comment-submit,
|
||||
.comment-reply-btn {
|
||||
font-size: 24rpx;
|
||||
color: var(--theme-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.comment-submit {
|
||||
min-width: 116rpx;
|
||||
height: 56rpx;
|
||||
line-height: 56rpx;
|
||||
text-align: center;
|
||||
border-radius: 999rpx;
|
||||
color: #ffffff;
|
||||
background: var(--theme-primary);
|
||||
}
|
||||
|
||||
.comment-empty {
|
||||
padding: 28rpx 0 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #9b8d94;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.comment-item {
|
||||
padding: 24rpx 0;
|
||||
border-bottom: 1rpx solid #f2e7eb;
|
||||
}
|
||||
|
||||
.comment-item:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.comment-name {
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.comment-text {
|
||||
margin-top: 12rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.8;
|
||||
color: #5d4b55;
|
||||
}
|
||||
|
||||
.comment-reply-btn {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.reply-list {
|
||||
margin-top: 14rpx;
|
||||
padding: 16rpx;
|
||||
border-radius: 18rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.reply-item {
|
||||
padding: 6rpx 0;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.7;
|
||||
color: #5d4b55;
|
||||
}
|
||||
|
||||
.reply-name {
|
||||
color: var(--text-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.footer-bar {
|
||||
position: fixed;
|
||||
left: 24rpx;
|
||||
right: 24rpx;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 20rpx);
|
||||
z-index: 20;
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 30rpx;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
box-shadow: 0 18rpx 50rpx rgba(122, 67, 88, 0.12);
|
||||
}
|
||||
|
||||
.footer-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.footer-btn.secondary {
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-accent);
|
||||
}
|
||||
|
||||
.footer-btn.primary {
|
||||
background: var(--theme-gradient);
|
||||
color: #ffffff;
|
||||
}
|
||||
Reference in New Issue
Block a user