功能:同步小程序流程
This commit is contained in:
@@ -1,18 +1,62 @@
|
||||
/**
|
||||
* Purpose: cartApi supports index.js by holding or executing the cart api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const cartApi = require('../../api/cart')
|
||||
/**
|
||||
* Purpose: productApi supports index.js by holding or executing the product api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const productApi = require('../../api/product')
|
||||
/**
|
||||
* Purpose: productLikeApi supports index.js by holding or executing the product like api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const productLikeApi = require('../../api/product-like')
|
||||
/**
|
||||
* Purpose: commentApi supports index.js by holding or executing the comment api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const commentApi = require('../../api/comment')
|
||||
/**
|
||||
* Purpose: shopApi supports index.js by holding or executing the shop api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const shopApi = require('../../api/shop')
|
||||
/**
|
||||
* Purpose: wishlistApi supports index.js by holding or executing the wishlist api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const wishlistApi = require('../../api/wishlist')
|
||||
/**
|
||||
* Purpose: actionGuard supports index.js by holding or executing the action guard page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { getSignedUrl, resolveImageList } = require('../../utils/file')
|
||||
const { getSignedUrl, resolveImageList, previewImagesSafely } = require('../../utils/file')
|
||||
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
|
||||
const { formatPrice, getProductTitle, splitCsv } = require('../../utils/format')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* Purpose: parseTimeRange supports index.js by holding or executing the parse time range page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function parseTimeRange(businessHours) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
@@ -37,6 +81,10 @@ function parseTimeRange(businessHours) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: estimateEarliestBookable supports index.js by holding or executing the estimate earliest bookable page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function estimateEarliestBookable(businessHours) {
|
||||
const range = parseTimeRange(businessHours)
|
||||
/**
|
||||
@@ -255,9 +303,37 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
wx.previewImage({
|
||||
current,
|
||||
urls: this.data.productImages
|
||||
previewImagesSafely(current, this.data.productImages)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShareAppMessage exposes the product detail as a native mini-program share target.
|
||||
* Usage: WeChat calls it from the share menu; keep title and path aligned with the current product id.
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
const product = this.data.product || {}
|
||||
return {
|
||||
title: product.displayTitle || 'YumiNail 美甲款式',
|
||||
path: `/pages/product-detail/index?id=${product.id || this.data.productId}`,
|
||||
imageUrl: this.data.productImages[0] || DEFAULT_PRODUCT_IMAGE
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCopyShareLink copies a mini-program route for users who cannot invoke native share.
|
||||
* Usage: bind it to the visible share action in the product info card.
|
||||
*/
|
||||
handleCopyShareLink() {
|
||||
const product = this.data.product || {}
|
||||
const path = `/pages/product-detail/index?id=${product.id || this.data.productId}`
|
||||
wx.setClipboardData({
|
||||
data: path,
|
||||
success: () => {
|
||||
wx.showToast({
|
||||
title: '分享路径已复制',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@
|
||||
<view class="action-pill {{isFavorite ? 'active' : ''}}" bindtap="handleToggleFavorite">
|
||||
收藏 {{product.collectCount || 0}}
|
||||
</view>
|
||||
<button class="action-pill share-pill" open-type="share">分享</button>
|
||||
<view class="action-pill" bindtap="handleCopyShareLink">复制路径</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{product.tagInfos && product.tagInfos.length}}" class="tags-wrap">
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
|
||||
.actions-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
@@ -123,6 +124,12 @@
|
||||
color: var(--theme-accent);
|
||||
font-size: 24rpx;
|
||||
font-weight: 600;
|
||||
border: 0;
|
||||
line-height: 68rpx;
|
||||
}
|
||||
|
||||
.share-pill::after {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.action-pill.active {
|
||||
|
||||
Reference in New Issue
Block a user