diff --git a/WeChatProgram/api/nail-artist.js b/WeChatProgram/api/nail-artist.js
new file mode 100644
index 00000000..30001cb5
--- /dev/null
+++ b/WeChatProgram/api/nail-artist.js
@@ -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`
+ })
+ }
+}
diff --git a/WeChatProgram/api/order.js b/WeChatProgram/api/order.js
index b35a5bd4..4a54aca6 100644
--- a/WeChatProgram/api/order.js
+++ b/WeChatProgram/api/order.js
@@ -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.
* 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.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
diff --git a/WeChatProgram/api/shop.js b/WeChatProgram/api/shop.js
index 904012b0..6b97f1fe 100644
--- a/WeChatProgram/api/shop.js
+++ b/WeChatProgram/api/shop.js
@@ -33,5 +33,15 @@ module.exports = {
return request({
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}`
+ })
}
}
diff --git a/WeChatProgram/api/tag.js b/WeChatProgram/api/tag.js
index 41d68c61..4134d2d2 100644
--- a/WeChatProgram/api/tag.js
+++ b/WeChatProgram/api/tag.js
@@ -13,5 +13,16 @@ module.exports = {
return request({
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
+ })
}
}
diff --git a/WeChatProgram/api/wishlist.js b/WeChatProgram/api/wishlist.js
index b480e9f0..b093749b 100644
--- a/WeChatProgram/api/wishlist.js
+++ b/WeChatProgram/api/wishlist.js
@@ -54,5 +54,33 @@ module.exports = {
return request({
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
+ })
}
}
diff --git a/WeChatProgram/app.json b/WeChatProgram/app.json
index 59b51f45..0d9bb90a 100644
--- a/WeChatProgram/app.json
+++ b/WeChatProgram/app.json
@@ -7,6 +7,7 @@
"pages/profile/index",
"pages/auth/index",
"pages/product-detail/index",
+ "pages/artist-profile/index",
"pages/shop-detail/index",
"pages/orders/index",
"pages/wishlist/index",
diff --git a/WeChatProgram/pages/artist-profile/index.js b/WeChatProgram/pages/artist-profile/index.js
new file mode 100644
index 00000000..848d8c7b
--- /dev/null
+++ b/WeChatProgram/pages/artist-profile/index.js
@@ -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}`
+ })
+ }
+})
diff --git a/WeChatProgram/pages/artist-profile/index.json b/WeChatProgram/pages/artist-profile/index.json
new file mode 100644
index 00000000..b16ef3e3
--- /dev/null
+++ b/WeChatProgram/pages/artist-profile/index.json
@@ -0,0 +1,4 @@
+{
+ "navigationStyle": "custom",
+ "usingComponents": {}
+}
diff --git a/WeChatProgram/pages/artist-profile/index.wxml b/WeChatProgram/pages/artist-profile/index.wxml
new file mode 100644
index 00000000..8386784f
--- /dev/null
+++ b/WeChatProgram/pages/artist-profile/index.wxml
@@ -0,0 +1,98 @@
+
+
+
+
+ 加载中...
+
+
+
+ 暂时无法查看个人页
+ {{loadError}}
+ 重试
+
+
+
+
+
+
+
+
+ 艺
+
+ {{artistName}}
+ {{artistDesc}}
+ {{shopName}}
+
+
+
+
+
+
+ 评分
+ {{ratingText}}
+
+
+ 服务
+ {{serviceCountText}}
+
+
+ 工时
+ {{workTimeText}}
+
+
+
+
+ 擅长风格
+
+ {{item}}
+
+ 暂未设置风格标签
+
+
+
+ 近期可预约
+
+
+ {{item.dateText}}
+ {{item.timeText}}
+
+
+ 近期暂未放出可预约时间
+
+
+
+ 作品
+
+
+
+ {{item.title}}
+ {{item.priceText}}
+
+
+ 作品正在整理中
+
+
+
+ 评价 {{reviews.length}}
+
+
+
+
+ 客
+
+ {{item.customerName}}
+ {{item.submittedAtText}}
+
+ {{item.ratingText}}
+
+ {{item.content}}
+
+
+ 还没有公开评价
+
+
+
diff --git a/WeChatProgram/pages/artist-profile/index.wxss b/WeChatProgram/pages/artist-profile/index.wxss
new file mode 100644
index 00000000..2555ed99
--- /dev/null
+++ b/WeChatProgram/pages/artist-profile/index.wxss
@@ -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;
+}
diff --git a/WeChatProgram/pages/cart/index.js b/WeChatProgram/pages/cart/index.js
index 09ab8072..3b123788 100644
--- a/WeChatProgram/pages/cart/index.js
+++ b/WeChatProgram/pages/cart/index.js
@@ -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.
*/
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.
* 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 { NO_COUPON_KEY } = require('../../utils/config')
const { runWithLoading } = require('../../utils/loading')
+const { clearBuyNowContext, isBuyNowCartItem, readBuyNowContext } = require('../../utils/buy-now')
+const { buildRecoveryState, clearRecoveryState } = require('../../utils/recovery')
const {
buildAppointmentValue,
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.
*/
function getCouponDisplay(coupon) {
+ if (coupon && coupon.displayText) {
+ return coupon.displayText
+ }
if (Number(coupon.couponType) === 1) {
return `${coupon.couponName} ${coupon.discountValue} 折`
}
@@ -71,6 +71,9 @@ function calculateCouponDiscount(coupon, amount) {
if (!coupon || amount <= 0) {
return 0
}
+ if (coupon.discountAmount !== undefined && coupon.discountAmount !== null) {
+ return Number(coupon.discountAmount || 0)
+ }
if (Number(coupon.couponType) === 1) {
const discountValue = Number(coupon.discountValue || 0)
@@ -160,6 +163,9 @@ Page({
minDate: getMinDateText(),
cartItems: [],
availableCoupons: [],
+ unavailableCoupons: [],
+ checkoutPreview: null,
+ vipTip: '',
selectedCouponKey: NO_COUPON_KEY,
/**
* Purpose: couponSelectionTouched records whether the user explicitly chose a coupon option.
@@ -167,13 +173,18 @@ Page({
*/
couponSelectionTouched: false,
selectedCount: 0,
+ isBuyNowMode: false,
+ heroKicker: '结算准备',
+ heroTitle: '已选 0 个预约项目',
+ heroDesc: '确认美甲师和时间后再下单。',
totalQuantity: 0,
subtotalAmount: 0,
subtotalText: '¥0.00',
discountAmountText: '¥0.00',
totalAmountText: '¥0.00',
checkoutIssues: [],
- submittingOrder: false
+ submittingOrder: false,
+ recoveryState: clearRecoveryState()
}),
/**
@@ -214,13 +225,19 @@ Page({
const selectedCoupon = this.getSelectedCoupon()
const selectedCount = selectedItems.length
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 discountAmount = calculateCouponDiscount(selectedCoupon, subtotalAmount)
- const totalAmount = Math.max(0, subtotalAmount - discountAmount)
+ const localSubtotalAmount = selectedItems.reduce((sum, item) => sum + Number(item.price || 0) * Number(item.quantity || 0), 0)
+ const preview = this.data.checkoutPreview || {}
+ 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 isBuyNowMode = Boolean(this.data.isBuyNowMode)
this.setData({
selectedCount,
+ heroKicker: isBuyNowMode ? '确认订单' : '结算准备',
+ heroTitle: isBuyNowMode ? '确认本次预约' : `已选 ${selectedCount} 个预约项目`,
+ heroDesc: isBuyNowMode ? '本次只会提交刚刚选择的作品,不会混入购物车其他项目。' : '确认美甲师和时间后再下单。',
totalQuantity,
subtotalAmount,
subtotalText: `¥${formatPrice(subtotalAmount)}`,
@@ -232,9 +249,13 @@ Page({
async loadCartItems() {
const isLoggedIn = auth.isLoggedIn()
+ const buyNowContext = isLoggedIn ? readBuyNowContext() : null
+ const buyNowProductId = buyNowContext && buyNowContext.productId ? String(buyNowContext.productId) : ''
this.setData({
isLoggedIn,
- loading: isLoggedIn
+ isBuyNowMode: Boolean(buyNowProductId),
+ loading: isLoggedIn,
+ recoveryState: clearRecoveryState()
})
/**
@@ -245,9 +266,13 @@ Page({
this.setData({
cartItems: [],
availableCoupons: [],
+ unavailableCoupons: [],
+ checkoutPreview: null,
+ vipTip: '',
selectedCouponKey: NO_COUPON_KEY,
couponSelectionTouched: false,
- loading: false
+ loading: false,
+ recoveryState: clearRecoveryState()
})
this.refreshSummary()
return
@@ -273,7 +298,7 @@ Page({
...item,
productImageUrl,
priceText: `¥${formatPrice(item.price)}`,
- selected: true,
+ selected: buyNowProductId ? isBuyNowCartItem(item, buyNowProductId) : true,
artistId: item.artistId || '',
artistName: artist ? artist.name : '',
availableArtists,
@@ -286,16 +311,26 @@ Page({
this.setData({
cartItems: formattedItems,
selectedCouponKey: NO_COUPON_KEY,
- couponSelectionTouched: false
+ couponSelectionTouched: false,
+ recoveryState: clearRecoveryState()
})
+ if (buyNowProductId) {
+ clearBuyNowContext()
+ }
await this.loadAvailableCoupons()
} catch (error) {
this.setData({
- cartItems: []
- })
- wx.showToast({
- title: error.message || '购物车加载失败',
- icon: 'none'
+ cartItems: [],
+ recoveryState: buildRecoveryState({
+ title: '购物车加载失败',
+ message: error,
+ fallbackMessage: '购物车暂时没有加载出来,请重试或先去逛作品。',
+ actions: [
+ { key: 'retryCartLoad', text: '重试' },
+ { key: 'products', text: '去逛作品' },
+ { key: 'contact', text: '联系客服' }
+ ]
+ })
})
} finally {
this.setData({
@@ -314,6 +349,9 @@ Page({
if (!selectedItems.length) {
this.setData({
availableCoupons: [],
+ unavailableCoupons: [],
+ checkoutPreview: null,
+ vipTip: '',
selectedCouponKey: NO_COUPON_KEY,
couponSelectionTouched: false
})
@@ -321,24 +359,25 @@ Page({
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 {
- const coupons = await couponApi.getAvailableCoupons(
- Array.from(tags).join(','),
- subtotalAmount,
- selectedItems[0].shopId
- )
+ const selectedCoupon = this.getSelectedCoupon()
+ const preview = await orderApi.checkoutPreview({
+ couponId: selectedCoupon ? selectedCoupon.id : undefined,
+ 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,
key: getCouponKey(item),
displayText: getCouponDisplay(item)
@@ -348,6 +387,7 @@ Page({
if (selectedCouponKey !== NO_COUPON_KEY && !list.find(item => item.key === selectedCouponKey)) {
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.
@@ -355,8 +395,7 @@ Page({
*/
if (selectedCouponKey === NO_COUPON_KEY && !this.data.couponSelectionTouched) {
const bestCoupons = list
- .filter(item => item.sourceType === 'SYSTEM_VIP')
- .sort((left, right) => calculateCouponDiscount(right, subtotalAmount) - calculateCouponDiscount(left, subtotalAmount))
+ .sort((left, right) => calculateCouponDiscount(right, previewSubtotalAmount) - calculateCouponDiscount(left, previewSubtotalAmount))
/**
* `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.
@@ -368,11 +407,17 @@ Page({
this.setData({
availableCoupons: list,
+ unavailableCoupons,
+ checkoutPreview: preview || null,
+ vipTip: preview && preview.vipTip ? preview.vipTip : '',
selectedCouponKey
})
} catch (error) {
this.setData({
availableCoupons: [],
+ unavailableCoupons: [],
+ checkoutPreview: null,
+ vipTip: '',
selectedCouponKey: NO_COUPON_KEY,
couponSelectionTouched: false
})
@@ -397,6 +442,60 @@ Page({
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) {
const index = Number(event.currentTarget.dataset.index)
const cartItems = this.data.cartItems.slice()
@@ -640,7 +739,7 @@ Page({
selectedCouponKey: event.detail.value,
couponSelectionTouched: true
})
- this.refreshSummary()
+ this.loadAvailableCoupons()
},
async handleCheckout() {
@@ -704,9 +803,18 @@ Page({
icon: 'none'
})
} catch (error) {
- wx.showToast({
- title: error.message || '订单创建失败',
- icon: 'none'
+ this.setData({
+ recoveryState: buildRecoveryState({
+ title: '下单失败',
+ message: error,
+ fallbackMessage: '订单创建失败,请重试;如果担心重复下单,请先查看订单。',
+ actions: [
+ { key: 'retryCheckout', text: '重试下单' },
+ { key: 'orders', text: '查看订单' },
+ { key: 'contact', text: '联系客服' },
+ { key: 'cart', text: '返回购物车' }
+ ]
+ })
})
} finally {
this.setData({
diff --git a/WeChatProgram/pages/cart/index.wxml b/WeChatProgram/pages/cart/index.wxml
index e6030bd8..94cb091f 100644
--- a/WeChatProgram/pages/cart/index.wxml
+++ b/WeChatProgram/pages/cart/index.wxml
@@ -9,10 +9,24 @@
+
+ {{recoveryState.title}}
+ {{recoveryState.message}}
+
+ {{item.text}}
+
+
+
- 结算准备
- 已选 {{selectedCount}} 个预约项目
- 确认美甲师和时间后再下单。
+ {{heroKicker}}
+ {{heroTitle}}
+ {{heroDesc}}
@@ -93,7 +107,7 @@
优惠方式
- 系统会优先匹配 VIP 优惠。
+ {{vipTip || '系统会优先匹配 VIP 优惠。'}}
+
+
+ 本单暂不可用
+
+ {{coupon.displayText}}
+ {{coupon.unavailableReason || '本单暂不可用'}}
+
+
+ {{checkoutPreview.summaryText}}
+ {{vipTip}}
选中项目
{{selectedCount}} 项
@@ -124,11 +148,11 @@
{{totalQuantity}} 件
- 小计
+ 商品小计
{{subtotalText}}
- 优惠
+ 已省
-{{discountAmountText}}
@@ -142,6 +166,20 @@
正在加载购物车
+
+ {{recoveryState.title}}
+ {{recoveryState.message}}
+
+ {{item.text}}
+
+
+
购物车还是空的
先加购,再预约。
diff --git a/WeChatProgram/pages/cart/index.wxss b/WeChatProgram/pages/cart/index.wxss
index 87a39a13..f219f625 100644
--- a/WeChatProgram/pages/cart/index.wxss
+++ b/WeChatProgram/pages/cart/index.wxss
@@ -31,6 +31,54 @@
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,
.coupon-card,
.summary-card {
@@ -260,6 +308,55 @@
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 {
display: flex;
align-items: center;
diff --git a/WeChatProgram/pages/orders/index.js b/WeChatProgram/pages/orders/index.js
index 48a2d457..e140a724 100644
--- a/WeChatProgram/pages/orders/index.js
+++ b/WeChatProgram/pages/orders/index.js
@@ -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.
*/
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.
* 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 { formatDateTime, formatPrice, getOrderStatusClass, getOrderStatusText } = require('../../utils/format')
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.
@@ -137,20 +139,49 @@ function buildPendingReview(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.
* 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) {
return null
}
- const originalName = request.originalArtistName || '原美甲师'
- const requestedName = request.requestedArtistName || '新美甲师'
+ const originalName = request.originalArtistName || request.fromArtistName || (orderItem && orderItem.artistName) || '原美甲师'
+ 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 {
...request,
+ originalArtistText,
+ requestedArtistText,
+ artistLines: [originalArtistText, requestedArtistText],
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.
* 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 => (
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,
pendingChangesPromise,
- orderReviewListsPromise
+ orderReviewListsPromise,
+ orderChangeListsPromise
])
const submittedReviews = []
@@ -208,7 +314,16 @@ async function loadAssistData(orders) {
return {
pendingReviewByItemId: indexByOrderItemId(pendingReviews),
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 {}
}
+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({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
loading: false,
@@ -240,7 +369,8 @@ Page({
* Usage: set it from onLoad route options and compare it while formatting order cards.
*/
focusOrderId: '',
- reviewScoreOptions: REVIEW_SCORE_OPTIONS
+ reviewScoreOptions: REVIEW_SCORE_OPTIONS,
+ recoveryState: clearRecoveryState()
}),
/**
@@ -249,7 +379,10 @@ Page({
*/
onLoad(options) {
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()
this.setData({
isLoggedIn,
- loading: isLoggedIn
+ loading: isLoggedIn,
+ recoveryState: clearRecoveryState()
})
if (!isLoggedIn) {
this.setData({
orders: [],
- loading: false
+ loading: false,
+ recoveryState: clearRecoveryState()
})
return
}
@@ -280,13 +415,27 @@ Page({
const orders = await orderApi.getOrderList()
const list = safeList(orders)
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 => ({
...order,
- focusTarget: sameId(order.id, this.data.focusOrderId),
+ focusTarget: sameId(order.id, resolvedFocusOrderId),
statusText: getOrderStatusText(order),
statusClass: getOrderStatusClass(order),
shopNameText: order.shopName ? `所属店铺:${order.shopName}` : '',
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 => {
const itemId = toId(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 pendingReview = buildPendingReview(inlinePendingReview || assistData.pendingReviewByItemId[itemId])
const reviewSummary = buildReviewSummary(inlineReviewSummary || assistData.submittedReviewByItemId[itemId])
- const pendingArtistChangeRequest = buildArtistChangeSummary(inlinePendingChange || assistData.pendingChangeByItemId[itemId])
+ const pendingArtistChangeRequest = buildArtistChangeSummary(inlinePendingChange || assistData.pendingChangeByItemId[itemId], item)
return {
...item,
productImageUrl: await resolveLegacyImage(item.productImage),
priceText: `\u00a5${formatPrice(item.price)}`,
appointmentText: formatDateTime(item.appointmentTime),
+ focusTarget: sameId(order.id, resolvedFocusOrderId) && (!resolvedFocusOrderItemId || sameId(item.id, resolvedFocusOrderItemId)),
pendingReview,
reviewSummary,
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({
- orders: formattedOrders
+ orders: formattedOrders,
+ recoveryState: clearRecoveryState()
})
} catch (error) {
this.setData({
- orders: []
- })
- wx.showToast({
- title: error.message || '\u8ba2\u5355\u5217\u8868\u52a0\u8f7d\u5931\u8d25',
- icon: 'none'
+ orders: [],
+ recoveryState: buildRecoveryState({
+ title: '订单列表加载失败',
+ message: error,
+ fallbackMessage: '订单暂时没有加载出来,请重试或稍后再查看。',
+ actions: [
+ { key: 'retryOrdersLoad', text: '重试' },
+ { key: 'products', text: '去逛作品' },
+ { key: 'profile', text: '返回我的' }
+ ]
+ })
})
} finally {
this.setData({
@@ -343,6 +504,33 @@ Page({
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.
* 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) {
const requestId = event.currentTarget.dataset.requestId
+ const confirmText = event.currentTarget.dataset.confirmText
if (!requestId) {
return
}
@@ -446,7 +635,7 @@ Page({
const confirmed = await new Promise(resolve => {
wx.showModal({
title: '同意改派',
- content: '确认同意这次美甲师改派申请吗?',
+ content: confirmText || '确认同意这次美甲师改派申请吗?',
success: modalRes => resolve(Boolean(modalRes.confirm))
})
})
@@ -476,6 +665,7 @@ Page({
async handleRejectArtistChange(event) {
const requestId = event.currentTarget.dataset.requestId
+ const confirmText = event.currentTarget.dataset.confirmText
if (!requestId) {
return
}
@@ -485,7 +675,7 @@ Page({
const confirmed = await new Promise(resolve => {
wx.showModal({
title: '拒绝改派',
- content: '确认拒绝这次美甲师改派申请吗?拒绝后可在下一步补充原因。',
+ content: confirmText ? `${confirmText}\n\n确认拒绝这次改派申请吗?拒绝后可在下一步补充原因。` : '确认拒绝这次美甲师改派申请吗?拒绝后可在下一步补充原因。',
confirmText: '拒绝',
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) {
const orderId = event.currentTarget.dataset.orderId
if (!orderId) {
diff --git a/WeChatProgram/pages/orders/index.wxml b/WeChatProgram/pages/orders/index.wxml
index 5a5cf97f..ad5f0e3e 100644
--- a/WeChatProgram/pages/orders/index.wxml
+++ b/WeChatProgram/pages/orders/index.wxml
@@ -25,7 +25,20 @@
{{item.shopNameText}}
-
+
+
+ {{node.title}}
+ {{node.text}}
+ {{node.subText}}
+
+
+
+
{{orderItem.productTitle}}
@@ -69,11 +82,20 @@
待确认改派
- {{orderItem.pendingArtistChangeRequest.displayText}}
+ {{orderItem.pendingArtistChangeRequest.originalArtistText}}
+ {{orderItem.pendingArtistChangeRequest.requestedArtistText}}
原因:{{orderItem.pendingArtistChangeRequest.reasonText}}
+
+ {{impactLine}}
+
- 同意改派
- 拒绝
+ 同意改派
+ 拒绝
@@ -81,7 +103,10 @@
@@ -90,6 +115,20 @@
正在加载订单
+
+ {{recoveryState.title}}
+ {{recoveryState.message}}
+
+ {{item.text}}
+
+
+
你还没有订单
先去预约喜欢的款式。
diff --git a/WeChatProgram/pages/orders/index.wxss b/WeChatProgram/pages/orders/index.wxss
index f74c203e..6669efff 100644
--- a/WeChatProgram/pages/orders/index.wxss
+++ b/WeChatProgram/pages/orders/index.wxss
@@ -2,6 +2,53 @@
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 {
margin-top: 20rpx;
}
@@ -35,6 +82,51 @@
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 {
flex: 1;
min-width: 0;
@@ -87,6 +179,13 @@
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 {
width: 132rpx;
height: 132rpx;
@@ -118,13 +217,21 @@
align-items: center;
}
+.order-actions {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: 14rpx;
+}
+
.order-amount {
font-size: 28rpx;
font-weight: 700;
color: #2d2430;
}
-.cancel-btn {
+.cancel-btn,
+.rebook-btn {
display: inline-flex;
align-items: center;
justify-content: center;
@@ -132,12 +239,20 @@
height: 60rpx;
padding: 0 18rpx;
border-radius: 999rpx;
- background: var(--theme-primary-soft);
- color: var(--theme-accent);
font-size: 24rpx;
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-panel,
.change-panel {
@@ -182,6 +297,20 @@
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 {
display: flex;
flex-wrap: wrap;
diff --git a/WeChatProgram/pages/product-detail/index.js b/WeChatProgram/pages/product-detail/index.js
index 030bd4a1..6555e9eb 100644
--- a/WeChatProgram/pages/product-detail/index.js
+++ b/WeChatProgram/pages/product-detail/index.js
@@ -52,6 +52,7 @@ const { getSignedUrl, resolveImageList, previewImagesSafely } = require('../../u
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
const { formatPrice, getProductTitle, splitCsv } = require('../../utils/format')
const { runWithLoading } = require('../../utils/loading')
+const { saveBuyNowContext } = require('../../utils/buy-now')
/**
* Purpose: parseTimeRange supports index.js by holding or executing the parse time range page or API role.
@@ -208,7 +209,9 @@ Page({
...product,
displayTitle: getProductTitle(product),
priceText: `¥${formatPrice(product.price)}`,
- descriptionText: product.description || '商家还没有补充作品说明。'
+ descriptionText: product.description || '商家还没有补充作品说明。',
+ targetAudienceText: product.targetAudience || '',
+ precautionsText: product.precautions || ''
}
this.setData({
@@ -303,7 +306,10 @@ Page({
return
}
- previewImagesSafely(current, this.data.productImages)
+ previewImagesSafely(current, this.data.productImages, {
+ failMessage: '图片可能已过期,请重试;仍失败时可以返回作品列表重新进入。',
+ emptyMessage: '这件作品暂时没有可预览图片,可以返回作品列表查看其他款式。'
+ })
},
/**
@@ -488,6 +494,7 @@ Page({
message: '操作进行中,请勿重复点击'
})
await getApp().updateCartBadge()
+ saveBuyNowContext(product.id)
wx.switchTab({
url: '/pages/cart/index'
})
diff --git a/WeChatProgram/pages/product-detail/index.wxml b/WeChatProgram/pages/product-detail/index.wxml
index 80460e73..4ad2aa84 100644
--- a/WeChatProgram/pages/product-detail/index.wxml
+++ b/WeChatProgram/pages/product-detail/index.wxml
@@ -79,6 +79,16 @@
款式说明
{{product.descriptionText}}
+
+
+ 适合人群
+ {{product.targetAudienceText}}
+
+
+ 注意事项
+ {{product.precautionsText}}
+
+
+
+ 待评价 {{pendingReviewCount}}
+ 给服务过你的美甲师一点反馈
+
@@ -57,6 +61,7 @@
常用入口