功能(小程序):同步用户体验流程到小程序
This commit is contained in:
@@ -20,6 +20,7 @@ const navigation = require('../../utils/navigation')
|
||||
const theme = require('../../utils/theme')
|
||||
const { getSignedUrl, resolveImageList, previewImagesSafely } = require('../../utils/file')
|
||||
const { DEFAULT_SHOP_IMAGE } = require('../../utils/config')
|
||||
const { showRecoveryModal } = require('../../utils/recovery')
|
||||
|
||||
/**
|
||||
* shop-detail page logic.
|
||||
@@ -38,6 +39,7 @@ Page({
|
||||
*/
|
||||
managerContact: null,
|
||||
distanceText: '',
|
||||
trustProfile: null,
|
||||
shopImages: []
|
||||
}),
|
||||
|
||||
@@ -78,7 +80,11 @@ Page({
|
||||
|
||||
try {
|
||||
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)
|
||||
this.setData(theme.pageThemeData(shopTheme))
|
||||
if (shopTheme.backgroundImageFileId) {
|
||||
@@ -91,6 +97,7 @@ Page({
|
||||
}
|
||||
this.setData({
|
||||
shopInfo,
|
||||
trustProfile: this.normalizeTrustProfile(trustProfile),
|
||||
shopImages,
|
||||
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.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
@@ -164,9 +212,21 @@ Page({
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '联系方式获取失败',
|
||||
icon: 'none'
|
||||
showRecoveryModal({
|
||||
title: '联系方式获取失败',
|
||||
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 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-metric">
|
||||
<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>
|
||||
</view>
|
||||
<view class="summary-metric">
|
||||
@@ -36,7 +51,7 @@
|
||||
|
||||
<view class="detail-group">
|
||||
<view class="detail-label">营业时间</view>
|
||||
<view class="detail-value">{{shopInfo.businessHours || '待补充'}}</view>
|
||||
<view class="detail-value">{{trustProfile.businessHoursText || shopInfo.businessHours || '待补充'}}</view>
|
||||
</view>
|
||||
|
||||
<view class="detail-group">
|
||||
@@ -63,6 +78,52 @@
|
||||
</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-head">
|
||||
<view class="section-copy">
|
||||
|
||||
@@ -57,6 +57,34 @@
|
||||
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 {
|
||||
font-size: 26rpx;
|
||||
line-height: 1.6;
|
||||
@@ -120,6 +148,86 @@
|
||||
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 {
|
||||
width: calc(50% - 9rpx);
|
||||
height: 240rpx;
|
||||
|
||||
Reference in New Issue
Block a user