功能:同步小程序流程

This commit is contained in:
xiaowang
2026-05-23 18:45:41 +08:00
parent 844516988b
commit 30ae763e18
117 changed files with 8823 additions and 76 deletions
+44
View File
@@ -5,6 +5,10 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: sendVerificationCode supports auth.js by holding or executing the send verification code 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.
*/
sendVerificationCode(data) {
return request({
url: '/user/send-verification-code',
@@ -13,6 +17,10 @@ module.exports = {
})
},
/**
* Purpose: login supports auth.js by holding or executing the login 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.
*/
login(data) {
return request({
url: '/user/login',
@@ -21,6 +29,10 @@ module.exports = {
})
},
/**
* Purpose: phoneLogin supports auth.js by holding or executing the phone login 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.
*/
phoneLogin(data) {
return request({
url: '/user/phone-login',
@@ -29,6 +41,10 @@ module.exports = {
})
},
/**
* Purpose: wechatMiniAutoLogin supports auth.js by holding or executing the wechat mini auto login 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.
*/
wechatMiniAutoLogin(data) {
return request({
url: '/user/wechat-mini/auto-login',
@@ -37,6 +53,10 @@ module.exports = {
})
},
/**
* Purpose: wechatMiniPhoneLogin supports auth.js by holding or executing the wechat mini phone login 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.
*/
wechatMiniPhoneLogin(data) {
return request({
url: '/user/wechat-mini/phone-login',
@@ -45,6 +65,10 @@ module.exports = {
})
},
/**
* Purpose: confirmWechatMiniLogin supports auth.js by holding or executing the confirm wechat mini login 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.
*/
confirmWechatMiniLogin(data) {
return request({
url: '/user/wechat-mini/confirm-login',
@@ -53,6 +77,10 @@ module.exports = {
})
},
/**
* Purpose: register supports auth.js by holding or executing the register 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.
*/
register(data) {
return request({
url: '/user/register',
@@ -61,6 +89,10 @@ module.exports = {
})
},
/**
* Purpose: logout supports auth.js by holding or executing the logout 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.
*/
logout() {
return request({
url: '/user/logout',
@@ -68,6 +100,10 @@ module.exports = {
})
},
/**
* Purpose: switchShop supports auth.js by holding or executing the switch shop 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.
*/
switchShop(data) {
return request({
url: '/user/switch-shop',
@@ -76,6 +112,10 @@ module.exports = {
})
},
/**
* Purpose: resetPasswordByPhone supports auth.js by holding or executing the reset password by phone 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.
*/
resetPasswordByPhone(data) {
return request({
url: '/user/reset-password-by-phone',
@@ -84,6 +124,10 @@ module.exports = {
})
},
/**
* Purpose: getCurrentAgreements supports auth.js by holding or executing the get current agreements 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.
*/
getCurrentAgreements() {
return request({
url: '/legal-agreement/current',
+20
View File
@@ -5,6 +5,10 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: addToCart supports cart.js by holding or executing the add to cart 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.
*/
addToCart(data) {
return request({
url: '/cart/add',
@@ -13,6 +17,10 @@ module.exports = {
})
},
/**
* Purpose: removeFromCart supports cart.js by holding or executing the remove from cart 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.
*/
removeFromCart(productId) {
return request({
url: `/cart/remove/${productId}`,
@@ -20,6 +28,10 @@ module.exports = {
})
},
/**
* Purpose: updateCartQuantity supports cart.js by holding or executing the update cart quantity 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.
*/
updateCartQuantity(data) {
return request({
url: '/cart/update',
@@ -28,12 +40,20 @@ module.exports = {
})
},
/**
* Purpose: getCartList supports cart.js by holding or executing the get cart list page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
getCartList() {
return request({
url: '/cart/list'
})
},
/**
* Purpose: clearCart supports cart.js by holding or executing the clear cart 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.
*/
clearCart() {
return request({
url: '/cart/clear',
+12
View File
@@ -5,12 +5,20 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: listByProduct supports comment.js by holding or executing the list by product 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.
*/
listByProduct(productId) {
return request({
url: `/comment/list/product/${productId}`
})
},
/**
* Purpose: create supports comment.js by holding or executing the create 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.
*/
create(data) {
return request({
url: '/comment/create',
@@ -19,6 +27,10 @@ module.exports = {
})
},
/**
* Purpose: delete supports comment.js by holding or executing the delete 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.
*/
delete(id) {
return request({
url: `/comment/delete/${id}`,
+8
View File
@@ -5,6 +5,10 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: listUserCoupons supports coupon.js by holding or executing the list user coupons 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.
*/
listUserCoupons(status) {
return request({
url: '/coupon/user/list',
@@ -14,6 +18,10 @@ module.exports = {
})
},
/**
* Purpose: getAvailableCoupons supports coupon.js by holding or executing the get available coupons 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.
*/
getAvailableCoupons(productTags, productPrice, shopId) {
return request({
url: '/coupon/available',
+4
View File
@@ -5,6 +5,10 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: getSignedUrl supports file.js by holding or executing the get signed url 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.
*/
getSignedUrl(fileId, expiryTimeInMinutes) {
return request({
url: `/file/get-signed-url/${fileId}`,
+44
View File
@@ -5,6 +5,10 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: createOrder supports order.js by holding or executing the create order 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.
*/
createOrder(data) {
return request({
url: '/order/create',
@@ -13,24 +17,40 @@ module.exports = {
})
},
/**
* Purpose: getOrderList supports order.js by holding or executing the get order list page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
getOrderList() {
return request({
url: '/order/list'
})
},
/**
* Purpose: listMyPendingReviews supports order.js by holding or executing the list my pending reviews 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.
*/
listMyPendingReviews() {
return request({
url: '/order/review/my-pending'
})
},
/**
* Purpose: listOrderReviews supports order.js by holding or executing the list order reviews 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.
*/
listOrderReviews(orderId) {
return request({
url: `/order/${orderId}/reviews`
})
},
/**
* Purpose: submitArtistReview supports order.js by holding or executing the submit artist review page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
submitArtistReview(reviewId, data) {
return request({
url: `/order/review/${reviewId}/submit`,
@@ -39,6 +59,10 @@ module.exports = {
})
},
/**
* Purpose: getArtistChangeOptions supports order.js by holding or executing the get artist change options 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.
*/
getArtistChangeOptions(orderId, orderItemId) {
return request({
url: `/order/${orderId}/artist-change/options`,
@@ -48,6 +72,10 @@ module.exports = {
})
},
/**
* Purpose: requestArtistChange supports order.js by holding or executing the request artist change 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.
*/
requestArtistChange(data) {
return request({
url: '/order/artist-change/request',
@@ -56,12 +84,20 @@ module.exports = {
})
},
/**
* Purpose: listMyPendingArtistChangeRequests supports order.js by holding or executing the list my pending artist change requests 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.
*/
listMyPendingArtistChangeRequests() {
return request({
url: '/order/artist-change/my-pending'
})
},
/**
* Purpose: approveArtistChange supports order.js by holding or executing the approve artist change 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.
*/
approveArtistChange(requestId) {
return request({
url: `/order/artist-change/${requestId}/approve`,
@@ -70,6 +106,10 @@ module.exports = {
})
},
/**
* Purpose: rejectArtistChange supports order.js by holding or executing the reject artist change 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.
*/
rejectArtistChange(requestId, data) {
return request({
url: `/order/artist-change/${requestId}/reject`,
@@ -78,6 +118,10 @@ module.exports = {
})
},
/**
* Purpose: cancelOrder supports order.js by holding or executing the cancel order 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.
*/
cancelOrder(orderId) {
return request({
url: `/order/cancel/${orderId}`,
+12
View File
@@ -5,6 +5,10 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: likeProduct supports product-like.js by holding or executing the like product 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.
*/
likeProduct(productId) {
return request({
url: `/product-like/like/${productId}`,
@@ -12,6 +16,10 @@ module.exports = {
})
},
/**
* Purpose: unlikeProduct supports product-like.js by holding or executing the unlike product 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.
*/
unlikeProduct(productId) {
return request({
url: `/product-like/unlike/${productId}`,
@@ -19,6 +27,10 @@ module.exports = {
})
},
/**
* Purpose: checkLikeStatus supports product-like.js by holding or executing the check like status 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.
*/
checkLikeStatus(productId) {
return request({
url: `/product-like/check/${productId}`
+20
View File
@@ -5,6 +5,10 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: getProductPage supports product.js by holding or executing the get product page 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.
*/
getProductPage(params) {
return request({
url: '/product/list/page',
@@ -12,24 +16,40 @@ module.exports = {
})
},
/**
* Purpose: getAllProducts supports product.js by holding or executing the get all products 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.
*/
getAllProducts() {
return request({
url: '/product/list/all'
})
},
/**
* Purpose: getProductById supports product.js by holding or executing the get product by id 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.
*/
getProductById(id) {
return request({
url: `/product/get/${id}`
})
},
/**
* Purpose: getProductsByTag supports product.js by holding or executing the get products by tag 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.
*/
getProductsByTag(tag) {
return request({
url: `/product/list/tag/${encodeURIComponent(tag)}`
})
},
/**
* Purpose: searchProducts supports product.js by holding or executing the search products 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.
*/
searchProducts(keyword) {
return request({
url: '/product/list/search',
+12
View File
@@ -5,18 +5,30 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: getPublicShops supports shop.js by holding or executing the get public shops 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.
*/
getPublicShops() {
return request({
url: '/shop/list/public'
})
},
/**
* Purpose: getShopsSimple supports shop.js by holding or executing the get shops simple 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.
*/
getShopsSimple() {
return request({
url: '/shop/list/simple'
})
},
/**
* Purpose: getShopById supports shop.js by holding or executing the get shop by id 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.
*/
getShopById(id) {
return request({
url: `/shop/get/${id}`
+4
View File
@@ -5,6 +5,10 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: getAllTags supports tag.js by holding or executing the get all tags 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.
*/
getAllTags() {
return request({
url: '/tag/list/all'
+100
View File
@@ -3,9 +3,17 @@
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
*/
const request = require('../utils/request')
/**
* Purpose: actionGuard supports user.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 { API_BASE_URL, REQUEST_TIMEOUT } = require('../utils/config')
/**
* Purpose: normalizeUploadResponse supports user.js by holding or executing the normalize upload response 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 normalizeUploadResponse(response) {
if (!response) {
throw new Error('头像上传失败')
@@ -37,6 +45,10 @@ function normalizeUploadResponse(response) {
}
module.exports = {
/**
* Purpose: getUserInfo supports user.js by holding or executing the get user info 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.
*/
getUserInfo() {
return request({
url: '/user/info'
@@ -51,30 +63,50 @@ module.exports = {
})
},
/**
* Purpose: getMyBalanceHistory supports user.js by holding or executing the get my balance history 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.
*/
getMyBalanceHistory() {
return request({
url: '/user/balance/history/me'
})
},
/**
* Purpose: listMyMessages supports user.js by holding or executing the list my messages 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.
*/
listMyMessages() {
return request({
url: '/system-message/my/list'
})
},
/**
* Purpose: listMyPopupMessages supports user.js by holding or executing the list my popup messages 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.
*/
listMyPopupMessages() {
return request({
url: '/system-message/my/popup'
})
},
/**
* Purpose: getMyUnreadMessageCount supports user.js by holding or executing the get my unread message count 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.
*/
getMyUnreadMessageCount() {
return request({
url: '/system-message/my/unread-count'
})
},
/**
* Purpose: markMessagePopupShown supports user.js by holding or executing the mark message popup shown 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.
*/
markMessagePopupShown(id) {
return request({
url: `/system-message/my/${id}/popup-shown`,
@@ -83,6 +115,10 @@ module.exports = {
})
},
/**
* Purpose: markMessageRead supports user.js by holding or executing the mark message read 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.
*/
markMessageRead(id) {
return request({
url: `/system-message/my/${id}/read`,
@@ -91,6 +127,10 @@ module.exports = {
})
},
/**
* Purpose: listMyAnnouncements supports user.js by holding or executing the list my announcements 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.
*/
listMyAnnouncements() {
return request({
url: '/announcement/my/list'
@@ -104,18 +144,30 @@ module.exports = {
})
},
/**
* Purpose: getShopManagerContact supports user.js by holding or executing the get shop manager contact 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.
*/
getShopManagerContact(shopId) {
return request({
url: `/contact-info/shop/${shopId}/manager`
})
},
/**
* Purpose: getProductArtistContact supports user.js by holding or executing the get product artist contact 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.
*/
getProductArtistContact(productId, artistId) {
return request({
url: `/contact-info/product/${productId}/artist/${artistId}`
})
},
/**
* Purpose: getOrderArtistContact supports user.js by holding or executing the get order artist contact 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.
*/
getOrderArtistContact(orderId, artistId) {
return request({
url: `/contact-info/order/${orderId}/artist`,
@@ -123,6 +175,10 @@ module.exports = {
})
},
/**
* Purpose: updateUserInfo supports user.js by holding or executing the update user info 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.
*/
updateUserInfo(data) {
return request({
url: '/user/update',
@@ -131,6 +187,10 @@ module.exports = {
})
},
/**
* Purpose: updatePassword supports user.js by holding or executing the update password 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.
*/
updatePassword(data) {
return request({
url: '/user/password',
@@ -139,6 +199,10 @@ module.exports = {
})
},
/**
* Purpose: bindPhone supports user.js by holding or executing the bind phone 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.
*/
bindPhone(data) {
return request({
url: '/user/bind-phone',
@@ -147,6 +211,10 @@ module.exports = {
})
},
/**
* Purpose: updatePhone supports user.js by holding or executing the update phone 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.
*/
updatePhone(data) {
return request({
url: '/user/phone',
@@ -155,6 +223,10 @@ module.exports = {
})
},
/**
* Purpose: deactivateAccount supports user.js by holding or executing the deactivate account 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.
*/
deactivateAccount() {
return request({
url: '/user/deactivate',
@@ -162,6 +234,10 @@ module.exports = {
})
},
/**
* Purpose: uploadAvatar supports user.js by holding or executing the upload avatar 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.
*/
uploadAvatar(filePath) {
const signedHeaders = request.buildSignatureHeaders({
url: '/user/upload-avatar',
@@ -192,36 +268,60 @@ module.exports = {
})
},
/**
* Purpose: checkAccountAvailability supports user.js by holding or executing the check account availability 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.
*/
checkAccountAvailability(account) {
return request({
url: `/user/check/account/${encodeURIComponent(account)}`
})
},
/**
* Purpose: checkLoginAccountAvailability supports user.js by holding or executing the check login account availability 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.
*/
checkLoginAccountAvailability(account) {
return request({
url: `/user/check/login-account/${encodeURIComponent(account)}`
})
},
/**
* Purpose: getLoginShopsByAccount supports user.js by holding or executing the get login shops by account 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.
*/
getLoginShopsByAccount(account) {
return request({
url: `/user/check/login-shops/account/${encodeURIComponent(account)}`
})
},
/**
* Purpose: getLoginShopsByPhone supports user.js by holding or executing the get login shops by phone 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.
*/
getLoginShopsByPhone(phone) {
return request({
url: `/user/check/login-shops/phone/${encodeURIComponent(phone)}`
})
},
/**
* Purpose: checkPhoneAvailability supports user.js by holding or executing the check phone availability 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.
*/
checkPhoneAvailability(phone) {
return request({
url: `/user/check/phone/${encodeURIComponent(phone)}`
})
},
/**
* Purpose: sendVerificationCode supports user.js by holding or executing the send verification code 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.
*/
sendVerificationCode(data) {
return request({
url: '/user/send-verification-code',
+16
View File
@@ -5,6 +5,10 @@
const request = require('../utils/request')
module.exports = {
/**
* Purpose: addToWishlist supports wishlist.js by holding or executing the add to wishlist 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.
*/
addToWishlist(productId) {
return request({
url: '/wishlist/add',
@@ -15,6 +19,10 @@ module.exports = {
})
},
/**
* Purpose: removeFromWishlist supports wishlist.js by holding or executing the remove from wishlist 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.
*/
removeFromWishlist(productId) {
return request({
url: '/wishlist/remove',
@@ -25,6 +33,10 @@ module.exports = {
})
},
/**
* Purpose: checkWishlist supports wishlist.js by holding or executing the check wishlist 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.
*/
checkWishlist(productId) {
return request({
url: '/wishlist/check',
@@ -34,6 +46,10 @@ module.exports = {
})
},
/**
* Purpose: getWishlist supports wishlist.js by holding or executing the get wishlist 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.
*/
getWishlist() {
return request({
url: '/wishlist/list'
+142
View File
@@ -1,10 +1,47 @@
/**
* Purpose: authApi supports app.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: cartApi supports app.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: shopApi supports app.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 app.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 app.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: idleSession supports app.js by holding or executing the idle session 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 idleSession = require('./utils/idle-session')
/**
* Purpose: theme supports app.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: navigation opens popup-message action paths from the global App lifecycle.
* Usage: call openSystemMessage after marking a popup message as shown.
*/
const navigation = require('./utils/navigation')
/**
* Purpose: file supports app.js by holding or executing the file 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 file = require('./utils/file')
const { IDLE_TIMEOUT_MS, IDLE_WARNING_MS } = require('./utils/config')
@@ -19,6 +56,44 @@ App({
wechatMiniAutoLoginState: 'idle'
},
/**
* Purpose: checkPopupMessages globally mirrors Web popup-message behavior across mini-program pages.
* Usage: call it from onShow after login so pending popup messages are shown even outside the profile page.
*/
async checkPopupMessages() {
if (!auth.isLoggedIn() || this._checkingPopupMessages || !this._appShownOnce) {
return
}
this._checkingPopupMessages = true
try {
const messages = await userApi.listMyPopupMessages()
for (const item of messages || []) {
await new Promise(resolve => {
wx.showModal({
title: item.title || '消息通知',
content: item.content || '',
showCancel: false,
confirmText: navigation.buildMessageActionPath(item) ? '去查看' : '我知道了',
complete: resolve
})
})
await userApi.markMessagePopupShown(item.id)
const opened = await navigation.openSystemMessage(item)
if (opened) {
break
}
}
} catch (error) {
console.error('加载待弹窗消息失败', error)
} finally {
this._checkingPopupMessages = false
}
},
/**
* Purpose: onLaunch supports app.js by holding or executing the on launch 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.
*/
onLaunch() {
idleSession.init({
timeoutMs: IDLE_TIMEOUT_MS,
@@ -32,14 +107,28 @@ App({
}
},
/**
* Purpose: onShow supports app.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() {
idleSession.onAppShow()
this._appShownOnce = true
this.checkPopupMessages()
},
/**
* Purpose: onHide supports app.js by holding or executing the on hide 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.
*/
onHide() {
idleSession.onAppHide()
},
/**
* Purpose: bootstrapSession supports app.js by holding or executing the bootstrap session 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.
*/
bootstrapSession() {
const userInfo = auth.getStoredUserInfo()
const isLoggedIn = auth.isLoggedIn()
@@ -91,6 +180,10 @@ App({
return this._wechatMiniAutoLoginPromise
},
/**
* Purpose: handleWechatMiniLoginResult supports app.js by holding or executing the handle wechat mini login result 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.
*/
handleWechatMiniLoginResult(result, options) {
const config = options || {}
const status = result && result.status ? result.status : ''
@@ -125,6 +218,10 @@ App({
return false
},
/**
* Purpose: requestWechatMiniCode supports app.js by holding or executing the request wechat mini code 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.
*/
requestWechatMiniCode() {
return new Promise((resolve, reject) => {
wx.login({
@@ -140,28 +237,52 @@ App({
})
},
/**
* Purpose: isWechatMiniAutoLoginPending supports app.js by holding or executing the is wechat mini auto login pending 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.
*/
isWechatMiniAutoLoginPending() {
return this.globalData.wechatMiniAutoLoginState === 'pending'
},
/**
* Purpose: waitForWechatMiniAutoLogin supports app.js by holding or executing the wait for wechat mini auto login 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.
*/
waitForWechatMiniAutoLogin() {
return this._wechatMiniAutoLoginPromise || Promise.resolve(auth.isLoggedIn())
},
/**
* Purpose: setPendingWechatMiniLogin supports app.js by holding or executing the set pending wechat mini login 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.
*/
setPendingWechatMiniLogin(payload) {
this.globalData.pendingWechatMiniLogin = payload || null
},
/**
* Purpose: consumePendingWechatMiniLogin supports app.js by holding or executing the consume pending wechat mini login 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.
*/
consumePendingWechatMiniLogin() {
const pending = this.globalData.pendingWechatMiniLogin
this.globalData.pendingWechatMiniLogin = null
return pending
},
/**
* Purpose: clearPendingWechatMiniLogin supports app.js by holding or executing the clear pending wechat mini login 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.
*/
clearPendingWechatMiniLogin() {
this.globalData.pendingWechatMiniLogin = null
},
/**
* Purpose: setUserSession supports app.js by holding or executing the set user session 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.
*/
setUserSession(payload) {
auth.setSession(payload)
this.globalData.userInfo = auth.getStoredUserInfo()
@@ -173,8 +294,13 @@ App({
}
this.updateCartBadge()
this.checkPopupMessages()
},
/**
* Purpose: refreshUserInfo supports app.js by holding or executing the refresh user info 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.
*/
refreshUserInfo(userInfo) {
auth.updateStoredUserInfo(userInfo)
this.globalData.userInfo = userInfo
@@ -186,6 +312,10 @@ App({
}
},
/**
* Purpose: clearUserSession supports app.js by holding or executing the clear user session 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.
*/
clearUserSession() {
auth.clearSession()
this.globalData.userInfo = null
@@ -194,6 +324,10 @@ App({
this.clearCartBadge()
},
/**
* Purpose: setShopTheme supports app.js by holding or executing the set shop theme 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.
*/
setShopTheme(shop) {
const resolvedTheme = theme.resolveShopTheme(shop)
this.globalData.shopTheme = resolvedTheme
@@ -236,6 +370,10 @@ App({
}
},
/**
* Purpose: syncThemeToCurrentPages supports app.js by holding or executing the sync theme to current pages 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.
*/
syncThemeToCurrentPages() {
const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : []
const data = theme.pageThemeData(this.globalData.shopTheme)
@@ -305,6 +443,10 @@ App({
}
},
/**
* Purpose: clearCartBadge supports app.js by holding or executing the clear cart badge 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.
*/
clearCartBadge() {
this.globalData.cartCount = 0
wx.removeTabBarBadge({
@@ -1,3 +1,7 @@
/**
* Purpose: navigation supports navigation-bar.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')
Component({
@@ -70,10 +74,26 @@ Component({
this.updateResolvedBack()
},
},
/**
* Purpose: data supports navigation-bar.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: displayStyle supports navigation-bar.js by holding or executing the display style 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.
*/
displayStyle: '',
/**
* Purpose: resolvedShowBack supports navigation-bar.js by holding or executing the resolved show back 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.
*/
resolvedShowBack: false,
},
/**
* Purpose: lifetimes supports navigation-bar.js by holding or executing the lifetimes 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.
*/
lifetimes: {
attached() {
const rect = wx.getMenuButtonBoundingClientRect()
@@ -87,14 +107,34 @@ Component({
const windowWidth = windowInfo.windowWidth || deviceInfo.windowWidth || 375
this.setData({
/**
* Purpose: ios supports navigation-bar.js by holding or executing the ios 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.
*/
ios: !isAndroid,
/**
* Purpose: innerPaddingRight supports navigation-bar.js by holding or executing the inner padding right 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.
*/
innerPaddingRight: `padding-right: ${windowWidth - rect.left}px`,
/**
* Purpose: leftWidth supports navigation-bar.js by holding or executing the left width 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.
*/
leftWidth: `width: ${windowWidth - rect.left}px`,
/**
* Purpose: safeAreaTop supports navigation-bar.js by holding or executing the safe area top 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.
*/
safeAreaTop: isDevtools || isAndroid ? `height: calc(var(--height) + ${top}px); padding-top: ${top}px` : '',
})
this.updateResolvedBack()
},
},
/**
* Purpose: methods supports navigation-bar.js by holding or executing the methods 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.
*/
methods: {
updateResolvedBack() {
const resolvedShowBack = !this.data.isTabPage && Boolean(this.data.showBack && this.data.back)
@@ -118,6 +158,10 @@ Component({
const pages = getCurrentPages()
if (this.data.delta && pages.length > this.data.delta) {
wx.navigateBack({
/**
* Purpose: delta supports navigation-bar.js by holding or executing the delta 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.
*/
delta: this.data.delta,
})
return
@@ -127,6 +171,10 @@ Component({
},
home() {
wx.switchTab({
/**
* Purpose: url supports navigation-bar.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',
})
},
+56
View File
@@ -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,
+56 -5
View File
@@ -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()
},
+20
View File
@@ -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} 折`
+28
View File
@@ -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')
/**
+16
View File
@@ -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'
})
},
+89 -6
View File
@@ -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() {},
/**
+147 -2
View File
@@ -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) {
+42 -42
View File
@@ -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>
+6
View File
@@ -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 {
+80 -4
View File
@@ -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 {
+44
View File
@@ -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'
/**
+42 -1
View File
@@ -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
}
+32
View File
@@ -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'
/**
+105 -5
View File
@@ -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>
+17 -1
View File
@@ -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;
+116
View File
@@ -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'
})
}
+24
View File
@@ -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')
+32
View File
@@ -1,5 +1,13 @@
/**
* Purpose: inflightScopes supports action-guard.js by holding or executing the inflight scopes 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 inflightScopes = new Map()
/**
* Purpose: resolveScopeId supports action-guard.js by holding or executing the resolve scope 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 resolveScopeId(scope) {
if (scope && typeof scope === 'string') {
return scope
@@ -17,6 +25,10 @@ function resolveScopeId(scope) {
return 'global'
}
/**
* Purpose: getScopeMap supports action-guard.js by holding or executing the get scope map 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 getScopeMap(scopeId) {
if (!inflightScopes.has(scopeId)) {
inflightScopes.set(scopeId, new Map())
@@ -24,6 +36,10 @@ function getScopeMap(scopeId) {
return inflightScopes.get(scopeId)
}
/**
* Purpose: createGuardError supports action-guard.js by holding or executing the create guard error 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 createGuardError(message, scopeId, actionKey) {
const error = new Error(message || '\u64cd\u4f5c\u8fdb\u884c\u4e2d\uff0c\u8bf7\u52ff\u91cd\u590d\u70b9\u51fb')
error.isActionGuardError = true
@@ -32,6 +48,10 @@ function createGuardError(message, scopeId, actionKey) {
return error
}
/**
* Purpose: run supports action-guard.js by holding or executing the run 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 run(scope, actionKey, task, options) {
const scopeId = resolveScopeId(scope)
const normalizedKey = String(actionKey || 'default')
@@ -52,6 +72,10 @@ async function run(scope, actionKey, task, options) {
}
}
/**
* Purpose: isRunning supports action-guard.js by holding or executing the is running 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 isRunning(scope, actionKey) {
const scopeId = resolveScopeId(scope)
const scopeMap = inflightScopes.get(scopeId)
@@ -61,10 +85,18 @@ function isRunning(scope, actionKey) {
return Boolean(scopeMap.get(String(actionKey || 'default')))
}
/**
* Purpose: clearScope supports action-guard.js by holding or executing the clear scope 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 clearScope(scope) {
inflightScopes.delete(resolveScopeId(scope))
}
/**
* Purpose: isGuardError supports action-guard.js by holding or executing the is guard error 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 isGuardError(error) {
return Boolean(error && error.isActionGuardError)
}
+56
View File
@@ -1,6 +1,14 @@
const { STORAGE_KEYS, getStorage, removeStorage, setStorage } = require('./storage')
/**
* Purpose: SIGNED_URL_SAFE_BUFFER_MS supports auth.js by holding or executing the signed url safe buffer ms 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 SIGNED_URL_SAFE_BUFFER_MS = 60 * 1000
/**
* Purpose: parseSignedUrlExpireAt supports auth.js by holding or executing the parse signed url expire at 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 parseSignedUrlExpireAt(url) {
const rawUrl = String(url || '').trim()
if (!rawUrl || rawUrl.indexOf('?') < 0) {
@@ -42,6 +50,10 @@ function parseSignedUrlExpireAt(url) {
return 0
}
/**
* Purpose: sanitizeStoredUserInfo supports auth.js by holding or executing the sanitize stored user info 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 sanitizeStoredUserInfo(userInfo) {
if (!userInfo || typeof userInfo !== 'object') {
return userInfo
@@ -57,14 +69,26 @@ function sanitizeStoredUserInfo(userInfo) {
return nextUserInfo
}
/**
* Purpose: getAccessToken supports auth.js by holding or executing the get access token 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 getAccessToken() {
return getStorage(STORAGE_KEYS.ACCESS_TOKEN, '')
}
/**
* Purpose: getRefreshToken supports auth.js by holding or executing the get refresh token 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 getRefreshToken() {
return getStorage(STORAGE_KEYS.REFRESH_TOKEN, '')
}
/**
* Purpose: getStoredUserInfo supports auth.js by holding or executing the get stored user info 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 getStoredUserInfo() {
const userInfo = sanitizeStoredUserInfo(getStorage(STORAGE_KEYS.USER_INFO, null))
if (userInfo) {
@@ -73,18 +97,34 @@ function getStoredUserInfo() {
return userInfo
}
/**
* Purpose: getNeedSetPassword supports auth.js by holding or executing the get need set password 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 getNeedSetPassword() {
return Boolean(getStorage(STORAGE_KEYS.NEED_SET_PASSWORD, false))
}
/**
* Purpose: getPreferredMiniLoginShopId supports auth.js by holding or executing the get preferred mini login shop 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 getPreferredMiniLoginShopId() {
return getStorage(STORAGE_KEYS.PREFERRED_MINI_LOGIN_SHOP_ID, '')
}
/**
* Purpose: isLoggedIn supports auth.js by holding or executing the is logged in 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 isLoggedIn() {
return Boolean(getAccessToken())
}
/**
* Purpose: setSession supports auth.js by holding or executing the set session 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 setSession(payload) {
if (!payload || !payload.accessToken || !payload.refreshToken) {
return
@@ -104,6 +144,10 @@ function setSession(payload) {
}
}
/**
* Purpose: updateStoredUserInfo supports auth.js by holding or executing the update stored user info 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 updateStoredUserInfo(userInfo) {
if (!userInfo) {
removeStorage(STORAGE_KEYS.USER_INFO)
@@ -113,6 +157,10 @@ function updateStoredUserInfo(userInfo) {
setStorage(STORAGE_KEYS.USER_INFO, sanitizeStoredUserInfo(userInfo))
}
/**
* Purpose: setNeedSetPassword supports auth.js by holding or executing the set need set password 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 setNeedSetPassword(value) {
if (value) {
setStorage(STORAGE_KEYS.NEED_SET_PASSWORD, true)
@@ -122,6 +170,10 @@ function setNeedSetPassword(value) {
removeStorage(STORAGE_KEYS.NEED_SET_PASSWORD)
}
/**
* Purpose: clearSession supports auth.js by holding or executing the clear session 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 clearSession() {
removeStorage(STORAGE_KEYS.ACCESS_TOKEN)
removeStorage(STORAGE_KEYS.REFRESH_TOKEN)
@@ -129,6 +181,10 @@ function clearSession() {
removeStorage(STORAGE_KEYS.NEED_SET_PASSWORD)
}
/**
* Purpose: setPreferredMiniLoginShopId supports auth.js by holding or executing the set preferred mini login shop 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 setPreferredMiniLoginShopId(shopId) {
if (shopId === undefined || shopId === null || shopId === '') {
removeStorage(STORAGE_KEYS.PREFERRED_MINI_LOGIN_SHOP_ID)
+44
View File
@@ -1,15 +1,39 @@
/**
* Purpose: CACHE_PREFIX supports cache.js by holding or executing the cache prefix 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_PREFIX = 'miniCache:'
/**
* Purpose: memoryCache supports cache.js by holding or executing the memory 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 memoryCache = {}
/**
* Purpose: inflightCache supports cache.js by holding or executing the inflight 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 inflightCache = {}
/**
* Purpose: now supports cache.js by holding or executing the now 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 now() {
return Date.now()
}
/**
* Purpose: buildKey supports cache.js by holding or executing the build 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 buildKey(key) {
return `${CACHE_PREFIX}${key}`
}
/**
* Purpose: clearExpiredEntry supports cache.js by holding or executing the clear expired entry 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 clearExpiredEntry(key, entry) {
if (!entry) {
return
@@ -22,6 +46,10 @@ function clearExpiredEntry(key, entry) {
}
}
/**
* Purpose: getCache supports cache.js by holding or executing the get cache 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 getCache(key, defaultValue) {
if (!key) {
return defaultValue
@@ -45,6 +73,10 @@ function getCache(key, defaultValue) {
return defaultValue
}
/**
* Purpose: setCache supports cache.js by holding or executing the set cache 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 setCache(key, value, ttlMs) {
if (!key) {
return value
@@ -61,6 +93,10 @@ function setCache(key, value, ttlMs) {
return value
}
/**
* Purpose: removeCache supports cache.js by holding or executing the remove cache 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 removeCache(key) {
if (!key) {
return
@@ -71,6 +107,10 @@ function removeCache(key) {
} catch (error) {}
}
/**
* Purpose: removeByPrefix supports cache.js by holding or executing the remove by prefix 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 removeByPrefix(prefix) {
Object.keys(memoryCache).forEach(key => {
if (key.startsWith(prefix)) {
@@ -82,6 +122,10 @@ function removeByPrefix(prefix) {
})
}
/**
* Purpose: remember supports cache.js by holding or executing the remember 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 remember(key, ttlMs, loader) {
const cached = getCache(key, undefined)
if (cached !== undefined) {
+56
View File
@@ -1,3 +1,7 @@
/**
* Purpose: safeRequire supports config.js by holding or executing the safe require 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 safeRequire(modulePath) {
try {
return require(modulePath)
@@ -6,6 +10,10 @@ function safeRequire(modulePath) {
}
}
/**
* Purpose: getEnvVersion supports config.js by holding or executing the get env version 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 getEnvVersion() {
if (typeof wx === 'undefined') {
return 'develop'
@@ -30,6 +38,10 @@ function getEnvVersion() {
return 'develop'
}
/**
* Purpose: getRuntimePlatform supports config.js by holding or executing the get runtime platform 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 getRuntimePlatform() {
if (typeof wx === 'undefined') {
return 'devtools'
@@ -56,6 +68,10 @@ function getRuntimePlatform() {
return 'unknown'
}
/**
* Purpose: normalizeDomain supports config.js by holding or executing the normalize domain 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 normalizeDomain(value, fallbackValue) {
const target = String(value || fallbackValue || '').trim()
if (!target) {
@@ -64,6 +80,10 @@ function normalizeDomain(value, fallbackValue) {
return target.replace(/\/+$/, '')
}
/**
* Purpose: ensureHttps supports config.js by holding or executing the ensure https 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 ensureHttps(value, envVersion) {
if (!value) {
throw new Error(`Missing API domain for ${envVersion}`)
@@ -74,11 +94,31 @@ function ensureHttps(value, envVersion) {
return value
}
/**
* Purpose: localOverride supports config.js by holding or executing the local override 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 localOverride = safeRequire('./config.local')
/**
* Purpose: ENV_VERSION supports config.js by holding or executing the env version 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 ENV_VERSION = getEnvVersion()
/**
* Purpose: RUNTIME_PLATFORM supports config.js by holding or executing the runtime platform 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 RUNTIME_PLATFORM = getRuntimePlatform()
/**
* Purpose: IS_DEVTOOLS supports config.js by holding or executing the is devtools 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 IS_DEVTOOLS = RUNTIME_PLATFORM === 'devtools'
/**
* Purpose: DEFAULT_DOMAINS supports config.js by holding or executing the default domains 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 DEFAULT_DOMAINS = {
local: 'http://127.0.0.1:80',
tunnel: 'https://yunail.art',
@@ -87,13 +127,29 @@ const DEFAULT_DOMAINS = {
release: 'https://yunail.art'
}
/**
* Purpose: DOMAIN_MAP supports config.js by holding or executing the domain map 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 DOMAIN_MAP = {
...DEFAULT_DOMAINS,
...(localOverride.domains || {})
}
/**
* Purpose: DEFAULT_DEVELOP_TARGET supports config.js by holding or executing the default develop target 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 DEFAULT_DEVELOP_TARGET = IS_DEVTOOLS ? 'local' : 'dev-remote'
/**
* Purpose: DEVELOP_TARGET supports config.js by holding or executing the develop target 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 DEVELOP_TARGET = String(localOverride.developTarget || DEFAULT_DEVELOP_TARGET)
/**
* Purpose: API_DOMAIN supports config.js by holding or executing the api domain 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 API_DOMAIN = ensureHttps(
ENV_VERSION === 'develop'
? normalizeDomain(DOMAIN_MAP[DEVELOP_TARGET], DOMAIN_MAP['dev-remote'])
+36
View File
@@ -1,3 +1,7 @@
/**
* Purpose: utf8ToBytes supports crypto.js by holding or executing the utf8 to bytes 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 utf8ToBytes(text) {
const encoded = unescape(encodeURIComponent(String(text || '')))
const bytes = []
@@ -7,14 +11,26 @@ function utf8ToBytes(text) {
return bytes
}
/**
* Purpose: bytesToHex supports crypto.js by holding or executing the bytes to hex 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 bytesToHex(bytes) {
return (Array.isArray(bytes) ? bytes : []).map(item => item.toString(16).padStart(2, '0')).join('')
}
/**
* Purpose: rightRotate supports crypto.js by holding or executing the right rotate 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 rightRotate(value, amount) {
return (value >>> amount) | (value << (32 - amount))
}
/**
* Purpose: sha256Bytes supports crypto.js by holding or executing the sha256 bytes 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 sha256Bytes(messageBytes) {
const k = [
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
@@ -113,10 +129,18 @@ function sha256Bytes(messageBytes) {
return output
}
/**
* Purpose: sha256Hex supports crypto.js by holding or executing the sha256 hex 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 sha256Hex(text) {
return bytesToHex(sha256Bytes(utf8ToBytes(text)))
}
/**
* Purpose: hmacSha256Hex supports crypto.js by holding or executing the hmac sha256 hex 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 hmacSha256Hex(secret, message) {
let keyBytes = utf8ToBytes(secret)
if (keyBytes.length > 64) {
@@ -137,6 +161,10 @@ function hmacSha256Hex(secret, message) {
return bytesToHex(sha256Bytes(outer.concat(innerDigest)))
}
/**
* Purpose: buildCanonicalParams supports crypto.js by holding or executing the build canonical params 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 buildCanonicalParams(input) {
const source = input || {}
const keys = Object.keys(source)
@@ -154,6 +182,10 @@ function buildCanonicalParams(input) {
}).join('&')
}
/**
* Purpose: buildJsonPayload supports crypto.js by holding or executing the build json payload 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 buildJsonPayload(data) {
if (data === undefined || data === null || data === '') {
return ''
@@ -164,6 +196,10 @@ function buildJsonPayload(data) {
return JSON.stringify(data)
}
/**
* Purpose: randomNonce supports crypto.js by holding or executing the random nonce 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 randomNonce() {
return `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`
}
+8
View File
@@ -1,10 +1,18 @@
const { STORAGE_KEYS, getStorage, setStorage } = require('./storage')
/**
* Purpose: createDeviceId supports device.js by holding or executing the create device 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 createDeviceId() {
const randomText = Math.random().toString(36).slice(2, 10)
return `mini-device-${Date.now()}-${randomText}`
}
/**
* Purpose: getDeviceId supports device.js by holding or executing the get device 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 getDeviceId() {
let value = getStorage(STORAGE_KEYS.DEVICE_ID, '')
if (value) {
+54
View File
@@ -1,10 +1,22 @@
/**
* Purpose: fileApi supports file.js by holding or executing the file 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 fileApi = require('../api/file')
const { DEFAULT_PRODUCT_IMAGE } = require('./config')
const { CACHE_TTL } = require('./config')
const { splitCsv } = require('./format')
/**
* Purpose: urlCache supports file.js by holding or executing the url 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 urlCache = {}
/**
* Purpose: getSignedUrl supports file.js by holding or executing the get signed url 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 getSignedUrl(fileId) {
const key = String(fileId || '')
if (!key) {
@@ -24,6 +36,10 @@ async function getSignedUrl(fileId) {
return urlCache[key].value
}
/**
* Purpose: extractLegacyFileId supports file.js by holding or executing the extract legacy file 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 extractLegacyFileId(value) {
const match = String(value || '')
.replace(/<[^>]*>/g, '')
@@ -32,6 +48,10 @@ function extractLegacyFileId(value) {
return match && match[1] ? match[1] : ''
}
/**
* Purpose: resolveImageList supports file.js by holding or executing the resolve image 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.
*/
async function resolveImageList(fileIds, fallbackImage) {
const ids = Array.isArray(fileIds) ? fileIds : splitCsv(fileIds)
if (!ids.length) {
@@ -49,6 +69,10 @@ async function resolveImageList(fileIds, fallbackImage) {
return urls.length ? urls : [fallbackImage || DEFAULT_PRODUCT_IMAGE]
}
/**
* Purpose: resolveLegacyImage supports file.js by holding or executing the resolve legacy image 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 resolveLegacyImage(value, fallbackImage) {
const fileId = extractLegacyFileId(value)
if (!fileId) {
@@ -63,11 +87,41 @@ async function resolveLegacyImage(value, fallbackImage) {
}
}
/**
* Purpose: previewImagesSafely opens wx.previewImage with a user-facing fallback when signed URLs expire or preview fails.
* Usage: pass the current image URL and full URL list from image tap handlers instead of calling wx.previewImage directly.
*/
function previewImagesSafely(current, urls) {
const list = (Array.isArray(urls) ? urls : [current]).filter(Boolean)
if (!current || !list.length) {
wx.showToast({
title: '图片暂不可预览',
icon: 'none'
})
return
}
wx.previewImage({
current,
urls: list,
fail: () => {
wx.showToast({
title: '图片预览失败,请稍后重试',
icon: 'none'
})
}
})
}
module.exports = {
getSignedUrl,
extractLegacyFileId,
resolveImageList,
resolveLegacyImage,
previewImagesSafely,
/**
* Purpose: clearSignedUrlCache supports file.js by holding or executing the clear signed url cache 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.
*/
clearSignedUrlCache(fileId) {
if (fileId === undefined || fileId === null || fileId === '') {
Object.keys(urlCache).forEach(key => delete urlCache[key])
+32
View File
@@ -1,9 +1,21 @@
/**
* Purpose: DRAFT_PREFIX supports form-draft.js by holding or executing the draft prefix 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 DRAFT_PREFIX = 'miniDraft:'
/**
* Purpose: buildDraftKey supports form-draft.js by holding or executing the build draft 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 buildDraftKey(key) {
return `${DRAFT_PREFIX}${key}`
}
/**
* Purpose: loadDraft supports form-draft.js by holding or executing the load 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 loadDraft(key, defaultValue) {
if (!key) {
return defaultValue
@@ -16,6 +28,10 @@ function loadDraft(key, defaultValue) {
}
}
/**
* Purpose: saveDraft supports form-draft.js by holding or executing the save 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 saveDraft(key, value) {
if (!key) {
return
@@ -28,6 +44,10 @@ function saveDraft(key, value) {
} catch (error) {}
}
/**
* Purpose: clearDraft supports form-draft.js by holding or executing the clear 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 clearDraft(key) {
if (!key) {
return
@@ -37,6 +57,10 @@ function clearDraft(key) {
} catch (error) {}
}
/**
* Purpose: getDraftValue supports form-draft.js by holding or executing the get draft value 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 getDraftValue(key, defaultValue) {
const record = loadDraft(key, null)
if (!record || typeof record !== 'object' || !Object.prototype.hasOwnProperty.call(record, 'value')) {
@@ -45,6 +69,10 @@ function getDraftValue(key, defaultValue) {
return record.value
}
/**
* Purpose: scheduleDraftSave supports form-draft.js by holding or executing the schedule draft save 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 scheduleDraftSave(context, key, buildValue, delay) {
if (!context) {
return
@@ -57,6 +85,10 @@ function scheduleDraftSave(context, key, buildValue, delay) {
}, delay || 300)
}
/**
* Purpose: clearDraftTimer supports form-draft.js by holding or executing the clear draft timer 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 clearDraftTimer(context) {
if (context && context.__draftSaveTimer) {
clearTimeout(context.__draftSaveTimer)
+44
View File
@@ -1,11 +1,23 @@
/**
* Purpose: formatPrice supports format.js by holding or executing the format price 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 formatPrice(value) {
return Number(value || 0).toFixed(2)
}
/**
* Purpose: getProductTitle supports format.js by holding or executing the get product title 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 getProductTitle(product) {
return (product && (product.title || product.name)) || '未命名作品'
}
/**
* Purpose: splitCsv supports format.js by holding or executing the split csv 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 splitCsv(value) {
return String(value || '')
.split(',')
@@ -13,10 +25,18 @@ function splitCsv(value) {
.filter(Boolean)
}
/**
* Purpose: sameId supports format.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) {
return String(left || '') === String(right || '')
}
/**
* Purpose: formatDateTime supports format.js by holding or executing the format date 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 formatDateTime(value) {
if (!value) {
return ''
@@ -24,6 +44,10 @@ function formatDateTime(value) {
return String(value).replace('T', ' ').slice(0, 16)
}
/**
* Purpose: parseAppointmentParts supports format.js by holding or executing the parse appointment parts 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 parseAppointmentParts(value) {
const text = formatDateTime(value)
if (!text) {
@@ -40,6 +64,10 @@ function parseAppointmentParts(value) {
}
}
/**
* Purpose: buildAppointmentValue supports format.js by holding or executing the build appointment value 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 buildAppointmentValue(date, clock) {
if (!date || !clock) {
return ''
@@ -47,6 +75,10 @@ function buildAppointmentValue(date, clock) {
return `${date} ${clock}:00`
}
/**
* Purpose: isPastAppointment supports format.js by holding or executing the is past appointment 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 isPastAppointment(value) {
if (!value) {
return false
@@ -54,6 +86,10 @@ function isPastAppointment(value) {
return new Date(String(value).replace(' ', 'T')).getTime() < Date.now() + 5 * 60 * 1000
}
/**
* Purpose: getMinDateText supports format.js by holding or executing the get min date 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 getMinDateText() {
const now = new Date()
const year = now.getFullYear()
@@ -62,6 +98,10 @@ function getMinDateText() {
return `${year}-${month}-${date}`
}
/**
* Purpose: getOrderStatusText supports format.js by holding or executing the get order status 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 getOrderStatusText(order) {
if (order && order.statusText) {
return order.statusText
@@ -77,6 +117,10 @@ function getOrderStatusText(order) {
return '已取消'
}
/**
* Purpose: getOrderStatusClass supports format.js by holding or executing the get order status class 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 getOrderStatusClass(order) {
const status = Number(order && order.status)
if (status === 1) {
+76
View File
@@ -1,11 +1,43 @@
/**
* Purpose: options supports idle-session.js by holding or executing the options page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let options = null
/**
* Purpose: timer supports idle-session.js by holding or executing the timer page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let timer = null
/**
* Purpose: warningShown supports idle-session.js by holding or executing the warning shown page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let warningShown = false
/**
* Purpose: loggingOut supports idle-session.js by holding or executing the logging out page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let loggingOut = false
/**
* Purpose: hiddenAt supports idle-session.js by holding or executing the hidden at page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let hiddenAt = 0
/**
* Purpose: lastActiveAt supports idle-session.js by holding or executing the last active at page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let lastActiveAt = Date.now()
/**
* Purpose: pagePatched supports idle-session.js by holding or executing the page patched page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let pagePatched = false
/**
* Purpose: shouldTrackMethod supports idle-session.js by holding or executing the should track method 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 shouldTrackMethod(name) {
return ![
'onHide',
@@ -15,6 +47,10 @@ function shouldTrackMethod(name) {
].includes(name)
}
/**
* Purpose: ensurePagePatched supports idle-session.js by holding or executing the ensure page patched 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 ensurePagePatched() {
if (pagePatched || typeof Page !== 'function') {
return
@@ -40,6 +76,10 @@ function ensurePagePatched() {
pagePatched = true
}
/**
* Purpose: start supports idle-session.js by holding or executing the start 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 start() {
stop()
if (!options) {
@@ -48,6 +88,10 @@ function start() {
timer = setInterval(check, 15000)
}
/**
* Purpose: stop supports idle-session.js by holding or executing the stop 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 stop() {
if (timer) {
clearInterval(timer)
@@ -55,10 +99,18 @@ function stop() {
}
}
/**
* Purpose: isLoggedIn supports idle-session.js by holding or executing the is logged in 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 isLoggedIn() {
return options && typeof options.isLoggedIn === 'function' ? Boolean(options.isLoggedIn()) : false
}
/**
* Purpose: markActive supports idle-session.js by holding or executing the mark active 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 markActive() {
if (!options || !isLoggedIn() || loggingOut) {
return
@@ -67,6 +119,10 @@ function markActive() {
warningShown = false
}
/**
* Purpose: onAppShow supports idle-session.js by holding or executing the on app show 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 onAppShow() {
if (!options) {
return
@@ -83,11 +139,19 @@ function onAppShow() {
start()
}
/**
* Purpose: onAppHide supports idle-session.js by holding or executing the on app hide 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 onAppHide() {
hiddenAt = Date.now()
stop()
}
/**
* Purpose: check supports idle-session.js by holding or executing the check 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 check() {
if (!options || !isLoggedIn() || loggingOut) {
return
@@ -102,6 +166,10 @@ function check() {
}
}
/**
* Purpose: showWarning supports idle-session.js by holding or executing the show warning 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 showWarning() {
if (!options || warningShown || loggingOut) {
return
@@ -129,6 +197,10 @@ function showWarning() {
})
}
/**
* Purpose: forceLogout supports idle-session.js by holding or executing the force logout 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 forceLogout() {
if (!options || loggingOut) {
return
@@ -145,6 +217,10 @@ function forceLogout() {
})
}
/**
* Purpose: init supports idle-session.js by holding or executing the init 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 init(nextOptions) {
options = nextOptions || null
lastActiveAt = Date.now()
+56
View File
@@ -1,8 +1,28 @@
/**
* Purpose: DEFAULT_CURSOR_SPACING supports keyboard-safe.js by holding or executing the default cursor spacing 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 DEFAULT_CURSOR_SPACING = 96
/**
* Purpose: DEFAULT_SPACER_EXTRA_RPX supports keyboard-safe.js by holding or executing the default spacer extra rpx 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 DEFAULT_SPACER_EXTRA_RPX = 48
/**
* Purpose: DEFAULT_SCROLL_DELAY supports keyboard-safe.js by holding or executing the default scroll delay 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 DEFAULT_SCROLL_DELAY = 32
/**
* Purpose: MAX_CURSOR_SPACING supports keyboard-safe.js by holding or executing the max cursor spacing 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 MAX_CURSOR_SPACING = 180
/**
* Purpose: getWindowWidth supports keyboard-safe.js by holding or executing the get window width 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 getWindowWidth() {
try {
if (typeof wx.getWindowInfo === 'function') {
@@ -18,10 +38,18 @@ function getWindowWidth() {
}
}
/**
* Purpose: pxToRpx supports keyboard-safe.js by holding or executing the px to rpx 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 pxToRpx(px) {
return Math.round((Number(px) || 0) * 750 / getWindowWidth())
}
/**
* Purpose: createKeyboardSafeData supports keyboard-safe.js by holding or executing the create keyboard safe 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.
*/
function createKeyboardSafeData(options = {}) {
const cursorSpacing = Number(options.cursorSpacing) > 0
? Math.round(Number(options.cursorSpacing))
@@ -36,6 +64,10 @@ function createKeyboardSafeData(options = {}) {
}
}
/**
* Purpose: clearKeyboardTimers supports keyboard-safe.js by holding or executing the clear keyboard timers 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 clearKeyboardTimers(state) {
if (!state) {
return
@@ -52,6 +84,10 @@ function clearKeyboardTimers(state) {
}
}
/**
* Purpose: queueAnchorScroll supports keyboard-safe.js by holding or executing the queue anchor scroll 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 queueAnchorScroll(page, anchorId) {
const state = page && page.__keyboardSafe
if (!page || !state || !anchorId) {
@@ -83,6 +119,10 @@ function queueAnchorScroll(page, anchorId) {
state.anchorTimer = setTimeout(updateAnchor, 0)
}
/**
* Purpose: attachKeyboardSafe supports keyboard-safe.js by holding or executing the attach keyboard safe 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 attachKeyboardSafe(page, options = {}) {
if (!page) {
return
@@ -141,6 +181,10 @@ function attachKeyboardSafe(page, options = {}) {
}
}
/**
* Purpose: detachKeyboardSafe supports keyboard-safe.js by holding or executing the detach keyboard safe 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 detachKeyboardSafe(page) {
if (!page || !page.__keyboardSafe) {
return
@@ -158,6 +202,10 @@ function detachKeyboardSafe(page) {
delete page.__keyboardSafe
}
/**
* Purpose: handleKeyboardFocus supports keyboard-safe.js by holding or executing the handle keyboard focus 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 handleKeyboardFocus(page, event) {
const state = page && page.__keyboardSafe
if (!page || !state) {
@@ -191,6 +239,10 @@ function handleKeyboardFocus(page, event) {
}
}
/**
* Purpose: resetKeyboardSafe supports keyboard-safe.js by holding or executing the reset keyboard safe 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 resetKeyboardSafe(page, options = {}) {
if (!page) {
return
@@ -215,6 +267,10 @@ function resetKeyboardSafe(page, options = {}) {
})
}
/**
* Purpose: handleKeyboardBlur supports keyboard-safe.js by holding or executing the handle keyboard blur 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 handleKeyboardBlur(page) {
const state = page && page.__keyboardSafe
if (!page || !state) {
+20
View File
@@ -1,5 +1,13 @@
/**
* Purpose: activeLoadingCount supports loading.js by holding or executing the active loading count page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let activeLoadingCount = 0
/**
* Purpose: showLoading supports loading.js by holding or executing the show loading 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 showLoading(options) {
const config = options || {}
activeLoadingCount += 1
@@ -14,6 +22,10 @@ function showLoading(options) {
})
}
/**
* Purpose: hideLoading supports loading.js by holding or executing the hide loading 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 hideLoading() {
activeLoadingCount = Math.max(0, activeLoadingCount - 1)
@@ -26,6 +38,10 @@ function hideLoading() {
})
}
/**
* Purpose: resetLoading supports loading.js by holding or executing the reset loading 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 resetLoading() {
activeLoadingCount = 0
wx.hideLoading({
@@ -33,6 +49,10 @@ function resetLoading() {
})
}
/**
* Purpose: runWithLoading supports loading.js by holding or executing the run with loading 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 runWithLoading(task, options) {
showLoading(options)
+141
View File
@@ -1,8 +1,20 @@
/**
* Purpose: auth supports navigation.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('./auth')
const { TAB_PAGES } = require('./config')
/**
* Purpose: waitingForAutoLoginNavigation supports navigation.js by holding or executing the waiting for auto login navigation page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let waitingForAutoLoginNavigation = false
/**
* Purpose: buildUrl supports navigation.js by holding or executing the build url 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 buildUrl(path, params) {
const query = Object.keys(params || {})
.filter(key => params[key] !== undefined && params[key] !== null && params[key] !== '')
@@ -12,6 +24,10 @@ function buildUrl(path, params) {
return query ? `${path}?${query}` : path
}
/**
* Purpose: getCurrentPageUrl supports navigation.js by holding or executing the get current page url 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 getCurrentPageUrl() {
const pages = getCurrentPages()
const current = pages[pages.length - 1]
@@ -22,11 +38,19 @@ function getCurrentPageUrl() {
return buildUrl(`/${current.route}`, current.options || {})
}
/**
* Purpose: isTabPage supports navigation.js by holding or executing the is tab page 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 isTabPage(path) {
const purePath = String(path || '').split('?')[0]
return TAB_PAGES.includes(purePath)
}
/**
* Purpose: navigate supports navigation.js by holding or executing the navigate 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 navigate(path, params) {
return new Promise((resolve, reject) => {
wx.navigateTo({
@@ -37,6 +61,10 @@ function navigate(path, params) {
})
}
/**
* Purpose: switchTab supports navigation.js by holding or executing the switch tab 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 switchTab(path) {
return new Promise((resolve, reject) => {
wx.switchTab({
@@ -47,6 +75,10 @@ function switchTab(path) {
})
}
/**
* Purpose: normalizeActionPath supports navigation.js by holding or executing the normalize action path 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 normalizeActionPath(value) {
const rawPath = String(value || '').trim()
if (!rawPath || !rawPath.startsWith('/') || rawPath.startsWith('//')) {
@@ -59,6 +91,28 @@ function normalizeActionPath(value) {
return `/pages/orders/index${query}`
}
if (rawPath.startsWith('/product/')) {
const id = rawPath.split('/')[2] || ''
return buildUrl('/pages/product-detail/index', { id })
}
if (rawPath.startsWith('/shop/')) {
const id = rawPath.split('/')[2] || ''
return buildUrl('/pages/shop-detail/index', { id })
}
if (rawPath === '/coupons' || rawPath.startsWith('/coupons?')) {
return rawPath.replace('/coupons', '/pages/coupons/index')
}
if (rawPath === '/vip-center' || rawPath.startsWith('/vip-center?')) {
return rawPath.replace('/vip-center', '/pages/vip-center/index')
}
if (rawPath === '/cart' || rawPath.startsWith('/cart?')) {
return rawPath.replace('/cart', '/pages/cart/index')
}
if (rawPath.startsWith('/pages/')) {
return rawPath
}
@@ -66,6 +120,47 @@ function normalizeActionPath(value) {
return ''
}
/**
* Purpose: buildMessageActionPath converts backend system-message business fields into a mini-program route.
* Usage: call it when actionPath is absent so review and artist-change popup messages still land on orders.
*/
function buildMessageActionPath(message) {
if (!message) {
return ''
}
const actionPath = normalizeActionPath(message.actionPath)
if (actionPath) {
return actionPath
}
const businessType = String(message.businessType || '').toUpperCase()
const businessId = message.businessId || ''
if (businessType === 'ORDER_ARTIST_REVIEW' || businessType === 'ORDER_ARTIST_CHANGE' || businessType === 'ORDER') {
return buildUrl('/pages/orders/index', businessId ? { orderId: businessId } : {})
}
if (businessType === 'PRODUCT') {
return buildUrl('/pages/product-detail/index', businessId ? { id: businessId } : {})
}
if (businessType === 'SHOP') {
return buildUrl('/pages/shop-detail/index', businessId ? { id: businessId } : {})
}
if (businessType === 'VIP') {
return '/pages/vip-center/index'
}
if (businessType === 'COUPON') {
return '/pages/coupons/index'
}
if (businessType === 'CART') {
return '/pages/cart/index'
}
return ''
}
/**
* Purpose: openActionPath supports navigation.js by holding or executing the open action path 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 openActionPath(value) {
const target = normalizeActionPath(value)
if (!target) {
@@ -86,6 +181,18 @@ function openActionPath(value) {
})
}
/**
* Purpose: openSystemMessage opens a backend system-message action using actionPath first and business fields as fallback.
* Usage: pass a full system-message record from popup or notification list taps.
*/
function openSystemMessage(message) {
return openActionPath(buildMessageActionPath(message))
}
/**
* Purpose: goBack supports navigation.js by holding or executing the go back 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 goBack(fallbackPath) {
const pages = getCurrentPages()
if (pages.length > 1) {
@@ -105,6 +212,10 @@ function goBack(fallbackPath) {
})
}
/**
* Purpose: parseQuery supports navigation.js by holding or executing the parse query 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 parseQuery(url) {
const queryString = String(url || '').split('?')[1] || ''
if (!queryString) {
@@ -122,6 +233,10 @@ function parseQuery(url) {
}, {})
}
/**
* Purpose: decodeRedirectValue supports navigation.js by holding or executing the decode redirect value 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 decodeRedirectValue(value) {
let current = String(value || '')
@@ -140,6 +255,10 @@ function decodeRedirectValue(value) {
return current
}
/**
* Purpose: redirectAfterLogin supports navigation.js by holding or executing the redirect after login 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 redirectAfterLogin(redirect) {
const target = redirect ? decodeRedirectValue(redirect) : ''
if (!target) {
@@ -166,12 +285,20 @@ function redirectAfterLogin(redirect) {
})
}
/**
* Purpose: openAuth supports navigation.js by holding or executing the open auth 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 openAuth(redirect) {
return navigate('/pages/auth/index', {
redirect: redirect || getCurrentPageUrl()
})
}
/**
* Purpose: showLoginToast supports navigation.js by holding or executing the show login toast 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 showLoginToast(actionText) {
wx.showToast({
title: `${actionText || '继续操作'}前请先登录`,
@@ -179,6 +306,10 @@ function showLoginToast(actionText) {
})
}
/**
* Purpose: scheduleOpenAuth supports navigation.js by holding or executing the schedule open auth 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 scheduleOpenAuth(actionText) {
showLoginToast(actionText)
setTimeout(() => {
@@ -186,6 +317,10 @@ function scheduleOpenAuth(actionText) {
}, 120)
}
/**
* Purpose: ensureLogin supports navigation.js by holding or executing the ensure login 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 ensureLogin(actionText) {
if (auth.isLoggedIn()) {
return true
@@ -226,11 +361,17 @@ module.exports = {
navigate,
switchTab,
normalizeActionPath,
buildMessageActionPath,
openActionPath,
openSystemMessage,
goBack,
redirectAfterLogin,
openAuth,
ensureLogin,
/**
* Purpose: openProducts supports navigation.js by holding or executing the open products 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.
*/
openProducts(filter) {
const app = getApp()
app.globalData.pendingProductFilter = filter || {}
+12
View File
@@ -2,6 +2,10 @@ const { formatPrice, getProductTitle } = require('./format')
const { resolveImageList } = require('./file')
const { DEFAULT_PRODUCT_IMAGE } = require('./config')
/**
* Purpose: getProductTags supports product.js by holding or executing the get product tags 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 getProductTags(product) {
if (Array.isArray(product && product.tagInfos)) {
return product.tagInfos
@@ -13,6 +17,10 @@ function getProductTags(product) {
return []
}
/**
* Purpose: buildProductCard supports product.js by holding or executing the build product card 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 buildProductCard(product) {
const images = await resolveImageList(product && product.imageFileIds, DEFAULT_PRODUCT_IMAGE)
return {
@@ -28,6 +36,10 @@ async function buildProductCard(product) {
}
}
/**
* Purpose: buildProductCards supports product.js by holding or executing the build product cards 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 buildProductCards(products) {
const list = Array.isArray(products) ? products : []
return Promise.all(list.map(item => buildProductCard(item)))
+116
View File
@@ -1,21 +1,73 @@
/**
* Purpose: auth supports request.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('./auth')
/**
* Purpose: actionGuard supports request.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('./action-guard')
/**
* Purpose: idleSession supports request.js by holding or executing the idle session 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 idleSession = require('./idle-session')
const { API_BASE_URL, REQUEST_TIMEOUT, ENABLE_REQUEST_SIGNING } = require('./config')
const { getDeviceId } = require('./device')
const { sha256Hex, hmacSha256Hex, buildCanonicalParams, buildJsonPayload, randomNonce } = require('./crypto')
/**
* Purpose: HEADER_TIMESTAMP supports request.js by holding or executing the header timestamp 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 HEADER_TIMESTAMP = 'X-Timestamp'
/**
* Purpose: HEADER_NONCE supports request.js by holding or executing the header nonce 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 HEADER_NONCE = 'X-Nonce'
/**
* Purpose: HEADER_SIGNATURE supports request.js by holding or executing the header signature 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 HEADER_SIGNATURE = 'X-Signature'
/**
* Purpose: HEADER_SIGNATURE_VERSION supports request.js by holding or executing the header signature version 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 HEADER_SIGNATURE_VERSION = 'X-Sign-Version'
/**
* Purpose: DEVICE_ID_HEADER supports request.js by holding or executing the device id header 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 DEVICE_ID_HEADER = 'X-Device-Id'
/**
* Purpose: isRefreshing supports request.js by holding or executing the is refreshing page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let isRefreshing = false
/**
* Purpose: requestQueue supports request.js by holding or executing the request queue page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let requestQueue = []
/**
* Purpose: redirectingToAuth supports request.js by holding or executing the redirecting to auth page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
let redirectingToAuth = false
/**
* Purpose: inflightRequests supports request.js by holding or executing the inflight requests 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 inflightRequests = {}
/**
* Purpose: buildRequestUrl supports request.js by holding or executing the build request url 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 buildRequestUrl(url, params) {
const query = Object.keys(params || {})
.filter(key => params[key] !== undefined && params[key] !== null && params[key] !== '')
@@ -26,6 +78,10 @@ function buildRequestUrl(url, params) {
return query ? `${target}${target.includes('?') ? '&' : '?'}${query}` : target
}
/**
* Purpose: isWhitelistedPath supports request.js by holding or executing the is whitelisted path 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 isWhitelistedPath(url) {
return [
'/user/login',
@@ -48,6 +104,10 @@ function isWhitelistedPath(url) {
].some(path => String(url || '').includes(path))
}
/**
* Purpose: normalizeError supports request.js by holding or executing the normalize error 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 normalizeError(message, statusCode, raw) {
const error = new Error(message || '\u8bf7\u6c42\u5931\u8d25')
error.statusCode = statusCode
@@ -55,6 +115,10 @@ function normalizeError(message, statusCode, raw) {
return error
}
/**
* Purpose: rawRequest supports request.js by holding or executing the raw request 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 rawRequest(options) {
idleSession.markActive()
return new Promise((resolve, reject) => {
@@ -66,6 +130,10 @@ function rawRequest(options) {
})
}
/**
* Purpose: queueRequest supports request.js by holding or executing the queue request 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 queueRequest(retry) {
return new Promise((resolve, reject) => {
requestQueue.push({
@@ -76,6 +144,10 @@ function queueRequest(retry) {
})
}
/**
* Purpose: flushQueue supports request.js by holding or executing the flush queue 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 flushQueue(error) {
const queue = requestQueue.slice()
requestQueue = []
@@ -89,6 +161,10 @@ function flushQueue(error) {
})
}
/**
* Purpose: redirectToAuth supports request.js by holding or executing the redirect to auth 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 redirectToAuth() {
if (redirectingToAuth) {
return
@@ -119,6 +195,10 @@ function redirectToAuth() {
}, 300)
}
/**
* Purpose: buildSignatureHeaders supports request.js by holding or executing the build signature headers 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 buildSignatureHeaders(options) {
const headers = {
[DEVICE_ID_HEADER]: getDeviceId()
@@ -156,6 +236,10 @@ function buildSignatureHeaders(options) {
return headers
}
/**
* Purpose: refreshToken supports request.js by holding or executing the refresh token 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 refreshToken() {
const refreshTokenValue = auth.getRefreshToken()
if (!refreshTokenValue) {
@@ -191,6 +275,10 @@ async function refreshToken() {
)
}
/**
* Purpose: handleUnauthorized supports request.js by holding or executing the handle unauthorized 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 handleUnauthorized(options) {
if (isWhitelistedPath(options.url)) {
throw normalizeError('\u8bf7\u6c42\u9700\u8981\u767b\u5f55\uff0c\u4f46\u5f53\u524d\u9875\u9762\u5141\u8bb8\u533f\u540d\u67e5\u770b', 401)
@@ -235,6 +323,10 @@ async function handleUnauthorized(options) {
}
}
/**
* Purpose: unwrapResponse supports request.js by holding or executing the unwrap response 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 unwrapResponse(res, options) {
idleSession.markActive()
@@ -261,6 +353,10 @@ async function unwrapResponse(res, options) {
return payload
}
/**
* Purpose: buildDedupeKey supports request.js by holding or executing the build dedupe 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 buildDedupeKey(options, method) {
if (options.skipDedupe) {
return ''
@@ -274,10 +370,18 @@ function buildDedupeKey(options, method) {
return ''
}
/**
* Purpose: isSafeMethod supports request.js by holding or executing the is safe method 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 isSafeMethod(method) {
return ['GET', 'HEAD', 'OPTIONS'].includes(method)
}
/**
* Purpose: buildActionFingerprint supports request.js by holding or executing the build action fingerprint 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 buildActionFingerprint(options, method) {
const paramsText = buildCanonicalParams(options.params)
const payloadText = isSafeMethod(method) ? '' : buildJsonPayload(options.data)
@@ -288,6 +392,10 @@ function buildActionFingerprint(options, method) {
].join('\n'))
}
/**
* Purpose: resolveRepeatMessage supports request.js by holding or executing the resolve repeat message 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 resolveRepeatMessage(url) {
const path = String(url || '')
if (
@@ -320,6 +428,10 @@ function resolveRepeatMessage(url) {
return '\u64cd\u4f5c\u8fdb\u884c\u4e2d\uff0c\u8bf7\u52ff\u91cd\u590d\u70b9\u51fb'
}
/**
* Purpose: buildActionGuardConfig supports request.js by holding or executing the build action guard config 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 buildActionGuardConfig(options, method) {
if (options.skipActionGuard || isSafeMethod(method)) {
return null
@@ -332,6 +444,10 @@ function buildActionGuardConfig(options, method) {
}
}
/**
* Purpose: request supports request.js by holding or executing the request 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 request(options) {
const method = String(options.method || 'GET').toUpperCase()
const dedupeKey = buildDedupeKey(options, method)
+16
View File
@@ -1,3 +1,7 @@
/**
* Purpose: STORAGE_KEYS supports storage.js by holding or executing the storage keys 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 STORAGE_KEYS = {
ACCESS_TOKEN: 'accessToken',
REFRESH_TOKEN: 'refreshToken',
@@ -7,6 +11,10 @@ const STORAGE_KEYS = {
DEVICE_ID: 'miniDeviceId'
}
/**
* Purpose: getStorage supports storage.js by holding or executing the get storage 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 getStorage(key, defaultValue) {
try {
const value = wx.getStorageSync(key)
@@ -16,10 +24,18 @@ function getStorage(key, defaultValue) {
}
}
/**
* Purpose: setStorage supports storage.js by holding or executing the set storage 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 setStorage(key, value) {
wx.setStorageSync(key, value)
}
/**
* Purpose: removeStorage supports storage.js by holding or executing the remove storage 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 removeStorage(key) {
wx.removeStorageSync(key)
}
+40
View File
@@ -1,5 +1,13 @@
/**
* Purpose: HEX_COLOR_PATTERN supports theme.js by holding or executing the hex color pattern 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 HEX_COLOR_PATTERN = /^#[0-9a-fA-F]{6}$/
/**
* Purpose: normalizeHexColor supports theme.js by holding or executing the normalize hex color 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 normalizeHexColor(value) {
if (!value || typeof value !== 'string') {
return ''
@@ -8,6 +16,10 @@ function normalizeHexColor(value) {
return HEX_COLOR_PATTERN.test(normalized) ? normalized.toUpperCase() : ''
}
/**
* Purpose: hexToRgb supports theme.js by holding or executing the hex to rgb 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 hexToRgb(color) {
const value = color.replace('#', '')
return {
@@ -17,14 +29,26 @@ function hexToRgb(color) {
}
}
/**
* Purpose: toHex supports theme.js by holding or executing the to hex 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 toHex(value) {
return Math.min(255, Math.max(0, value)).toString(16).padStart(2, '0').toUpperCase()
}
/**
* Purpose: rgbToHex supports theme.js by holding or executing the rgb to hex 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 rgbToHex(rgb) {
return `#${toHex(rgb.r)}${toHex(rgb.g)}${toHex(rgb.b)}`
}
/**
* Purpose: mixColor supports theme.js by holding or executing the mix color 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 mixColor(foreground, background, backgroundWeight) {
const fg = hexToRgb(foreground)
const bg = hexToRgb(background)
@@ -36,6 +60,10 @@ function mixColor(foreground, background, backgroundWeight) {
})
}
/**
* Purpose: buildStyleVars supports theme.js by holding or executing the build style vars 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 buildStyleVars(theme) {
const styleVars = [
`--theme-primary: ${theme.primaryColor};`,
@@ -58,6 +86,10 @@ function buildStyleVars(theme) {
return styleVars.join(' ')
}
/**
* Purpose: resolveShopTheme supports theme.js by holding or executing the resolve shop theme 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 resolveShopTheme(source) {
const themeSource = source || {}
const normalizedPrimaryColor = normalizeHexColor(themeSource.themePrimaryColor)
@@ -95,6 +127,10 @@ function resolveShopTheme(source) {
return theme
}
/**
* Purpose: DEFAULT_SHOP_THEME supports theme.js by holding or executing the default shop 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 DEFAULT_SHOP_THEME = {
primaryColor: '#C6597D',
secondaryColor: '#E9B7C7',
@@ -111,6 +147,10 @@ const DEFAULT_SHOP_THEME = {
DEFAULT_SHOP_THEME.styleVars = buildStyleVars(DEFAULT_SHOP_THEME)
/**
* Purpose: pageThemeData supports theme.js by holding or executing the page theme 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.
*/
function pageThemeData(theme, backgroundImageUrl) {
const resolved = theme || DEFAULT_SHOP_THEME
const themeData = backgroundImageUrl
+20
View File
@@ -1,6 +1,18 @@
/**
* Purpose: assert supports theme.test.js by holding or executing the assert 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 assert = require('assert')
/**
* Purpose: theme supports theme.test.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('./theme')
/**
* Purpose: customized supports theme.test.js by holding or executing the customized 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 customized = theme.resolveShopTheme({
themePrimaryColor: '#8b4f65',
themeSecondaryColor: '#f2c9d4',
@@ -19,10 +31,18 @@ assert.strictEqual(customized.backgroundImageFileId, 'bg-file')
assert.ok(customized.styleVars.includes('--theme-primary: #8B4F65;'))
assert.ok(customized.styleVars.includes('--theme-gradient: linear-gradient(135deg, #8B4F65 0%, #F2C9D4 100%);'))
/**
* Purpose: themedPageData supports theme.test.js by holding or executing the themed page data 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 themedPageData = theme.pageThemeData(customized, 'https://static.example.test/bg.jpg')
assert.ok(themedPageData.themeVars.includes('background-image: url("https://static.example.test/bg.jpg");'))
assert.strictEqual(themedPageData.theme.backgroundImageUrl, 'https://static.example.test/bg.jpg')
/**
* Purpose: fallback supports theme.test.js by holding or executing the fallback 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 fallback = theme.resolveShopTheme({
themePrimaryColor: '#fff',
themeSecondaryColor: 'blue'