功能(小程序):同步用户体验流程到小程序
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Mini program API wrapper for public nail artist pages.
|
||||||
|
*/
|
||||||
|
const request = require('../utils/request')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getPublicProfile(artistId) {
|
||||||
|
return request({
|
||||||
|
url: `/nail-artist/profile/${artistId}`
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
getAvailability(artistId) {
|
||||||
|
return request({
|
||||||
|
url: `/nail-artist/${artistId}/availability`
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
listReviews(artistId) {
|
||||||
|
return request({
|
||||||
|
url: `/nail-artist/${artistId}/reviews`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,14 @@ module.exports = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
checkoutPreview(data) {
|
||||||
|
return request({
|
||||||
|
url: '/order/checkout-preview',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: getOrderList supports order.js by holding or executing the get order list page or API role.
|
* Purpose: getOrderList supports order.js by holding or executing the get order list page or API role.
|
||||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -47,6 +55,16 @@ module.exports = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: listOrderArtistChangeRequests loads every change request attached to one order for timeline display.
|
||||||
|
* Usage: call it from the order page after loading the order list; callers may fall back to an empty list.
|
||||||
|
*/
|
||||||
|
listOrderArtistChangeRequests(orderId) {
|
||||||
|
return request({
|
||||||
|
url: `/order/${orderId}/artist-change/requests`
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: submitArtistReview supports order.js by holding or executing the submit artist review page or API role.
|
* Purpose: submitArtistReview supports order.js by holding or executing the submit artist review page or API role.
|
||||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
|
|||||||
@@ -33,5 +33,15 @@ module.exports = {
|
|||||||
return request({
|
return request({
|
||||||
url: `/shop/get/${id}`
|
url: `/shop/get/${id}`
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: getTrustProfile loads public trust signals for the shop detail page.
|
||||||
|
* Usage: render ratings, recent reviews, environment images, and booking hints.
|
||||||
|
*/
|
||||||
|
getTrustProfile(id) {
|
||||||
|
return request({
|
||||||
|
url: `/shop/trust-profile/${id}`
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,16 @@ module.exports = {
|
|||||||
return request({
|
return request({
|
||||||
url: '/tag/list/all'
|
url: '/tag/list/all'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: getFilterOptions loads grouped public tag filters for scene-based browsing.
|
||||||
|
* Usage: call it from product list pages, then pass selected tag ids to getProductPage.
|
||||||
|
*/
|
||||||
|
getFilterOptions(shopId) {
|
||||||
|
return request({
|
||||||
|
url: '/tag/list/filter-options',
|
||||||
|
params: shopId ? { shopId } : undefined
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,5 +54,33 @@ module.exports = {
|
|||||||
return request({
|
return request({
|
||||||
url: '/wishlist/list'
|
url: '/wishlist/list'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
getGroups() {
|
||||||
|
return request({
|
||||||
|
url: '/wishlist/groups'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
getInspiration() {
|
||||||
|
return request({
|
||||||
|
url: '/wishlist/inspiration'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
addWithGroup(data) {
|
||||||
|
return request({
|
||||||
|
url: '/wishlist/add-with-group',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
moveWishlist(data) {
|
||||||
|
return request({
|
||||||
|
url: '/wishlist/move',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"pages/profile/index",
|
"pages/profile/index",
|
||||||
"pages/auth/index",
|
"pages/auth/index",
|
||||||
"pages/product-detail/index",
|
"pages/product-detail/index",
|
||||||
|
"pages/artist-profile/index",
|
||||||
"pages/shop-detail/index",
|
"pages/shop-detail/index",
|
||||||
"pages/orders/index",
|
"pages/orders/index",
|
||||||
"pages/wishlist/index",
|
"pages/wishlist/index",
|
||||||
|
|||||||
@@ -0,0 +1,136 @@
|
|||||||
|
const nailArtistApi = require('../../api/nail-artist')
|
||||||
|
const navigation = require('../../utils/navigation')
|
||||||
|
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
|
||||||
|
|
||||||
|
function formatPrice(price) {
|
||||||
|
const value = Number(price || 0)
|
||||||
|
return value > 0 ? `¥${value.toFixed(2)}` : '到店确认'
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDateTime(value) {
|
||||||
|
if (!value) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
return String(value).replace('T', ' ').slice(0, 16)
|
||||||
|
}
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
loading: true,
|
||||||
|
loadError: '',
|
||||||
|
artistId: '',
|
||||||
|
profile: null,
|
||||||
|
works: [],
|
||||||
|
reviews: [],
|
||||||
|
availability: [],
|
||||||
|
heroImage: DEFAULT_PRODUCT_IMAGE,
|
||||||
|
artistName: '美甲师',
|
||||||
|
artistDesc: '专注细节与稳定出品',
|
||||||
|
shopName: '门店待确认',
|
||||||
|
styleTags: [],
|
||||||
|
ratingText: '0.0',
|
||||||
|
serviceCountText: '0',
|
||||||
|
workTimeText: '到店确认'
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad(options) {
|
||||||
|
this.setData({
|
||||||
|
artistId: options && options.id ? options.id : ''
|
||||||
|
})
|
||||||
|
this.loadArtistProfile()
|
||||||
|
},
|
||||||
|
|
||||||
|
async onPullDownRefresh() {
|
||||||
|
await this.loadArtistProfile()
|
||||||
|
wx.stopPullDownRefresh()
|
||||||
|
},
|
||||||
|
|
||||||
|
async loadArtistProfile() {
|
||||||
|
if (!this.data.artistId) {
|
||||||
|
this.setData({
|
||||||
|
loading: false,
|
||||||
|
loadError: '缺少美甲师信息'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setData({
|
||||||
|
loading: true,
|
||||||
|
loadError: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [profile, availability, reviews] = await Promise.all([
|
||||||
|
nailArtistApi.getPublicProfile(this.data.artistId),
|
||||||
|
nailArtistApi.getAvailability(this.data.artistId),
|
||||||
|
nailArtistApi.listReviews(this.data.artistId)
|
||||||
|
])
|
||||||
|
const works = (profile.works || []).map(work => ({
|
||||||
|
...work,
|
||||||
|
title: work.title || '美甲作品',
|
||||||
|
coverImageUrl: work.coverImageUrl || DEFAULT_PRODUCT_IMAGE,
|
||||||
|
priceText: formatPrice(work.price)
|
||||||
|
}))
|
||||||
|
const formattedReviews = (reviews || profile.reviews || []).map(review => ({
|
||||||
|
...review,
|
||||||
|
customerName: review.customerName || '匿名用户',
|
||||||
|
content: review.content || '这位用户没有填写文字评价',
|
||||||
|
submittedAtText: formatDateTime(review.submittedAt),
|
||||||
|
ratingText: Number(review.rating || 0).toFixed(1)
|
||||||
|
}))
|
||||||
|
const start = profile.workStartTime ? String(profile.workStartTime).slice(0, 5) : ''
|
||||||
|
const end = profile.workEndTime ? String(profile.workEndTime).slice(0, 5) : ''
|
||||||
|
|
||||||
|
this.setData({
|
||||||
|
profile,
|
||||||
|
works,
|
||||||
|
reviews: formattedReviews,
|
||||||
|
availability: availability || profile.availability || [],
|
||||||
|
heroImage: (works.find(work => work.coverImageUrl) || {}).coverImageUrl || DEFAULT_PRODUCT_IMAGE,
|
||||||
|
artistName: profile.artistName || '美甲师',
|
||||||
|
artistDesc: profile.identity || profile.signature || '专注细节与稳定出品',
|
||||||
|
shopName: profile.shopName || '门店待确认',
|
||||||
|
styleTags: (profile.styleTags || []).filter(Boolean),
|
||||||
|
ratingText: Number(profile.rating || 0).toFixed(1),
|
||||||
|
serviceCountText: String(profile.serviceCount || 0),
|
||||||
|
workTimeText: start && end ? `${start}-${end}` : '到店确认'
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
this.setData({
|
||||||
|
loadError: error.message || '美甲师个人页加载失败'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
this.setData({
|
||||||
|
loading: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleBack() {
|
||||||
|
navigation.goBack('/pages/home/index')
|
||||||
|
},
|
||||||
|
|
||||||
|
handleRetry() {
|
||||||
|
this.loadArtistProfile()
|
||||||
|
},
|
||||||
|
|
||||||
|
handleOpenShop() {
|
||||||
|
const profile = this.data.profile
|
||||||
|
if (!profile || !profile.shopId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wx.navigateTo({
|
||||||
|
url: `/pages/shop-detail/index?id=${profile.shopId}`
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
handleOpenWork(event) {
|
||||||
|
const id = event.currentTarget.dataset.id
|
||||||
|
if (!id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wx.navigateTo({
|
||||||
|
url: `/pages/product-detail/index?id=${id}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"navigationStyle": "custom",
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<view class="artist-page">
|
||||||
|
<view class="page-header">
|
||||||
|
<view class="back-btn" bindtap="handleBack">‹</view>
|
||||||
|
<text class="page-title">{{artistName}}</text>
|
||||||
|
<view class="header-spacer"></view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{loading}}" class="state-box">
|
||||||
|
<text>加载中...</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view wx:elif="{{loadError}}" class="state-box">
|
||||||
|
<text class="state-title">暂时无法查看个人页</text>
|
||||||
|
<text class="state-desc">{{loadError}}</text>
|
||||||
|
<view class="primary-btn" bindtap="handleRetry">重试</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<scroll-view wx:else scroll-y class="content-scroll">
|
||||||
|
<view class="hero">
|
||||||
|
<image class="hero-image" src="{{heroImage}}" mode="aspectFill"></image>
|
||||||
|
<view class="hero-mask"></view>
|
||||||
|
<view class="artist-card">
|
||||||
|
<image wx:if="{{profile.avatar}}" class="avatar" src="{{profile.avatar}}" mode="aspectFill"></image>
|
||||||
|
<view wx:else class="avatar placeholder">艺</view>
|
||||||
|
<view class="artist-main">
|
||||||
|
<text class="artist-name">{{artistName}}</text>
|
||||||
|
<text class="artist-desc">{{artistDesc}}</text>
|
||||||
|
<view class="shop-link" bindtap="handleOpenShop">{{shopName}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="metrics">
|
||||||
|
<view class="metric-item">
|
||||||
|
<text>评分</text>
|
||||||
|
<text class="metric-value">{{ratingText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="metric-item">
|
||||||
|
<text>服务</text>
|
||||||
|
<text class="metric-value">{{serviceCountText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="metric-item">
|
||||||
|
<text>工时</text>
|
||||||
|
<text class="metric-value">{{workTimeText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="section">
|
||||||
|
<view class="section-head">擅长风格</view>
|
||||||
|
<view class="tag-list" wx:if="{{styleTags.length}}">
|
||||||
|
<text class="tag" wx:for="{{styleTags}}" wx:key="*this">{{item}}</text>
|
||||||
|
</view>
|
||||||
|
<text wx:else class="empty-text">暂未设置风格标签</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="section">
|
||||||
|
<view class="section-head">近期可预约</view>
|
||||||
|
<view class="slot-grid" wx:if="{{availability.length}}">
|
||||||
|
<view class="slot" wx:for="{{availability}}" wx:key="startTime">
|
||||||
|
<text>{{item.dateText}}</text>
|
||||||
|
<text class="slot-time">{{item.timeText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text wx:else class="empty-text">近期暂未放出可预约时间</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="section">
|
||||||
|
<view class="section-head">作品</view>
|
||||||
|
<view class="work-grid" wx:if="{{works.length}}">
|
||||||
|
<view class="work-card" wx:for="{{works}}" wx:key="id" data-id="{{item.id}}" bindtap="handleOpenWork">
|
||||||
|
<image src="{{item.coverImageUrl}}" mode="aspectFill"></image>
|
||||||
|
<text class="work-title">{{item.title}}</text>
|
||||||
|
<text class="work-price">{{item.priceText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text wx:else class="empty-text">作品正在整理中</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="section">
|
||||||
|
<view class="section-head">评价 {{reviews.length}}</view>
|
||||||
|
<view class="review-list" wx:if="{{reviews.length}}">
|
||||||
|
<view class="review-card" wx:for="{{reviews}}" wx:key="id">
|
||||||
|
<view class="review-top">
|
||||||
|
<image wx:if="{{item.customerAvatar}}" class="review-avatar" src="{{item.customerAvatar}}" mode="aspectFill"></image>
|
||||||
|
<view wx:else class="review-avatar placeholder">客</view>
|
||||||
|
<view class="review-meta">
|
||||||
|
<text>{{item.customerName}}</text>
|
||||||
|
<text>{{item.submittedAtText}}</text>
|
||||||
|
</view>
|
||||||
|
<text class="review-score">{{item.ratingText}}</text>
|
||||||
|
</view>
|
||||||
|
<text class="review-content">{{item.content}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text wx:else class="empty-text">还没有公开评价</text>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
@@ -0,0 +1,336 @@
|
|||||||
|
.artist-page {
|
||||||
|
min-height: 100vh;
|
||||||
|
background: #f6f7fb;
|
||||||
|
color: #1f2933;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 5;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
height: 96rpx;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.95);
|
||||||
|
border-bottom: 1rpx solid #e6e9ef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-btn,
|
||||||
|
.header-spacer {
|
||||||
|
width: 64rpx;
|
||||||
|
height: 64rpx;
|
||||||
|
line-height: 58rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 48rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-title {
|
||||||
|
flex: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-scroll {
|
||||||
|
height: calc(100vh - 96rpx);
|
||||||
|
}
|
||||||
|
|
||||||
|
.state-box {
|
||||||
|
display: flex;
|
||||||
|
min-height: 60vh;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 20rpx;
|
||||||
|
padding: 40rpx;
|
||||||
|
color: #65717f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.state-title {
|
||||||
|
color: #1f2933;
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.state-desc {
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-btn {
|
||||||
|
padding: 18rpx 36rpx;
|
||||||
|
color: #fff;
|
||||||
|
background: #c6597d;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero {
|
||||||
|
position: relative;
|
||||||
|
height: 520rpx;
|
||||||
|
margin: 20rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #222831;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-image,
|
||||||
|
.hero-mask {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-mask {
|
||||||
|
background: linear-gradient(180deg, rgba(10, 14, 20, 0.08), rgba(10, 14, 20, 0.72));
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-card {
|
||||||
|
position: absolute;
|
||||||
|
right: 28rpx;
|
||||||
|
bottom: 28rpx;
|
||||||
|
left: 28rpx;
|
||||||
|
display: flex;
|
||||||
|
gap: 22rpx;
|
||||||
|
align-items: center;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
width: 112rpx;
|
||||||
|
height: 112rpx;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 3rpx solid rgba(255, 255, 255, 0.8);
|
||||||
|
border-radius: 56rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: #d8dde6;
|
||||||
|
color: #5f6b7a;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-main {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-name,
|
||||||
|
.artist-desc,
|
||||||
|
.shop-link {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-name {
|
||||||
|
font-size: 44rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-desc {
|
||||||
|
margin-top: 10rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.88);
|
||||||
|
font-size: 26rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-link {
|
||||||
|
max-width: 440rpx;
|
||||||
|
margin-top: 16rpx;
|
||||||
|
padding: 12rpx 18rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.18);
|
||||||
|
border: 1rpx solid rgba(255, 255, 255, 0.28);
|
||||||
|
border-radius: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metrics {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 16rpx;
|
||||||
|
margin: 0 20rpx 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-item {
|
||||||
|
display: flex;
|
||||||
|
min-height: 132rpx;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10rpx;
|
||||||
|
padding: 20rpx;
|
||||||
|
background: #fff;
|
||||||
|
border: 1rpx solid #e6e9ef;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-item text:first-child {
|
||||||
|
color: #65717f;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-value {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
margin: 20rpx;
|
||||||
|
padding: 28rpx;
|
||||||
|
background: #fff;
|
||||||
|
border: 1rpx solid #e6e9ef;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-head {
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-list {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
padding: 10rpx 18rpx;
|
||||||
|
color: #394554;
|
||||||
|
background: #eef1f5;
|
||||||
|
border-radius: 999rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-text {
|
||||||
|
color: #7b8794;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slot-grid,
|
||||||
|
.work-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slot {
|
||||||
|
display: flex;
|
||||||
|
min-height: 104rpx;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8rpx;
|
||||||
|
padding: 18rpx;
|
||||||
|
background: #f6f7fb;
|
||||||
|
border: 1rpx solid #dfe4ea;
|
||||||
|
border-radius: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slot text:first-child {
|
||||||
|
color: #65717f;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slot-time {
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-card {
|
||||||
|
overflow: hidden;
|
||||||
|
background: #fff;
|
||||||
|
border: 1rpx solid #e6e9ef;
|
||||||
|
border-radius: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-card image {
|
||||||
|
width: 100%;
|
||||||
|
height: 210rpx;
|
||||||
|
background: #eef1f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-title,
|
||||||
|
.work-price {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0 16rpx;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-title {
|
||||||
|
margin-top: 14rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-price {
|
||||||
|
margin: 8rpx 0 16rpx;
|
||||||
|
color: #c6597d;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-card {
|
||||||
|
padding: 22rpx;
|
||||||
|
background: #f8fafc;
|
||||||
|
border: 1rpx solid #e6e9ef;
|
||||||
|
border-radius: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-top {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-avatar {
|
||||||
|
width: 72rpx;
|
||||||
|
height: 72rpx;
|
||||||
|
border-radius: 36rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-meta {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-meta text {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-meta text:last-child {
|
||||||
|
margin-top: 4rpx;
|
||||||
|
color: #7b8794;
|
||||||
|
font-size: 22rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-score {
|
||||||
|
color: #c6597d;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-content {
|
||||||
|
display: block;
|
||||||
|
margin-top: 18rpx;
|
||||||
|
color: #3f4a56;
|
||||||
|
line-height: 1.7;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
@@ -3,11 +3,6 @@
|
|||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* 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')
|
const cartApi = require('../../api/cart')
|
||||||
/**
|
|
||||||
* Purpose: couponApi supports index.js by holding or executing the coupon 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 couponApi = require('../../api/coupon')
|
|
||||||
/**
|
/**
|
||||||
* Purpose: orderApi supports index.js by holding or executing the order api page or API role.
|
* Purpose: orderApi supports index.js by holding or executing the order 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.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -31,6 +26,8 @@ const theme = require('../../utils/theme')
|
|||||||
const { resolveLegacyImage } = require('../../utils/file')
|
const { resolveLegacyImage } = require('../../utils/file')
|
||||||
const { NO_COUPON_KEY } = require('../../utils/config')
|
const { NO_COUPON_KEY } = require('../../utils/config')
|
||||||
const { runWithLoading } = require('../../utils/loading')
|
const { runWithLoading } = require('../../utils/loading')
|
||||||
|
const { clearBuyNowContext, isBuyNowCartItem, readBuyNowContext } = require('../../utils/buy-now')
|
||||||
|
const { buildRecoveryState, clearRecoveryState } = require('../../utils/recovery')
|
||||||
const {
|
const {
|
||||||
buildAppointmentValue,
|
buildAppointmentValue,
|
||||||
formatDateTime,
|
formatDateTime,
|
||||||
@@ -53,6 +50,9 @@ function getCouponKey(coupon) {
|
|||||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
function getCouponDisplay(coupon) {
|
function getCouponDisplay(coupon) {
|
||||||
|
if (coupon && coupon.displayText) {
|
||||||
|
return coupon.displayText
|
||||||
|
}
|
||||||
if (Number(coupon.couponType) === 1) {
|
if (Number(coupon.couponType) === 1) {
|
||||||
return `${coupon.couponName} ${coupon.discountValue} 折`
|
return `${coupon.couponName} ${coupon.discountValue} 折`
|
||||||
}
|
}
|
||||||
@@ -71,6 +71,9 @@ function calculateCouponDiscount(coupon, amount) {
|
|||||||
if (!coupon || amount <= 0) {
|
if (!coupon || amount <= 0) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
if (coupon.discountAmount !== undefined && coupon.discountAmount !== null) {
|
||||||
|
return Number(coupon.discountAmount || 0)
|
||||||
|
}
|
||||||
|
|
||||||
if (Number(coupon.couponType) === 1) {
|
if (Number(coupon.couponType) === 1) {
|
||||||
const discountValue = Number(coupon.discountValue || 0)
|
const discountValue = Number(coupon.discountValue || 0)
|
||||||
@@ -160,6 +163,9 @@ Page({
|
|||||||
minDate: getMinDateText(),
|
minDate: getMinDateText(),
|
||||||
cartItems: [],
|
cartItems: [],
|
||||||
availableCoupons: [],
|
availableCoupons: [],
|
||||||
|
unavailableCoupons: [],
|
||||||
|
checkoutPreview: null,
|
||||||
|
vipTip: '',
|
||||||
selectedCouponKey: NO_COUPON_KEY,
|
selectedCouponKey: NO_COUPON_KEY,
|
||||||
/**
|
/**
|
||||||
* Purpose: couponSelectionTouched records whether the user explicitly chose a coupon option.
|
* Purpose: couponSelectionTouched records whether the user explicitly chose a coupon option.
|
||||||
@@ -167,13 +173,18 @@ Page({
|
|||||||
*/
|
*/
|
||||||
couponSelectionTouched: false,
|
couponSelectionTouched: false,
|
||||||
selectedCount: 0,
|
selectedCount: 0,
|
||||||
|
isBuyNowMode: false,
|
||||||
|
heroKicker: '结算准备',
|
||||||
|
heroTitle: '已选 0 个预约项目',
|
||||||
|
heroDesc: '确认美甲师和时间后再下单。',
|
||||||
totalQuantity: 0,
|
totalQuantity: 0,
|
||||||
subtotalAmount: 0,
|
subtotalAmount: 0,
|
||||||
subtotalText: '¥0.00',
|
subtotalText: '¥0.00',
|
||||||
discountAmountText: '¥0.00',
|
discountAmountText: '¥0.00',
|
||||||
totalAmountText: '¥0.00',
|
totalAmountText: '¥0.00',
|
||||||
checkoutIssues: [],
|
checkoutIssues: [],
|
||||||
submittingOrder: false
|
submittingOrder: false,
|
||||||
|
recoveryState: clearRecoveryState()
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,13 +225,19 @@ Page({
|
|||||||
const selectedCoupon = this.getSelectedCoupon()
|
const selectedCoupon = this.getSelectedCoupon()
|
||||||
const selectedCount = selectedItems.length
|
const selectedCount = selectedItems.length
|
||||||
const totalQuantity = selectedItems.reduce((sum, item) => sum + Number(item.quantity || 0), 0)
|
const totalQuantity = selectedItems.reduce((sum, item) => sum + Number(item.quantity || 0), 0)
|
||||||
const subtotalAmount = selectedItems.reduce((sum, item) => sum + Number(item.price || 0) * Number(item.quantity || 0), 0)
|
const localSubtotalAmount = selectedItems.reduce((sum, item) => sum + Number(item.price || 0) * Number(item.quantity || 0), 0)
|
||||||
const discountAmount = calculateCouponDiscount(selectedCoupon, subtotalAmount)
|
const preview = this.data.checkoutPreview || {}
|
||||||
const totalAmount = Math.max(0, subtotalAmount - discountAmount)
|
const subtotalAmount = preview.subtotalAmount !== undefined ? Number(preview.subtotalAmount || 0) : localSubtotalAmount
|
||||||
|
const discountAmount = preview.savedAmount !== undefined ? Number(preview.savedAmount || 0) : calculateCouponDiscount(selectedCoupon, subtotalAmount)
|
||||||
|
const totalAmount = preview.payableAmount !== undefined ? Number(preview.payableAmount || 0) : Math.max(0, subtotalAmount - discountAmount)
|
||||||
const checkoutIssues = buildCheckoutIssues(this.data.cartItems)
|
const checkoutIssues = buildCheckoutIssues(this.data.cartItems)
|
||||||
|
const isBuyNowMode = Boolean(this.data.isBuyNowMode)
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
selectedCount,
|
selectedCount,
|
||||||
|
heroKicker: isBuyNowMode ? '确认订单' : '结算准备',
|
||||||
|
heroTitle: isBuyNowMode ? '确认本次预约' : `已选 ${selectedCount} 个预约项目`,
|
||||||
|
heroDesc: isBuyNowMode ? '本次只会提交刚刚选择的作品,不会混入购物车其他项目。' : '确认美甲师和时间后再下单。',
|
||||||
totalQuantity,
|
totalQuantity,
|
||||||
subtotalAmount,
|
subtotalAmount,
|
||||||
subtotalText: `¥${formatPrice(subtotalAmount)}`,
|
subtotalText: `¥${formatPrice(subtotalAmount)}`,
|
||||||
@@ -232,9 +249,13 @@ Page({
|
|||||||
|
|
||||||
async loadCartItems() {
|
async loadCartItems() {
|
||||||
const isLoggedIn = auth.isLoggedIn()
|
const isLoggedIn = auth.isLoggedIn()
|
||||||
|
const buyNowContext = isLoggedIn ? readBuyNowContext() : null
|
||||||
|
const buyNowProductId = buyNowContext && buyNowContext.productId ? String(buyNowContext.productId) : ''
|
||||||
this.setData({
|
this.setData({
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
loading: isLoggedIn
|
isBuyNowMode: Boolean(buyNowProductId),
|
||||||
|
loading: isLoggedIn,
|
||||||
|
recoveryState: clearRecoveryState()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -245,9 +266,13 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
cartItems: [],
|
cartItems: [],
|
||||||
availableCoupons: [],
|
availableCoupons: [],
|
||||||
|
unavailableCoupons: [],
|
||||||
|
checkoutPreview: null,
|
||||||
|
vipTip: '',
|
||||||
selectedCouponKey: NO_COUPON_KEY,
|
selectedCouponKey: NO_COUPON_KEY,
|
||||||
couponSelectionTouched: false,
|
couponSelectionTouched: false,
|
||||||
loading: false
|
loading: false,
|
||||||
|
recoveryState: clearRecoveryState()
|
||||||
})
|
})
|
||||||
this.refreshSummary()
|
this.refreshSummary()
|
||||||
return
|
return
|
||||||
@@ -273,7 +298,7 @@ Page({
|
|||||||
...item,
|
...item,
|
||||||
productImageUrl,
|
productImageUrl,
|
||||||
priceText: `¥${formatPrice(item.price)}`,
|
priceText: `¥${formatPrice(item.price)}`,
|
||||||
selected: true,
|
selected: buyNowProductId ? isBuyNowCartItem(item, buyNowProductId) : true,
|
||||||
artistId: item.artistId || '',
|
artistId: item.artistId || '',
|
||||||
artistName: artist ? artist.name : '',
|
artistName: artist ? artist.name : '',
|
||||||
availableArtists,
|
availableArtists,
|
||||||
@@ -286,16 +311,26 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
cartItems: formattedItems,
|
cartItems: formattedItems,
|
||||||
selectedCouponKey: NO_COUPON_KEY,
|
selectedCouponKey: NO_COUPON_KEY,
|
||||||
couponSelectionTouched: false
|
couponSelectionTouched: false,
|
||||||
|
recoveryState: clearRecoveryState()
|
||||||
})
|
})
|
||||||
|
if (buyNowProductId) {
|
||||||
|
clearBuyNowContext()
|
||||||
|
}
|
||||||
await this.loadAvailableCoupons()
|
await this.loadAvailableCoupons()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.setData({
|
this.setData({
|
||||||
cartItems: []
|
cartItems: [],
|
||||||
})
|
recoveryState: buildRecoveryState({
|
||||||
wx.showToast({
|
title: '购物车加载失败',
|
||||||
title: error.message || '购物车加载失败',
|
message: error,
|
||||||
icon: 'none'
|
fallbackMessage: '购物车暂时没有加载出来,请重试或先去逛作品。',
|
||||||
|
actions: [
|
||||||
|
{ key: 'retryCartLoad', text: '重试' },
|
||||||
|
{ key: 'products', text: '去逛作品' },
|
||||||
|
{ key: 'contact', text: '联系客服' }
|
||||||
|
]
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
this.setData({
|
this.setData({
|
||||||
@@ -314,6 +349,9 @@ Page({
|
|||||||
if (!selectedItems.length) {
|
if (!selectedItems.length) {
|
||||||
this.setData({
|
this.setData({
|
||||||
availableCoupons: [],
|
availableCoupons: [],
|
||||||
|
unavailableCoupons: [],
|
||||||
|
checkoutPreview: null,
|
||||||
|
vipTip: '',
|
||||||
selectedCouponKey: NO_COUPON_KEY,
|
selectedCouponKey: NO_COUPON_KEY,
|
||||||
couponSelectionTouched: false
|
couponSelectionTouched: false
|
||||||
})
|
})
|
||||||
@@ -321,24 +359,25 @@ Page({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const tags = new Set()
|
|
||||||
const subtotalAmount = selectedItems.reduce((sum, item) => sum + Number(item.price || 0) * Number(item.quantity || 0), 0)
|
|
||||||
selectedItems.forEach(item => {
|
|
||||||
String(item.tagNames || '')
|
|
||||||
.split(',')
|
|
||||||
.map(tag => tag.trim())
|
|
||||||
.filter(Boolean)
|
|
||||||
.forEach(tag => tags.add(tag))
|
|
||||||
})
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const coupons = await couponApi.getAvailableCoupons(
|
const selectedCoupon = this.getSelectedCoupon()
|
||||||
Array.from(tags).join(','),
|
const preview = await orderApi.checkoutPreview({
|
||||||
subtotalAmount,
|
couponId: selectedCoupon ? selectedCoupon.id : undefined,
|
||||||
selectedItems[0].shopId
|
couponSourceType: selectedCoupon ? selectedCoupon.sourceType : (this.data.couponSelectionTouched && this.data.selectedCouponKey === NO_COUPON_KEY ? NO_COUPON_KEY : undefined),
|
||||||
)
|
items: selectedItems.map(item => ({
|
||||||
|
productId: item.productId,
|
||||||
|
quantity: item.quantity,
|
||||||
|
artistId: item.artistId,
|
||||||
|
appointmentTime: item.appointmentValue
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
const list = Array.isArray(coupons) ? coupons.map(item => ({
|
const list = Array.isArray(preview && preview.availableCoupons) ? preview.availableCoupons.map(item => ({
|
||||||
|
...item,
|
||||||
|
key: getCouponKey(item),
|
||||||
|
displayText: getCouponDisplay(item)
|
||||||
|
})) : []
|
||||||
|
const unavailableCoupons = Array.isArray(preview && preview.unavailableCoupons) ? preview.unavailableCoupons.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
key: getCouponKey(item),
|
key: getCouponKey(item),
|
||||||
displayText: getCouponDisplay(item)
|
displayText: getCouponDisplay(item)
|
||||||
@@ -348,6 +387,7 @@ Page({
|
|||||||
if (selectedCouponKey !== NO_COUPON_KEY && !list.find(item => item.key === selectedCouponKey)) {
|
if (selectedCouponKey !== NO_COUPON_KEY && !list.find(item => item.key === selectedCouponKey)) {
|
||||||
selectedCouponKey = NO_COUPON_KEY
|
selectedCouponKey = NO_COUPON_KEY
|
||||||
}
|
}
|
||||||
|
const previewSubtotalAmount = Number((preview && preview.subtotalAmount) || this.data.subtotalAmount || 0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||||
@@ -355,8 +395,7 @@ Page({
|
|||||||
*/
|
*/
|
||||||
if (selectedCouponKey === NO_COUPON_KEY && !this.data.couponSelectionTouched) {
|
if (selectedCouponKey === NO_COUPON_KEY && !this.data.couponSelectionTouched) {
|
||||||
const bestCoupons = list
|
const bestCoupons = list
|
||||||
.filter(item => item.sourceType === 'SYSTEM_VIP')
|
.sort((left, right) => calculateCouponDiscount(right, previewSubtotalAmount) - calculateCouponDiscount(left, previewSubtotalAmount))
|
||||||
.sort((left, right) => calculateCouponDiscount(right, subtotalAmount) - calculateCouponDiscount(left, subtotalAmount))
|
|
||||||
/**
|
/**
|
||||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
* `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.
|
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||||
@@ -368,11 +407,17 @@ Page({
|
|||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
availableCoupons: list,
|
availableCoupons: list,
|
||||||
|
unavailableCoupons,
|
||||||
|
checkoutPreview: preview || null,
|
||||||
|
vipTip: preview && preview.vipTip ? preview.vipTip : '',
|
||||||
selectedCouponKey
|
selectedCouponKey
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.setData({
|
this.setData({
|
||||||
availableCoupons: [],
|
availableCoupons: [],
|
||||||
|
unavailableCoupons: [],
|
||||||
|
checkoutPreview: null,
|
||||||
|
vipTip: '',
|
||||||
selectedCouponKey: NO_COUPON_KEY,
|
selectedCouponKey: NO_COUPON_KEY,
|
||||||
couponSelectionTouched: false
|
couponSelectionTouched: false
|
||||||
})
|
})
|
||||||
@@ -397,6 +442,60 @@ Page({
|
|||||||
navigation.switchTab('/pages/products/index')
|
navigation.switchTab('/pages/products/index')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleRecoveryAction(event) {
|
||||||
|
const key = event.currentTarget.dataset.key
|
||||||
|
if (key === 'retryCartLoad') {
|
||||||
|
this.setData({ recoveryState: clearRecoveryState() })
|
||||||
|
this.loadCartItems()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (key === 'retryCheckout') {
|
||||||
|
this.setData({ recoveryState: clearRecoveryState() })
|
||||||
|
this.handleCheckout()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (key === 'contact') {
|
||||||
|
this.handleContactSupport()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (key === 'cart') {
|
||||||
|
this.setData({ recoveryState: clearRecoveryState() })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions = this.data.recoveryState.actions || []
|
||||||
|
const action = actions.find(item => item.key === key)
|
||||||
|
if (action && action.route) {
|
||||||
|
this.openRecoveryRoute(action.route)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
openRecoveryRoute(route) {
|
||||||
|
const pureRoute = String(route || '').split('?')[0]
|
||||||
|
if (!pureRoute) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (navigation.isTabPage(pureRoute)) {
|
||||||
|
navigation.switchTab(pureRoute)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
navigation.navigate(route)
|
||||||
|
},
|
||||||
|
|
||||||
|
handleContactSupport() {
|
||||||
|
wx.showModal({
|
||||||
|
title: '联系客服',
|
||||||
|
content: '请截图保留失败提示;如果担心重复下单,请先查看订单。也可以前往“我的”页联系门店或平台客服。',
|
||||||
|
confirmText: '去我的',
|
||||||
|
cancelText: '留在本页',
|
||||||
|
success: res => {
|
||||||
|
if (res.confirm) {
|
||||||
|
navigation.switchTab('/pages/profile/index')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
async handleToggleSelect(event) {
|
async handleToggleSelect(event) {
|
||||||
const index = Number(event.currentTarget.dataset.index)
|
const index = Number(event.currentTarget.dataset.index)
|
||||||
const cartItems = this.data.cartItems.slice()
|
const cartItems = this.data.cartItems.slice()
|
||||||
@@ -640,7 +739,7 @@ Page({
|
|||||||
selectedCouponKey: event.detail.value,
|
selectedCouponKey: event.detail.value,
|
||||||
couponSelectionTouched: true
|
couponSelectionTouched: true
|
||||||
})
|
})
|
||||||
this.refreshSummary()
|
this.loadAvailableCoupons()
|
||||||
},
|
},
|
||||||
|
|
||||||
async handleCheckout() {
|
async handleCheckout() {
|
||||||
@@ -704,9 +803,18 @@ Page({
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
wx.showToast({
|
this.setData({
|
||||||
title: error.message || '订单创建失败',
|
recoveryState: buildRecoveryState({
|
||||||
icon: 'none'
|
title: '下单失败',
|
||||||
|
message: error,
|
||||||
|
fallbackMessage: '订单创建失败,请重试;如果担心重复下单,请先查看订单。',
|
||||||
|
actions: [
|
||||||
|
{ key: 'retryCheckout', text: '重试下单' },
|
||||||
|
{ key: 'orders', text: '查看订单' },
|
||||||
|
{ key: 'contact', text: '联系客服' },
|
||||||
|
{ key: 'cart', text: '返回购物车' }
|
||||||
|
]
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
this.setData({
|
this.setData({
|
||||||
|
|||||||
@@ -9,10 +9,24 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<block wx:elif="{{cartItems.length}}">
|
<block wx:elif="{{cartItems.length}}">
|
||||||
|
<view wx:if="{{recoveryState.visible}}" class="page-card recovery-card">
|
||||||
|
<text class="recovery-title">{{recoveryState.title}}</text>
|
||||||
|
<text class="recovery-desc">{{recoveryState.message}}</text>
|
||||||
|
<view class="recovery-actions">
|
||||||
|
<view
|
||||||
|
wx:for="{{recoveryState.actions}}"
|
||||||
|
wx:key="key"
|
||||||
|
class="recovery-btn {{item.primary ? 'primary' : ''}}"
|
||||||
|
data-key="{{item.key}}"
|
||||||
|
bindtap="handleRecoveryAction"
|
||||||
|
>{{item.text}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="page-hero cart-hero">
|
<view class="page-hero cart-hero">
|
||||||
<text class="hero-kicker">结算准备</text>
|
<text class="hero-kicker">{{heroKicker}}</text>
|
||||||
<text class="hero-title">已选 {{selectedCount}} 个预约项目</text>
|
<text class="hero-title">{{heroTitle}}</text>
|
||||||
<text class="hero-desc">确认美甲师和时间后再下单。</text>
|
<text class="hero-desc">{{heroDesc}}</text>
|
||||||
|
|
||||||
<view class="summary-strip">
|
<view class="summary-strip">
|
||||||
<view class="summary-metric">
|
<view class="summary-metric">
|
||||||
@@ -93,7 +107,7 @@
|
|||||||
|
|
||||||
<view wx:if="{{selectedCount}}" class="page-card coupon-card">
|
<view wx:if="{{selectedCount}}" class="page-card coupon-card">
|
||||||
<view class="section-title">优惠方式</view>
|
<view class="section-title">优惠方式</view>
|
||||||
<view class="section-subtitle">系统会优先匹配 VIP 优惠。</view>
|
<view class="section-subtitle">{{vipTip || '系统会优先匹配 VIP 优惠。'}}</view>
|
||||||
|
|
||||||
<radio-group bindchange="handleCouponChange">
|
<radio-group bindchange="handleCouponChange">
|
||||||
<label class="coupon-option">
|
<label class="coupon-option">
|
||||||
@@ -107,14 +121,24 @@
|
|||||||
<radio value="{{coupon.key}}" checked="{{selectedCouponKey === coupon.key}}" color="{{navThemeColor || '#C6597D'}}"></radio>
|
<radio value="{{coupon.key}}" checked="{{selectedCouponKey === coupon.key}}" color="{{navThemeColor || '#C6597D'}}"></radio>
|
||||||
<view class="coupon-texts">
|
<view class="coupon-texts">
|
||||||
<view class="coupon-name">{{coupon.displayText}}</view>
|
<view class="coupon-name">{{coupon.displayText}}</view>
|
||||||
<view class="coupon-desc">{{coupon.sourceType === 'SYSTEM_VIP' ? 'VIP 自动折扣' : '用户优惠券'}}</view>
|
<view class="coupon-desc">{{coupon.savingText || (coupon.sourceType === 'SYSTEM_VIP' ? 'VIP 自动折扣' : '用户优惠券')}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="coupon-tag">{{coupon.sourceType === 'SYSTEM_VIP' ? '推荐' : '手动选择'}}</view>
|
<view class="coupon-tag">{{coupon.sourceType === 'SYSTEM_VIP' ? '推荐' : '手动选择'}}</view>
|
||||||
</label>
|
</label>
|
||||||
</radio-group>
|
</radio-group>
|
||||||
|
|
||||||
|
<view wx:if="{{unavailableCoupons.length}}" class="unavailable-coupon-list">
|
||||||
|
<view class="unavailable-title">本单暂不可用</view>
|
||||||
|
<view wx:for="{{unavailableCoupons}}" wx:key="key" wx:for-item="coupon" class="unavailable-coupon">
|
||||||
|
<text>{{coupon.displayText}}</text>
|
||||||
|
<text>{{coupon.unavailableReason || '本单暂不可用'}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="page-card summary-card">
|
<view class="page-card summary-card">
|
||||||
|
<view wx:if="{{checkoutPreview && checkoutPreview.summaryText}}" class="summary-preview">{{checkoutPreview.summaryText}}</view>
|
||||||
|
<view wx:if="{{vipTip}}" class="summary-vip">{{vipTip}}</view>
|
||||||
<view class="summary-row">
|
<view class="summary-row">
|
||||||
<text>选中项目</text>
|
<text>选中项目</text>
|
||||||
<text>{{selectedCount}} 项</text>
|
<text>{{selectedCount}} 项</text>
|
||||||
@@ -124,11 +148,11 @@
|
|||||||
<text>{{totalQuantity}} 件</text>
|
<text>{{totalQuantity}} 件</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="summary-row">
|
<view class="summary-row">
|
||||||
<text>小计</text>
|
<text>商品小计</text>
|
||||||
<text>{{subtotalText}}</text>
|
<text>{{subtotalText}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="summary-row">
|
<view class="summary-row">
|
||||||
<text>优惠</text>
|
<text>已省</text>
|
||||||
<text>-{{discountAmountText}}</text>
|
<text>-{{discountAmountText}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="summary-row total">
|
<view class="summary-row total">
|
||||||
@@ -142,6 +166,20 @@
|
|||||||
<text class="empty-title">正在加载购物车</text>
|
<text class="empty-title">正在加载购物车</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view wx:elif="{{recoveryState.visible}}" class="page-card recovery-card">
|
||||||
|
<text class="recovery-title">{{recoveryState.title}}</text>
|
||||||
|
<text class="recovery-desc">{{recoveryState.message}}</text>
|
||||||
|
<view class="recovery-actions">
|
||||||
|
<view
|
||||||
|
wx:for="{{recoveryState.actions}}"
|
||||||
|
wx:key="key"
|
||||||
|
class="recovery-btn {{item.primary ? 'primary' : ''}}"
|
||||||
|
data-key="{{item.key}}"
|
||||||
|
bindtap="handleRecoveryAction"
|
||||||
|
>{{item.text}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view wx:else class="page-card empty-card">
|
<view wx:else class="page-card empty-card">
|
||||||
<text class="empty-title">购物车还是空的</text>
|
<text class="empty-title">购物车还是空的</text>
|
||||||
<text class="empty-desc">先加购,再预约。</text>
|
<text class="empty-desc">先加购,再预约。</text>
|
||||||
|
|||||||
@@ -31,6 +31,54 @@
|
|||||||
line-height: 1.7;
|
line-height: 1.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.recovery-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
padding: 26rpx;
|
||||||
|
border: 2rpx solid var(--theme-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-title {
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #2d2430;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-desc {
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #8d7a84;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 136rpx;
|
||||||
|
height: 60rpx;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
border-radius: 999rpx;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 2rpx solid var(--theme-border);
|
||||||
|
color: #5d4b55;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-btn.primary {
|
||||||
|
background: var(--theme-primary);
|
||||||
|
border-color: var(--theme-primary);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
.cart-item-card + .cart-item-card,
|
.cart-item-card + .cart-item-card,
|
||||||
.coupon-card,
|
.coupon-card,
|
||||||
.summary-card {
|
.summary-card {
|
||||||
@@ -260,6 +308,55 @@
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.unavailable-coupon-list {
|
||||||
|
margin-top: 22rpx;
|
||||||
|
padding-top: 18rpx;
|
||||||
|
border-top: 2rpx solid #f6eaee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unavailable-title {
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #8d7a84;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unavailable-coupon {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 18rpx;
|
||||||
|
margin-top: 14rpx;
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #8d7a84;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unavailable-coupon text:first-child {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
color: #5d4b55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unavailable-coupon text:last-child {
|
||||||
|
max-width: 260rpx;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-preview,
|
||||||
|
.summary-vip {
|
||||||
|
margin-bottom: 14rpx;
|
||||||
|
padding: 16rpx 18rpx;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
background: var(--theme-primary-soft);
|
||||||
|
color: #5d4b55;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-vip {
|
||||||
|
color: var(--theme-primary);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
.summary-row {
|
.summary-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
const orderApi = require('../../api/order')
|
const orderApi = require('../../api/order')
|
||||||
|
const cartApi = require('../../api/cart')
|
||||||
/**
|
/**
|
||||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
* 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.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -26,6 +27,7 @@ const theme = require('../../utils/theme')
|
|||||||
const { resolveLegacyImage } = require('../../utils/file')
|
const { resolveLegacyImage } = require('../../utils/file')
|
||||||
const { formatDateTime, formatPrice, getOrderStatusClass, getOrderStatusText } = require('../../utils/format')
|
const { formatDateTime, formatPrice, getOrderStatusClass, getOrderStatusText } = require('../../utils/format')
|
||||||
const { runWithLoading } = require('../../utils/loading')
|
const { runWithLoading } = require('../../utils/loading')
|
||||||
|
const { buildRecoveryState, clearRecoveryState } = require('../../utils/recovery')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: REVIEW_SCORE_OPTIONS supports index.js by holding or executing the review score options page or API role.
|
* Purpose: REVIEW_SCORE_OPTIONS supports index.js by holding or executing the review score options page or API role.
|
||||||
@@ -137,20 +139,49 @@ function buildPendingReview(review) {
|
|||||||
return review
|
return review
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: formatImpactTime supports index.js by normalizing backend or order item appointment values for change summaries.
|
||||||
|
* Usage: call it when building user-visible artist-change cards and confirmation modal copy.
|
||||||
|
*/
|
||||||
|
function formatImpactTime(value) {
|
||||||
|
return formatDateTime(value)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: buildArtistChangeSummary supports index.js by holding or executing the build artist change summary page or API role.
|
* Purpose: buildArtistChangeSummary supports index.js by holding or executing the build artist change summary 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.
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
function buildArtistChangeSummary(request) {
|
function buildArtistChangeSummary(request, orderItem) {
|
||||||
if (!request) {
|
if (!request) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const originalName = request.originalArtistName || '原美甲师'
|
const originalName = request.originalArtistName || request.fromArtistName || (orderItem && orderItem.artistName) || '原美甲师'
|
||||||
const requestedName = request.requestedArtistName || '新美甲师'
|
const requestedName = request.requestedArtistName || request.toArtistName || '新美甲师'
|
||||||
|
const appointmentTime = formatImpactTime(request.appointmentTime || (orderItem && orderItem.appointmentTime))
|
||||||
|
const timeImpactText = request.timeImpactText || (request.timeAffected ? '预约时间可能调整' : '预约时间不变')
|
||||||
|
const priceImpactText = request.priceImpactText || (request.priceAffected ? '订单价格可能调整' : '价格不变')
|
||||||
|
const priceValue = request.priceAffected ? request.newPrice : (request.newPrice || request.originalPrice || (orderItem && orderItem.price))
|
||||||
|
const priceText = priceValue !== undefined && priceValue !== null && priceValue !== '' ? `¥${formatPrice(priceValue)}` : ''
|
||||||
|
const impactLines = [
|
||||||
|
appointmentTime ? `${timeImpactText}:${appointmentTime}` : timeImpactText,
|
||||||
|
priceText ? `${priceImpactText}:${priceText}` : priceImpactText
|
||||||
|
].filter(Boolean)
|
||||||
|
const originalArtistText = `原美甲师:${originalName}`
|
||||||
|
const requestedArtistText = `新美甲师:${requestedName}`
|
||||||
return {
|
return {
|
||||||
...request,
|
...request,
|
||||||
|
originalArtistText,
|
||||||
|
requestedArtistText,
|
||||||
|
artistLines: [originalArtistText, requestedArtistText],
|
||||||
displayText: `改派申请:${originalName} → ${requestedName}`,
|
displayText: `改派申请:${originalName} → ${requestedName}`,
|
||||||
reasonText: trimText(request.reason)
|
reasonText: trimText(request.reason),
|
||||||
|
impactLines,
|
||||||
|
confirmText: [
|
||||||
|
`原美甲师:${originalName}`,
|
||||||
|
`新美甲师:${requestedName}`,
|
||||||
|
request.reason ? `原因:${trimText(request.reason)}` : '',
|
||||||
|
...impactLines
|
||||||
|
].filter(Boolean).join('\n')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +198,77 @@ function indexByOrderItemId(list) {
|
|||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: formatTimelineTime keeps timeline timestamps short enough for mini-program cards.
|
||||||
|
* Usage: call it while building the order lifecycle timeline from backend date fields.
|
||||||
|
*/
|
||||||
|
function formatTimelineTime(value) {
|
||||||
|
return formatDateTime(value) || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: latestChangeTime picks the most meaningful time from a change request record.
|
||||||
|
* Usage: use it when summarizing historical artist-change requests on the timeline.
|
||||||
|
*/
|
||||||
|
function latestChangeTime(request) {
|
||||||
|
return (request && (request.approvedTime || request.rejectedTime || request.reviewTime || request.createTime)) || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: buildOrderTimeline creates a compact lifecycle timeline for one order.
|
||||||
|
* Usage: call it after pending reviews, submitted reviews, and change requests are loaded.
|
||||||
|
*/
|
||||||
|
function buildOrderTimeline(order, orderReviews, changeRequests, pendingReviews) {
|
||||||
|
const items = safeList(order && order.items)
|
||||||
|
const firstAppointment = items.map(item => item && item.appointmentTime).find(Boolean)
|
||||||
|
const changes = safeList(changeRequests)
|
||||||
|
const latestChange = changes
|
||||||
|
.slice()
|
||||||
|
.sort((left, right) => String(latestChangeTime(right)).localeCompare(String(latestChangeTime(left))))[0]
|
||||||
|
const submittedReviews = safeList(orderReviews).filter(isSubmittedReview)
|
||||||
|
const hasPendingReview = safeList(pendingReviews).some(review => sameId(review && review.orderId, order && order.id))
|
||||||
|
const status = Number(order && order.status)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
key: 'created',
|
||||||
|
title: '已创建',
|
||||||
|
text: formatTimelineTime(order && order.createTime) || '已提交',
|
||||||
|
done: true,
|
||||||
|
active: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'appointment',
|
||||||
|
title: '预约时间',
|
||||||
|
text: formatTimelineTime(firstAppointment) || '待确认',
|
||||||
|
done: Boolean(firstAppointment),
|
||||||
|
active: status === 1
|
||||||
|
},
|
||||||
|
changes.length ? {
|
||||||
|
key: 'artist-change',
|
||||||
|
title: '改派记录',
|
||||||
|
text: `${changes.length} 次申请`,
|
||||||
|
subText: formatTimelineTime(latestChangeTime(latestChange)),
|
||||||
|
done: changes.every(request => String((request && request.status) || '').toUpperCase() !== 'PENDING'),
|
||||||
|
active: changes.some(request => String((request && request.status) || '').toUpperCase() === 'PENDING')
|
||||||
|
} : null,
|
||||||
|
{
|
||||||
|
key: status === 3 ? 'cancelled' : 'completed',
|
||||||
|
title: status === 3 ? '已取消' : '已完成',
|
||||||
|
text: formatTimelineTime(order && (order.completeTime || order.cancelTime || order.updateTime)) || (status === 2 ? '服务完成' : (status === 3 ? '订单已取消' : '等待服务')),
|
||||||
|
done: status === 2 || status === 3,
|
||||||
|
active: status === 2 || status === 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'review',
|
||||||
|
title: '评价',
|
||||||
|
text: submittedReviews.length ? '已评价' : (hasPendingReview ? '待评价' : '完成后可评价'),
|
||||||
|
subText: formatTimelineTime((submittedReviews[0] && (submittedReviews[0].reviewTime || submittedReviews[0].submitTime)) || ''),
|
||||||
|
done: submittedReviews.length > 0,
|
||||||
|
active: hasPendingReview
|
||||||
|
}
|
||||||
|
].filter(Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: safeCall supports index.js by holding or executing the safe call page or API role.
|
* Purpose: safeCall supports index.js by holding or executing the safe call 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.
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -190,10 +292,14 @@ async function loadAssistData(orders) {
|
|||||||
const orderReviewListsPromise = Promise.all(orders.map(order => (
|
const orderReviewListsPromise = Promise.all(orders.map(order => (
|
||||||
safeCall(() => orderApi.listOrderReviews(order.id), [])
|
safeCall(() => orderApi.listOrderReviews(order.id), [])
|
||||||
)))
|
)))
|
||||||
const [pendingReviews, pendingChanges, orderReviewLists] = await Promise.all([
|
const orderChangeListsPromise = Promise.all(orders.map(order => (
|
||||||
|
safeCall(() => orderApi.listOrderArtistChangeRequests(order.id), [])
|
||||||
|
)))
|
||||||
|
const [pendingReviews, pendingChanges, orderReviewLists, orderChangeLists] = await Promise.all([
|
||||||
pendingReviewsPromise,
|
pendingReviewsPromise,
|
||||||
pendingChangesPromise,
|
pendingChangesPromise,
|
||||||
orderReviewListsPromise
|
orderReviewListsPromise,
|
||||||
|
orderChangeListsPromise
|
||||||
])
|
])
|
||||||
|
|
||||||
const submittedReviews = []
|
const submittedReviews = []
|
||||||
@@ -208,7 +314,16 @@ async function loadAssistData(orders) {
|
|||||||
return {
|
return {
|
||||||
pendingReviewByItemId: indexByOrderItemId(pendingReviews),
|
pendingReviewByItemId: indexByOrderItemId(pendingReviews),
|
||||||
submittedReviewByItemId: indexByOrderItemId(submittedReviews),
|
submittedReviewByItemId: indexByOrderItemId(submittedReviews),
|
||||||
pendingChangeByItemId: indexByOrderItemId(pendingChanges)
|
pendingChangeByItemId: indexByOrderItemId(pendingChanges),
|
||||||
|
pendingReviews,
|
||||||
|
reviewsByOrderId: safeList(orders).reduce((result, order, index) => {
|
||||||
|
result[toId(order && order.id)] = safeList(orderReviewLists[index])
|
||||||
|
return result
|
||||||
|
}, {}),
|
||||||
|
changesByOrderId: safeList(orders).reduce((result, order, index) => {
|
||||||
|
result[toId(order && order.id)] = safeList(orderChangeLists[index])
|
||||||
|
return result
|
||||||
|
}, {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +345,20 @@ function findReviewDraft(orders, reviewId) {
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeRebookQuantity(quantity) {
|
||||||
|
const value = Number(quantity)
|
||||||
|
return isFinite(value) && value > 0 ? Math.max(1, Math.floor(value)) : 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRebookableOrderItems(order) {
|
||||||
|
return safeList(order && order.items).filter(item => item && item.productId !== undefined && item.productId !== null)
|
||||||
|
}
|
||||||
|
|
||||||
|
function findOrderById(orders, orderId) {
|
||||||
|
const orderIdText = toId(orderId)
|
||||||
|
return safeList(orders).find(order => toId(order.id) === orderIdText) || null
|
||||||
|
}
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -240,7 +369,8 @@ Page({
|
|||||||
* Usage: set it from onLoad route options and compare it while formatting order cards.
|
* Usage: set it from onLoad route options and compare it while formatting order cards.
|
||||||
*/
|
*/
|
||||||
focusOrderId: '',
|
focusOrderId: '',
|
||||||
reviewScoreOptions: REVIEW_SCORE_OPTIONS
|
reviewScoreOptions: REVIEW_SCORE_OPTIONS,
|
||||||
|
recoveryState: clearRecoveryState()
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -249,7 +379,10 @@ Page({
|
|||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.setData({
|
this.setData({
|
||||||
focusOrderId: (options && options.orderId) || ''
|
focusOrderId: (options && options.orderId) || '',
|
||||||
|
focusOrderItemId: (options && options.orderItemId) || '',
|
||||||
|
focusReviewId: (options && options.reviewId) || '',
|
||||||
|
focusReviewMode: (options && options.review) || ''
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -265,13 +398,15 @@ Page({
|
|||||||
const isLoggedIn = auth.isLoggedIn()
|
const isLoggedIn = auth.isLoggedIn()
|
||||||
this.setData({
|
this.setData({
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
loading: isLoggedIn
|
loading: isLoggedIn,
|
||||||
|
recoveryState: clearRecoveryState()
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!isLoggedIn) {
|
if (!isLoggedIn) {
|
||||||
this.setData({
|
this.setData({
|
||||||
orders: [],
|
orders: [],
|
||||||
loading: false
|
loading: false,
|
||||||
|
recoveryState: clearRecoveryState()
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -280,13 +415,27 @@ Page({
|
|||||||
const orders = await orderApi.getOrderList()
|
const orders = await orderApi.getOrderList()
|
||||||
const list = safeList(orders)
|
const list = safeList(orders)
|
||||||
const assistData = await loadAssistData(list)
|
const assistData = await loadAssistData(list)
|
||||||
|
let resolvedFocusOrderId = this.data.focusOrderId
|
||||||
|
let resolvedFocusOrderItemId = this.data.focusOrderItemId
|
||||||
|
const targetReviewId = toId(this.data.focusReviewId)
|
||||||
|
if (!resolvedFocusOrderId && this.data.focusReviewMode === 'pending') {
|
||||||
|
const firstPending = safeList(assistData.pendingReviews)[0]
|
||||||
|
resolvedFocusOrderId = toId(firstPending && firstPending.orderId)
|
||||||
|
resolvedFocusOrderItemId = toId(firstPending && firstPending.orderItemId)
|
||||||
|
} else if (targetReviewId) {
|
||||||
|
const submittedReviews = Object.values(assistData.reviewsByOrderId || {}).reduce((all, reviews) => all.concat(safeList(reviews)), [])
|
||||||
|
const matchedReview = safeList(assistData.pendingReviews).concat(submittedReviews).find(review => sameId(review && review.id, targetReviewId))
|
||||||
|
resolvedFocusOrderId = toId(matchedReview && matchedReview.orderId) || resolvedFocusOrderId
|
||||||
|
resolvedFocusOrderItemId = toId(matchedReview && matchedReview.orderItemId) || resolvedFocusOrderItemId
|
||||||
|
}
|
||||||
const formattedOrders = await Promise.all(list.map(async order => ({
|
const formattedOrders = await Promise.all(list.map(async order => ({
|
||||||
...order,
|
...order,
|
||||||
focusTarget: sameId(order.id, this.data.focusOrderId),
|
focusTarget: sameId(order.id, resolvedFocusOrderId),
|
||||||
statusText: getOrderStatusText(order),
|
statusText: getOrderStatusText(order),
|
||||||
statusClass: getOrderStatusClass(order),
|
statusClass: getOrderStatusClass(order),
|
||||||
shopNameText: order.shopName ? `所属店铺:${order.shopName}` : '',
|
shopNameText: order.shopName ? `所属店铺:${order.shopName}` : '',
|
||||||
actualAmountText: `\u00a5${formatPrice(order.actualAmount)}`,
|
actualAmountText: `\u00a5${formatPrice(order.actualAmount)}`,
|
||||||
|
timeline: buildOrderTimeline(order, assistData.reviewsByOrderId[toId(order.id)], assistData.changesByOrderId[toId(order.id)], assistData.pendingReviews),
|
||||||
items: await Promise.all(safeList(order.items).map(async item => {
|
items: await Promise.all(safeList(order.items).map(async item => {
|
||||||
const itemId = toId(item.id)
|
const itemId = toId(item.id)
|
||||||
const inlinePendingReview = resolveRelatedRecord(item.pendingReview || order.pendingReview, item.id)
|
const inlinePendingReview = resolveRelatedRecord(item.pendingReview || order.pendingReview, item.id)
|
||||||
@@ -294,13 +443,14 @@ Page({
|
|||||||
const inlinePendingChange = resolveRelatedRecord(item.pendingArtistChangeRequest || order.pendingArtistChangeRequest, item.id)
|
const inlinePendingChange = resolveRelatedRecord(item.pendingArtistChangeRequest || order.pendingArtistChangeRequest, item.id)
|
||||||
const pendingReview = buildPendingReview(inlinePendingReview || assistData.pendingReviewByItemId[itemId])
|
const pendingReview = buildPendingReview(inlinePendingReview || assistData.pendingReviewByItemId[itemId])
|
||||||
const reviewSummary = buildReviewSummary(inlineReviewSummary || assistData.submittedReviewByItemId[itemId])
|
const reviewSummary = buildReviewSummary(inlineReviewSummary || assistData.submittedReviewByItemId[itemId])
|
||||||
const pendingArtistChangeRequest = buildArtistChangeSummary(inlinePendingChange || assistData.pendingChangeByItemId[itemId])
|
const pendingArtistChangeRequest = buildArtistChangeSummary(inlinePendingChange || assistData.pendingChangeByItemId[itemId], item)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
productImageUrl: await resolveLegacyImage(item.productImage),
|
productImageUrl: await resolveLegacyImage(item.productImage),
|
||||||
priceText: `\u00a5${formatPrice(item.price)}`,
|
priceText: `\u00a5${formatPrice(item.price)}`,
|
||||||
appointmentText: formatDateTime(item.appointmentTime),
|
appointmentText: formatDateTime(item.appointmentTime),
|
||||||
|
focusTarget: sameId(order.id, resolvedFocusOrderId) && (!resolvedFocusOrderItemId || sameId(item.id, resolvedFocusOrderItemId)),
|
||||||
pendingReview,
|
pendingReview,
|
||||||
reviewSummary,
|
reviewSummary,
|
||||||
reviewDraft: pendingReview ? { rating: 0, content: '' } : null,
|
reviewDraft: pendingReview ? { rating: 0, content: '' } : null,
|
||||||
@@ -309,16 +459,27 @@ Page({
|
|||||||
}))
|
}))
|
||||||
})))
|
})))
|
||||||
|
|
||||||
|
formattedOrders.forEach(order => {
|
||||||
|
order.canRebook = Number(order.status) === 2 && getRebookableOrderItems(order).length > 0
|
||||||
|
})
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
orders: formattedOrders
|
orders: formattedOrders,
|
||||||
|
recoveryState: clearRecoveryState()
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.setData({
|
this.setData({
|
||||||
orders: []
|
orders: [],
|
||||||
})
|
recoveryState: buildRecoveryState({
|
||||||
wx.showToast({
|
title: '订单列表加载失败',
|
||||||
title: error.message || '\u8ba2\u5355\u5217\u8868\u52a0\u8f7d\u5931\u8d25',
|
message: error,
|
||||||
icon: 'none'
|
fallbackMessage: '订单暂时没有加载出来,请重试或稍后再查看。',
|
||||||
|
actions: [
|
||||||
|
{ key: 'retryOrdersLoad', text: '重试' },
|
||||||
|
{ key: 'products', text: '去逛作品' },
|
||||||
|
{ key: 'profile', text: '返回我的' }
|
||||||
|
]
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
this.setData({
|
this.setData({
|
||||||
@@ -343,6 +504,33 @@ Page({
|
|||||||
navigation.goBack('/pages/profile/index')
|
navigation.goBack('/pages/profile/index')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleRecoveryAction(event) {
|
||||||
|
const key = event.currentTarget.dataset.key
|
||||||
|
if (key === 'retryOrdersLoad') {
|
||||||
|
this.setData({ recoveryState: clearRecoveryState() })
|
||||||
|
this.loadOrders()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions = this.data.recoveryState.actions || []
|
||||||
|
const action = actions.find(item => item.key === key)
|
||||||
|
if (action && action.route) {
|
||||||
|
this.openRecoveryRoute(action.route)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
openRecoveryRoute(route) {
|
||||||
|
const pureRoute = String(route || '').split('?')[0]
|
||||||
|
if (!pureRoute) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (navigation.isTabPage(pureRoute)) {
|
||||||
|
navigation.switchTab(pureRoute)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
navigation.navigate(route)
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: updateReviewDraft supports index.js by holding or executing the update review draft page or API role.
|
* Purpose: updateReviewDraft supports index.js by holding or executing the update review draft page or API role.
|
||||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -437,6 +625,7 @@ Page({
|
|||||||
|
|
||||||
async handleApproveArtistChange(event) {
|
async handleApproveArtistChange(event) {
|
||||||
const requestId = event.currentTarget.dataset.requestId
|
const requestId = event.currentTarget.dataset.requestId
|
||||||
|
const confirmText = event.currentTarget.dataset.confirmText
|
||||||
if (!requestId) {
|
if (!requestId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -446,7 +635,7 @@ Page({
|
|||||||
const confirmed = await new Promise(resolve => {
|
const confirmed = await new Promise(resolve => {
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '同意改派',
|
title: '同意改派',
|
||||||
content: '确认同意这次美甲师改派申请吗?',
|
content: confirmText || '确认同意这次美甲师改派申请吗?',
|
||||||
success: modalRes => resolve(Boolean(modalRes.confirm))
|
success: modalRes => resolve(Boolean(modalRes.confirm))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -476,6 +665,7 @@ Page({
|
|||||||
|
|
||||||
async handleRejectArtistChange(event) {
|
async handleRejectArtistChange(event) {
|
||||||
const requestId = event.currentTarget.dataset.requestId
|
const requestId = event.currentTarget.dataset.requestId
|
||||||
|
const confirmText = event.currentTarget.dataset.confirmText
|
||||||
if (!requestId) {
|
if (!requestId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -485,7 +675,7 @@ Page({
|
|||||||
const confirmed = await new Promise(resolve => {
|
const confirmed = await new Promise(resolve => {
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '拒绝改派',
|
title: '拒绝改派',
|
||||||
content: '确认拒绝这次美甲师改派申请吗?拒绝后可在下一步补充原因。',
|
content: confirmText ? `${confirmText}\n\n确认拒绝这次改派申请吗?拒绝后可在下一步补充原因。` : '确认拒绝这次美甲师改派申请吗?拒绝后可在下一步补充原因。',
|
||||||
confirmText: '拒绝',
|
confirmText: '拒绝',
|
||||||
success: modalRes => resolve(Boolean(modalRes.confirm))
|
success: modalRes => resolve(Boolean(modalRes.confirm))
|
||||||
})
|
})
|
||||||
@@ -541,6 +731,54 @@ Page({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async handleRebookOrder(event) {
|
||||||
|
const orderId = event.currentTarget.dataset.orderId
|
||||||
|
const order = findOrderById(this.data.orders, orderId)
|
||||||
|
if (!order || !order.canRebook) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '这笔订单暂无可复刻作品',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const items = getRebookableOrderItems(order)
|
||||||
|
try {
|
||||||
|
await actionGuard.run(this, `order:rebook:${orderId}`, async () => {
|
||||||
|
await runWithLoading(async () => {
|
||||||
|
for (let i = 0; i < items.length; i += 1) {
|
||||||
|
await cartApi.addToCart({
|
||||||
|
productId: items[i].productId,
|
||||||
|
quantity: normalizeRebookQuantity(items[i].quantity)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await getApp().updateCartBadge()
|
||||||
|
})
|
||||||
|
await new Promise(resolve => {
|
||||||
|
wx.showModal({
|
||||||
|
title: '已加入购物车',
|
||||||
|
content: '请重新选择美甲师和预约时间后再提交订单。',
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: '去选择',
|
||||||
|
success: () => resolve(),
|
||||||
|
fail: () => resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
await navigation.switchTab('/pages/cart/index')
|
||||||
|
}, {
|
||||||
|
message: '正在加入购物车,请勿重复点击'
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
if (actionGuard.isGuardError(error)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '复刻同款失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async handleCancelOrder(event) {
|
async handleCancelOrder(event) {
|
||||||
const orderId = event.currentTarget.dataset.orderId
|
const orderId = event.currentTarget.dataset.orderId
|
||||||
if (!orderId) {
|
if (!orderId) {
|
||||||
|
|||||||
@@ -25,7 +25,20 @@
|
|||||||
</view>
|
</view>
|
||||||
<view wx:if="{{item.shopNameText}}" class="order-shop">{{item.shopNameText}}</view>
|
<view wx:if="{{item.shopNameText}}" class="order-shop">{{item.shopNameText}}</view>
|
||||||
|
|
||||||
<view wx:for="{{item.items}}" wx:key="id" wx:for-item="orderItem" class="order-item">
|
<view wx:if="{{item.timeline && item.timeline.length}}" class="order-timeline">
|
||||||
|
<view
|
||||||
|
wx:for="{{item.timeline}}"
|
||||||
|
wx:key="key"
|
||||||
|
wx:for-item="node"
|
||||||
|
class="timeline-node {{node.done ? 'done' : ''}} {{node.active ? 'active' : ''}}"
|
||||||
|
>
|
||||||
|
<text class="timeline-title">{{node.title}}</text>
|
||||||
|
<text class="timeline-text">{{node.text}}</text>
|
||||||
|
<text wx:if="{{node.subText}}" class="timeline-sub">{{node.subText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view wx:for="{{item.items}}" wx:key="id" wx:for-item="orderItem" class="order-item {{orderItem.focusTarget ? 'focus-target' : ''}}">
|
||||||
<image class="order-thumb" src="{{orderItem.productImageUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
|
<image class="order-thumb" src="{{orderItem.productImageUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
|
||||||
<view class="order-main">
|
<view class="order-main">
|
||||||
<view class="order-title">{{orderItem.productTitle}}</view>
|
<view class="order-title">{{orderItem.productTitle}}</view>
|
||||||
@@ -69,11 +82,20 @@
|
|||||||
|
|
||||||
<view wx:if="{{orderItem.pendingArtistChangeRequest}}" class="change-panel">
|
<view wx:if="{{orderItem.pendingArtistChangeRequest}}" class="change-panel">
|
||||||
<text class="assist-label">待确认改派</text>
|
<text class="assist-label">待确认改派</text>
|
||||||
<text class="assist-main">{{orderItem.pendingArtistChangeRequest.displayText}}</text>
|
<text class="assist-main">{{orderItem.pendingArtistChangeRequest.originalArtistText}}</text>
|
||||||
|
<text class="assist-main">{{orderItem.pendingArtistChangeRequest.requestedArtistText}}</text>
|
||||||
<text wx:if="{{orderItem.pendingArtistChangeRequest.reasonText}}" class="assist-desc">原因:{{orderItem.pendingArtistChangeRequest.reasonText}}</text>
|
<text wx:if="{{orderItem.pendingArtistChangeRequest.reasonText}}" class="assist-desc">原因:{{orderItem.pendingArtistChangeRequest.reasonText}}</text>
|
||||||
|
<view class="impact-list">
|
||||||
|
<text
|
||||||
|
wx:for="{{orderItem.pendingArtistChangeRequest.impactLines}}"
|
||||||
|
wx:key="*this"
|
||||||
|
wx:for-item="impactLine"
|
||||||
|
class="impact-line"
|
||||||
|
>{{impactLine}}</text>
|
||||||
|
</view>
|
||||||
<view class="change-actions">
|
<view class="change-actions">
|
||||||
<view class="change-btn primary" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleApproveArtistChange">同意改派</view>
|
<view class="change-btn primary" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" data-confirm-text="{{orderItem.pendingArtistChangeRequest.confirmText}}" bindtap="handleApproveArtistChange">同意改派</view>
|
||||||
<view class="change-btn" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleRejectArtistChange">拒绝</view>
|
<view class="change-btn" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" data-confirm-text="{{orderItem.pendingArtistChangeRequest.confirmText}}" bindtap="handleRejectArtistChange">拒绝</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -81,7 +103,10 @@
|
|||||||
|
|
||||||
<view class="order-foot">
|
<view class="order-foot">
|
||||||
<text class="order-amount">总计:{{item.actualAmountText}}</text>
|
<text class="order-amount">总计:{{item.actualAmountText}}</text>
|
||||||
<view wx:if="{{item.status == 1}}" class="cancel-btn" data-order-id="{{item.id}}" bindtap="handleCancelOrder">取消订单</view>
|
<view class="order-actions">
|
||||||
|
<view wx:if="{{item.canRebook}}" class="rebook-btn" data-order-id="{{item.id}}" bindtap="handleRebookOrder">复刻同款</view>
|
||||||
|
<view wx:if="{{item.status == 1}}" class="cancel-btn" data-order-id="{{item.id}}" bindtap="handleCancelOrder">取消订单</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
@@ -90,6 +115,20 @@
|
|||||||
<text class="empty-title">正在加载订单</text>
|
<text class="empty-title">正在加载订单</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view wx:elif="{{recoveryState.visible}}" class="page-card recovery-card">
|
||||||
|
<text class="recovery-title">{{recoveryState.title}}</text>
|
||||||
|
<text class="recovery-desc">{{recoveryState.message}}</text>
|
||||||
|
<view class="recovery-actions">
|
||||||
|
<view
|
||||||
|
wx:for="{{recoveryState.actions}}"
|
||||||
|
wx:key="key"
|
||||||
|
class="recovery-btn {{item.primary ? 'primary' : ''}}"
|
||||||
|
data-key="{{item.key}}"
|
||||||
|
bindtap="handleRecoveryAction"
|
||||||
|
>{{item.text}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view wx:else class="page-card empty-card">
|
<view wx:else class="page-card empty-card">
|
||||||
<text class="empty-title">你还没有订单</text>
|
<text class="empty-title">你还没有订单</text>
|
||||||
<text class="empty-desc">先去预约喜欢的款式。</text>
|
<text class="empty-desc">先去预约喜欢的款式。</text>
|
||||||
|
|||||||
@@ -2,6 +2,53 @@
|
|||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.recovery-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14rpx;
|
||||||
|
padding: 26rpx;
|
||||||
|
border: 2rpx solid var(--theme-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-title {
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #2d2430;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-desc {
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #8d7a84;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 136rpx;
|
||||||
|
height: 60rpx;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
border-radius: 999rpx;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 2rpx solid var(--theme-border);
|
||||||
|
color: #5d4b55;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recovery-btn.primary {
|
||||||
|
background: var(--theme-primary);
|
||||||
|
border-color: var(--theme-primary);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
.order-card + .order-card {
|
.order-card + .order-card {
|
||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
}
|
}
|
||||||
@@ -35,6 +82,51 @@
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order-timeline {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
|
gap: 10rpx;
|
||||||
|
margin-top: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-node {
|
||||||
|
min-width: 0;
|
||||||
|
padding: 12rpx 10rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
background: var(--theme-primary-soft);
|
||||||
|
color: #8d7a84;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-node.done {
|
||||||
|
color: var(--theme-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-node.active {
|
||||||
|
outline: 2rpx solid var(--theme-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-title,
|
||||||
|
.timeline-text,
|
||||||
|
.timeline-sub {
|
||||||
|
display: block;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-title {
|
||||||
|
font-size: 21rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #2d2430;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-text,
|
||||||
|
.timeline-sub {
|
||||||
|
margin-top: 4rpx;
|
||||||
|
font-size: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.order-head-copy {
|
.order-head-copy {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
@@ -87,6 +179,13 @@
|
|||||||
margin-top: 22rpx;
|
margin-top: 22rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order-item.focus-target {
|
||||||
|
padding: 12rpx;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
background: rgba(255, 247, 249, 0.9);
|
||||||
|
outline: 2rpx solid var(--theme-primary);
|
||||||
|
}
|
||||||
|
|
||||||
.order-thumb {
|
.order-thumb {
|
||||||
width: 132rpx;
|
width: 132rpx;
|
||||||
height: 132rpx;
|
height: 132rpx;
|
||||||
@@ -118,13 +217,21 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.order-amount {
|
.order-amount {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #2d2430;
|
color: #2d2430;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cancel-btn {
|
.cancel-btn,
|
||||||
|
.rebook-btn {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -132,12 +239,20 @@
|
|||||||
height: 60rpx;
|
height: 60rpx;
|
||||||
padding: 0 18rpx;
|
padding: 0 18rpx;
|
||||||
border-radius: 999rpx;
|
border-radius: 999rpx;
|
||||||
background: var(--theme-primary-soft);
|
|
||||||
color: var(--theme-accent);
|
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rebook-btn {
|
||||||
|
background: var(--theme-primary);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cancel-btn {
|
||||||
|
background: var(--theme-primary-soft);
|
||||||
|
color: var(--theme-accent);
|
||||||
|
}
|
||||||
|
|
||||||
.review-summary,
|
.review-summary,
|
||||||
.review-panel,
|
.review-panel,
|
||||||
.change-panel {
|
.change-panel {
|
||||||
@@ -182,6 +297,20 @@
|
|||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.impact-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8rpx;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.impact-line {
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--theme-primary);
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
.score-row {
|
.score-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ const { getSignedUrl, resolveImageList, previewImagesSafely } = require('../../u
|
|||||||
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
|
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
|
||||||
const { formatPrice, getProductTitle, splitCsv } = require('../../utils/format')
|
const { formatPrice, getProductTitle, splitCsv } = require('../../utils/format')
|
||||||
const { runWithLoading } = require('../../utils/loading')
|
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.
|
* Purpose: parseTimeRange supports index.js by holding or executing the parse time range page or API role.
|
||||||
@@ -208,7 +209,9 @@ Page({
|
|||||||
...product,
|
...product,
|
||||||
displayTitle: getProductTitle(product),
|
displayTitle: getProductTitle(product),
|
||||||
priceText: `¥${formatPrice(product.price)}`,
|
priceText: `¥${formatPrice(product.price)}`,
|
||||||
descriptionText: product.description || '商家还没有补充作品说明。'
|
descriptionText: product.description || '商家还没有补充作品说明。',
|
||||||
|
targetAudienceText: product.targetAudience || '',
|
||||||
|
precautionsText: product.precautions || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
@@ -303,7 +306,10 @@ Page({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
previewImagesSafely(current, this.data.productImages)
|
previewImagesSafely(current, this.data.productImages, {
|
||||||
|
failMessage: '图片可能已过期,请重试;仍失败时可以返回作品列表重新进入。',
|
||||||
|
emptyMessage: '这件作品暂时没有可预览图片,可以返回作品列表查看其他款式。'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -488,6 +494,7 @@ Page({
|
|||||||
message: '操作进行中,请勿重复点击'
|
message: '操作进行中,请勿重复点击'
|
||||||
})
|
})
|
||||||
await getApp().updateCartBadge()
|
await getApp().updateCartBadge()
|
||||||
|
saveBuyNowContext(product.id)
|
||||||
wx.switchTab({
|
wx.switchTab({
|
||||||
url: '/pages/cart/index'
|
url: '/pages/cart/index'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -79,6 +79,16 @@
|
|||||||
<view class="section-title">款式说明</view>
|
<view class="section-title">款式说明</view>
|
||||||
<view class="desc-text">{{product.descriptionText}}</view>
|
<view class="desc-text">{{product.descriptionText}}</view>
|
||||||
</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>
|
||||||
|
|
||||||
<view class="page-card comment-card">
|
<view class="page-card comment-card">
|
||||||
|
|||||||
@@ -164,6 +164,19 @@
|
|||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
color: #5d4b55;
|
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 {
|
.comment-card {
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ Page({
|
|||||||
loading: false,
|
loading: false,
|
||||||
loadingMore: false,
|
loadingMore: false,
|
||||||
categories: [ALL_CATEGORY],
|
categories: [ALL_CATEGORY],
|
||||||
|
filterGroups: [],
|
||||||
|
selectedTagId: '',
|
||||||
selectedCategory: ALL_CATEGORY,
|
selectedCategory: ALL_CATEGORY,
|
||||||
searchKeyword: '',
|
searchKeyword: '',
|
||||||
products: [],
|
products: [],
|
||||||
@@ -197,10 +199,16 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
async loadTags() {
|
async loadTags() {
|
||||||
const tags = await cache.remember('tags:all', CACHE_TTL.tags, () => tagApi.getAllTags())
|
const groups = await cache.remember('tags:filter-options', CACHE_TTL.tags, () => tagApi.getFilterOptions())
|
||||||
const names = Array.isArray(tags) ? tags.map(item => item.tagName).filter(Boolean) : []
|
const normalizedGroups = (Array.isArray(groups) ? groups : []).map(group => ({
|
||||||
|
...group,
|
||||||
|
tags: (Array.isArray(group.tags) ? group.tags : []).map(tag => ({
|
||||||
|
...tag,
|
||||||
|
idText: String(tag.id)
|
||||||
|
}))
|
||||||
|
}))
|
||||||
this.setData({
|
this.setData({
|
||||||
categories: [ALL_CATEGORY].concat(names)
|
filterGroups: normalizedGroups
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -225,10 +233,13 @@ Page({
|
|||||||
async applyFilter(filter) {
|
async applyFilter(filter) {
|
||||||
const keyword = String(filter.keyword || '').trim()
|
const keyword = String(filter.keyword || '').trim()
|
||||||
const tag = String(filter.tag || '').trim()
|
const tag = String(filter.tag || '').trim()
|
||||||
|
const tagId = String(filter.tagId || '').trim()
|
||||||
|
const matchedTag = this.resolveFilterTag(tagId, tag)
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
searchKeyword: keyword,
|
searchKeyword: keyword,
|
||||||
selectedCategory: tag && this.data.categories.includes(tag) ? tag : ALL_CATEGORY,
|
selectedTagId: matchedTag ? String(matchedTag.id) : '',
|
||||||
|
selectedCategory: matchedTag ? (matchedTag.displayName || matchedTag.tagName) : ALL_CATEGORY,
|
||||||
page: 1,
|
page: 1,
|
||||||
total: 0,
|
total: 0,
|
||||||
hasMore: false
|
hasMore: false
|
||||||
@@ -246,11 +257,13 @@ Page({
|
|||||||
try {
|
try {
|
||||||
const keyword = String(this.data.searchKeyword || '').trim()
|
const keyword = String(this.data.searchKeyword || '').trim()
|
||||||
const tag = this.data.selectedCategory === ALL_CATEGORY ? '' : this.data.selectedCategory
|
const tag = this.data.selectedCategory === ALL_CATEGORY ? '' : this.data.selectedCategory
|
||||||
|
const tagIds = this.data.selectedTagId || ''
|
||||||
const result = await productApi.getProductPage({
|
const result = await productApi.getProductPage({
|
||||||
page: nextPage,
|
page: nextPage,
|
||||||
size: this.data.pageSize,
|
size: this.data.pageSize,
|
||||||
keyword: keyword || undefined,
|
keyword: keyword || undefined,
|
||||||
tag: tag || undefined
|
tag: tagIds ? undefined : (tag || undefined),
|
||||||
|
tagIds: tagIds || undefined
|
||||||
})
|
})
|
||||||
const cards = await buildProductCards(result && result.list ? result.list : [])
|
const cards = await buildProductCards(result && result.list ? result.list : [])
|
||||||
const displayCards = await this.attachCartState(cards)
|
const displayCards = await this.attachCartState(cards)
|
||||||
@@ -333,6 +346,33 @@ Page({
|
|||||||
return chips.join(' \u00b7 ')
|
return chips.join(' \u00b7 ')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: flattenFilterTags returns all scene-filter tags for query matching.
|
||||||
|
* Usage: call before applying route or pending filters.
|
||||||
|
*/
|
||||||
|
flattenFilterTags() {
|
||||||
|
return (Array.isArray(this.data.filterGroups) ? this.data.filterGroups : [])
|
||||||
|
.reduce((list, group) => list.concat(Array.isArray(group.tags) ? group.tags : []), [])
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: resolveFilterTag matches route filter text or id to a visible scene tag.
|
||||||
|
* Usage: call from applyFilter so old tag query links still select the right chip.
|
||||||
|
*/
|
||||||
|
resolveFilterTag(tagId, tagName) {
|
||||||
|
const tags = this.flattenFilterTags()
|
||||||
|
if (tagId) {
|
||||||
|
const byId = tags.find(item => String(item.id) === tagId)
|
||||||
|
if (byId) {
|
||||||
|
return byId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!tagName) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return tags.find(item => item.tagName === tagName || item.displayName === tagName) || null
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `normalizeId` page method. Use this from WXML event bindings or lifecycle hooks.
|
* `normalizeId` 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.
|
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||||
@@ -447,6 +487,7 @@ Page({
|
|||||||
await actionGuard.run(this, 'products:search', async () => {
|
await actionGuard.run(this, 'products:search', async () => {
|
||||||
this.setData({
|
this.setData({
|
||||||
selectedCategory: ALL_CATEGORY,
|
selectedCategory: ALL_CATEGORY,
|
||||||
|
selectedTagId: '',
|
||||||
page: 1
|
page: 1
|
||||||
})
|
})
|
||||||
await runWithLoading(() => this.loadProducts(true))
|
await runWithLoading(() => this.loadProducts(true))
|
||||||
@@ -466,11 +507,13 @@ Page({
|
|||||||
|
|
||||||
async handleSelectCategory(event) {
|
async handleSelectCategory(event) {
|
||||||
const category = event.currentTarget.dataset.category
|
const category = event.currentTarget.dataset.category
|
||||||
|
const tagId = event.currentTarget.dataset.tagId ? String(event.currentTarget.dataset.tagId) : ''
|
||||||
resetKeyboardSafe(this)
|
resetKeyboardSafe(this)
|
||||||
try {
|
try {
|
||||||
await actionGuard.run(this, `products:category:${category}`, async () => {
|
await actionGuard.run(this, `products:category:${category}:${tagId}`, async () => {
|
||||||
this.setData({
|
this.setData({
|
||||||
selectedCategory: category,
|
selectedCategory: category,
|
||||||
|
selectedTagId: tagId,
|
||||||
searchKeyword: '',
|
searchKeyword: '',
|
||||||
page: 1
|
page: 1
|
||||||
})
|
})
|
||||||
@@ -495,6 +538,7 @@ Page({
|
|||||||
await actionGuard.run(this, 'products:reset', async () => {
|
await actionGuard.run(this, 'products:reset', async () => {
|
||||||
this.setData({
|
this.setData({
|
||||||
selectedCategory: ALL_CATEGORY,
|
selectedCategory: ALL_CATEGORY,
|
||||||
|
selectedTagId: '',
|
||||||
searchKeyword: '',
|
searchKeyword: '',
|
||||||
page: 1
|
page: 1
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -25,13 +25,26 @@
|
|||||||
<scroll-view class="category-scroll" scroll-x enable-flex show-scrollbar="false">
|
<scroll-view class="category-scroll" scroll-x enable-flex show-scrollbar="false">
|
||||||
<view class="category-list">
|
<view class="category-list">
|
||||||
<view
|
<view
|
||||||
wx:for="{{categories}}"
|
class="category-item {{selectedCategory === '全部' ? 'active' : ''}}"
|
||||||
wx:key="*this"
|
data-category="全部"
|
||||||
class="category-item {{selectedCategory === item ? 'active' : ''}}"
|
data-tag-id=""
|
||||||
data-category="{{item}}"
|
|
||||||
bindtap="handleSelectCategory"
|
bindtap="handleSelectCategory"
|
||||||
>
|
>
|
||||||
{{item}}
|
全部
|
||||||
|
</view>
|
||||||
|
<view wx:for="{{filterGroups}}" wx:for-item="group" wx:key="groupName" class="filter-group">
|
||||||
|
<view class="filter-group-title">{{group.groupName}}</view>
|
||||||
|
<view
|
||||||
|
wx:for="{{group.tags}}"
|
||||||
|
wx:for-item="tag"
|
||||||
|
wx:key="id"
|
||||||
|
class="category-item {{selectedTagId === tag.idText ? 'active' : ''}}"
|
||||||
|
data-category="{{tag.displayName || tag.tagName}}"
|
||||||
|
data-tag-id="{{tag.idText}}"
|
||||||
|
bindtap="handleSelectCategory"
|
||||||
|
>
|
||||||
|
{{tag.displayName || tag.tagName}}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|||||||
@@ -83,6 +83,19 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filter-group {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-group-title {
|
||||||
|
color: #a4939c;
|
||||||
|
font-size: 22rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
.category-item.active {
|
.category-item.active {
|
||||||
background: var(--theme-primary-soft);
|
background: var(--theme-primary-soft);
|
||||||
color: var(--theme-primary);
|
color: var(--theme-primary);
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ Page({
|
|||||||
needSetPassword: false,
|
needSetPassword: false,
|
||||||
userInfo: null,
|
userInfo: null,
|
||||||
orderCount: 0,
|
orderCount: 0,
|
||||||
|
pendingReviewCount: 0,
|
||||||
couponCount: 0,
|
couponCount: 0,
|
||||||
wishlistCount: 0,
|
wishlistCount: 0,
|
||||||
unreadMessageCount: 0,
|
unreadMessageCount: 0,
|
||||||
@@ -96,18 +97,20 @@ Page({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [userInfo, orders, coupons, wishlist, unreadMessages] = await Promise.all([
|
const [userInfo, orders, coupons, wishlist, unreadMessages, pendingReviews] = await Promise.all([
|
||||||
userApi.getUserInfo(),
|
userApi.getUserInfo(),
|
||||||
orderApi.getOrderList(),
|
orderApi.getOrderList(),
|
||||||
couponApi.listUserCoupons(),
|
couponApi.listUserCoupons(),
|
||||||
wishlistApi.getWishlist(),
|
wishlistApi.getWishlist(),
|
||||||
userApi.getMyUnreadMessageCount()
|
userApi.getMyUnreadMessageCount(),
|
||||||
|
orderApi.listMyPendingReviews().catch(() => [])
|
||||||
])
|
])
|
||||||
|
|
||||||
getApp().refreshUserInfo(userInfo)
|
getApp().refreshUserInfo(userInfo)
|
||||||
this.setData({
|
this.setData({
|
||||||
userInfo,
|
userInfo,
|
||||||
orderCount: Array.isArray(orders) ? orders.length : 0,
|
orderCount: Array.isArray(orders) ? orders.length : 0,
|
||||||
|
pendingReviewCount: Array.isArray(pendingReviews) ? pendingReviews.length : 0,
|
||||||
couponCount: Array.isArray(coupons) ? coupons.length : 0,
|
couponCount: Array.isArray(coupons) ? coupons.length : 0,
|
||||||
wishlistCount: Array.isArray(wishlist) ? wishlist.length : 0,
|
wishlistCount: Array.isArray(wishlist) ? wishlist.length : 0,
|
||||||
unreadMessageCount: Number((unreadMessages && unreadMessages.unreadCount) || 0)
|
unreadMessageCount: Number((unreadMessages && unreadMessages.unreadCount) || 0)
|
||||||
@@ -160,6 +163,20 @@ Page({
|
|||||||
navigation.navigate('/pages/orders/index')
|
navigation.navigate('/pages/orders/index')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: handleOpenPendingReviews jumps straight to the order-page pending review focus.
|
||||||
|
* Usage: bind the pending-review card in profile WXML.
|
||||||
|
*/
|
||||||
|
handleOpenPendingReviews() {
|
||||||
|
if (!navigation.ensureLogin('查看待评价')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
navigation.navigate('/pages/orders/index', {
|
||||||
|
review: 'pending',
|
||||||
|
source: 'profile'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `handleOpenWishlist` page method. Use this from WXML event bindings or lifecycle hooks.
|
* `handleOpenWishlist` 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.
|
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||||
|
|||||||
@@ -37,6 +37,10 @@
|
|||||||
<text class="summary-value">{{couponCount}}</text>
|
<text class="summary-value">{{couponCount}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view wx:if="{{pendingReviewCount > 0}}" class="pending-review-card" bindtap="handleOpenPendingReviews">
|
||||||
|
<text>待评价 {{pendingReviewCount}}</text>
|
||||||
|
<text>给服务过你的美甲师一点反馈</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="shop-box" bindtap="handleSwitchShop">
|
<view class="shop-box" bindtap="handleSwitchShop">
|
||||||
<view>
|
<view>
|
||||||
@@ -57,6 +61,7 @@
|
|||||||
<view class="section-title">常用入口</view>
|
<view class="section-title">常用入口</view>
|
||||||
<view class="menu-item" bindtap="handleOpenOrders">
|
<view class="menu-item" bindtap="handleOpenOrders">
|
||||||
<text>我的订单</text>
|
<text>我的订单</text>
|
||||||
|
<text wx:if="{{pendingReviewCount > 0}}" class="menu-badge">待评价 {{pendingReviewCount}}</text>
|
||||||
<text class="menu-arrow">></text>
|
<text class="menu-arrow">></text>
|
||||||
</view>
|
</view>
|
||||||
<view class="menu-item" bindtap="handleOpenWishlist">
|
<view class="menu-item" bindtap="handleOpenWishlist">
|
||||||
|
|||||||
@@ -94,6 +94,23 @@
|
|||||||
margin-top: 26rpx;
|
margin-top: 26rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pending-review-card {
|
||||||
|
display: grid;
|
||||||
|
gap: 8rpx;
|
||||||
|
margin-top: 22rpx;
|
||||||
|
padding: 20rpx 24rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
background: var(--theme-primary-soft);
|
||||||
|
color: #8d7a84;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pending-review-card text:first-child {
|
||||||
|
color: var(--theme-primary);
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
.shop-box {
|
.shop-box {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const navigation = require('../../utils/navigation')
|
|||||||
const theme = require('../../utils/theme')
|
const theme = require('../../utils/theme')
|
||||||
const { getSignedUrl, resolveImageList, previewImagesSafely } = require('../../utils/file')
|
const { getSignedUrl, resolveImageList, previewImagesSafely } = require('../../utils/file')
|
||||||
const { DEFAULT_SHOP_IMAGE } = require('../../utils/config')
|
const { DEFAULT_SHOP_IMAGE } = require('../../utils/config')
|
||||||
|
const { showRecoveryModal } = require('../../utils/recovery')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* shop-detail page logic.
|
* shop-detail page logic.
|
||||||
@@ -38,6 +39,7 @@ Page({
|
|||||||
*/
|
*/
|
||||||
managerContact: null,
|
managerContact: null,
|
||||||
distanceText: '',
|
distanceText: '',
|
||||||
|
trustProfile: null,
|
||||||
shopImages: []
|
shopImages: []
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -78,7 +80,11 @@ Page({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const shopInfo = await shopApi.getShopById(this.data.shopId)
|
const shopInfo = await shopApi.getShopById(this.data.shopId)
|
||||||
const shopImages = await resolveImageList(shopInfo.imageFileIds || shopInfo.coverImageFileId, DEFAULT_SHOP_IMAGE)
|
const trustProfile = await shopApi.getTrustProfile(this.data.shopId).catch(() => null)
|
||||||
|
const trustImages = trustProfile && Array.isArray(trustProfile.environmentImages) ? trustProfile.environmentImages.filter(Boolean) : []
|
||||||
|
const shopImages = trustImages.length
|
||||||
|
? trustImages
|
||||||
|
: await resolveImageList(shopInfo.imageFileIds || shopInfo.coverImageFileId, DEFAULT_SHOP_IMAGE)
|
||||||
const shopTheme = theme.resolveShopTheme(shopInfo)
|
const shopTheme = theme.resolveShopTheme(shopInfo)
|
||||||
this.setData(theme.pageThemeData(shopTheme))
|
this.setData(theme.pageThemeData(shopTheme))
|
||||||
if (shopTheme.backgroundImageFileId) {
|
if (shopTheme.backgroundImageFileId) {
|
||||||
@@ -91,6 +97,7 @@ Page({
|
|||||||
}
|
}
|
||||||
this.setData({
|
this.setData({
|
||||||
shopInfo,
|
shopInfo,
|
||||||
|
trustProfile: this.normalizeTrustProfile(trustProfile),
|
||||||
shopImages,
|
shopImages,
|
||||||
distanceText: ''
|
distanceText: ''
|
||||||
})
|
})
|
||||||
@@ -106,6 +113,47 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: normalizeTrustProfile prepares backend trust fields for WXML display.
|
||||||
|
* Usage: call after getTrustProfile so metrics and lists have safe defaults.
|
||||||
|
*/
|
||||||
|
normalizeTrustProfile(profile) {
|
||||||
|
if (!profile) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const stats = profile.stats || {}
|
||||||
|
return {
|
||||||
|
...profile,
|
||||||
|
ratingText: Number(stats.averageRating || 0) > 0 ? Number(stats.averageRating).toFixed(1) : '暂无',
|
||||||
|
reviewCount: Number(stats.reviewCount || 0),
|
||||||
|
productCount: Number(stats.productCount || 0),
|
||||||
|
availabilityText: profile.availabilitySummary && profile.availabilitySummary.summaryText
|
||||||
|
? profile.availabilitySummary.summaryText
|
||||||
|
: '预约前会再次确认档期',
|
||||||
|
featuredProducts: (Array.isArray(profile.featuredProducts) ? profile.featuredProducts : []).map(item => ({
|
||||||
|
...item,
|
||||||
|
priceText: Number(item.price || 0).toFixed(2)
|
||||||
|
})),
|
||||||
|
recentReviews: (Array.isArray(profile.recentReviews) ? profile.recentReviews : []).map(item => ({
|
||||||
|
...item,
|
||||||
|
ratingText: Number(item.ratingScore || 0) > 0 ? Number(item.ratingScore).toFixed(1) : '暂无',
|
||||||
|
submittedText: item.submittedAt ? String(item.submittedAt).replace('T', ' ').slice(0, 16) : ''
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purpose: handleOpenProduct navigates from trust-profile cards to product details.
|
||||||
|
* Usage: bind product cards to this method with data-id.
|
||||||
|
*/
|
||||||
|
handleOpenProduct(event) {
|
||||||
|
const productId = event.currentTarget.dataset.id
|
||||||
|
if (!productId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
navigation.navigate('/pages/product-detail/index', { id: productId })
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
* `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.
|
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||||
@@ -164,9 +212,21 @@ Page({
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
wx.showToast({
|
showRecoveryModal({
|
||||||
title: error.message || '联系方式获取失败',
|
title: '联系方式获取失败',
|
||||||
icon: 'none'
|
message: error.message || '暂时没有拿到联系方式,请重试;也可以先复制门店名,稍后从“我的”页联系客服。',
|
||||||
|
actions: [
|
||||||
|
{ key: 'retry', text: '重试联系' },
|
||||||
|
{ key: 'profile', text: '去我的' }
|
||||||
|
]
|
||||||
|
}).then(action => {
|
||||||
|
if (action && action.key === 'retry') {
|
||||||
|
this.handleContactManager()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (action && action.key === 'profile') {
|
||||||
|
navigation.switchTab('/pages/profile/index')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,10 +21,25 @@
|
|||||||
<view class="shop-address" bindtap="handleCopyAddress">{{shopInfo.address || '门店地址待补充'}}</view>
|
<view class="shop-address" bindtap="handleCopyAddress">{{shopInfo.address || '门店地址待补充'}}</view>
|
||||||
<view wx:if="{{distanceText}}" class="shop-distance">{{distanceText}}</view>
|
<view wx:if="{{distanceText}}" class="shop-distance">{{distanceText}}</view>
|
||||||
|
|
||||||
|
<view wx:if="{{trustProfile}}" class="trust-grid">
|
||||||
|
<view class="trust-card">
|
||||||
|
<text class="trust-value">{{trustProfile.ratingText}}</text>
|
||||||
|
<text class="trust-label">{{trustProfile.reviewCount}} 条评价</text>
|
||||||
|
</view>
|
||||||
|
<view class="trust-card">
|
||||||
|
<text class="trust-value">{{trustProfile.productCount}}</text>
|
||||||
|
<text class="trust-label">在售作品</text>
|
||||||
|
</view>
|
||||||
|
<view class="trust-card">
|
||||||
|
<text class="trust-value">{{trustProfile.businessStatusText || '可浏览'}}</text>
|
||||||
|
<text class="trust-label">{{trustProfile.availabilityText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="summary-strip shop-summary">
|
<view class="summary-strip shop-summary">
|
||||||
<view class="summary-metric">
|
<view class="summary-metric">
|
||||||
<text class="summary-label">营业时间</text>
|
<text class="summary-label">营业时间</text>
|
||||||
<text class="summary-value shop-summary-value">{{shopInfo.businessHours || '待补充'}}</text>
|
<text class="summary-value shop-summary-value">{{trustProfile.businessHoursText || shopInfo.businessHours || '待补充'}}</text>
|
||||||
<text class="summary-note">以到店服务时间为准</text>
|
<text class="summary-note">以到店服务时间为准</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="summary-metric">
|
<view class="summary-metric">
|
||||||
@@ -36,7 +51,7 @@
|
|||||||
|
|
||||||
<view class="detail-group">
|
<view class="detail-group">
|
||||||
<view class="detail-label">营业时间</view>
|
<view class="detail-label">营业时间</view>
|
||||||
<view class="detail-value">{{shopInfo.businessHours || '待补充'}}</view>
|
<view class="detail-value">{{trustProfile.businessHoursText || shopInfo.businessHours || '待补充'}}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="detail-group">
|
<view class="detail-group">
|
||||||
@@ -63,6 +78,52 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{trustProfile && trustProfile.featuredProducts.length}}" class="section-block">
|
||||||
|
<view class="section-head">
|
||||||
|
<view class="section-copy">
|
||||||
|
<text class="section-kicker">可预约作品</text>
|
||||||
|
<text class="section-title">先看看本店热门款</text>
|
||||||
|
<text class="section-subtitle">{{trustProfile.availabilityText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="featured-list">
|
||||||
|
<view
|
||||||
|
wx:for="{{trustProfile.featuredProducts}}"
|
||||||
|
wx:key="id"
|
||||||
|
class="featured-card"
|
||||||
|
data-id="{{item.id}}"
|
||||||
|
bindtap="handleOpenProduct"
|
||||||
|
>
|
||||||
|
<image wx:if="{{item.imageUrl}}" class="featured-cover" src="{{item.imageUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
|
||||||
|
<view wx:else class="featured-cover placeholder">作</view>
|
||||||
|
<view class="featured-info">
|
||||||
|
<text class="featured-title">{{item.title || '美甲作品'}}</text>
|
||||||
|
<text class="featured-price">¥{{item.priceText}}</text>
|
||||||
|
<text class="featured-hint">{{item.bookingHint || '下单前选择美甲师和时间'}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{trustProfile && trustProfile.recentReviews.length}}" class="section-block">
|
||||||
|
<view class="section-head">
|
||||||
|
<view class="section-copy">
|
||||||
|
<text class="section-kicker">近期评价</text>
|
||||||
|
<text class="section-title">真实体验反馈</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="review-list">
|
||||||
|
<view wx:for="{{trustProfile.recentReviews}}" wx:key="id" class="review-card">
|
||||||
|
<view class="review-head">
|
||||||
|
<text>{{item.productTitle || '订单评价'}}</text>
|
||||||
|
<text>{{item.ratingText}}</text>
|
||||||
|
</view>
|
||||||
|
<text class="review-content">{{item.content || '用户已完成评价'}}</text>
|
||||||
|
<text class="review-time">{{item.submittedText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="section-block">
|
<view class="section-block">
|
||||||
<view class="section-head">
|
<view class="section-head">
|
||||||
<view class="section-copy">
|
<view class="section-copy">
|
||||||
|
|||||||
@@ -57,6 +57,34 @@
|
|||||||
margin-top: 24rpx;
|
margin-top: 24rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.trust-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 14rpx;
|
||||||
|
margin-top: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trust-card {
|
||||||
|
display: grid;
|
||||||
|
gap: 8rpx;
|
||||||
|
min-height: 112rpx;
|
||||||
|
padding: 18rpx;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
background: var(--theme-primary-soft);
|
||||||
|
}
|
||||||
|
|
||||||
|
.trust-value {
|
||||||
|
color: var(--theme-primary);
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trust-label {
|
||||||
|
color: #8d7a84;
|
||||||
|
font-size: 22rpx;
|
||||||
|
line-height: 1.35;
|
||||||
|
}
|
||||||
|
|
||||||
.shop-summary-value {
|
.shop-summary-value {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
@@ -120,6 +148,86 @@
|
|||||||
gap: 18rpx;
|
gap: 18rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.featured-list,
|
||||||
|
.review-list {
|
||||||
|
display: grid;
|
||||||
|
gap: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured-card {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 150rpx minmax(0, 1fr);
|
||||||
|
gap: 18rpx;
|
||||||
|
padding: 18rpx;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured-cover {
|
||||||
|
width: 150rpx;
|
||||||
|
height: 150rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
background: var(--theme-primary-soft);
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured-cover.placeholder {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--theme-primary);
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured-info {
|
||||||
|
display: grid;
|
||||||
|
align-content: center;
|
||||||
|
gap: 10rpx;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured-title {
|
||||||
|
color: #2d2430;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured-price {
|
||||||
|
color: var(--theme-primary);
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured-hint,
|
||||||
|
.review-time {
|
||||||
|
color: #8d7a84;
|
||||||
|
font-size: 22rpx;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-card {
|
||||||
|
display: grid;
|
||||||
|
gap: 12rpx;
|
||||||
|
padding: 22rpx;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16rpx;
|
||||||
|
color: #2d2430;
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-content {
|
||||||
|
color: #5d4b55;
|
||||||
|
font-size: 25rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
.gallery-image {
|
.gallery-image {
|
||||||
width: calc(50% - 9rpx);
|
width: calc(50% - 9rpx);
|
||||||
height: 240rpx;
|
height: 240rpx;
|
||||||
|
|||||||
@@ -39,7 +39,10 @@ Page({
|
|||||||
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
||||||
loading: false,
|
loading: false,
|
||||||
isLoggedIn: false,
|
isLoggedIn: false,
|
||||||
wishlist: []
|
wishlist: [],
|
||||||
|
visibleWishlist: [],
|
||||||
|
groups: [],
|
||||||
|
activeGroupId: ''
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,29 +68,42 @@ Page({
|
|||||||
this.cartProductIdSet = new Set()
|
this.cartProductIdSet = new Set()
|
||||||
this.setData({
|
this.setData({
|
||||||
wishlist: [],
|
wishlist: [],
|
||||||
|
visibleWishlist: [],
|
||||||
|
groups: [],
|
||||||
|
activeGroupId: '',
|
||||||
loading: false
|
loading: false
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const wishlist = await wishlistApi.getWishlist()
|
const [wishlist, groups] = await Promise.all([
|
||||||
|
wishlistApi.getWishlist(),
|
||||||
|
wishlistApi.getGroups()
|
||||||
|
])
|
||||||
const list = Array.isArray(wishlist) ? wishlist : []
|
const list = Array.isArray(wishlist) ? wishlist : []
|
||||||
|
const groupList = Array.isArray(groups) ? groups : []
|
||||||
const cartProductIdSet = await this.fetchCartProductIdSet()
|
const cartProductIdSet = await this.fetchCartProductIdSet()
|
||||||
const cards = await Promise.all(list.map(async item => ({
|
const cards = await Promise.all(list.map(async item => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
productId: item.productId,
|
productId: item.productId,
|
||||||
|
groupId: this.normalizeId(item.groupId),
|
||||||
|
groupName: item.groupName || '\u6700\u8fd1\u60f3\u505a',
|
||||||
|
note: item.note || '',
|
||||||
productCard: this.markCardInCart(
|
productCard: this.markCardInCart(
|
||||||
await buildProductCard(item.product || {}),
|
await buildProductCard(item.product || {}),
|
||||||
cartProductIdSet
|
cartProductIdSet
|
||||||
)
|
)
|
||||||
})))
|
})))
|
||||||
this.setData({
|
this.setData({
|
||||||
wishlist: cards
|
wishlist: cards,
|
||||||
|
groups: this.buildGroupTabs(groupList, this.data.activeGroupId),
|
||||||
|
visibleWishlist: this.filterWishlist(cards, this.data.activeGroupId)
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.setData({
|
this.setData({
|
||||||
wishlist: []
|
wishlist: [],
|
||||||
|
visibleWishlist: []
|
||||||
})
|
})
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: error.message || '\u6536\u85cf\u5217\u8868\u52a0\u8f7d\u5931\u8d25',
|
title: error.message || '\u6536\u85cf\u5217\u8868\u52a0\u8f7d\u5931\u8d25',
|
||||||
@@ -108,6 +124,36 @@ Page({
|
|||||||
return value === undefined || value === null ? '' : String(value)
|
return value === undefined || value === null ? '' : String(value)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
filterWishlist(list, groupId) {
|
||||||
|
const normalizedGroupId = this.normalizeId(groupId)
|
||||||
|
if (!normalizedGroupId) {
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
return list.filter(item => this.normalizeId(item && item.groupId) === normalizedGroupId)
|
||||||
|
},
|
||||||
|
|
||||||
|
buildGroupTabs(groups, activeGroupId) {
|
||||||
|
const normalizedActiveGroupId = this.normalizeId(activeGroupId)
|
||||||
|
return (Array.isArray(groups) ? groups : []).map(group => {
|
||||||
|
const id = this.normalizeId(group && group.id)
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
name: group.name,
|
||||||
|
itemCount: group.itemCount || 0,
|
||||||
|
active: id === normalizedActiveGroupId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
handleGroupSelect(event) {
|
||||||
|
const groupId = this.normalizeId(event.currentTarget.dataset.groupId)
|
||||||
|
this.setData({
|
||||||
|
activeGroupId: groupId,
|
||||||
|
groups: this.buildGroupTabs(this.data.groups, groupId),
|
||||||
|
visibleWishlist: this.filterWishlist(this.data.wishlist, groupId)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
async fetchCartProductIdSet() {
|
async fetchCartProductIdSet() {
|
||||||
try {
|
try {
|
||||||
const cartList = await cartApi.getCartList()
|
const cartList = await cartApi.getCartList()
|
||||||
@@ -152,18 +198,20 @@ Page({
|
|||||||
this.cartProductIdSet = this.cartProductIdSet || new Set()
|
this.cartProductIdSet = this.cartProductIdSet || new Set()
|
||||||
this.cartProductIdSet.add(normalizedId)
|
this.cartProductIdSet.add(normalizedId)
|
||||||
|
|
||||||
this.setData({
|
const nextWishlist = this.data.wishlist.map(item => (
|
||||||
wishlist: this.data.wishlist.map(item => (
|
this.normalizeId(item && item.productId) === normalizedId
|
||||||
this.normalizeId(item && item.productId) === normalizedId
|
? {
|
||||||
? {
|
...item,
|
||||||
...item,
|
productCard: {
|
||||||
productCard: {
|
...item.productCard,
|
||||||
...item.productCard,
|
inCart: true
|
||||||
inCart: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
: item
|
}
|
||||||
))
|
: item
|
||||||
|
))
|
||||||
|
this.setData({
|
||||||
|
wishlist: nextWishlist,
|
||||||
|
visibleWishlist: this.filterWishlist(nextWishlist, this.data.activeGroupId)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,22 @@
|
|||||||
<text class="hero-desc">喜欢的款式先收藏。</text>
|
<text class="hero-desc">喜欢的款式先收藏。</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view wx:for="{{wishlist}}" wx:key="id" class="wishlist-item">
|
<scroll-view wx:if="{{groups.length}}" class="wishlist-groups" scroll-x enhanced show-scrollbar="{{false}}">
|
||||||
|
<view
|
||||||
|
class="wishlist-group-chip {{!activeGroupId ? 'wishlist-group-chip--active' : ''}}"
|
||||||
|
data-group-id=""
|
||||||
|
bindtap="handleGroupSelect"
|
||||||
|
>全部</view>
|
||||||
|
<view
|
||||||
|
wx:for="{{groups}}"
|
||||||
|
wx:key="id"
|
||||||
|
class="wishlist-group-chip {{item.active ? 'wishlist-group-chip--active' : ''}}"
|
||||||
|
data-group-id="{{item.id}}"
|
||||||
|
bindtap="handleGroupSelect"
|
||||||
|
>{{item.name}}</view>
|
||||||
|
</scroll-view>
|
||||||
|
|
||||||
|
<view wx:for="{{visibleWishlist}}" wx:key="id" class="wishlist-item">
|
||||||
<product-card
|
<product-card
|
||||||
item="{{item.productCard}}"
|
item="{{item.productCard}}"
|
||||||
show-quick-add="{{true}}"
|
show-quick-add="{{true}}"
|
||||||
@@ -23,10 +38,18 @@
|
|||||||
bindselect="handleProductSelect"
|
bindselect="handleProductSelect"
|
||||||
bindquickadd="handleQuickAdd"
|
bindquickadd="handleQuickAdd"
|
||||||
></product-card>
|
></product-card>
|
||||||
|
<view class="wishlist-meta">
|
||||||
|
<text class="wishlist-group-name">{{item.groupName || '最近想做'}}</text>
|
||||||
|
<text wx:if="{{item.note}}" class="wishlist-note">{{item.note}}</text>
|
||||||
|
</view>
|
||||||
<view class="wishlist-actions">
|
<view class="wishlist-actions">
|
||||||
<view class="wishlist-action wishlist-action--secondary" data-product-id="{{item.productId}}" bindtap="handleRemove">取消收藏</view>
|
<view class="wishlist-action wishlist-action--secondary" data-product-id="{{item.productId}}" bindtap="handleRemove">取消收藏</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{!visibleWishlist.length}}" class="page-card empty-card">
|
||||||
|
<text class="empty-title">当前分组还没有作品</text>
|
||||||
|
</view>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<view wx:elif="{{loading}}" class="page-card empty-card">
|
<view wx:elif="{{loading}}" class="page-card empty-card">
|
||||||
|
|||||||
@@ -6,6 +6,58 @@
|
|||||||
margin-top: 22rpx;
|
margin-top: 22rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wishlist-groups {
|
||||||
|
display: block;
|
||||||
|
white-space: nowrap;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wishlist-group-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 58rpx;
|
||||||
|
min-width: 92rpx;
|
||||||
|
margin-right: 14rpx;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
border: 2rpx solid var(--theme-border);
|
||||||
|
border-radius: 16rpx;
|
||||||
|
background: var(--theme-card-bg);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 24rpx;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wishlist-group-chip--active {
|
||||||
|
border-color: var(--theme-primary);
|
||||||
|
background: var(--theme-primary-soft);
|
||||||
|
color: var(--theme-primary);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wishlist-meta {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8rpx;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wishlist-group-name {
|
||||||
|
align-self: flex-start;
|
||||||
|
padding: 4rpx 16rpx;
|
||||||
|
border-radius: 14rpx;
|
||||||
|
background: var(--theme-primary-soft);
|
||||||
|
color: var(--theme-accent);
|
||||||
|
font-size: 22rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wishlist-note {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
.wishlist-actions {
|
.wishlist-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 16rpx;
|
gap: 16rpx;
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
const STORAGE_KEY = 'YUMI_BUY_NOW_CONTEXT'
|
||||||
|
|
||||||
|
function createBuyNowContext(productId) {
|
||||||
|
return {
|
||||||
|
mode: 'buyNow',
|
||||||
|
productId: String(productId || ''),
|
||||||
|
createdAt: Date.now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveBuyNowContext(productId) {
|
||||||
|
const context = createBuyNowContext(productId)
|
||||||
|
wx.setStorageSync(STORAGE_KEY, context)
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
function readBuyNowContext(maxAgeMs = 5 * 60 * 1000) {
|
||||||
|
const context = wx.getStorageSync(STORAGE_KEY)
|
||||||
|
if (!context || context.mode !== 'buyNow' || !context.productId) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (Date.now() - Number(context.createdAt || 0) > maxAgeMs) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearBuyNowContext() {
|
||||||
|
wx.removeStorageSync(STORAGE_KEY)
|
||||||
|
}
|
||||||
|
|
||||||
|
function consumeBuyNowContext(maxAgeMs = 5 * 60 * 1000) {
|
||||||
|
const context = readBuyNowContext(maxAgeMs)
|
||||||
|
clearBuyNowContext()
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBuyNowCartItem(item, productId) {
|
||||||
|
return Boolean(productId) && String(item && item.productId || '') === String(productId)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
STORAGE_KEY,
|
||||||
|
clearBuyNowContext,
|
||||||
|
consumeBuyNowContext,
|
||||||
|
isBuyNowCartItem,
|
||||||
|
readBuyNowContext,
|
||||||
|
saveBuyNowContext
|
||||||
|
}
|
||||||
+45
-13
@@ -6,6 +6,17 @@ const fileApi = require('../api/file')
|
|||||||
const { DEFAULT_PRODUCT_IMAGE } = require('./config')
|
const { DEFAULT_PRODUCT_IMAGE } = require('./config')
|
||||||
const { CACHE_TTL } = require('./config')
|
const { CACHE_TTL } = require('./config')
|
||||||
const { splitCsv } = require('./format')
|
const { splitCsv } = require('./format')
|
||||||
|
const { showRecoveryModal } = require('./recovery')
|
||||||
|
|
||||||
|
function handlePreviewRecoveryAction(action) {
|
||||||
|
if (!action || action.key !== 'products') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wx.switchTab({
|
||||||
|
url: '/pages/products/index',
|
||||||
|
fail() {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: urlCache supports file.js by holding or executing the url cache page or API role.
|
* Purpose: urlCache supports file.js by holding or executing the url cache page or API role.
|
||||||
@@ -91,24 +102,45 @@ async function resolveLegacyImage(value, fallbackImage) {
|
|||||||
* Purpose: previewImagesSafely opens wx.previewImage with a user-facing fallback when signed URLs expire or preview fails.
|
* Purpose: previewImagesSafely opens wx.previewImage with a user-facing fallback when signed URLs expire or preview fails.
|
||||||
* Usage: pass the current image URL and full URL list from image tap handlers instead of calling wx.previewImage directly.
|
* Usage: pass the current image URL and full URL list from image tap handlers instead of calling wx.previewImage directly.
|
||||||
*/
|
*/
|
||||||
function previewImagesSafely(current, urls) {
|
function previewImagesSafely(current, urls, options) {
|
||||||
|
const config = options || {}
|
||||||
const list = (Array.isArray(urls) ? urls : [current]).filter(Boolean)
|
const list = (Array.isArray(urls) ? urls : [current]).filter(Boolean)
|
||||||
if (!current || !list.length) {
|
if (!current || !list.length) {
|
||||||
wx.showToast({
|
return showRecoveryModal({
|
||||||
title: '图片暂不可预览',
|
title: '图片暂不可预览',
|
||||||
icon: 'none'
|
message: config.emptyMessage || '没有可预览的图片,请返回作品列表查看其他款式。',
|
||||||
|
actions: [
|
||||||
|
{ key: 'dismiss', text: '知道了' },
|
||||||
|
{ key: 'products', text: '看作品' }
|
||||||
|
]
|
||||||
|
}).then(action => {
|
||||||
|
handlePreviewRecoveryAction(action)
|
||||||
|
return action
|
||||||
})
|
})
|
||||||
return
|
|
||||||
}
|
}
|
||||||
wx.previewImage({
|
return new Promise(resolve => {
|
||||||
current,
|
wx.previewImage({
|
||||||
urls: list,
|
current,
|
||||||
fail: () => {
|
urls: list,
|
||||||
wx.showToast({
|
success: () => resolve(null),
|
||||||
title: '图片预览失败,请稍后重试',
|
fail: () => {
|
||||||
icon: 'none'
|
showRecoveryModal({
|
||||||
})
|
title: '图片预览失败',
|
||||||
}
|
message: config.failMessage || '图片链接可能已过期,请重试;仍失败时可以返回作品列表重新进入。',
|
||||||
|
actions: [
|
||||||
|
{ key: 'retry', text: '重试' },
|
||||||
|
{ key: 'products', text: '看作品' }
|
||||||
|
]
|
||||||
|
}).then(action => {
|
||||||
|
if (action && action.key === 'retry') {
|
||||||
|
previewImagesSafely(current, list, config).then(resolve)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
handlePreviewRecoveryAction(action)
|
||||||
|
resolve(action)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
const DEFAULT_ROUTES = {
|
||||||
|
cart: '/pages/cart/index',
|
||||||
|
orders: '/pages/orders/index',
|
||||||
|
products: '/pages/products/index',
|
||||||
|
profile: '/pages/profile/index'
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeRecoveryMessage(error, fallbackMessage) {
|
||||||
|
if (typeof error === 'string' && error.trim()) {
|
||||||
|
return error.trim()
|
||||||
|
}
|
||||||
|
if (error && error.message) {
|
||||||
|
return String(error.message).trim()
|
||||||
|
}
|
||||||
|
return fallbackMessage || '操作失败,请稍后重试'
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeRecoveryActions(actions) {
|
||||||
|
return (Array.isArray(actions) ? actions : [])
|
||||||
|
.filter(action => action && action.key && action.text)
|
||||||
|
.map((action, index) => ({
|
||||||
|
key: action.key,
|
||||||
|
text: action.text,
|
||||||
|
route: action.route || DEFAULT_ROUTES[action.key] || '',
|
||||||
|
primary: action.primary !== undefined ? Boolean(action.primary) : index === 0
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildRecoveryState(options) {
|
||||||
|
const config = options || {}
|
||||||
|
return {
|
||||||
|
visible: true,
|
||||||
|
title: config.title || '操作失败',
|
||||||
|
message: normalizeRecoveryMessage(config.message || config.error, config.fallbackMessage),
|
||||||
|
actions: normalizeRecoveryActions(config.actions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearRecoveryState() {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
title: '',
|
||||||
|
message: '',
|
||||||
|
actions: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showRecoveryModal(options) {
|
||||||
|
const state = buildRecoveryState(options)
|
||||||
|
const primaryAction = state.actions.find(action => action.primary) || state.actions[0]
|
||||||
|
const secondaryAction = state.actions.find(action => action !== primaryAction)
|
||||||
|
|
||||||
|
return new Promise(resolve => {
|
||||||
|
wx.showModal({
|
||||||
|
title: state.title,
|
||||||
|
content: state.message,
|
||||||
|
confirmText: primaryAction ? primaryAction.text : '知道了',
|
||||||
|
cancelText: secondaryAction ? secondaryAction.text : '取消',
|
||||||
|
showCancel: Boolean(secondaryAction),
|
||||||
|
success: result => {
|
||||||
|
if (result.confirm) {
|
||||||
|
resolve(primaryAction || null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resolve(secondaryAction || null)
|
||||||
|
},
|
||||||
|
fail: () => resolve(null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
DEFAULT_ROUTES,
|
||||||
|
normalizeRecoveryMessage,
|
||||||
|
buildRecoveryState,
|
||||||
|
clearRecoveryState,
|
||||||
|
showRecoveryModal
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
const assert = require('assert')
|
||||||
|
|
||||||
|
const recovery = require('./recovery')
|
||||||
|
|
||||||
|
const checkoutState = recovery.buildRecoveryState({
|
||||||
|
title: '下单失败',
|
||||||
|
message: new Error('库存不足'),
|
||||||
|
fallbackMessage: '订单创建失败',
|
||||||
|
actions: [
|
||||||
|
{ key: 'retry', text: '重试下单' },
|
||||||
|
{ key: 'orders', text: '查看订单' },
|
||||||
|
{ key: 'contact', text: '联系客服' },
|
||||||
|
{ key: 'cart', text: '返回购物车' }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.strictEqual(checkoutState.visible, true)
|
||||||
|
assert.strictEqual(checkoutState.title, '下单失败')
|
||||||
|
assert.strictEqual(checkoutState.message, '库存不足')
|
||||||
|
assert.strictEqual(checkoutState.actions.length, 4)
|
||||||
|
assert.strictEqual(checkoutState.actions[0].key, 'retry')
|
||||||
|
assert.strictEqual(checkoutState.actions[0].primary, true)
|
||||||
|
assert.strictEqual(checkoutState.actions[3].route, '/pages/cart/index')
|
||||||
|
|
||||||
|
const emptyState = recovery.clearRecoveryState()
|
||||||
|
assert.strictEqual(emptyState.visible, false)
|
||||||
|
assert.deepStrictEqual(emptyState.actions, [])
|
||||||
|
|
||||||
|
const normalized = recovery.normalizeRecoveryMessage(null, '图片预览失败')
|
||||||
|
assert.strictEqual(normalized, '图片预览失败')
|
||||||
@@ -96,10 +96,14 @@ function isWhitelistedPath(url) {
|
|||||||
'/product/get/',
|
'/product/get/',
|
||||||
'/product/list/',
|
'/product/list/',
|
||||||
'/comment/list/product/',
|
'/comment/list/product/',
|
||||||
|
'/nail-artist/profile/',
|
||||||
|
'/nail-artist/',
|
||||||
'/shop/get/',
|
'/shop/get/',
|
||||||
|
'/shop/trust-profile/',
|
||||||
'/shop/list/public',
|
'/shop/list/public',
|
||||||
'/shop/list/simple',
|
'/shop/list/simple',
|
||||||
'/tag/list/all',
|
'/tag/list/all',
|
||||||
|
'/tag/list/filter-options',
|
||||||
'/file/get-signed-url/'
|
'/file/get-signed-url/'
|
||||||
].some(path => String(url || '').includes(path))
|
].some(path => String(url || '').includes(path))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,6 +155,16 @@ Page({
|
|||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
description: '',
|
description: '',
|
||||||
|
/**
|
||||||
|
* Purpose: targetAudience records who or which scene this product is suitable for.
|
||||||
|
* Usage: edit it in the product form and submit it with create/update payloads.
|
||||||
|
*/
|
||||||
|
targetAudience: '',
|
||||||
|
/**
|
||||||
|
* Purpose: precautions records service reminders for this product.
|
||||||
|
* Usage: edit it in the product form and submit it with create/update payloads.
|
||||||
|
*/
|
||||||
|
precautions: '',
|
||||||
/**
|
/**
|
||||||
* Purpose: price supports index.js by holding or executing the price page or API role.
|
* Purpose: price supports index.js by holding or executing the price page or API role.
|
||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -230,6 +240,16 @@ Page({
|
|||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
description: currentProduct.description || '',
|
description: currentProduct.description || '',
|
||||||
|
/**
|
||||||
|
* Purpose: targetAudience restores the existing product suitable-audience text in edit mode.
|
||||||
|
* Usage: bind this field to the form textarea and submit it unchanged unless the operator edits it.
|
||||||
|
*/
|
||||||
|
targetAudience: currentProduct.targetAudience || '',
|
||||||
|
/**
|
||||||
|
* Purpose: precautions restores the existing product reminder text in edit mode.
|
||||||
|
* Usage: bind this field to the form textarea and submit it unchanged unless the operator edits it.
|
||||||
|
*/
|
||||||
|
precautions: currentProduct.precautions || '',
|
||||||
/**
|
/**
|
||||||
* Purpose: price supports index.js by holding or executing the price page or API role.
|
* Purpose: price supports index.js by holding or executing the price page or API role.
|
||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -700,6 +720,16 @@ Page({
|
|||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
description: this.data.form.description || undefined,
|
description: this.data.form.description || undefined,
|
||||||
|
/**
|
||||||
|
* Purpose: targetAudience sends the optional suitable-audience text to the backend.
|
||||||
|
* Usage: leave it undefined when empty so old products can hide the section on user detail pages.
|
||||||
|
*/
|
||||||
|
targetAudience: this.data.form.targetAudience || undefined,
|
||||||
|
/**
|
||||||
|
* Purpose: precautions sends the optional reminder text to the backend.
|
||||||
|
* Usage: leave it undefined when empty so old products can hide the section on user detail pages.
|
||||||
|
*/
|
||||||
|
precautions: this.data.form.precautions || undefined,
|
||||||
/**
|
/**
|
||||||
* Purpose: imageFileIds supports index.js by holding or executing the image file ids page or API role.
|
* Purpose: imageFileIds supports index.js by holding or executing the image file ids page or API role.
|
||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
|
|||||||
@@ -26,6 +26,14 @@
|
|||||||
<text class="field-label">作品描述</text>
|
<text class="field-label">作品描述</text>
|
||||||
<textarea class="field-textarea" value="{{form.description}}" data-field="description" bindinput="handleInputChange"></textarea>
|
<textarea class="field-textarea" value="{{form.description}}" data-field="description" bindinput="handleInputChange"></textarea>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="field-group">
|
||||||
|
<text class="field-label">适合人群</text>
|
||||||
|
<textarea class="field-textarea" value="{{form.targetAudience}}" data-field="targetAudience" bindinput="handleInputChange" placeholder="例如:短甲、通勤、婚礼跟妆"></textarea>
|
||||||
|
</view>
|
||||||
|
<view class="field-group">
|
||||||
|
<text class="field-label">注意事项</text>
|
||||||
|
<textarea class="field-textarea" value="{{form.precautions}}" data-field="precautions" bindinput="handleInputChange" placeholder="例如:完成后 24 小时内避免长时间热水浸泡"></textarea>
|
||||||
|
</view>
|
||||||
<view class="field-group">
|
<view class="field-group">
|
||||||
<text class="field-label">点赞数量</text>
|
<text class="field-label">点赞数量</text>
|
||||||
<input class="field-input" type="number" value="{{form.likeCount}}" data-field="likeCount" bindinput="handleInputChange"></input>
|
<input class="field-input" type="number" value="{{form.likeCount}}" data-field="likeCount" bindinput="handleInputChange"></input>
|
||||||
|
|||||||
Reference in New Issue
Block a user