功能:同步小程序流程
This commit is contained in:
@@ -1,9 +1,37 @@
|
||||
/**
|
||||
* Purpose: authApi supports index.js by holding or executing the auth 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 authApi = require('../../api/auth')
|
||||
/**
|
||||
* 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: userApi supports index.js by holding or executing the user 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 userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: authStore supports index.js by holding or executing the auth store 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 authStore = require('../../utils/auth')
|
||||
/**
|
||||
* 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: 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 { runWithLoading } = require('../../utils/loading')
|
||||
const {
|
||||
@@ -15,6 +43,10 @@ const {
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
|
||||
/**
|
||||
* Purpose: phoneRegex supports index.js by holding or executing the phone regex 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 phoneRegex = /^1[3-9]\d{9}$/
|
||||
|
||||
/**
|
||||
@@ -124,6 +156,10 @@ Page({
|
||||
detachKeyboardSafe(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: noop supports index.js by holding or executing the noop 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.
|
||||
*/
|
||||
noop() {},
|
||||
|
||||
/**
|
||||
@@ -273,6 +309,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: buildAgreementPayload supports index.js by holding or executing the build agreement payload 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.
|
||||
*/
|
||||
buildAgreementPayload() {
|
||||
const agreementVersions = {}
|
||||
;(this.data.agreements || []).forEach((item) => {
|
||||
@@ -287,6 +327,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: ensureAgreementAccepted supports index.js by holding or executing the ensure agreement accepted 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.
|
||||
*/
|
||||
ensureAgreementAccepted() {
|
||||
if (!this.data.agreementAccepted) {
|
||||
wx.showToast({
|
||||
@@ -307,12 +351,20 @@ Page({
|
||||
return true
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAgreementToggle supports index.js by holding or executing the handle agreement toggle 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.
|
||||
*/
|
||||
handleAgreementToggle() {
|
||||
this.setData({
|
||||
agreementAccepted: !this.data.agreementAccepted
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: openAgreement supports index.js by holding or executing the open agreement 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.
|
||||
*/
|
||||
openAgreement(event) {
|
||||
const type = event.currentTarget.dataset.type
|
||||
const selectedAgreement = (this.data.agreements || []).find((item) => item.agreementType === type)
|
||||
@@ -329,6 +381,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: closeAgreementModal supports index.js by holding or executing the close agreement modal 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.
|
||||
*/
|
||||
closeAgreementModal() {
|
||||
this.setData({
|
||||
agreementModalVisible: false,
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
/**
|
||||
* 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: 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.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
/**
|
||||
* 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 { resolveLegacyImage } = require('../../utils/file')
|
||||
const { NO_COUPON_KEY } = require('../../utils/config')
|
||||
@@ -16,10 +40,18 @@ const {
|
||||
parseAppointmentParts
|
||||
} = require('../../utils/format')
|
||||
|
||||
/**
|
||||
* Purpose: getCouponKey supports index.js by holding or executing the get coupon key 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 getCouponKey(coupon) {
|
||||
return `${coupon.sourceType || 'USER_COUPON'}:${coupon.id}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: getCouponDisplay supports index.js by holding or executing the get coupon display 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 getCouponDisplay(coupon) {
|
||||
if (Number(coupon.couponType) === 1) {
|
||||
return `${coupon.couponName} ${coupon.discountValue} 折`
|
||||
@@ -27,6 +59,10 @@ function getCouponDisplay(coupon) {
|
||||
return `${coupon.couponName} 满 ${coupon.minAmount} 减 ${coupon.reduceAmount}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: calculateCouponDiscount supports index.js by holding or executing the calculate coupon discount 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 calculateCouponDiscount(coupon, amount) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
@@ -48,6 +84,10 @@ function calculateCouponDiscount(coupon, amount) {
|
||||
return 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildCheckoutIssues supports index.js by holding or executing the build checkout issues 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 buildCheckoutIssues(items) {
|
||||
const issues = []
|
||||
const selectedItems = items.filter(item => item.selected)
|
||||
@@ -121,6 +161,11 @@ Page({
|
||||
cartItems: [],
|
||||
availableCoupons: [],
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
/**
|
||||
* Purpose: couponSelectionTouched records whether the user explicitly chose a coupon option.
|
||||
* Usage: keep normal user coupons manual-only while still allowing VIP auto coupons as default.
|
||||
*/
|
||||
couponSelectionTouched: false,
|
||||
selectedCount: 0,
|
||||
totalQuantity: 0,
|
||||
subtotalAmount: 0,
|
||||
@@ -201,6 +246,7 @@ Page({
|
||||
cartItems: [],
|
||||
availableCoupons: [],
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
couponSelectionTouched: false,
|
||||
loading: false
|
||||
})
|
||||
this.refreshSummary()
|
||||
@@ -239,7 +285,8 @@ Page({
|
||||
|
||||
this.setData({
|
||||
cartItems: formattedItems,
|
||||
selectedCouponKey: NO_COUPON_KEY
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
couponSelectionTouched: false
|
||||
})
|
||||
await this.loadAvailableCoupons()
|
||||
} catch (error) {
|
||||
@@ -267,7 +314,8 @@ Page({
|
||||
if (!selectedItems.length) {
|
||||
this.setData({
|
||||
availableCoupons: [],
|
||||
selectedCouponKey: NO_COUPON_KEY
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
couponSelectionTouched: false
|
||||
})
|
||||
this.refreshSummary()
|
||||
return
|
||||
@@ -305,8 +353,9 @@ Page({
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (selectedCouponKey === NO_COUPON_KEY) {
|
||||
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))
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
@@ -324,7 +373,8 @@ Page({
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
availableCoupons: [],
|
||||
selectedCouponKey: NO_COUPON_KEY
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
couponSelectionTouched: false
|
||||
})
|
||||
} finally {
|
||||
this.refreshSummary()
|
||||
@@ -587,7 +637,8 @@ Page({
|
||||
*/
|
||||
handleCouponChange(event) {
|
||||
this.setData({
|
||||
selectedCouponKey: event.detail.value
|
||||
selectedCouponKey: event.detail.value,
|
||||
couponSelectionTouched: true
|
||||
})
|
||||
this.refreshSummary()
|
||||
},
|
||||
|
||||
@@ -1,8 +1,28 @@
|
||||
/**
|
||||
* 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: 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')
|
||||
|
||||
/**
|
||||
* Purpose: getBenefitText supports index.js by holding or executing the get benefit text 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 getBenefitText(coupon) {
|
||||
if (Number(coupon.couponType) === 1) {
|
||||
return `${coupon.discountValue} 折`
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/**
|
||||
* 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: cache supports index.js by holding or executing the cache 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 cache = require('../../utils/cache')
|
||||
const { buildProductCards } = require('../../utils/product')
|
||||
const { resolveImageList } = require('../../utils/file')
|
||||
@@ -12,9 +24,25 @@ const {
|
||||
handleKeyboardBlur,
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
/**
|
||||
* 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: 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: userApi supports index.js by holding or executing the user 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 userApi = require('../../api/user')
|
||||
/**
|
||||
* 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')
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* 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')
|
||||
|
||||
/**
|
||||
@@ -5,7 +9,15 @@ const auth = require('../../utils/auth')
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: navTitle supports index.js by holding or executing the nav title 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.
|
||||
*/
|
||||
navTitle: '游客模式'
|
||||
},
|
||||
|
||||
@@ -16,6 +28,10 @@ Page({
|
||||
onLoad() {
|
||||
this.syncNavTitle()
|
||||
wx.switchTab({
|
||||
/**
|
||||
* Purpose: url supports index.js by holding or executing the url 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.
|
||||
*/
|
||||
url: '/pages/home/index'
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1,16 +1,49 @@
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user 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 userApi = require('../../api/user')
|
||||
/**
|
||||
* 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')
|
||||
const { previewImagesSafely } = require('../../utils/file')
|
||||
|
||||
/**
|
||||
* notifications page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: messages supports index.js by holding or executing the messages 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.
|
||||
*/
|
||||
messages: [],
|
||||
/**
|
||||
* Purpose: unreadCount supports index.js by holding or executing the unread count 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.
|
||||
*/
|
||||
unreadCount: 0,
|
||||
/**
|
||||
* Purpose: detailVisible supports index.js by holding or executing the detail visible 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.
|
||||
*/
|
||||
detailVisible: false,
|
||||
/**
|
||||
* Purpose: currentMessage supports index.js by holding or executing the current message 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.
|
||||
*/
|
||||
currentMessage: null
|
||||
},
|
||||
|
||||
@@ -31,12 +64,28 @@ Page({
|
||||
const messages = await userApi.listMyMessages()
|
||||
const list = Array.isArray(messages) ? messages : []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: messages supports index.js by holding or executing the messages 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.
|
||||
*/
|
||||
messages: list,
|
||||
/**
|
||||
* Purpose: unreadCount supports index.js by holding or executing the unread count 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.
|
||||
*/
|
||||
unreadCount: list.filter(item => item.readStatus !== 1).length
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title 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.
|
||||
*/
|
||||
title: error.message || '消息加载失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon 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.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
@@ -54,26 +103,43 @@ Page({
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
if (item.actionPath) {
|
||||
const actionTarget = navigation.buildMessageActionPath(item)
|
||||
if (actionTarget) {
|
||||
try {
|
||||
if (item.readStatus !== 1) {
|
||||
await userApi.markMessageRead(item.id)
|
||||
}
|
||||
const opened = await navigation.openActionPath(item.actionPath)
|
||||
const opened = await navigation.openActionPath(actionTarget)
|
||||
await this.loadMessages()
|
||||
if (opened) {
|
||||
return
|
||||
}
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title 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.
|
||||
*/
|
||||
title: error.message || '打开消息失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon 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.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: currentMessage supports index.js by holding or executing the current message 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.
|
||||
*/
|
||||
currentMessage: item,
|
||||
/**
|
||||
* Purpose: detailVisible supports index.js by holding or executing the detail visible 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.
|
||||
*/
|
||||
detailVisible: true
|
||||
})
|
||||
/**
|
||||
@@ -86,7 +152,15 @@ Page({
|
||||
await this.loadMessages()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title 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.
|
||||
*/
|
||||
title: error.message || '标记已读失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon 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.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
@@ -99,7 +173,15 @@ Page({
|
||||
*/
|
||||
handleCloseDetail() {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: detailVisible supports index.js by holding or executing the detail visible 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.
|
||||
*/
|
||||
detailVisible: false,
|
||||
/**
|
||||
* Purpose: currentMessage supports index.js by holding or executing the current message 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.
|
||||
*/
|
||||
currentMessage: null
|
||||
})
|
||||
},
|
||||
@@ -117,12 +199,13 @@ Page({
|
||||
if (!imageUrl) {
|
||||
return
|
||||
}
|
||||
wx.previewImage({
|
||||
current: imageUrl,
|
||||
urls: [imageUrl]
|
||||
})
|
||||
previewImagesSafely(imageUrl, [imageUrl])
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: noop supports index.js by holding or executing the noop 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.
|
||||
*/
|
||||
noop() {},
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,32 +1,76 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
/**
|
||||
* 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: 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: 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 { resolveLegacyImage } = require('../../utils/file')
|
||||
const { formatDateTime, formatPrice, getOrderStatusClass, getOrderStatusText } = require('../../utils/format')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* Purpose: REVIEW_SCORE_OPTIONS supports index.js by holding or executing the review score options 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 REVIEW_SCORE_OPTIONS = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
|
||||
|
||||
/**
|
||||
* Purpose: toId supports index.js by holding or executing the to id 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 toId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: sameId supports index.js by holding or executing the same id 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 sameId(left, right) {
|
||||
const leftId = toId(left)
|
||||
const rightId = toId(right)
|
||||
return leftId !== '' && leftId === rightId
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: safeList supports index.js by holding or executing the safe list 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 safeList(value) {
|
||||
return Array.isArray(value) ? value : []
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: trimText supports index.js by holding or executing the trim text 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 trimText(value) {
|
||||
return String(value || '').trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatRating supports index.js by holding or executing the format rating 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 formatRating(value) {
|
||||
const rating = Number(value)
|
||||
if (!isFinite(rating) || rating <= 0) {
|
||||
@@ -35,6 +79,10 @@ function formatRating(value) {
|
||||
return rating % 1 === 0 ? String(rating) : rating.toFixed(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isSubmittedReview supports index.js by holding or executing the is submitted review 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 isSubmittedReview(review) {
|
||||
if (!review) {
|
||||
return false
|
||||
@@ -45,6 +93,10 @@ function isSubmittedReview(review) {
|
||||
return Boolean(review.rating)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: resolveRelatedRecord supports index.js by holding or executing the resolve related record 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 resolveRelatedRecord(source, orderItemId) {
|
||||
if (Array.isArray(source)) {
|
||||
return source.find(item => sameId(item && item.orderItemId, orderItemId)) || null
|
||||
@@ -57,6 +109,10 @@ function resolveRelatedRecord(source, orderItemId) {
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildReviewSummary supports index.js by holding or executing the build review 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 buildReviewSummary(review) {
|
||||
if (!review || !isSubmittedReview(review)) {
|
||||
return null
|
||||
@@ -70,6 +126,10 @@ function buildReviewSummary(review) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildPendingReview supports index.js by holding or executing the build pending review 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 buildPendingReview(review) {
|
||||
if (!review || isSubmittedReview(review)) {
|
||||
return null
|
||||
@@ -77,6 +137,10 @@ function buildPendingReview(review) {
|
||||
return review
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
if (!request) {
|
||||
return null
|
||||
@@ -90,6 +154,10 @@ function buildArtistChangeSummary(request) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: indexByOrderItemId supports index.js by holding or executing the index by order item id 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 indexByOrderItemId(list) {
|
||||
return safeList(list).reduce((result, item) => {
|
||||
if (item && item.orderItemId) {
|
||||
@@ -99,6 +167,10 @@ function indexByOrderItemId(list) {
|
||||
}, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
async function safeCall(factory, fallbackValue) {
|
||||
try {
|
||||
const result = await factory()
|
||||
@@ -108,6 +180,10 @@ async function safeCall(factory, fallbackValue) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: loadAssistData supports index.js by holding or executing the load assist data 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.
|
||||
*/
|
||||
async function loadAssistData(orders) {
|
||||
const pendingReviewsPromise = safeCall(() => orderApi.listMyPendingReviews(), [])
|
||||
const pendingChangesPromise = safeCall(() => orderApi.listMyPendingArtistChangeRequests(), [])
|
||||
@@ -136,6 +212,10 @@ async function loadAssistData(orders) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: findReviewDraft supports index.js by holding or executing the find review draft 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 findReviewDraft(orders, reviewId) {
|
||||
const reviewIdText = toId(reviewId)
|
||||
for (let i = 0; i < orders.length; i += 1) {
|
||||
@@ -155,9 +235,28 @@ Page({
|
||||
loading: false,
|
||||
isLoggedIn: false,
|
||||
orders: [],
|
||||
/**
|
||||
* Purpose: focusOrderId stores an optional order id from message navigation so the target order can be surfaced.
|
||||
* Usage: set it from onLoad route options and compare it while formatting order cards.
|
||||
*/
|
||||
focusOrderId: '',
|
||||
reviewScoreOptions: REVIEW_SCORE_OPTIONS
|
||||
}),
|
||||
|
||||
/**
|
||||
* Purpose: onLoad captures message or deep-link order ids before the order list is loaded.
|
||||
* Usage: mini-program runtime passes route options; store orderId for highlighting after loadOrders.
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
focusOrderId: (options && options.orderId) || ''
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadOrders()
|
||||
},
|
||||
@@ -183,6 +282,7 @@ Page({
|
||||
const assistData = await loadAssistData(list)
|
||||
const formattedOrders = await Promise.all(list.map(async order => ({
|
||||
...order,
|
||||
focusTarget: sameId(order.id, this.data.focusOrderId),
|
||||
statusText: getOrderStatusText(order),
|
||||
statusClass: getOrderStatusClass(order),
|
||||
shopNameText: order.shopName ? `所属店铺:${order.shopName}` : '',
|
||||
@@ -227,14 +327,26 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenAuth supports index.js by holding or executing the handle open auth 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.
|
||||
*/
|
||||
handleOpenAuth() {
|
||||
navigation.openAuth('/pages/orders/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBack supports index.js by holding or executing the handle back 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.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/profile/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
updateReviewDraft(reviewId, patch) {
|
||||
const reviewIdText = toId(reviewId)
|
||||
const orders = this.data.orders.map(order => ({
|
||||
@@ -258,6 +370,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSelectReviewScore supports index.js by holding or executing the handle select review score 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.
|
||||
*/
|
||||
handleSelectReviewScore(event) {
|
||||
const reviewId = event.currentTarget.dataset.reviewId
|
||||
const score = Number(event.currentTarget.dataset.score)
|
||||
@@ -266,6 +382,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleReviewContentInput supports index.js by holding or executing the handle review content input 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.
|
||||
*/
|
||||
handleReviewContentInput(event) {
|
||||
const reviewId = event.currentTarget.dataset.reviewId
|
||||
this.updateReviewDraft(reviewId, {
|
||||
@@ -365,7 +485,7 @@ Page({
|
||||
const confirmed = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '拒绝改派',
|
||||
content: '确认拒绝这次美甲师改派申请吗?',
|
||||
content: '确认拒绝这次美甲师改派申请吗?拒绝后可在下一步补充原因。',
|
||||
confirmText: '拒绝',
|
||||
success: modalRes => resolve(Boolean(modalRes.confirm))
|
||||
})
|
||||
@@ -374,8 +494,10 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
const rejectReason = await this.promptRejectReason()
|
||||
|
||||
await runWithLoading(() => orderApi.rejectArtistChange(requestId, {
|
||||
rejectReason: ''
|
||||
rejectReason
|
||||
}))
|
||||
wx.showToast({
|
||||
title: '已拒绝改派',
|
||||
@@ -396,6 +518,29 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: promptRejectReason collects an optional customer reason before rejecting an artist-change request.
|
||||
* Usage: call it after the confirmation dialog and pass the returned text to rejectArtistChange.
|
||||
*/
|
||||
promptRejectReason() {
|
||||
return new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '拒绝原因',
|
||||
editable: true,
|
||||
placeholderText: '可选,告诉美甲师原因',
|
||||
confirmText: '提交',
|
||||
success: res => {
|
||||
if (!res.confirm) {
|
||||
resolve('')
|
||||
return
|
||||
}
|
||||
resolve(trimText(res.content))
|
||||
},
|
||||
fail: () => resolve('')
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
async handleCancelOrder(event) {
|
||||
const orderId = event.currentTarget.dataset.orderId
|
||||
if (!orderId) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<text class="hero-desc">查看订单状态和预约时间。</text>
|
||||
</view>
|
||||
|
||||
<view wx:for="{{orders}}" wx:key="id" class="page-card order-card">
|
||||
<view wx:for="{{orders}}" wx:key="id" class="page-card order-card {{item.focusTarget ? 'focus-target' : ''}}">
|
||||
<view class="order-head">
|
||||
<view class="order-head-copy">
|
||||
<text class="order-label">订单号</text>
|
||||
@@ -32,50 +32,50 @@
|
||||
<view class="order-line">{{orderItem.priceText}} x {{orderItem.quantity}}</view>
|
||||
<view wx:if="{{orderItem.artistName}}" class="order-line">美甲师:{{orderItem.artistName}}</view>
|
||||
<view wx:if="{{orderItem.appointmentText}}" class="order-line">预约时间:{{orderItem.appointmentText}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{orderItem.reviewSummary}}" class="review-summary">
|
||||
<text class="assist-label">评价状态</text>
|
||||
<text class="assist-main">{{orderItem.reviewSummary.displayText}}</text>
|
||||
<text wx:if="{{orderItem.reviewSummary.contentText}}" class="assist-desc">{{orderItem.reviewSummary.contentText}}</text>
|
||||
</view>
|
||||
<view wx:if="{{orderItem.reviewSummary}}" class="review-summary">
|
||||
<text class="assist-label">评价状态</text>
|
||||
<text class="assist-main">{{orderItem.reviewSummary.displayText}}</text>
|
||||
<text wx:if="{{orderItem.reviewSummary.contentText}}" class="assist-desc">{{orderItem.reviewSummary.contentText}}</text>
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{orderItem.pendingReview}}" class="review-panel">
|
||||
<view class="review-panel-head">
|
||||
<text class="assist-label">评价美甲师</text>
|
||||
<text class="assist-desc">评分必填,文字可选</text>
|
||||
</view>
|
||||
<view class="score-row">
|
||||
<view
|
||||
wx:for="{{reviewScoreOptions}}"
|
||||
wx:key="*this"
|
||||
wx:for-item="score"
|
||||
class="score-chip {{orderItem.reviewDraft.rating == score ? 'active' : ''}}"
|
||||
data-review-id="{{orderItem.pendingReview.id}}"
|
||||
data-score="{{score}}"
|
||||
bindtap="handleSelectReviewScore"
|
||||
>{{score}}</view>
|
||||
</view>
|
||||
<textarea
|
||||
class="review-textarea"
|
||||
maxlength="200"
|
||||
placeholder="写下这次服务体验,可不填"
|
||||
placeholder-class="textarea-placeholder"
|
||||
value="{{orderItem.reviewDraft.content}}"
|
||||
data-review-id="{{orderItem.pendingReview.id}}"
|
||||
bindinput="handleReviewContentInput"
|
||||
></textarea>
|
||||
<view class="review-submit-btn" data-review-id="{{orderItem.pendingReview.id}}" bindtap="handleSubmitReview">提交评价</view>
|
||||
</view>
|
||||
<view wx:elif="{{orderItem.pendingReview}}" class="review-panel">
|
||||
<view class="review-panel-head">
|
||||
<text class="assist-label">评价美甲师</text>
|
||||
<text class="assist-desc">评分必填,文字可选</text>
|
||||
</view>
|
||||
<view class="score-row">
|
||||
<view
|
||||
wx:for="{{reviewScoreOptions}}"
|
||||
wx:key="*this"
|
||||
wx:for-item="score"
|
||||
class="score-chip {{orderItem.reviewDraft.rating == score ? 'active' : ''}}"
|
||||
data-review-id="{{orderItem.pendingReview.id}}"
|
||||
data-score="{{score}}"
|
||||
bindtap="handleSelectReviewScore"
|
||||
>{{score}}</view>
|
||||
</view>
|
||||
<textarea
|
||||
class="review-textarea"
|
||||
maxlength="200"
|
||||
placeholder="写下这次服务体验,可不填"
|
||||
placeholder-class="textarea-placeholder"
|
||||
value="{{orderItem.reviewDraft.content}}"
|
||||
data-review-id="{{orderItem.pendingReview.id}}"
|
||||
bindinput="handleReviewContentInput"
|
||||
></textarea>
|
||||
<view class="review-submit-btn" data-review-id="{{orderItem.pendingReview.id}}" bindtap="handleSubmitReview">提交评价</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{orderItem.pendingArtistChangeRequest}}" class="change-panel">
|
||||
<text class="assist-label">待确认改派</text>
|
||||
<text class="assist-main">{{orderItem.pendingArtistChangeRequest.displayText}}</text>
|
||||
<text wx:if="{{orderItem.pendingArtistChangeRequest.reasonText}}" class="assist-desc">原因:{{orderItem.pendingArtistChangeRequest.reasonText}}</text>
|
||||
<view class="change-actions">
|
||||
<view class="change-btn primary" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleApproveArtistChange">同意改派</view>
|
||||
<view class="change-btn" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleRejectArtistChange">拒绝</view>
|
||||
<view wx:if="{{orderItem.pendingArtistChangeRequest}}" class="change-panel">
|
||||
<text class="assist-label">待确认改派</text>
|
||||
<text class="assist-main">{{orderItem.pendingArtistChangeRequest.displayText}}</text>
|
||||
<text wx:if="{{orderItem.pendingArtistChangeRequest.reasonText}}" class="assist-desc">原因:{{orderItem.pendingArtistChangeRequest.reasonText}}</text>
|
||||
<view class="change-actions">
|
||||
<view class="change-btn primary" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleApproveArtistChange">同意改派</view>
|
||||
<view class="change-btn" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleRejectArtistChange">拒绝</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
padding: 26rpx;
|
||||
}
|
||||
|
||||
.order-card.focus-target {
|
||||
border-color: var(--theme-primary);
|
||||
box-shadow: 0 18rpx 48rpx rgba(224, 105, 92, 0.18);
|
||||
}
|
||||
|
||||
.order-head,
|
||||
.order-foot {
|
||||
display: flex;
|
||||
@@ -91,6 +96,7 @@
|
||||
|
||||
.order-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.order-title {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,11 +1,43 @@
|
||||
/**
|
||||
* 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: cache supports index.js by holding or executing the cache 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 cache = require('../../utils/cache')
|
||||
/**
|
||||
* Purpose: tagApi supports index.js by holding or executing the tag 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 tagApi = require('../../api/tag')
|
||||
/**
|
||||
* 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: 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: 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')
|
||||
const { buildProductCards } = require('../../utils/product')
|
||||
/**
|
||||
* 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 { runWithLoading } = require('../../utils/loading')
|
||||
const { CACHE_TTL } = require('../../utils/config')
|
||||
@@ -18,8 +50,20 @@ const {
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
|
||||
/**
|
||||
* Purpose: ALL_CATEGORY supports index.js by holding or executing the all category 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 ALL_CATEGORY = '\u5168\u90e8'
|
||||
/**
|
||||
* Purpose: FILTER_BUSY_MESSAGE supports index.js by holding or executing the filter busy message 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 FILTER_BUSY_MESSAGE = '\u7b5b\u9009\u5904\u7406\u4e2d\uff0c\u8bf7\u52ff\u91cd\u590d\u64cd\u4f5c'
|
||||
/**
|
||||
* Purpose: CART_BUSY_MESSAGE supports index.js by holding or executing the cart busy message 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 CART_BUSY_MESSAGE = '\u8d2d\u7269\u8f66\u5904\u7406\u4e2d\uff0c\u8bf7\u52ff\u91cd\u590d\u64cd\u4f5c'
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,47 @@
|
||||
/**
|
||||
* Purpose: authApi supports index.js by holding or executing the auth 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 authApi = require('../../api/auth')
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user 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 userApi = require('../../api/user')
|
||||
/**
|
||||
* 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 { DEFAULT_AVATAR } = require('../../utils/config')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
@@ -178,6 +214,11 @@ Page({
|
||||
}
|
||||
this._checkingPopupMessages = true
|
||||
try {
|
||||
const globalApp = getApp()
|
||||
if (globalApp && typeof globalApp.checkPopupMessages === 'function') {
|
||||
await globalApp.checkPopupMessages()
|
||||
return
|
||||
}
|
||||
const messages = await userApi.listMyPopupMessages()
|
||||
/**
|
||||
* `for` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
@@ -194,7 +235,7 @@ Page({
|
||||
})
|
||||
})
|
||||
await userApi.markMessagePopupShown(item.id)
|
||||
const opened = await navigation.openActionPath(item.actionPath)
|
||||
const opened = await navigation.openSystemMessage(item)
|
||||
if (opened) {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
/**
|
||||
* Purpose: authApi supports index.js by holding or executing the auth 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 authApi = require('../../api/auth')
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user 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 userApi = require('../../api/user')
|
||||
/**
|
||||
* 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 { DEFAULT_AVATAR } = require('../../utils/config')
|
||||
const { getDraftValue, clearDraft, scheduleDraftSave, clearDraftTimer } = require('../../utils/form-draft')
|
||||
@@ -15,8 +35,20 @@ const {
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
|
||||
/**
|
||||
* Purpose: phoneRegex supports index.js by holding or executing the phone regex 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 phoneRegex = /^1[3-9]\d{9}$/
|
||||
/**
|
||||
* Purpose: passwordRegex supports index.js by holding or executing the password regex 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 passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/
|
||||
/**
|
||||
* Purpose: SETTINGS_DRAFT_KEY supports index.js by holding or executing the settings draft key 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 SETTINGS_DRAFT_KEY = 'user-settings'
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,24 @@
|
||||
/**
|
||||
* 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: userApi loads contact information that is hidden until the customer explicitly asks for it.
|
||||
* Usage: call getShopManagerContact from the contact button after login checks pass.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* 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_SHOP_IMAGE } = require('../../utils/config')
|
||||
|
||||
/**
|
||||
@@ -15,6 +32,11 @@ Page({
|
||||
shopId: '',
|
||||
returnTo: '/pages/home/index',
|
||||
shopInfo: null,
|
||||
/**
|
||||
* Purpose: managerContact stores the shop manager contact returned after a customer requests it.
|
||||
* Usage: bind it to the contact card and keep it null until the API succeeds.
|
||||
*/
|
||||
managerContact: null,
|
||||
distanceText: '',
|
||||
shopImages: []
|
||||
}),
|
||||
@@ -106,10 +128,47 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
wx.previewImage({
|
||||
current: url,
|
||||
urls: this.data.shopImages
|
||||
})
|
||||
previewImagesSafely(url, this.data.shopImages)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleContactManager retrieves and shows the current shop manager contact.
|
||||
* Usage: bind it to the contact button and require login before exposing phone data.
|
||||
*/
|
||||
async handleContactManager() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
if (!shopInfo || !shopInfo.id || !navigation.ensureLogin('联系店长')) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const contact = await userApi.getShopManagerContact(shopInfo.id)
|
||||
this.setData({ managerContact: contact })
|
||||
if (contact && contact.phoneAvailable && contact.phone) {
|
||||
wx.showModal({
|
||||
title: contact.contactName || '店长联系方式',
|
||||
content: `${contact.roleLabel || '店长'}:${contact.phone}`,
|
||||
confirmText: '拨打',
|
||||
cancelText: '复制',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
wx.makePhoneCall({ phoneNumber: contact.phone })
|
||||
} else {
|
||||
wx.setClipboardData({ data: contact.phone })
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: (contact && contact.platformContactText) || '暂无可用联系方式',
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '联系方式获取失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -150,6 +209,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenLocation supports index.js by holding or executing the handle open location 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.
|
||||
*/
|
||||
handleOpenLocation() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
if (!shopInfo || !shopInfo.latitude || !shopInfo.longitude) {
|
||||
@@ -169,6 +232,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenAmapNavigation supports index.js by holding or executing the handle open amap navigation 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.
|
||||
*/
|
||||
handleOpenAmapNavigation() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
const amapUrl = shopInfo && shopInfo.navigationUrls && shopInfo.navigationUrls.AMAP
|
||||
@@ -190,6 +257,35 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCopyTencentNavigation copies a browser/Tencent-compatible navigation link when provided by the backend.
|
||||
* Usage: bind it to the navigation row as a fallback for users who prefer another map app.
|
||||
*/
|
||||
handleCopyTencentNavigation() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
const url = shopInfo && shopInfo.navigationUrls && (shopInfo.navigationUrls.TENCENT || shopInfo.navigationUrls.BROWSER)
|
||||
if (!url) {
|
||||
wx.showToast({
|
||||
title: '店铺暂未设置备用导航链接',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.setClipboardData({
|
||||
data: url,
|
||||
success: () => {
|
||||
wx.showToast({
|
||||
title: '导航链接已复制',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: loadCurrentDistance supports index.js by holding or executing the load current distance 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.
|
||||
*/
|
||||
loadCurrentDistance() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
if (!shopInfo || !shopInfo.latitude || !shopInfo.longitude || typeof wx.getLocation !== 'function') {
|
||||
@@ -205,6 +301,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: formatDistance supports index.js by holding or executing the format distance 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.
|
||||
*/
|
||||
formatDistance(currentLat, currentLng, shopLat, shopLng) {
|
||||
if (![currentLat, currentLng, shopLat, shopLng].every(Number.isFinite)) {
|
||||
return ''
|
||||
|
||||
@@ -49,9 +49,17 @@
|
||||
<view class="ghost-btn" bindtap="handleCopyAddress">复制地址</view>
|
||||
</view>
|
||||
|
||||
<view class="contact-row">
|
||||
<view class="primary-btn contact-btn" bindtap="handleContactManager">联系店长</view>
|
||||
<view wx:if="{{managerContact}}" class="contact-copy">
|
||||
{{managerContact.contactName || '店长'}} · {{managerContact.phoneAvailable ? managerContact.phone : (managerContact.platformContactText || '暂无电话')}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{shopInfo.longitude && shopInfo.latitude}}" class="map-row">
|
||||
<view class="primary-btn map-btn" bindtap="handleOpenLocation">查看地图位置</view>
|
||||
<view class="ghost-btn map-btn" bindtap="handleOpenAmapNavigation">复制高德导航链接</view>
|
||||
<view class="ghost-btn map-btn" bindtap="handleCopyTencentNavigation">复制备用导航</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -87,11 +87,27 @@
|
||||
|
||||
.map-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 16rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.contact-row {
|
||||
display: grid;
|
||||
gap: 12rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.contact-btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.contact-copy {
|
||||
color: #8d7a84;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.copy-row .ghost-btn,
|
||||
.map-btn {
|
||||
min-width: 0;
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user 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 userApi = require('../../api/user')
|
||||
/**
|
||||
* 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: money supports index.js by holding or executing the money 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 money(value) {
|
||||
return Number(value || 0).toFixed(2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatTime supports index.js by holding or executing the format time 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 formatTime(value) {
|
||||
return value ? String(value).replace('T', ' ').slice(0, 16) : '--'
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: sceneText supports index.js by holding or executing the scene text 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 sceneText(scene) {
|
||||
const map = {
|
||||
MANUAL_RECHARGE: '手工充值',
|
||||
@@ -26,17 +46,61 @@ function sceneText(scene) {
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: asset supports index.js by holding or executing the asset 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.
|
||||
*/
|
||||
asset: {
|
||||
/**
|
||||
* Purpose: vipLevel supports index.js by holding or executing the vip level 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.
|
||||
*/
|
||||
vipLevel: '普通',
|
||||
/**
|
||||
* Purpose: balanceText supports index.js by holding or executing the balance text 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.
|
||||
*/
|
||||
balanceText: '0.00',
|
||||
/**
|
||||
* Purpose: totalRechargeText supports index.js by holding or executing the total recharge text 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.
|
||||
*/
|
||||
totalRechargeText: '0.00',
|
||||
/**
|
||||
* Purpose: lastRechargeText supports index.js by holding or executing the last recharge text 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.
|
||||
*/
|
||||
lastRechargeText: '--',
|
||||
/**
|
||||
* Purpose: vipStartText supports index.js by holding or executing the vip start text 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.
|
||||
*/
|
||||
vipStartText: '--',
|
||||
/**
|
||||
* Purpose: manualOverride supports index.js by holding or executing the manual override 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.
|
||||
*/
|
||||
manualOverride: false
|
||||
},
|
||||
/**
|
||||
* Purpose: history supports index.js by holding or executing the history 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.
|
||||
*/
|
||||
history: [],
|
||||
/**
|
||||
* Purpose: rechargePlans supports index.js by holding or executing the recharge plans 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.
|
||||
*/
|
||||
rechargePlans: [],
|
||||
/**
|
||||
* Purpose: rechargePanelVisible supports index.js by holding or executing the recharge panel visible 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.
|
||||
*/
|
||||
rechargePanelVisible: false
|
||||
},
|
||||
|
||||
@@ -59,31 +123,83 @@ Page({
|
||||
userApi.listMyVipRechargePlans().catch(() => [])
|
||||
])
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: asset supports index.js by holding or executing the asset 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.
|
||||
*/
|
||||
asset: {
|
||||
...asset,
|
||||
/**
|
||||
* Purpose: balanceText supports index.js by holding or executing the balance text 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.
|
||||
*/
|
||||
balanceText: money(asset && asset.balance),
|
||||
/**
|
||||
* Purpose: totalRechargeText supports index.js by holding or executing the total recharge text 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.
|
||||
*/
|
||||
totalRechargeText: money(asset && asset.totalRechargeAmount),
|
||||
/**
|
||||
* Purpose: lastRechargeText supports index.js by holding or executing the last recharge text 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.
|
||||
*/
|
||||
lastRechargeText: formatTime(asset && asset.lastRechargeTime),
|
||||
/**
|
||||
* Purpose: vipStartText supports index.js by holding or executing the vip start text 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.
|
||||
*/
|
||||
vipStartText: formatTime(asset && asset.vipStartTime)
|
||||
},
|
||||
/**
|
||||
* Purpose: history supports index.js by holding or executing the history 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.
|
||||
*/
|
||||
history: (Array.isArray(history) ? history : []).map(item => {
|
||||
const amountNumber = Number(item.amount || 0)
|
||||
return {
|
||||
...item,
|
||||
amountNumber,
|
||||
/**
|
||||
* Purpose: amountText supports index.js by holding or executing the amount text 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.
|
||||
*/
|
||||
amountText: `${amountNumber > 0 ? '+' : ''}¥${money(amountNumber)}`,
|
||||
/**
|
||||
* Purpose: sceneText supports index.js by holding or executing the scene text 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.
|
||||
*/
|
||||
sceneText: sceneText(item.changeScene || item.type),
|
||||
/**
|
||||
* Purpose: changeTimeText supports index.js by holding or executing the change time text 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.
|
||||
*/
|
||||
changeTimeText: formatTime(item.changeTime)
|
||||
}
|
||||
}),
|
||||
/**
|
||||
* Purpose: rechargePlans supports index.js by holding or executing the recharge plans 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.
|
||||
*/
|
||||
rechargePlans: (Array.isArray(plans) ? plans : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: amountText supports index.js by holding or executing the amount text 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.
|
||||
*/
|
||||
amountText: `充 ${money(item.rechargeAmount)} 送 ${money(item.giftAmount)}`
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title 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.
|
||||
*/
|
||||
title: error.message || 'VIP 信息加载失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon 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.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
/**
|
||||
* 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: 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: 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 { buildProductCard } = require('../../utils/product')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
Reference in New Issue
Block a user