功能:同步小程序流程
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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}`,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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}`,
|
||||
|
||||
@@ -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}`,
|
||||
|
||||
@@ -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}`
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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}`
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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',
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1,9 +1,37 @@
|
||||
/**
|
||||
* Purpose: authApi supports index.js by holding or executing the auth api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const authApi = require('../../api/auth')
|
||||
/**
|
||||
* Purpose: shopApi supports index.js by holding or executing the shop api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const shopApi = require('../../api/shop')
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: authStore supports index.js by holding or executing the auth store page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const authStore = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: actionGuard supports index.js by holding or executing the action guard page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
const {
|
||||
@@ -15,6 +43,10 @@ const {
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
|
||||
/**
|
||||
* Purpose: phoneRegex supports index.js by holding or executing the phone regex page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const phoneRegex = /^1[3-9]\d{9}$/
|
||||
|
||||
/**
|
||||
@@ -124,6 +156,10 @@ Page({
|
||||
detachKeyboardSafe(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: noop supports index.js by holding or executing the noop page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
noop() {},
|
||||
|
||||
/**
|
||||
@@ -273,6 +309,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: buildAgreementPayload supports index.js by holding or executing the build agreement payload page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
buildAgreementPayload() {
|
||||
const agreementVersions = {}
|
||||
;(this.data.agreements || []).forEach((item) => {
|
||||
@@ -287,6 +327,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: ensureAgreementAccepted supports index.js by holding or executing the ensure agreement accepted page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
ensureAgreementAccepted() {
|
||||
if (!this.data.agreementAccepted) {
|
||||
wx.showToast({
|
||||
@@ -307,12 +351,20 @@ Page({
|
||||
return true
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAgreementToggle supports index.js by holding or executing the handle agreement toggle page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleAgreementToggle() {
|
||||
this.setData({
|
||||
agreementAccepted: !this.data.agreementAccepted
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: openAgreement supports index.js by holding or executing the open agreement page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
openAgreement(event) {
|
||||
const type = event.currentTarget.dataset.type
|
||||
const selectedAgreement = (this.data.agreements || []).find((item) => item.agreementType === type)
|
||||
@@ -329,6 +381,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: closeAgreementModal supports index.js by holding or executing the close agreement modal page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
closeAgreementModal() {
|
||||
this.setData({
|
||||
agreementModalVisible: false,
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
/**
|
||||
* Purpose: cartApi supports index.js by holding or executing the cart api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const cartApi = require('../../api/cart')
|
||||
/**
|
||||
* Purpose: couponApi supports index.js by holding or executing the coupon api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const couponApi = require('../../api/coupon')
|
||||
/**
|
||||
* Purpose: orderApi supports index.js by holding or executing the order api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { resolveLegacyImage } = require('../../utils/file')
|
||||
const { NO_COUPON_KEY } = require('../../utils/config')
|
||||
@@ -16,10 +40,18 @@ const {
|
||||
parseAppointmentParts
|
||||
} = require('../../utils/format')
|
||||
|
||||
/**
|
||||
* Purpose: getCouponKey supports index.js by holding or executing the get coupon key page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function getCouponKey(coupon) {
|
||||
return `${coupon.sourceType || 'USER_COUPON'}:${coupon.id}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: getCouponDisplay supports index.js by holding or executing the get coupon display page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function getCouponDisplay(coupon) {
|
||||
if (Number(coupon.couponType) === 1) {
|
||||
return `${coupon.couponName} ${coupon.discountValue} 折`
|
||||
@@ -27,6 +59,10 @@ function getCouponDisplay(coupon) {
|
||||
return `${coupon.couponName} 满 ${coupon.minAmount} 减 ${coupon.reduceAmount}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: calculateCouponDiscount supports index.js by holding or executing the calculate coupon discount page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function calculateCouponDiscount(coupon, amount) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
@@ -48,6 +84,10 @@ function calculateCouponDiscount(coupon, amount) {
|
||||
return 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildCheckoutIssues supports index.js by holding or executing the build checkout issues page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function buildCheckoutIssues(items) {
|
||||
const issues = []
|
||||
const selectedItems = items.filter(item => item.selected)
|
||||
@@ -121,6 +161,11 @@ Page({
|
||||
cartItems: [],
|
||||
availableCoupons: [],
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
/**
|
||||
* Purpose: couponSelectionTouched records whether the user explicitly chose a coupon option.
|
||||
* Usage: keep normal user coupons manual-only while still allowing VIP auto coupons as default.
|
||||
*/
|
||||
couponSelectionTouched: false,
|
||||
selectedCount: 0,
|
||||
totalQuantity: 0,
|
||||
subtotalAmount: 0,
|
||||
@@ -201,6 +246,7 @@ Page({
|
||||
cartItems: [],
|
||||
availableCoupons: [],
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
couponSelectionTouched: false,
|
||||
loading: false
|
||||
})
|
||||
this.refreshSummary()
|
||||
@@ -239,7 +285,8 @@ Page({
|
||||
|
||||
this.setData({
|
||||
cartItems: formattedItems,
|
||||
selectedCouponKey: NO_COUPON_KEY
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
couponSelectionTouched: false
|
||||
})
|
||||
await this.loadAvailableCoupons()
|
||||
} catch (error) {
|
||||
@@ -267,7 +314,8 @@ Page({
|
||||
if (!selectedItems.length) {
|
||||
this.setData({
|
||||
availableCoupons: [],
|
||||
selectedCouponKey: NO_COUPON_KEY
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
couponSelectionTouched: false
|
||||
})
|
||||
this.refreshSummary()
|
||||
return
|
||||
@@ -305,8 +353,9 @@ Page({
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (selectedCouponKey === NO_COUPON_KEY) {
|
||||
if (selectedCouponKey === NO_COUPON_KEY && !this.data.couponSelectionTouched) {
|
||||
const bestCoupons = list
|
||||
.filter(item => item.sourceType === 'SYSTEM_VIP')
|
||||
.sort((left, right) => calculateCouponDiscount(right, subtotalAmount) - calculateCouponDiscount(left, subtotalAmount))
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
@@ -324,7 +373,8 @@ Page({
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
availableCoupons: [],
|
||||
selectedCouponKey: NO_COUPON_KEY
|
||||
selectedCouponKey: NO_COUPON_KEY,
|
||||
couponSelectionTouched: false
|
||||
})
|
||||
} finally {
|
||||
this.refreshSummary()
|
||||
@@ -587,7 +637,8 @@ Page({
|
||||
*/
|
||||
handleCouponChange(event) {
|
||||
this.setData({
|
||||
selectedCouponKey: event.detail.value
|
||||
selectedCouponKey: event.detail.value,
|
||||
couponSelectionTouched: true
|
||||
})
|
||||
this.refreshSummary()
|
||||
},
|
||||
|
||||
@@ -1,8 +1,28 @@
|
||||
/**
|
||||
* Purpose: couponApi supports index.js by holding or executing the coupon api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const couponApi = require('../../api/coupon')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
|
||||
/**
|
||||
* Purpose: getBenefitText supports index.js by holding or executing the get benefit text page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function getBenefitText(coupon) {
|
||||
if (Number(coupon.couponType) === 1) {
|
||||
return `${coupon.discountValue} 折`
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: cache supports index.js by holding or executing the cache page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const cache = require('../../utils/cache')
|
||||
const { buildProductCards } = require('../../utils/product')
|
||||
const { resolveImageList } = require('../../utils/file')
|
||||
@@ -12,9 +24,25 @@ const {
|
||||
handleKeyboardBlur,
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
/**
|
||||
* Purpose: productApi supports index.js by holding or executing the product api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const productApi = require('../../api/product')
|
||||
/**
|
||||
* Purpose: shopApi supports index.js by holding or executing the shop api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const shopApi = require('../../api/shop')
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
|
||||
/**
|
||||
@@ -5,7 +9,15 @@ const auth = require('../../utils/auth')
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: navTitle supports index.js by holding or executing the nav title page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
navTitle: '游客模式'
|
||||
},
|
||||
|
||||
@@ -16,6 +28,10 @@ Page({
|
||||
onLoad() {
|
||||
this.syncNavTitle()
|
||||
wx.switchTab({
|
||||
/**
|
||||
* Purpose: url supports index.js by holding or executing the url page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
url: '/pages/home/index'
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1,16 +1,49 @@
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
const { previewImagesSafely } = require('../../utils/file')
|
||||
|
||||
/**
|
||||
* notifications page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: messages supports index.js by holding or executing the messages page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
messages: [],
|
||||
/**
|
||||
* Purpose: unreadCount supports index.js by holding or executing the unread count page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
unreadCount: 0,
|
||||
/**
|
||||
* Purpose: detailVisible supports index.js by holding or executing the detail visible page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
detailVisible: false,
|
||||
/**
|
||||
* Purpose: currentMessage supports index.js by holding or executing the current message page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
currentMessage: null
|
||||
},
|
||||
|
||||
@@ -31,12 +64,28 @@ Page({
|
||||
const messages = await userApi.listMyMessages()
|
||||
const list = Array.isArray(messages) ? messages : []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: messages supports index.js by holding or executing the messages page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
messages: list,
|
||||
/**
|
||||
* Purpose: unreadCount supports index.js by holding or executing the unread count page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
unreadCount: list.filter(item => item.readStatus !== 1).length
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
title: error.message || '消息加载失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
@@ -54,26 +103,43 @@ Page({
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
if (item.actionPath) {
|
||||
const actionTarget = navigation.buildMessageActionPath(item)
|
||||
if (actionTarget) {
|
||||
try {
|
||||
if (item.readStatus !== 1) {
|
||||
await userApi.markMessageRead(item.id)
|
||||
}
|
||||
const opened = await navigation.openActionPath(item.actionPath)
|
||||
const opened = await navigation.openActionPath(actionTarget)
|
||||
await this.loadMessages()
|
||||
if (opened) {
|
||||
return
|
||||
}
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
title: error.message || '打开消息失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: currentMessage supports index.js by holding or executing the current message page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
currentMessage: item,
|
||||
/**
|
||||
* Purpose: detailVisible supports index.js by holding or executing the detail visible page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
detailVisible: true
|
||||
})
|
||||
/**
|
||||
@@ -86,7 +152,15 @@ Page({
|
||||
await this.loadMessages()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
title: error.message || '标记已读失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
@@ -99,7 +173,15 @@ Page({
|
||||
*/
|
||||
handleCloseDetail() {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: detailVisible supports index.js by holding or executing the detail visible page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
detailVisible: false,
|
||||
/**
|
||||
* Purpose: currentMessage supports index.js by holding or executing the current message page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
currentMessage: null
|
||||
})
|
||||
},
|
||||
@@ -117,12 +199,13 @@ Page({
|
||||
if (!imageUrl) {
|
||||
return
|
||||
}
|
||||
wx.previewImage({
|
||||
current: imageUrl,
|
||||
urls: [imageUrl]
|
||||
})
|
||||
previewImagesSafely(imageUrl, [imageUrl])
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: noop supports index.js by holding or executing the noop page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
noop() {},
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,32 +1,76 @@
|
||||
/**
|
||||
* Purpose: orderApi supports index.js by holding or executing the order api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: actionGuard supports index.js by holding or executing the action guard page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { resolveLegacyImage } = require('../../utils/file')
|
||||
const { formatDateTime, formatPrice, getOrderStatusClass, getOrderStatusText } = require('../../utils/format')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* Purpose: REVIEW_SCORE_OPTIONS supports index.js by holding or executing the review score options page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const REVIEW_SCORE_OPTIONS = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
|
||||
|
||||
/**
|
||||
* Purpose: toId supports index.js by holding or executing the to id page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function toId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: sameId supports index.js by holding or executing the same id page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function sameId(left, right) {
|
||||
const leftId = toId(left)
|
||||
const rightId = toId(right)
|
||||
return leftId !== '' && leftId === rightId
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: safeList supports index.js by holding or executing the safe list page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function safeList(value) {
|
||||
return Array.isArray(value) ? value : []
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: trimText supports index.js by holding or executing the trim text page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function trimText(value) {
|
||||
return String(value || '').trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatRating supports index.js by holding or executing the format rating page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function formatRating(value) {
|
||||
const rating = Number(value)
|
||||
if (!isFinite(rating) || rating <= 0) {
|
||||
@@ -35,6 +79,10 @@ function formatRating(value) {
|
||||
return rating % 1 === 0 ? String(rating) : rating.toFixed(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isSubmittedReview supports index.js by holding or executing the is submitted review page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function isSubmittedReview(review) {
|
||||
if (!review) {
|
||||
return false
|
||||
@@ -45,6 +93,10 @@ function isSubmittedReview(review) {
|
||||
return Boolean(review.rating)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: resolveRelatedRecord supports index.js by holding or executing the resolve related record page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function resolveRelatedRecord(source, orderItemId) {
|
||||
if (Array.isArray(source)) {
|
||||
return source.find(item => sameId(item && item.orderItemId, orderItemId)) || null
|
||||
@@ -57,6 +109,10 @@ function resolveRelatedRecord(source, orderItemId) {
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildReviewSummary supports index.js by holding or executing the build review summary page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function buildReviewSummary(review) {
|
||||
if (!review || !isSubmittedReview(review)) {
|
||||
return null
|
||||
@@ -70,6 +126,10 @@ function buildReviewSummary(review) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildPendingReview supports index.js by holding or executing the build pending review page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function buildPendingReview(review) {
|
||||
if (!review || isSubmittedReview(review)) {
|
||||
return null
|
||||
@@ -77,6 +137,10 @@ function buildPendingReview(review) {
|
||||
return review
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildArtistChangeSummary supports index.js by holding or executing the build artist change summary page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function buildArtistChangeSummary(request) {
|
||||
if (!request) {
|
||||
return null
|
||||
@@ -90,6 +154,10 @@ function buildArtistChangeSummary(request) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: indexByOrderItemId supports index.js by holding or executing the index by order item id page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function indexByOrderItemId(list) {
|
||||
return safeList(list).reduce((result, item) => {
|
||||
if (item && item.orderItemId) {
|
||||
@@ -99,6 +167,10 @@ function indexByOrderItemId(list) {
|
||||
}, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: safeCall supports index.js by holding or executing the safe call page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
async function safeCall(factory, fallbackValue) {
|
||||
try {
|
||||
const result = await factory()
|
||||
@@ -108,6 +180,10 @@ async function safeCall(factory, fallbackValue) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: loadAssistData supports index.js by holding or executing the load assist data page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
async function loadAssistData(orders) {
|
||||
const pendingReviewsPromise = safeCall(() => orderApi.listMyPendingReviews(), [])
|
||||
const pendingChangesPromise = safeCall(() => orderApi.listMyPendingArtistChangeRequests(), [])
|
||||
@@ -136,6 +212,10 @@ async function loadAssistData(orders) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: findReviewDraft supports index.js by holding or executing the find review draft page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function findReviewDraft(orders, reviewId) {
|
||||
const reviewIdText = toId(reviewId)
|
||||
for (let i = 0; i < orders.length; i += 1) {
|
||||
@@ -155,9 +235,28 @@ Page({
|
||||
loading: false,
|
||||
isLoggedIn: false,
|
||||
orders: [],
|
||||
/**
|
||||
* Purpose: focusOrderId stores an optional order id from message navigation so the target order can be surfaced.
|
||||
* Usage: set it from onLoad route options and compare it while formatting order cards.
|
||||
*/
|
||||
focusOrderId: '',
|
||||
reviewScoreOptions: REVIEW_SCORE_OPTIONS
|
||||
}),
|
||||
|
||||
/**
|
||||
* Purpose: onLoad captures message or deep-link order ids before the order list is loaded.
|
||||
* Usage: mini-program runtime passes route options; store orderId for highlighting after loadOrders.
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
focusOrderId: (options && options.orderId) || ''
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadOrders()
|
||||
},
|
||||
@@ -183,6 +282,7 @@ Page({
|
||||
const assistData = await loadAssistData(list)
|
||||
const formattedOrders = await Promise.all(list.map(async order => ({
|
||||
...order,
|
||||
focusTarget: sameId(order.id, this.data.focusOrderId),
|
||||
statusText: getOrderStatusText(order),
|
||||
statusClass: getOrderStatusClass(order),
|
||||
shopNameText: order.shopName ? `所属店铺:${order.shopName}` : '',
|
||||
@@ -227,14 +327,26 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenAuth supports index.js by holding or executing the handle open auth page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleOpenAuth() {
|
||||
navigation.openAuth('/pages/orders/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBack supports index.js by holding or executing the handle back page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/profile/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: updateReviewDraft supports index.js by holding or executing the update review draft page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
updateReviewDraft(reviewId, patch) {
|
||||
const reviewIdText = toId(reviewId)
|
||||
const orders = this.data.orders.map(order => ({
|
||||
@@ -258,6 +370,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSelectReviewScore supports index.js by holding or executing the handle select review score page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleSelectReviewScore(event) {
|
||||
const reviewId = event.currentTarget.dataset.reviewId
|
||||
const score = Number(event.currentTarget.dataset.score)
|
||||
@@ -266,6 +382,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleReviewContentInput supports index.js by holding or executing the handle review content input page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleReviewContentInput(event) {
|
||||
const reviewId = event.currentTarget.dataset.reviewId
|
||||
this.updateReviewDraft(reviewId, {
|
||||
@@ -365,7 +485,7 @@ Page({
|
||||
const confirmed = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '拒绝改派',
|
||||
content: '确认拒绝这次美甲师改派申请吗?',
|
||||
content: '确认拒绝这次美甲师改派申请吗?拒绝后可在下一步补充原因。',
|
||||
confirmText: '拒绝',
|
||||
success: modalRes => resolve(Boolean(modalRes.confirm))
|
||||
})
|
||||
@@ -374,8 +494,10 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
const rejectReason = await this.promptRejectReason()
|
||||
|
||||
await runWithLoading(() => orderApi.rejectArtistChange(requestId, {
|
||||
rejectReason: ''
|
||||
rejectReason
|
||||
}))
|
||||
wx.showToast({
|
||||
title: '已拒绝改派',
|
||||
@@ -396,6 +518,29 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: promptRejectReason collects an optional customer reason before rejecting an artist-change request.
|
||||
* Usage: call it after the confirmation dialog and pass the returned text to rejectArtistChange.
|
||||
*/
|
||||
promptRejectReason() {
|
||||
return new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '拒绝原因',
|
||||
editable: true,
|
||||
placeholderText: '可选,告诉美甲师原因',
|
||||
confirmText: '提交',
|
||||
success: res => {
|
||||
if (!res.confirm) {
|
||||
resolve('')
|
||||
return
|
||||
}
|
||||
resolve(trimText(res.content))
|
||||
},
|
||||
fail: () => resolve('')
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
async handleCancelOrder(event) {
|
||||
const orderId = event.currentTarget.dataset.orderId
|
||||
if (!orderId) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<text class="hero-desc">查看订单状态和预约时间。</text>
|
||||
</view>
|
||||
|
||||
<view wx:for="{{orders}}" wx:key="id" class="page-card order-card">
|
||||
<view wx:for="{{orders}}" wx:key="id" class="page-card order-card {{item.focusTarget ? 'focus-target' : ''}}">
|
||||
<view class="order-head">
|
||||
<view class="order-head-copy">
|
||||
<text class="order-label">订单号</text>
|
||||
@@ -32,50 +32,50 @@
|
||||
<view class="order-line">{{orderItem.priceText}} x {{orderItem.quantity}}</view>
|
||||
<view wx:if="{{orderItem.artistName}}" class="order-line">美甲师:{{orderItem.artistName}}</view>
|
||||
<view wx:if="{{orderItem.appointmentText}}" class="order-line">预约时间:{{orderItem.appointmentText}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{orderItem.reviewSummary}}" class="review-summary">
|
||||
<text class="assist-label">评价状态</text>
|
||||
<text class="assist-main">{{orderItem.reviewSummary.displayText}}</text>
|
||||
<text wx:if="{{orderItem.reviewSummary.contentText}}" class="assist-desc">{{orderItem.reviewSummary.contentText}}</text>
|
||||
</view>
|
||||
<view wx:if="{{orderItem.reviewSummary}}" class="review-summary">
|
||||
<text class="assist-label">评价状态</text>
|
||||
<text class="assist-main">{{orderItem.reviewSummary.displayText}}</text>
|
||||
<text wx:if="{{orderItem.reviewSummary.contentText}}" class="assist-desc">{{orderItem.reviewSummary.contentText}}</text>
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{orderItem.pendingReview}}" class="review-panel">
|
||||
<view class="review-panel-head">
|
||||
<text class="assist-label">评价美甲师</text>
|
||||
<text class="assist-desc">评分必填,文字可选</text>
|
||||
</view>
|
||||
<view class="score-row">
|
||||
<view
|
||||
wx:for="{{reviewScoreOptions}}"
|
||||
wx:key="*this"
|
||||
wx:for-item="score"
|
||||
class="score-chip {{orderItem.reviewDraft.rating == score ? 'active' : ''}}"
|
||||
data-review-id="{{orderItem.pendingReview.id}}"
|
||||
data-score="{{score}}"
|
||||
bindtap="handleSelectReviewScore"
|
||||
>{{score}}</view>
|
||||
</view>
|
||||
<textarea
|
||||
class="review-textarea"
|
||||
maxlength="200"
|
||||
placeholder="写下这次服务体验,可不填"
|
||||
placeholder-class="textarea-placeholder"
|
||||
value="{{orderItem.reviewDraft.content}}"
|
||||
data-review-id="{{orderItem.pendingReview.id}}"
|
||||
bindinput="handleReviewContentInput"
|
||||
></textarea>
|
||||
<view class="review-submit-btn" data-review-id="{{orderItem.pendingReview.id}}" bindtap="handleSubmitReview">提交评价</view>
|
||||
</view>
|
||||
<view wx:elif="{{orderItem.pendingReview}}" class="review-panel">
|
||||
<view class="review-panel-head">
|
||||
<text class="assist-label">评价美甲师</text>
|
||||
<text class="assist-desc">评分必填,文字可选</text>
|
||||
</view>
|
||||
<view class="score-row">
|
||||
<view
|
||||
wx:for="{{reviewScoreOptions}}"
|
||||
wx:key="*this"
|
||||
wx:for-item="score"
|
||||
class="score-chip {{orderItem.reviewDraft.rating == score ? 'active' : ''}}"
|
||||
data-review-id="{{orderItem.pendingReview.id}}"
|
||||
data-score="{{score}}"
|
||||
bindtap="handleSelectReviewScore"
|
||||
>{{score}}</view>
|
||||
</view>
|
||||
<textarea
|
||||
class="review-textarea"
|
||||
maxlength="200"
|
||||
placeholder="写下这次服务体验,可不填"
|
||||
placeholder-class="textarea-placeholder"
|
||||
value="{{orderItem.reviewDraft.content}}"
|
||||
data-review-id="{{orderItem.pendingReview.id}}"
|
||||
bindinput="handleReviewContentInput"
|
||||
></textarea>
|
||||
<view class="review-submit-btn" data-review-id="{{orderItem.pendingReview.id}}" bindtap="handleSubmitReview">提交评价</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{orderItem.pendingArtistChangeRequest}}" class="change-panel">
|
||||
<text class="assist-label">待确认改派</text>
|
||||
<text class="assist-main">{{orderItem.pendingArtistChangeRequest.displayText}}</text>
|
||||
<text wx:if="{{orderItem.pendingArtistChangeRequest.reasonText}}" class="assist-desc">原因:{{orderItem.pendingArtistChangeRequest.reasonText}}</text>
|
||||
<view class="change-actions">
|
||||
<view class="change-btn primary" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleApproveArtistChange">同意改派</view>
|
||||
<view class="change-btn" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleRejectArtistChange">拒绝</view>
|
||||
<view wx:if="{{orderItem.pendingArtistChangeRequest}}" class="change-panel">
|
||||
<text class="assist-label">待确认改派</text>
|
||||
<text class="assist-main">{{orderItem.pendingArtistChangeRequest.displayText}}</text>
|
||||
<text wx:if="{{orderItem.pendingArtistChangeRequest.reasonText}}" class="assist-desc">原因:{{orderItem.pendingArtistChangeRequest.reasonText}}</text>
|
||||
<view class="change-actions">
|
||||
<view class="change-btn primary" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleApproveArtistChange">同意改派</view>
|
||||
<view class="change-btn" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" bindtap="handleRejectArtistChange">拒绝</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
padding: 26rpx;
|
||||
}
|
||||
|
||||
.order-card.focus-target {
|
||||
border-color: var(--theme-primary);
|
||||
box-shadow: 0 18rpx 48rpx rgba(224, 105, 92, 0.18);
|
||||
}
|
||||
|
||||
.order-head,
|
||||
.order-foot {
|
||||
display: flex;
|
||||
@@ -91,6 +96,7 @@
|
||||
|
||||
.order-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.order-title {
|
||||
|
||||
@@ -1,18 +1,62 @@
|
||||
/**
|
||||
* Purpose: cartApi supports index.js by holding or executing the cart api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const cartApi = require('../../api/cart')
|
||||
/**
|
||||
* Purpose: productApi supports index.js by holding or executing the product api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const productApi = require('../../api/product')
|
||||
/**
|
||||
* Purpose: productLikeApi supports index.js by holding or executing the product like api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const productLikeApi = require('../../api/product-like')
|
||||
/**
|
||||
* Purpose: commentApi supports index.js by holding or executing the comment api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const commentApi = require('../../api/comment')
|
||||
/**
|
||||
* Purpose: shopApi supports index.js by holding or executing the shop api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const shopApi = require('../../api/shop')
|
||||
/**
|
||||
* Purpose: wishlistApi supports index.js by holding or executing the wishlist api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const wishlistApi = require('../../api/wishlist')
|
||||
/**
|
||||
* Purpose: actionGuard supports index.js by holding or executing the action guard page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { getSignedUrl, resolveImageList } = require('../../utils/file')
|
||||
const { getSignedUrl, resolveImageList, previewImagesSafely } = require('../../utils/file')
|
||||
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
|
||||
const { formatPrice, getProductTitle, splitCsv } = require('../../utils/format')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* Purpose: parseTimeRange supports index.js by holding or executing the parse time range page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function parseTimeRange(businessHours) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
@@ -37,6 +81,10 @@ function parseTimeRange(businessHours) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: estimateEarliestBookable supports index.js by holding or executing the estimate earliest bookable page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function estimateEarliestBookable(businessHours) {
|
||||
const range = parseTimeRange(businessHours)
|
||||
/**
|
||||
@@ -255,9 +303,37 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
wx.previewImage({
|
||||
current,
|
||||
urls: this.data.productImages
|
||||
previewImagesSafely(current, this.data.productImages)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShareAppMessage exposes the product detail as a native mini-program share target.
|
||||
* Usage: WeChat calls it from the share menu; keep title and path aligned with the current product id.
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
const product = this.data.product || {}
|
||||
return {
|
||||
title: product.displayTitle || 'YumiNail 美甲款式',
|
||||
path: `/pages/product-detail/index?id=${product.id || this.data.productId}`,
|
||||
imageUrl: this.data.productImages[0] || DEFAULT_PRODUCT_IMAGE
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCopyShareLink copies a mini-program route for users who cannot invoke native share.
|
||||
* Usage: bind it to the visible share action in the product info card.
|
||||
*/
|
||||
handleCopyShareLink() {
|
||||
const product = this.data.product || {}
|
||||
const path = `/pages/product-detail/index?id=${product.id || this.data.productId}`
|
||||
wx.setClipboardData({
|
||||
data: path,
|
||||
success: () => {
|
||||
wx.showToast({
|
||||
title: '分享路径已复制',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@
|
||||
<view class="action-pill {{isFavorite ? 'active' : ''}}" bindtap="handleToggleFavorite">
|
||||
收藏 {{product.collectCount || 0}}
|
||||
</view>
|
||||
<button class="action-pill share-pill" open-type="share">分享</button>
|
||||
<view class="action-pill" bindtap="handleCopyShareLink">复制路径</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{product.tagInfos && product.tagInfos.length}}" class="tags-wrap">
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
|
||||
.actions-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
@@ -123,6 +124,12 @@
|
||||
color: var(--theme-accent);
|
||||
font-size: 24rpx;
|
||||
font-weight: 600;
|
||||
border: 0;
|
||||
line-height: 68rpx;
|
||||
}
|
||||
|
||||
.share-pill::after {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.action-pill.active {
|
||||
|
||||
@@ -1,11 +1,43 @@
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: cache supports index.js by holding or executing the cache page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const cache = require('../../utils/cache')
|
||||
/**
|
||||
* Purpose: tagApi supports index.js by holding or executing the tag api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const tagApi = require('../../api/tag')
|
||||
/**
|
||||
* Purpose: productApi supports index.js by holding or executing the product api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const productApi = require('../../api/product')
|
||||
/**
|
||||
* Purpose: cartApi supports index.js by holding or executing the cart api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const cartApi = require('../../api/cart')
|
||||
/**
|
||||
* Purpose: actionGuard supports index.js by holding or executing the action guard page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
const { buildProductCards } = require('../../utils/product')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
const { CACHE_TTL } = require('../../utils/config')
|
||||
@@ -18,8 +50,20 @@ const {
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
|
||||
/**
|
||||
* Purpose: ALL_CATEGORY supports index.js by holding or executing the all category page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const ALL_CATEGORY = '\u5168\u90e8'
|
||||
/**
|
||||
* Purpose: FILTER_BUSY_MESSAGE supports index.js by holding or executing the filter busy message page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const FILTER_BUSY_MESSAGE = '\u7b5b\u9009\u5904\u7406\u4e2d\uff0c\u8bf7\u52ff\u91cd\u590d\u64cd\u4f5c'
|
||||
/**
|
||||
* Purpose: CART_BUSY_MESSAGE supports index.js by holding or executing the cart busy message page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const CART_BUSY_MESSAGE = '\u8d2d\u7269\u8f66\u5904\u7406\u4e2d\uff0c\u8bf7\u52ff\u91cd\u590d\u64cd\u4f5c'
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,47 @@
|
||||
/**
|
||||
* Purpose: authApi supports index.js by holding or executing the auth api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const authApi = require('../../api/auth')
|
||||
/**
|
||||
* Purpose: couponApi supports index.js by holding or executing the coupon api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const couponApi = require('../../api/coupon')
|
||||
/**
|
||||
* Purpose: orderApi supports index.js by holding or executing the order api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: wishlistApi supports index.js by holding or executing the wishlist api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const wishlistApi = require('../../api/wishlist')
|
||||
/**
|
||||
* Purpose: actionGuard supports index.js by holding or executing the action guard page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { DEFAULT_AVATAR } = require('../../utils/config')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
@@ -178,6 +214,11 @@ Page({
|
||||
}
|
||||
this._checkingPopupMessages = true
|
||||
try {
|
||||
const globalApp = getApp()
|
||||
if (globalApp && typeof globalApp.checkPopupMessages === 'function') {
|
||||
await globalApp.checkPopupMessages()
|
||||
return
|
||||
}
|
||||
const messages = await userApi.listMyPopupMessages()
|
||||
/**
|
||||
* `for` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
@@ -194,7 +235,7 @@ Page({
|
||||
})
|
||||
})
|
||||
await userApi.markMessagePopupShown(item.id)
|
||||
const opened = await navigation.openActionPath(item.actionPath)
|
||||
const opened = await navigation.openSystemMessage(item)
|
||||
if (opened) {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
/**
|
||||
* Purpose: authApi supports index.js by holding or executing the auth api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const authApi = require('../../api/auth')
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { DEFAULT_AVATAR } = require('../../utils/config')
|
||||
const { getDraftValue, clearDraft, scheduleDraftSave, clearDraftTimer } = require('../../utils/form-draft')
|
||||
@@ -15,8 +35,20 @@ const {
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
|
||||
/**
|
||||
* Purpose: phoneRegex supports index.js by holding or executing the phone regex page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const phoneRegex = /^1[3-9]\d{9}$/
|
||||
/**
|
||||
* Purpose: passwordRegex supports index.js by holding or executing the password regex page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/
|
||||
/**
|
||||
* Purpose: SETTINGS_DRAFT_KEY supports index.js by holding or executing the settings draft key page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const SETTINGS_DRAFT_KEY = 'user-settings'
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,24 @@
|
||||
/**
|
||||
* Purpose: shopApi supports index.js by holding or executing the shop api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const shopApi = require('../../api/shop')
|
||||
/**
|
||||
* Purpose: userApi loads contact information that is hidden until the customer explicitly asks for it.
|
||||
* Usage: call getShopManagerContact from the contact button after login checks pass.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { getSignedUrl, resolveImageList } = require('../../utils/file')
|
||||
const { getSignedUrl, resolveImageList, previewImagesSafely } = require('../../utils/file')
|
||||
const { DEFAULT_SHOP_IMAGE } = require('../../utils/config')
|
||||
|
||||
/**
|
||||
@@ -15,6 +32,11 @@ Page({
|
||||
shopId: '',
|
||||
returnTo: '/pages/home/index',
|
||||
shopInfo: null,
|
||||
/**
|
||||
* Purpose: managerContact stores the shop manager contact returned after a customer requests it.
|
||||
* Usage: bind it to the contact card and keep it null until the API succeeds.
|
||||
*/
|
||||
managerContact: null,
|
||||
distanceText: '',
|
||||
shopImages: []
|
||||
}),
|
||||
@@ -106,10 +128,47 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
wx.previewImage({
|
||||
current: url,
|
||||
urls: this.data.shopImages
|
||||
})
|
||||
previewImagesSafely(url, this.data.shopImages)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleContactManager retrieves and shows the current shop manager contact.
|
||||
* Usage: bind it to the contact button and require login before exposing phone data.
|
||||
*/
|
||||
async handleContactManager() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
if (!shopInfo || !shopInfo.id || !navigation.ensureLogin('联系店长')) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const contact = await userApi.getShopManagerContact(shopInfo.id)
|
||||
this.setData({ managerContact: contact })
|
||||
if (contact && contact.phoneAvailable && contact.phone) {
|
||||
wx.showModal({
|
||||
title: contact.contactName || '店长联系方式',
|
||||
content: `${contact.roleLabel || '店长'}:${contact.phone}`,
|
||||
confirmText: '拨打',
|
||||
cancelText: '复制',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
wx.makePhoneCall({ phoneNumber: contact.phone })
|
||||
} else {
|
||||
wx.setClipboardData({ data: contact.phone })
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: (contact && contact.platformContactText) || '暂无可用联系方式',
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '联系方式获取失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -150,6 +209,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenLocation supports index.js by holding or executing the handle open location page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleOpenLocation() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
if (!shopInfo || !shopInfo.latitude || !shopInfo.longitude) {
|
||||
@@ -169,6 +232,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenAmapNavigation supports index.js by holding or executing the handle open amap navigation page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleOpenAmapNavigation() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
const amapUrl = shopInfo && shopInfo.navigationUrls && shopInfo.navigationUrls.AMAP
|
||||
@@ -190,6 +257,35 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCopyTencentNavigation copies a browser/Tencent-compatible navigation link when provided by the backend.
|
||||
* Usage: bind it to the navigation row as a fallback for users who prefer another map app.
|
||||
*/
|
||||
handleCopyTencentNavigation() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
const url = shopInfo && shopInfo.navigationUrls && (shopInfo.navigationUrls.TENCENT || shopInfo.navigationUrls.BROWSER)
|
||||
if (!url) {
|
||||
wx.showToast({
|
||||
title: '店铺暂未设置备用导航链接',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.setClipboardData({
|
||||
data: url,
|
||||
success: () => {
|
||||
wx.showToast({
|
||||
title: '导航链接已复制',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: loadCurrentDistance supports index.js by holding or executing the load current distance page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
loadCurrentDistance() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
if (!shopInfo || !shopInfo.latitude || !shopInfo.longitude || typeof wx.getLocation !== 'function') {
|
||||
@@ -205,6 +301,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: formatDistance supports index.js by holding or executing the format distance page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
formatDistance(currentLat, currentLng, shopLat, shopLng) {
|
||||
if (![currentLat, currentLng, shopLat, shopLng].every(Number.isFinite)) {
|
||||
return ''
|
||||
|
||||
@@ -49,9 +49,17 @@
|
||||
<view class="ghost-btn" bindtap="handleCopyAddress">复制地址</view>
|
||||
</view>
|
||||
|
||||
<view class="contact-row">
|
||||
<view class="primary-btn contact-btn" bindtap="handleContactManager">联系店长</view>
|
||||
<view wx:if="{{managerContact}}" class="contact-copy">
|
||||
{{managerContact.contactName || '店长'}} · {{managerContact.phoneAvailable ? managerContact.phone : (managerContact.platformContactText || '暂无电话')}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{shopInfo.longitude && shopInfo.latitude}}" class="map-row">
|
||||
<view class="primary-btn map-btn" bindtap="handleOpenLocation">查看地图位置</view>
|
||||
<view class="ghost-btn map-btn" bindtap="handleOpenAmapNavigation">复制高德导航链接</view>
|
||||
<view class="ghost-btn map-btn" bindtap="handleCopyTencentNavigation">复制备用导航</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -87,11 +87,27 @@
|
||||
|
||||
.map-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 16rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.contact-row {
|
||||
display: grid;
|
||||
gap: 12rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.contact-btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.contact-copy {
|
||||
color: #8d7a84;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.copy-row .ghost-btn,
|
||||
.map-btn {
|
||||
min-width: 0;
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
|
||||
/**
|
||||
* Purpose: money supports index.js by holding or executing the money page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function money(value) {
|
||||
return Number(value || 0).toFixed(2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatTime supports index.js by holding or executing the format time page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function formatTime(value) {
|
||||
return value ? String(value).replace('T', ' ').slice(0, 16) : '--'
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: sceneText supports index.js by holding or executing the scene text page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function sceneText(scene) {
|
||||
const map = {
|
||||
MANUAL_RECHARGE: '手工充值',
|
||||
@@ -26,17 +46,61 @@ function sceneText(scene) {
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: asset supports index.js by holding or executing the asset page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
asset: {
|
||||
/**
|
||||
* Purpose: vipLevel supports index.js by holding or executing the vip level page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
vipLevel: '普通',
|
||||
/**
|
||||
* Purpose: balanceText supports index.js by holding or executing the balance text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
balanceText: '0.00',
|
||||
/**
|
||||
* Purpose: totalRechargeText supports index.js by holding or executing the total recharge text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
totalRechargeText: '0.00',
|
||||
/**
|
||||
* Purpose: lastRechargeText supports index.js by holding or executing the last recharge text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
lastRechargeText: '--',
|
||||
/**
|
||||
* Purpose: vipStartText supports index.js by holding or executing the vip start text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
vipStartText: '--',
|
||||
/**
|
||||
* Purpose: manualOverride supports index.js by holding or executing the manual override page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
manualOverride: false
|
||||
},
|
||||
/**
|
||||
* Purpose: history supports index.js by holding or executing the history page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
history: [],
|
||||
/**
|
||||
* Purpose: rechargePlans supports index.js by holding or executing the recharge plans page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
rechargePlans: [],
|
||||
/**
|
||||
* Purpose: rechargePanelVisible supports index.js by holding or executing the recharge panel visible page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
rechargePanelVisible: false
|
||||
},
|
||||
|
||||
@@ -59,31 +123,83 @@ Page({
|
||||
userApi.listMyVipRechargePlans().catch(() => [])
|
||||
])
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: asset supports index.js by holding or executing the asset page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
asset: {
|
||||
...asset,
|
||||
/**
|
||||
* Purpose: balanceText supports index.js by holding or executing the balance text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
balanceText: money(asset && asset.balance),
|
||||
/**
|
||||
* Purpose: totalRechargeText supports index.js by holding or executing the total recharge text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
totalRechargeText: money(asset && asset.totalRechargeAmount),
|
||||
/**
|
||||
* Purpose: lastRechargeText supports index.js by holding or executing the last recharge text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
lastRechargeText: formatTime(asset && asset.lastRechargeTime),
|
||||
/**
|
||||
* Purpose: vipStartText supports index.js by holding or executing the vip start text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
vipStartText: formatTime(asset && asset.vipStartTime)
|
||||
},
|
||||
/**
|
||||
* Purpose: history supports index.js by holding or executing the history page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
history: (Array.isArray(history) ? history : []).map(item => {
|
||||
const amountNumber = Number(item.amount || 0)
|
||||
return {
|
||||
...item,
|
||||
amountNumber,
|
||||
/**
|
||||
* Purpose: amountText supports index.js by holding or executing the amount text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
amountText: `${amountNumber > 0 ? '+' : ''}¥${money(amountNumber)}`,
|
||||
/**
|
||||
* Purpose: sceneText supports index.js by holding or executing the scene text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
sceneText: sceneText(item.changeScene || item.type),
|
||||
/**
|
||||
* Purpose: changeTimeText supports index.js by holding or executing the change time text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
changeTimeText: formatTime(item.changeTime)
|
||||
}
|
||||
}),
|
||||
/**
|
||||
* Purpose: rechargePlans supports index.js by holding or executing the recharge plans page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
rechargePlans: (Array.isArray(plans) ? plans : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: amountText supports index.js by holding or executing the amount text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
amountText: `充 ${money(item.rechargeAmount)} 送 ${money(item.giftAmount)}`
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
title: error.message || 'VIP 信息加载失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
/**
|
||||
* Purpose: wishlistApi supports index.js by holding or executing the wishlist api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const wishlistApi = require('../../api/wishlist')
|
||||
/**
|
||||
* Purpose: cartApi supports index.js by holding or executing the cart api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const cartApi = require('../../api/cart')
|
||||
/**
|
||||
* Purpose: actionGuard supports index.js by holding or executing the action guard page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
const { buildProductCard } = require('../../utils/product')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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'])
|
||||
|
||||
@@ -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)}`
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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 || {}
|
||||
|
||||
@@ -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)))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
/**
|
||||
* Purpose: request supports auth.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
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: '/auth/login',
|
||||
@@ -9,12 +17,20 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getLoginShops supports auth.js by holding or executing the get login 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.
|
||||
*/
|
||||
getLoginShops(account) {
|
||||
return request({
|
||||
url: `/auth/login-shops/${encodeURIComponent(account)}`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 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(shopId) {
|
||||
return request({
|
||||
url: '/auth/switch-shop',
|
||||
@@ -25,6 +41,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: refreshToken supports auth.js by holding or executing the refresh token 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.
|
||||
*/
|
||||
refreshToken(refreshToken) {
|
||||
return request({
|
||||
url: '/auth/refresh',
|
||||
@@ -35,6 +55,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: '/auth/logout',
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
/**
|
||||
* Purpose: request supports comment.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listComments supports comment.js by holding or executing the list comments 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.
|
||||
*/
|
||||
listComments(params) {
|
||||
return request({
|
||||
url: '/comment/list',
|
||||
@@ -8,6 +16,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: deleteComment supports comment.js by holding or executing the delete comment 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.
|
||||
*/
|
||||
deleteComment(id) {
|
||||
return request({
|
||||
url: `/comment/delete/${id}`,
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
/**
|
||||
* Purpose: request supports coupon.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listCoupons supports coupon.js by holding or executing the list 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.
|
||||
*/
|
||||
listCoupons(params) {
|
||||
return request({
|
||||
url: '/coupon/list',
|
||||
@@ -8,6 +16,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: listAllCoupons supports coupon.js by holding or executing the list all 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.
|
||||
*/
|
||||
listAllCoupons(shopId) {
|
||||
return request({
|
||||
url: '/coupon/list/all',
|
||||
@@ -15,12 +27,20 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getCouponDetail supports coupon.js by holding or executing the get coupon detail 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.
|
||||
*/
|
||||
getCouponDetail(id) {
|
||||
return request({
|
||||
url: `/coupon/detail/${id}`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: createCoupon supports coupon.js by holding or executing the create coupon 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.
|
||||
*/
|
||||
createCoupon(data) {
|
||||
return request({
|
||||
url: '/coupon/create',
|
||||
@@ -29,6 +49,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: updateCoupon supports coupon.js by holding or executing the update coupon 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.
|
||||
*/
|
||||
updateCoupon(id, data) {
|
||||
return request({
|
||||
url: `/coupon/update/${id}`,
|
||||
@@ -37,6 +61,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: deleteCoupon supports coupon.js by holding or executing the delete coupon 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.
|
||||
*/
|
||||
deleteCoupon(id) {
|
||||
return request({
|
||||
url: `/coupon/delete/${id}`,
|
||||
@@ -44,6 +72,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: assignCoupon supports coupon.js by holding or executing the assign coupon 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.
|
||||
*/
|
||||
assignCoupon(data) {
|
||||
return request({
|
||||
url: '/coupon/assign',
|
||||
@@ -53,6 +85,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: distributeCoupon supports coupon.js by holding or executing the distribute coupon 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.
|
||||
*/
|
||||
distributeCoupon(data) {
|
||||
return request({
|
||||
url: '/coupon/distribute',
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
/**
|
||||
* Purpose: request supports dashboard.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: getStats supports dashboard.js by holding or executing the get stats 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.
|
||||
*/
|
||||
getStats() {
|
||||
return request({
|
||||
url: '/dashboard/stats'
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
/**
|
||||
* Purpose: request supports file.js by holding or executing the request 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 request = require('../utils/request')
|
||||
/**
|
||||
* Purpose: actionGuard supports file.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 { ADMIN_API_BASE_URL, REQUEST_TIMEOUT } = require('../utils/config')
|
||||
|
||||
/**
|
||||
* Purpose: normalizeUploadResponse supports file.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('上传失败')
|
||||
@@ -33,6 +45,10 @@ function normalizeUploadResponse(response) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: initChunkUpload supports file.js by holding or executing the init chunk upload 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.
|
||||
*/
|
||||
initChunkUpload(data) {
|
||||
return request({
|
||||
url: '/object-storage-file/upload/init',
|
||||
@@ -41,6 +57,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: uploadChunkFile supports file.js by holding or executing the upload chunk file 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.
|
||||
*/
|
||||
uploadChunkFile(options) {
|
||||
const signedHeaders = request.buildSignatureHeaders({
|
||||
url: '/object-storage-file/upload/chunk',
|
||||
@@ -91,6 +111,10 @@ module.exports = {
|
||||
)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: completeChunkUpload supports file.js by holding or executing the complete chunk upload 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.
|
||||
*/
|
||||
completeChunkUpload(uploadId) {
|
||||
return request({
|
||||
url: '/object-storage-file/upload/complete',
|
||||
@@ -101,6 +125,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: cancelChunkUpload supports file.js by holding or executing the cancel chunk upload 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.
|
||||
*/
|
||||
cancelChunkUpload(uploadId) {
|
||||
return request({
|
||||
url: `/object-storage-file/upload/${uploadId}`,
|
||||
@@ -108,6 +136,10 @@ 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) {
|
||||
return request({
|
||||
url: `/object-storage-file/get-signed-url/${fileId}`
|
||||
|
||||
@@ -1,18 +1,34 @@
|
||||
/**
|
||||
* Purpose: request supports nail-artist.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listNailArtists supports nail-artist.js by holding or executing the list nail artists 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.
|
||||
*/
|
||||
listNailArtists() {
|
||||
return request({
|
||||
url: '/nail-artist/list'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getNailArtistInfo supports nail-artist.js by holding or executing the get nail artist 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.
|
||||
*/
|
||||
getNailArtistInfo(userId) {
|
||||
return request({
|
||||
url: `/nail-artist/get/${userId}`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: saveNailArtistInfo supports nail-artist.js by holding or executing the save nail artist 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.
|
||||
*/
|
||||
saveNailArtistInfo(data) {
|
||||
return request({
|
||||
url: '/nail-artist/save',
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
/**
|
||||
* Purpose: request supports order.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listOrders supports order.js by holding or executing the list orders 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.
|
||||
*/
|
||||
listOrders(params) {
|
||||
return request({
|
||||
url: '/order/list',
|
||||
@@ -8,12 +16,30 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getOrderDetail loads an authoritative admin-scoped order detail row.
|
||||
* Usage: call with the order id when opening the order detail page so direct page entry works.
|
||||
*/
|
||||
getOrderDetail(id) {
|
||||
return request({
|
||||
url: `/order/detail/${id}`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 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: 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`,
|
||||
@@ -23,6 +49,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',
|
||||
@@ -31,12 +61,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: updateOrderStatus supports order.js by holding or executing the update order 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.
|
||||
*/
|
||||
updateOrderStatus(id, status) {
|
||||
return request({
|
||||
url: `/order/update-status/${id}`,
|
||||
|
||||
@@ -1,30 +1,54 @@
|
||||
/**
|
||||
* Purpose: request supports permission.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: getCurrentUserPermissions supports permission.js by holding or executing the get current user permissions 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.
|
||||
*/
|
||||
getCurrentUserPermissions() {
|
||||
return request({
|
||||
url: '/permission/user/current'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getUserPermissions supports permission.js by holding or executing the get user permissions 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.
|
||||
*/
|
||||
getUserPermissions(userId) {
|
||||
return request({
|
||||
url: `/permission/user/${userId}`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getAssignablePermissionIds supports permission.js by holding or executing the get assignable permission ids 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.
|
||||
*/
|
||||
getAssignablePermissionIds(userId) {
|
||||
return request({
|
||||
url: `/permission/assignable/${userId}`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: listAllPermissions supports permission.js by holding or executing the list all permissions 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.
|
||||
*/
|
||||
listAllPermissions() {
|
||||
return request({
|
||||
url: '/permission/list/all'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: createPermission supports permission.js by holding or executing the create permission 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.
|
||||
*/
|
||||
createPermission(data) {
|
||||
return request({
|
||||
url: '/permission/create',
|
||||
@@ -33,6 +57,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: updatePermission supports permission.js by holding or executing the update permission 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.
|
||||
*/
|
||||
updatePermission(id, data) {
|
||||
return request({
|
||||
url: `/permission/update/${id}`,
|
||||
@@ -41,6 +69,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: deletePermission supports permission.js by holding or executing the delete permission 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.
|
||||
*/
|
||||
deletePermission(id) {
|
||||
return request({
|
||||
url: `/permission/delete/${id}`,
|
||||
@@ -48,6 +80,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: assignUserPermissions supports permission.js by holding or executing the assign user permissions 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.
|
||||
*/
|
||||
assignUserPermissions(userId, permissionIds) {
|
||||
return request({
|
||||
url: `/permission/assign/${userId}`,
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
/**
|
||||
* Purpose: request supports product.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listProducts supports product.js by holding or executing the list 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.
|
||||
*/
|
||||
listProducts(params) {
|
||||
return request({
|
||||
url: '/product/list',
|
||||
@@ -8,12 +16,20 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: listAllProducts supports product.js by holding or executing the list 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.
|
||||
*/
|
||||
listAllProducts() {
|
||||
return request({
|
||||
url: '/product/list/all'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: createProduct supports product.js by holding or executing the create 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.
|
||||
*/
|
||||
createProduct(data) {
|
||||
return request({
|
||||
url: '/product/create',
|
||||
@@ -22,6 +38,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: updateProduct supports product.js by holding or executing the update 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.
|
||||
*/
|
||||
updateProduct(id, data) {
|
||||
return request({
|
||||
url: `/product/update/${id}`,
|
||||
@@ -30,6 +50,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: deleteProduct supports product.js by holding or executing the delete 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.
|
||||
*/
|
||||
deleteProduct(id) {
|
||||
return request({
|
||||
url: `/product/delete/${id}`,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Purpose: request sends signed admin mini-program requests to the backend audit API.
|
||||
* Usage: require this module from the audit page and call `listLogs` with filter params.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listLogs loads read-only security audit log rows for authorized administrators.
|
||||
* Usage: pass account, action, result, time range, page, and size filters, then render the returned page result.
|
||||
*/
|
||||
listLogs(params) {
|
||||
return request({
|
||||
url: '/security-audit/logs',
|
||||
params
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,14 @@
|
||||
/**
|
||||
* Purpose: request supports shop.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listShops supports shop.js by holding or executing the list 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.
|
||||
*/
|
||||
listShops(params) {
|
||||
return request({
|
||||
url: '/shops/list',
|
||||
@@ -8,18 +16,30 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: listAllShops supports shop.js by holding or executing the list all 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.
|
||||
*/
|
||||
listAllShops() {
|
||||
return request({
|
||||
url: '/shops/list/all'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getShop supports shop.js by holding or executing the get 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.
|
||||
*/
|
||||
getShop(id) {
|
||||
return request({
|
||||
url: `/shops/${id}`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: createShop supports shop.js by holding or executing the create 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.
|
||||
*/
|
||||
createShop(data) {
|
||||
return request({
|
||||
url: '/shops/create',
|
||||
@@ -28,6 +48,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: updateShop supports shop.js by holding or executing the update 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.
|
||||
*/
|
||||
updateShop(id, data) {
|
||||
return request({
|
||||
url: `/shops/update/${id}`,
|
||||
@@ -36,6 +60,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: updateShopStatus supports shop.js by holding or executing the update shop 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.
|
||||
*/
|
||||
updateShopStatus(id, status) {
|
||||
return request({
|
||||
url: `/shops/status/${id}`,
|
||||
@@ -46,6 +74,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: deleteShop supports shop.js by holding or executing the delete 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.
|
||||
*/
|
||||
deleteShop(id) {
|
||||
return request({
|
||||
url: `/shops/delete/${id}`,
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Purpose: request sends signed admin mini-program calls to the backend system-message endpoints.
|
||||
* Usage: keep all system-message API wrappers in this module so pages do not build URLs by hand.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listMessages loads admin-visible system messages including popup and business navigation metadata.
|
||||
* Usage: call it from the system-message management page during initial load or refresh.
|
||||
*/
|
||||
listMessages() {
|
||||
return request({
|
||||
url: '/system-message/admin/list'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: createMessage publishes a new system message to the selected target users.
|
||||
* Usage: pass validated form data with targetType, popupEnabled, and optional business fields.
|
||||
*/
|
||||
createMessage(data) {
|
||||
return request({
|
||||
url: '/system-message/admin/create',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: revokeMessage withdraws a previously published message when the operator has delete permission.
|
||||
* Usage: call it with the message id after an explicit confirmation dialog.
|
||||
*/
|
||||
revokeMessage(id) {
|
||||
return request({
|
||||
url: `/system-message/admin/${id}/revoke`,
|
||||
method: 'PUT',
|
||||
data: {}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getTargetOptions loads shops and users that the current operator may target.
|
||||
* Usage: call it before showing the publish form so picker data is permission-scoped.
|
||||
*/
|
||||
getTargetOptions() {
|
||||
return request({
|
||||
url: '/system-message/admin/target-options'
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,44 @@
|
||||
/**
|
||||
* Purpose: request supports tag.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listAllTags supports tag.js by holding or executing the list 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.
|
||||
*/
|
||||
listAllTags() {
|
||||
return request({
|
||||
url: '/tag/list/all'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: listTagsByShopId supports tag.js by holding or executing the list tags by shop 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.
|
||||
*/
|
||||
listTagsByShopId(shopId) {
|
||||
return request({
|
||||
url: `/tag/list/by-shop/${shopId}`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getTagById supports tag.js by holding or executing the get tag 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.
|
||||
*/
|
||||
getTagById(id) {
|
||||
return request({
|
||||
url: `/tag/get/${id}`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: createTag supports tag.js by holding or executing the create 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.
|
||||
*/
|
||||
createTag(data) {
|
||||
return request({
|
||||
url: '/tag/create',
|
||||
@@ -27,6 +47,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: updateTag supports tag.js by holding or executing the update 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.
|
||||
*/
|
||||
updateTag(id, data) {
|
||||
return request({
|
||||
url: `/tag/update/${id}`,
|
||||
@@ -35,6 +59,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: deleteTag supports tag.js by holding or executing the delete 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.
|
||||
*/
|
||||
deleteTag(id) {
|
||||
return request({
|
||||
url: `/tag/delete/${id}`,
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
/**
|
||||
* Purpose: request supports user.js by holding or executing the request 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 request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Purpose: listUsers supports user.js by holding or executing the list users 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.
|
||||
*/
|
||||
listUsers(params) {
|
||||
return request({
|
||||
url: '/user/list',
|
||||
@@ -8,12 +16,20 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: listAllUsers supports user.js by holding or executing the list all users 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.
|
||||
*/
|
||||
listAllUsers() {
|
||||
return request({
|
||||
url: '/user/list/all'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: listArtists supports user.js by holding or executing the list artists 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.
|
||||
*/
|
||||
listArtists(shopId) {
|
||||
return request({
|
||||
url: '/user/list/artists',
|
||||
@@ -21,6 +37,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: createUser supports user.js by holding or executing the create user 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.
|
||||
*/
|
||||
createUser(data) {
|
||||
return request({
|
||||
url: '/user/create',
|
||||
@@ -29,6 +49,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: updateUser supports user.js by holding or executing the update user 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.
|
||||
*/
|
||||
updateUser(id, data) {
|
||||
return request({
|
||||
url: `/user/update/${id}`,
|
||||
@@ -37,6 +61,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: updateUserStatus supports user.js by holding or executing the update user 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.
|
||||
*/
|
||||
updateUserStatus(id, status) {
|
||||
return request({
|
||||
url: `/user/status/${id}`,
|
||||
@@ -47,6 +75,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: deleteUser supports user.js by holding or executing the delete user 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.
|
||||
*/
|
||||
deleteUser(id) {
|
||||
return request({
|
||||
url: `/user/delete/${id}`,
|
||||
@@ -54,6 +86,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: unbindUser supports user.js by holding or executing the unbind user 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.
|
||||
*/
|
||||
unbindUser(id) {
|
||||
return request({
|
||||
url: `/user/unbind/${id}`,
|
||||
@@ -62,6 +98,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: resetPassword supports user.js by holding or executing the reset 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.
|
||||
*/
|
||||
resetPassword(id) {
|
||||
return request({
|
||||
url: `/user/reset-password/${id}`,
|
||||
@@ -69,24 +109,40 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getCurrentUserInfo supports user.js by holding or executing the get current 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.
|
||||
*/
|
||||
getCurrentUserInfo() {
|
||||
return request({
|
||||
url: '/user/info'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getUserAsset supports user.js by holding or executing the get user asset 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.
|
||||
*/
|
||||
getUserAsset(id) {
|
||||
return request({
|
||||
url: `/user/${id}/asset`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: getUserBalanceHistory supports user.js by holding or executing the get user 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.
|
||||
*/
|
||||
getUserBalanceHistory(id) {
|
||||
return request({
|
||||
url: `/user/${id}/balance/history`
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: changeUserBalance supports user.js by holding or executing the change user balance 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.
|
||||
*/
|
||||
changeUserBalance(id, data) {
|
||||
return request({
|
||||
url: `/user/${id}/balance/change`,
|
||||
@@ -95,6 +151,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: overrideUserVip supports user.js by holding or executing the override user vip 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.
|
||||
*/
|
||||
overrideUserVip(id, data) {
|
||||
return request({
|
||||
url: `/user/${id}/vip/override`,
|
||||
@@ -103,6 +163,10 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: recalculateUserVip supports user.js by holding or executing the recalculate user vip 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.
|
||||
*/
|
||||
recalculateUserVip(id) {
|
||||
return request({
|
||||
url: `/user/${id}/vip/recalculate`,
|
||||
|
||||
@@ -1,11 +1,35 @@
|
||||
/**
|
||||
* 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: permission supports app.js by holding or executing the permission 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 permission = require('./utils/permission')
|
||||
const { resetLoading } = require('./utils/loading')
|
||||
/**
|
||||
* 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')
|
||||
const { IDLE_TIMEOUT_MS, IDLE_WARNING_MS } = require('./utils/config')
|
||||
/**
|
||||
* Purpose: permissionApi supports app.js by holding or executing the permission 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 permissionApi = require('./api/permission')
|
||||
/**
|
||||
* 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: buildCurrentShop supports app.js by holding or executing the build current shop 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 buildCurrentShop(userInfo) {
|
||||
if (!userInfo || !userInfo.shopId) {
|
||||
return null
|
||||
@@ -27,6 +51,10 @@ App({
|
||||
pageDirtyFlags: {}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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,
|
||||
@@ -37,14 +65,26 @@ App({
|
||||
this.bootstrapSession()
|
||||
},
|
||||
|
||||
/**
|
||||
* 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()
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
resetLoading()
|
||||
|
||||
@@ -66,6 +106,10 @@ App({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: setPermissionState supports app.js by holding or executing the set permission state 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.
|
||||
*/
|
||||
setPermissionState(permissions) {
|
||||
const list = Array.isArray(permissions) ? permissions : []
|
||||
this.globalData.permissions = list
|
||||
@@ -91,6 +135,10 @@ App({
|
||||
return permissions
|
||||
},
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
||||
@@ -104,6 +152,10 @@ App({
|
||||
this.bootstrapSession()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: clearAdminSession supports app.js by holding or executing the clear admin 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.
|
||||
*/
|
||||
clearAdminSession() {
|
||||
auth.clearSession()
|
||||
this.globalData.isLoggedIn = false
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
"pages/shop-form/index",
|
||||
"pages/permissions/index",
|
||||
"pages/permission-form/index",
|
||||
"pages/system-messages/index",
|
||||
"pages/security-audit/index",
|
||||
"pages/order-detail/index"
|
||||
],
|
||||
"window": {
|
||||
|
||||
@@ -55,8 +55,16 @@ Component({
|
||||
* 组件的初始数据
|
||||
*/
|
||||
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: 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()
|
||||
@@ -65,9 +73,25 @@ Component({
|
||||
const isDevtools = platform === 'devtools'
|
||||
const { windowWidth, safeArea: { top = 0, bottom = 0 } = {} } = wx.getWindowInfo() || wx.getSystemInfoSync()
|
||||
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` : ``
|
||||
})
|
||||
},
|
||||
@@ -94,6 +118,10 @@ Component({
|
||||
const pages = getCurrentPages()
|
||||
if (data.delta && pages.length > 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: data.delta
|
||||
})
|
||||
return
|
||||
@@ -102,6 +130,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/workbench/index'
|
||||
})
|
||||
this.triggerEvent('home', {}, {})
|
||||
|
||||
@@ -1,16 +1,52 @@
|
||||
/**
|
||||
* Purpose: artistApi supports index.js by holding or executing the artist 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 artistApi = require('../../api/nail-artist')
|
||||
/**
|
||||
* 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: 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: 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: 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: format supports index.js by holding or executing the format 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 format = require('../../utils/format')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* Purpose: normalizeId supports index.js by holding or executing the normalize 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 normalizeId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildCheckableList supports index.js by holding or executing the build checkable 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 buildCheckableList(list, selectedIds, labelKey) {
|
||||
return (Array.isArray(list) ? list : []).map(item => ({
|
||||
...item,
|
||||
@@ -20,11 +56,19 @@ function buildCheckableList(list, selectedIds, labelKey) {
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: syncSelectedIds supports index.js by holding or executing the sync selected ids 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 syncSelectedIds(selectedIds, list) {
|
||||
const availableIds = new Set((Array.isArray(list) ? list : []).map(item => normalizeId(item.id)))
|
||||
return (Array.isArray(selectedIds) ? selectedIds : []).filter(id => availableIds.has(normalizeId(id)))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: filterProductsByShop supports index.js by holding or executing the filter products by shop 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 filterProductsByShop(products, shopId) {
|
||||
const targetShopId = normalizeId(shopId)
|
||||
if (!targetShopId) {
|
||||
@@ -35,36 +79,128 @@ function filterProductsByShop(products, shopId) {
|
||||
}
|
||||
|
||||
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: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: '',
|
||||
/**
|
||||
* Purpose: shops supports index.js by holding or executing the shops 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.
|
||||
*/
|
||||
shops: [],
|
||||
/**
|
||||
* Purpose: shopIndex supports index.js by holding or executing the shop index 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.
|
||||
*/
|
||||
shopIndex: 0,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: '',
|
||||
/**
|
||||
* Purpose: statusOptions supports index.js by holding or executing the status options 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.
|
||||
*/
|
||||
statusOptions: ['营业中', '休息中'],
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status index 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.
|
||||
*/
|
||||
statusIndex: 0,
|
||||
/**
|
||||
* Purpose: userForm supports index.js by holding or executing the user form 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.
|
||||
*/
|
||||
userForm: {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: artistForm supports index.js by holding or executing the artist form 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.
|
||||
*/
|
||||
artistForm: {
|
||||
/**
|
||||
* Purpose: identity supports index.js by holding or executing the identity 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.
|
||||
*/
|
||||
identity: '',
|
||||
/**
|
||||
* Purpose: experience supports index.js by holding or executing the experience 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.
|
||||
*/
|
||||
experience: '',
|
||||
/**
|
||||
* Purpose: rating supports index.js by holding or executing the rating 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.
|
||||
*/
|
||||
rating: '',
|
||||
/**
|
||||
* Purpose: portfolioText supports index.js by holding or executing the portfolio 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.
|
||||
*/
|
||||
portfolioText: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: [],
|
||||
/**
|
||||
* Purpose: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
products: []
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const mode = options && options.mode ? options.mode : 'create'
|
||||
const currentArtist = getTempRecord('currentArtist', null)
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: options && options.userId ? options.userId : ''
|
||||
})
|
||||
|
||||
@@ -77,19 +213,67 @@ Page({
|
||||
this._selectedProductIds = format.splitCsv(currentArtist.portfolio)
|
||||
this._initialShopId = currentArtist.shopId
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: artistForm supports index.js by holding or executing the artist form 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.
|
||||
*/
|
||||
artistForm: {
|
||||
/**
|
||||
* Purpose: identity supports index.js by holding or executing the identity 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.
|
||||
*/
|
||||
identity: currentArtist.identity || '',
|
||||
/**
|
||||
* Purpose: experience supports index.js by holding or executing the experience 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.
|
||||
*/
|
||||
experience: currentArtist.experience || '',
|
||||
/**
|
||||
* Purpose: rating supports index.js by holding or executing the rating 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.
|
||||
*/
|
||||
rating: currentArtist.rating || '',
|
||||
/**
|
||||
* Purpose: portfolioText supports index.js by holding or executing the portfolio 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.
|
||||
*/
|
||||
portfolioText: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: userForm supports index.js by holding or executing the user form 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.
|
||||
*/
|
||||
userForm: {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: currentArtist.nickname || '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: currentArtist.signature || ''
|
||||
},
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status index 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.
|
||||
*/
|
||||
statusIndex: Number(currentArtist.status) === 0 ? 1 : 0
|
||||
})
|
||||
}
|
||||
@@ -97,6 +281,10 @@ Page({
|
||||
this.loadDependencies()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentArtist')
|
||||
},
|
||||
@@ -132,11 +320,35 @@ Page({
|
||||
const userRecord = (Array.isArray(users) ? users : []).find(item => normalizeId(item.id) === normalizeId(this.data.userId))
|
||||
if (userRecord) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: userForm supports index.js by holding or executing the user form 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.
|
||||
*/
|
||||
userForm: {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: userRecord.nickname || '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: userRecord.account || '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: userRecord.phone || '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: userRecord.signature || ''
|
||||
}
|
||||
})
|
||||
@@ -144,15 +356,31 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: shops supports index.js by holding or executing the shops 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.
|
||||
*/
|
||||
shops: availableShops,
|
||||
shopIndex,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: selectedShop ? selectedShop.shopName : ''
|
||||
})
|
||||
|
||||
await this.loadShopScopedOptions(selectedShop ? selectedShop.id : '')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -163,7 +391,15 @@ Page({
|
||||
this._selectedTagIds = []
|
||||
this._selectedProductIds = []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: [],
|
||||
/**
|
||||
* Purpose: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
products: []
|
||||
})
|
||||
return
|
||||
@@ -175,21 +411,49 @@ Page({
|
||||
this._selectedTagIds = syncSelectedIds(this._selectedTagIds, tagList)
|
||||
this._selectedProductIds = syncSelectedIds(this._selectedProductIds, productList)
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: buildCheckableList(tagList, this._selectedTagIds, 'tagName'),
|
||||
/**
|
||||
* Purpose: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
products: buildCheckableList(productList, this._selectedProductIds, 'title')
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: [],
|
||||
/**
|
||||
* Purpose: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
products: []
|
||||
})
|
||||
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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleUserInput supports index.js by holding or executing the handle user 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.
|
||||
*/
|
||||
handleUserInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
let value = event.detail.value
|
||||
@@ -206,6 +470,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleArtistInput supports index.js by holding or executing the handle artist 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.
|
||||
*/
|
||||
handleArtistInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -213,42 +481,86 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShopChange supports index.js by holding or executing the handle shop 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.
|
||||
*/
|
||||
handleShopChange(event) {
|
||||
const shopIndex = Number(event.detail.value)
|
||||
const selectedShop = this.data.shops[shopIndex]
|
||||
this.setData({
|
||||
shopIndex,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: selectedShop ? selectedShop.shopName : ''
|
||||
})
|
||||
this.loadShopScopedOptions(selectedShop ? selectedShop.id : '')
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleStatusChange supports index.js by holding or executing the handle status 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.
|
||||
*/
|
||||
handleStatusChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status index 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.
|
||||
*/
|
||||
statusIndex: Number(event.detail.value)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTagChange supports index.js by holding or executing the handle tag 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.
|
||||
*/
|
||||
handleTagChange(event) {
|
||||
this._selectedTagIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: this.data.tags.map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: this._selectedTagIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleProductChange supports index.js by holding or executing the handle product 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.
|
||||
*/
|
||||
handleProductChange(event) {
|
||||
this._selectedProductIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
products: this.data.products.map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: this._selectedProductIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: validateForm supports index.js by holding or executing the validate form 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.
|
||||
*/
|
||||
validateForm() {
|
||||
if (!this.data.userForm.nickname) {
|
||||
return '请输入美甲师昵称'
|
||||
@@ -272,7 +584,15 @@ Page({
|
||||
const errorMessage = this.validateForm()
|
||||
if (errorMessage) {
|
||||
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: errorMessage,
|
||||
/**
|
||||
* 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
|
||||
@@ -280,11 +600,35 @@ Page({
|
||||
|
||||
const selectedShop = this.data.shops[this.data.shopIndex]
|
||||
const userPayload = {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: this.data.userForm.nickname,
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: this.data.userForm.account,
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: this.data.userForm.phone,
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: this.data.userForm.signature || undefined,
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: 3,
|
||||
/**
|
||||
* Purpose: shopIds supports index.js by holding or executing the shop ids 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.
|
||||
*/
|
||||
shopIds: selectedShop ? [Number(selectedShop.id)] : []
|
||||
}
|
||||
|
||||
@@ -301,26 +645,82 @@ Page({
|
||||
}
|
||||
|
||||
await artistApi.saveNailArtistInfo({
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: Number(targetUserId),
|
||||
/**
|
||||
* Purpose: identity supports index.js by holding or executing the identity 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.
|
||||
*/
|
||||
identity: this.data.artistForm.identity || undefined,
|
||||
/**
|
||||
* Purpose: experience supports index.js by holding or executing the experience 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.
|
||||
*/
|
||||
experience: this.data.artistForm.experience ? Number(this.data.artistForm.experience) : 0,
|
||||
/**
|
||||
* Purpose: skills supports index.js by holding or executing the skills 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.
|
||||
*/
|
||||
skills: this._selectedTagIds.join(',') || undefined,
|
||||
/**
|
||||
* Purpose: rating supports index.js by holding or executing the rating 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.
|
||||
*/
|
||||
rating: this.data.artistForm.rating ? Number(this.data.artistForm.rating) : 0,
|
||||
/**
|
||||
* Purpose: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: this.data.statusIndex === 1 ? 0 : 1,
|
||||
/**
|
||||
* Purpose: portfolio supports index.js by holding or executing the portfolio 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.
|
||||
*/
|
||||
portfolio: this._selectedProductIds.join(',') || undefined,
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: this.data.userForm.nickname,
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: selectedShop ? Number(selectedShop.id) : undefined,
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: this.data.userForm.signature || undefined
|
||||
})
|
||||
|
||||
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: this.data.mode === 'edit' ? '美甲师已更新' : '美甲师已创建',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
navigation.goBack('/pages/artists/index')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,13 +1,37 @@
|
||||
/**
|
||||
* Purpose: artistApi supports index.js by holding or executing the artist 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 artistApi = require('../../api/nail-artist')
|
||||
/**
|
||||
* 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 { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入美甲师管理')) {
|
||||
return
|
||||
@@ -15,6 +39,10 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('user:create') || permissionCodes.includes('nail_artist:edit')
|
||||
})
|
||||
this.loadArtists()
|
||||
@@ -24,31 +52,67 @@ Page({
|
||||
try {
|
||||
const list = await artistApi.listNailArtists()
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(list) ? list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayStatusText supports index.js by holding or executing the display status 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.
|
||||
*/
|
||||
displayStatusText: Number(item.status) === 0 ? '休息中' : '营业中'
|
||||
}))
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentArtist')
|
||||
navigation.navigate('/pages/artist-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const artist = event.currentTarget.dataset.artist
|
||||
setTempRecord('currentArtist', artist)
|
||||
navigation.navigate('/pages/artist-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'edit',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: artist.userId
|
||||
}).catch(() => undefined)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,36 @@
|
||||
/**
|
||||
* 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')
|
||||
|
||||
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: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: comments supports index.js by holding or executing the comments 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.
|
||||
*/
|
||||
comments: []
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.loadComments()
|
||||
},
|
||||
@@ -16,8 +40,16 @@ Page({
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
@@ -26,14 +58,30 @@ Page({
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const comments = await commentApi.listComments({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined
|
||||
})
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: comments supports index.js by holding or executing the comments 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.
|
||||
*/
|
||||
comments: Array.isArray(comments) ? comments : []
|
||||
})
|
||||
} 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 {
|
||||
@@ -41,19 +89,43 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadComments()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDelete supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleDelete(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: '删除评论',
|
||||
/**
|
||||
* Purpose: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: '确认删除这条评论?',
|
||||
/**
|
||||
* Purpose: confirmText supports index.js by holding or executing the confirm 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.
|
||||
*/
|
||||
confirmText: '删除',
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async res => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
|
||||
@@ -1,14 +1,42 @@
|
||||
/**
|
||||
* 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: 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: 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: 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: format supports index.js by holding or executing the format 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 format = require('../../utils/format')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* Purpose: normalizeId supports index.js by holding or executing the normalize 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 normalizeId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildCheckableList supports index.js by holding or executing the build checkable 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 buildCheckableList(list, selectedIds, labelKey) {
|
||||
return (Array.isArray(list) ? list : []).map(item => ({
|
||||
...item,
|
||||
@@ -18,47 +46,167 @@ function buildCheckableList(list, selectedIds, labelKey) {
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: syncSelectedIds supports index.js by holding or executing the sync selected ids 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 syncSelectedIds(selectedIds, list) {
|
||||
const availableIds = new Set((Array.isArray(list) ? list : []).map(item => normalizeId(item.id)))
|
||||
return (Array.isArray(selectedIds) ? selectedIds : []).filter(id => availableIds.has(normalizeId(id)))
|
||||
}
|
||||
|
||||
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: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create',
|
||||
/**
|
||||
* Purpose: couponId supports index.js by holding or executing the coupon id 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.
|
||||
*/
|
||||
couponId: '',
|
||||
/**
|
||||
* Purpose: shops supports index.js by holding or executing the shops 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.
|
||||
*/
|
||||
shops: [],
|
||||
/**
|
||||
* Purpose: shopIndex supports index.js by holding or executing the shop index 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.
|
||||
*/
|
||||
shopIndex: 0,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: '',
|
||||
/**
|
||||
* Purpose: couponTypeOptions supports index.js by holding or executing the coupon type options 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.
|
||||
*/
|
||||
couponTypeOptions: ['折扣券', '满减券'],
|
||||
/**
|
||||
* Purpose: couponTypeIndex supports index.js by holding or executing the coupon type index 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.
|
||||
*/
|
||||
couponTypeIndex: 0,
|
||||
/**
|
||||
* Purpose: couponTypeLabel supports index.js by holding or executing the coupon type label 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.
|
||||
*/
|
||||
couponTypeLabel: '折扣券',
|
||||
/**
|
||||
* Purpose: vipLevelOptions supports index.js by holding or executing the vip level options 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.
|
||||
*/
|
||||
vipLevelOptions: ['普通', '青铜', '白银', '黄金'],
|
||||
/**
|
||||
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level index 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.
|
||||
*/
|
||||
vipLevelIndex: 0,
|
||||
/**
|
||||
* Purpose: vipLevelLabel supports index.js by holding or executing the vip level label 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.
|
||||
*/
|
||||
vipLevelLabel: '普通',
|
||||
/**
|
||||
* Purpose: startDate supports index.js by holding or executing the start date 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.
|
||||
*/
|
||||
startDate: '',
|
||||
/**
|
||||
* Purpose: startTime supports index.js by holding or executing the start time 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.
|
||||
*/
|
||||
startTime: '',
|
||||
/**
|
||||
* Purpose: endDate supports index.js by holding or executing the end date 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.
|
||||
*/
|
||||
endDate: '',
|
||||
/**
|
||||
* Purpose: endTime supports index.js by holding or executing the end time 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.
|
||||
*/
|
||||
endTime: '',
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available tags 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.
|
||||
*/
|
||||
availableTags: [],
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable tags 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.
|
||||
*/
|
||||
unavailableTags: [],
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: couponName supports index.js by holding or executing the coupon name 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.
|
||||
*/
|
||||
couponName: '',
|
||||
/**
|
||||
* Purpose: couponCode supports index.js by holding or executing the coupon code 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.
|
||||
*/
|
||||
couponCode: '',
|
||||
/**
|
||||
* Purpose: discountValue supports index.js by holding or executing the discount value 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.
|
||||
*/
|
||||
discountValue: '',
|
||||
/**
|
||||
* Purpose: minAmount supports index.js by holding or executing the min amount 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.
|
||||
*/
|
||||
minAmount: '',
|
||||
/**
|
||||
* Purpose: reduceAmount supports index.js by holding or executing the reduce amount 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.
|
||||
*/
|
||||
reduceAmount: '',
|
||||
/**
|
||||
* Purpose: totalCount supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
totalCount: '',
|
||||
/**
|
||||
* Purpose: couponScene supports index.js by holding or executing the coupon scene 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.
|
||||
*/
|
||||
couponScene: '',
|
||||
/**
|
||||
* Purpose: autoMatch supports index.js by holding or executing the auto match 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.
|
||||
*/
|
||||
autoMatch: false
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const mode = options && options.mode ? options.mode : 'create'
|
||||
const currentCoupon = getTempRecord('currentCoupon', null)
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: couponId supports index.js by holding or executing the coupon id 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.
|
||||
*/
|
||||
couponId: options && options.id ? options.id : ''
|
||||
})
|
||||
|
||||
@@ -72,23 +220,91 @@ Page({
|
||||
this._selectedUnavailableTagIds = Array.isArray(currentCoupon.unavailableTags) ? currentCoupon.unavailableTags.map(item => String(item.id)) : []
|
||||
this._initialShopId = currentCoupon.shopId
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: couponName supports index.js by holding or executing the coupon name 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.
|
||||
*/
|
||||
couponName: currentCoupon.couponName || '',
|
||||
/**
|
||||
* Purpose: couponCode supports index.js by holding or executing the coupon code 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.
|
||||
*/
|
||||
couponCode: currentCoupon.couponCode || '',
|
||||
/**
|
||||
* Purpose: discountValue supports index.js by holding or executing the discount value 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.
|
||||
*/
|
||||
discountValue: currentCoupon.discountValue || '',
|
||||
/**
|
||||
* Purpose: minAmount supports index.js by holding or executing the min amount 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.
|
||||
*/
|
||||
minAmount: currentCoupon.minAmount || '',
|
||||
/**
|
||||
* Purpose: reduceAmount supports index.js by holding or executing the reduce amount 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.
|
||||
*/
|
||||
reduceAmount: currentCoupon.reduceAmount || '',
|
||||
/**
|
||||
* Purpose: totalCount supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
totalCount: currentCoupon.totalCount || '',
|
||||
/**
|
||||
* Purpose: couponScene supports index.js by holding or executing the coupon scene 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.
|
||||
*/
|
||||
couponScene: currentCoupon.couponScene || '',
|
||||
/**
|
||||
* Purpose: autoMatch supports index.js by holding or executing the auto match 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.
|
||||
*/
|
||||
autoMatch: Number(currentCoupon.autoMatch) === 1
|
||||
},
|
||||
/**
|
||||
* Purpose: couponTypeIndex supports index.js by holding or executing the coupon type index 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.
|
||||
*/
|
||||
couponTypeIndex: Number(currentCoupon.couponType) === 2 ? 1 : 0,
|
||||
/**
|
||||
* Purpose: couponTypeLabel supports index.js by holding or executing the coupon type label 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.
|
||||
*/
|
||||
couponTypeLabel: Number(currentCoupon.couponType) === 2 ? '满减券' : '折扣券',
|
||||
/**
|
||||
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level index 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.
|
||||
*/
|
||||
vipLevelIndex: this.data.vipLevelOptions.findIndex(item => item === (currentCoupon.requiredVipLevel || '普通')),
|
||||
/**
|
||||
* Purpose: vipLevelLabel supports index.js by holding or executing the vip level label 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.
|
||||
*/
|
||||
vipLevelLabel: currentCoupon.requiredVipLevel || '普通',
|
||||
/**
|
||||
* Purpose: startDate supports index.js by holding or executing the start date 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.
|
||||
*/
|
||||
startDate: start.date,
|
||||
/**
|
||||
* Purpose: startTime supports index.js by holding or executing the start time 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.
|
||||
*/
|
||||
startTime: start.time,
|
||||
/**
|
||||
* Purpose: endDate supports index.js by holding or executing the end date 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.
|
||||
*/
|
||||
endDate: end.date,
|
||||
/**
|
||||
* Purpose: endTime supports index.js by holding or executing the end time 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.
|
||||
*/
|
||||
endTime: end.time
|
||||
})
|
||||
}
|
||||
@@ -96,6 +312,10 @@ Page({
|
||||
this.loadDependencies()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentCoupon')
|
||||
},
|
||||
@@ -125,13 +345,25 @@ Page({
|
||||
this.setData({
|
||||
shops,
|
||||
shopIndex,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: selectedShop ? selectedShop.shopName : ''
|
||||
})
|
||||
|
||||
await this.loadTagOptions(selectedShop ? selectedShop.id : '')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -142,7 +374,15 @@ Page({
|
||||
this._selectedAvailableTagIds = []
|
||||
this._selectedUnavailableTagIds = []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available tags 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.
|
||||
*/
|
||||
availableTags: [],
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable tags 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.
|
||||
*/
|
||||
unavailableTags: []
|
||||
})
|
||||
return
|
||||
@@ -153,21 +393,49 @@ Page({
|
||||
this._selectedAvailableTagIds = syncSelectedIds(this._selectedAvailableTagIds, tagList)
|
||||
this._selectedUnavailableTagIds = syncSelectedIds(this._selectedUnavailableTagIds, tagList)
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available tags 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.
|
||||
*/
|
||||
availableTags: buildCheckableList(tagList, this._selectedAvailableTagIds, 'tagName'),
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable tags 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.
|
||||
*/
|
||||
unavailableTags: buildCheckableList(tagList, this._selectedUnavailableTagIds, 'tagName')
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available tags 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.
|
||||
*/
|
||||
availableTags: [],
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable tags 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.
|
||||
*/
|
||||
unavailableTags: []
|
||||
})
|
||||
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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleInputChange supports index.js by holding or executing the handle input 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.
|
||||
*/
|
||||
handleInputChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const value = event.detail.value
|
||||
@@ -176,32 +444,60 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShopChange supports index.js by holding or executing the handle shop 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.
|
||||
*/
|
||||
handleShopChange(event) {
|
||||
const shopIndex = Number(event.detail.value)
|
||||
const selectedShop = this.data.shops[shopIndex]
|
||||
this.setData({
|
||||
shopIndex,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: selectedShop ? selectedShop.shopName : ''
|
||||
})
|
||||
this.loadTagOptions(selectedShop ? selectedShop.id : '')
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCouponTypeChange supports index.js by holding or executing the handle coupon type 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.
|
||||
*/
|
||||
handleCouponTypeChange(event) {
|
||||
const couponTypeIndex = Number(event.detail.value)
|
||||
this.setData({
|
||||
couponTypeIndex,
|
||||
/**
|
||||
* Purpose: couponTypeLabel supports index.js by holding or executing the coupon type label 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.
|
||||
*/
|
||||
couponTypeLabel: this.data.couponTypeOptions[couponTypeIndex]
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleVipLevelChange supports index.js by holding or executing the handle vip level 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.
|
||||
*/
|
||||
handleVipLevelChange(event) {
|
||||
const vipLevelIndex = Number(event.detail.value)
|
||||
this.setData({
|
||||
vipLevelIndex,
|
||||
/**
|
||||
* Purpose: vipLevelLabel supports index.js by holding or executing the vip level label 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.
|
||||
*/
|
||||
vipLevelLabel: this.data.vipLevelOptions[vipLevelIndex]
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDateTimeChange supports index.js by holding or executing the handle date time 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.
|
||||
*/
|
||||
handleDateTimeChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -209,27 +505,55 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAutoMatchChange supports index.js by holding or executing the handle auto match 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.
|
||||
*/
|
||||
handleAutoMatchChange(event) {
|
||||
this.setData({
|
||||
'form.autoMatch': event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAvailableTagChange supports index.js by holding or executing the handle available tag 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.
|
||||
*/
|
||||
handleAvailableTagChange(event) {
|
||||
this._selectedAvailableTagIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available tags 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.
|
||||
*/
|
||||
availableTags: this.data.availableTags.map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: this._selectedAvailableTagIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleUnavailableTagChange supports index.js by holding or executing the handle unavailable tag 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.
|
||||
*/
|
||||
handleUnavailableTagChange(event) {
|
||||
this._selectedUnavailableTagIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable tags 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.
|
||||
*/
|
||||
unavailableTags: this.data.unavailableTags.map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: this._selectedUnavailableTagIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
@@ -239,34 +563,110 @@ Page({
|
||||
const selectedShop = this.data.shops[this.data.shopIndex]
|
||||
if (!this.data.form.couponName) {
|
||||
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: '请输入优惠券名称',
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
if (!selectedShop) {
|
||||
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: '请选择所属店铺',
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
const payload = {
|
||||
/**
|
||||
* Purpose: couponCode supports index.js by holding or executing the coupon code 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.
|
||||
*/
|
||||
couponCode: this.data.form.couponCode || undefined,
|
||||
/**
|
||||
* Purpose: couponName supports index.js by holding or executing the coupon name 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.
|
||||
*/
|
||||
couponName: this.data.form.couponName,
|
||||
/**
|
||||
* Purpose: couponType supports index.js by holding or executing the coupon type 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.
|
||||
*/
|
||||
couponType: this.data.couponTypeIndex === 1 ? 2 : 1,
|
||||
/**
|
||||
* Purpose: discountValue supports index.js by holding or executing the discount value 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.
|
||||
*/
|
||||
discountValue: this.data.couponTypeIndex === 0 ? Number(this.data.form.discountValue || 0) : undefined,
|
||||
/**
|
||||
* Purpose: minAmount supports index.js by holding or executing the min amount 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.
|
||||
*/
|
||||
minAmount: this.data.couponTypeIndex === 1 ? Number(this.data.form.minAmount || 0) : undefined,
|
||||
/**
|
||||
* Purpose: reduceAmount supports index.js by holding or executing the reduce amount 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.
|
||||
*/
|
||||
reduceAmount: this.data.couponTypeIndex === 1 ? Number(this.data.form.reduceAmount || 0) : undefined,
|
||||
/**
|
||||
* Purpose: totalCount supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
totalCount: this.data.form.totalCount ? Number(this.data.form.totalCount) : undefined,
|
||||
/**
|
||||
* Purpose: startTime supports index.js by holding or executing the start time 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.
|
||||
*/
|
||||
startTime: format.buildDateTime(this.data.startDate, this.data.startTime),
|
||||
/**
|
||||
* Purpose: endTime supports index.js by holding or executing the end time 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.
|
||||
*/
|
||||
endTime: format.buildDateTime(this.data.endDate, this.data.endTime),
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: selectedShop.id,
|
||||
/**
|
||||
* Purpose: couponScene supports index.js by holding or executing the coupon scene 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.
|
||||
*/
|
||||
couponScene: this.data.form.couponScene || undefined,
|
||||
/**
|
||||
* Purpose: requiredVipLevel supports index.js by holding or executing the required 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.
|
||||
*/
|
||||
requiredVipLevel: this.data.vipLevelLabel || undefined,
|
||||
/**
|
||||
* Purpose: autoMatch supports index.js by holding or executing the auto match 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.
|
||||
*/
|
||||
autoMatch: this.data.form.autoMatch ? 1 : 0,
|
||||
/**
|
||||
* Purpose: availableTagIds supports index.js by holding or executing the available tag ids 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.
|
||||
*/
|
||||
availableTagIds: this._selectedAvailableTagIds.map(item => Number(item)),
|
||||
/**
|
||||
* Purpose: unavailableTagIds supports index.js by holding or executing the unavailable tag ids 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.
|
||||
*/
|
||||
unavailableTagIds: this._selectedUnavailableTagIds.map(item => Number(item))
|
||||
}
|
||||
|
||||
@@ -277,13 +677,29 @@ Page({
|
||||
await couponApi.createCoupon(payload)
|
||||
}
|
||||
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: this.data.mode === 'edit' ? '优惠券已更新' : '优惠券已创建',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
navigation.goBack('/pages/coupons/index')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,14 +1,42 @@
|
||||
/**
|
||||
* 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: format supports index.js by holding or executing the format 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 format = require('../../utils/format')
|
||||
/**
|
||||
* 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 { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入优惠券管理')) {
|
||||
return
|
||||
@@ -16,6 +44,10 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('coupon:create')
|
||||
})
|
||||
this.loadCoupons()
|
||||
@@ -24,54 +56,130 @@ Page({
|
||||
async loadCoupons() {
|
||||
try {
|
||||
const result = await couponApi.listCoupons({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20
|
||||
})
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(result && result.list) ? result.list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayTypeText supports index.js by holding or executing the display type 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.
|
||||
*/
|
||||
displayTypeText: format.getCouponTypeText(item.couponType),
|
||||
/**
|
||||
* Purpose: displayValueText supports index.js by holding or executing the display value 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.
|
||||
*/
|
||||
displayValueText: format.getCouponValueText(item),
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: item.shopName || '当前店铺'
|
||||
}))
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentCoupon')
|
||||
navigation.navigate('/pages/coupon-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const coupon = event.currentTarget.dataset.coupon
|
||||
setTempRecord('currentCoupon', coupon)
|
||||
navigation.navigate('/pages/coupon-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: coupon.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDistribute supports index.js by holding or executing the handle distribute 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.
|
||||
*/
|
||||
handleDistribute(event) {
|
||||
const coupon = event.currentTarget.dataset.coupon
|
||||
setTempRecord('currentCoupon', coupon)
|
||||
navigation.navigate('/pages/coupon-distribute/index', {
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: coupon.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDelete supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleDelete(event) {
|
||||
const coupon = event.currentTarget.dataset.coupon
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: '删除优惠券',
|
||||
/**
|
||||
* Purpose: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: `确认删除优惠券“${coupon.couponName}”吗?`,
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -79,13 +187,29 @@ Page({
|
||||
try {
|
||||
await couponApi.deleteCoupon(coupon.id)
|
||||
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: '优惠券已删除',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.loadCoupons()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,31 +1,111 @@
|
||||
/**
|
||||
* 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: 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')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* Purpose: ACCOUNT_REGEX supports index.js by holding or executing the account 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 ACCOUNT_REGEX = /[^A-Za-z0-9]/g
|
||||
|
||||
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: redirect supports index.js by holding or executing the redirect 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.
|
||||
*/
|
||||
redirect: '',
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: loginShops supports index.js by holding or executing the login shops 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.
|
||||
*/
|
||||
loginShops: [],
|
||||
/**
|
||||
* Purpose: loginShopIndex supports index.js by holding or executing the login shop index 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.
|
||||
*/
|
||||
loginShopIndex: -1,
|
||||
/**
|
||||
* Purpose: loginShopDisplayName supports index.js by holding or executing the login shop display name 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.
|
||||
*/
|
||||
loginShopDisplayName: '',
|
||||
/**
|
||||
* Purpose: allowShoplessLogin supports index.js by holding or executing the allow shopless login 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.
|
||||
*/
|
||||
allowShoplessLogin: false,
|
||||
/**
|
||||
* Purpose: loginShopMessage supports index.js by holding or executing the login shop 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.
|
||||
*/
|
||||
loginShopMessage: '',
|
||||
/**
|
||||
* Purpose: accountStatusText supports index.js by holding or executing the account status 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.
|
||||
*/
|
||||
accountStatusText: '',
|
||||
/**
|
||||
* Purpose: accountStatusType supports index.js by holding or executing the account status type 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.
|
||||
*/
|
||||
accountStatusType: '',
|
||||
/**
|
||||
* 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: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
this._lookupTicket = 0
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: redirect supports index.js by holding or executing the redirect 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.
|
||||
*/
|
||||
redirect: options && options.redirect ? options.redirect : ''
|
||||
})
|
||||
|
||||
@@ -34,12 +114,20 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
if (this._accountTimer) {
|
||||
clearTimeout(this._accountTimer)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleInputChange supports index.js by holding or executing the handle input 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.
|
||||
*/
|
||||
handleInputChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
let value = event.detail.value
|
||||
@@ -57,17 +145,33 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShopChange supports index.js by holding or executing the handle shop 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.
|
||||
*/
|
||||
handleShopChange(event) {
|
||||
const index = Number(event.detail.value)
|
||||
const shop = this.data.loginShops[index]
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loginShopIndex supports index.js by holding or executing the login shop index 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.
|
||||
*/
|
||||
loginShopIndex: index,
|
||||
/**
|
||||
* Purpose: loginShopDisplayName supports index.js by holding or executing the login shop display name 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.
|
||||
*/
|
||||
loginShopDisplayName: shop ? shop.shopName || '' : '',
|
||||
'form.shopId': shop ? shop.id : ''
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: resetAccountState supports index.js by holding or executing the reset account state 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.
|
||||
*/
|
||||
resetAccountState() {
|
||||
if (this._accountTimer) {
|
||||
clearTimeout(this._accountTimer)
|
||||
@@ -76,17 +180,49 @@ Page({
|
||||
this._lookupTicket += 1
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: accountStatusText supports index.js by holding or executing the account status 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.
|
||||
*/
|
||||
accountStatusText: '',
|
||||
/**
|
||||
* Purpose: accountStatusType supports index.js by holding or executing the account status type 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.
|
||||
*/
|
||||
accountStatusType: '',
|
||||
/**
|
||||
* Purpose: loginShops supports index.js by holding or executing the login shops 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.
|
||||
*/
|
||||
loginShops: [],
|
||||
/**
|
||||
* Purpose: loginShopIndex supports index.js by holding or executing the login shop index 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.
|
||||
*/
|
||||
loginShopIndex: -1,
|
||||
/**
|
||||
* Purpose: loginShopDisplayName supports index.js by holding or executing the login shop display name 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.
|
||||
*/
|
||||
loginShopDisplayName: '',
|
||||
/**
|
||||
* Purpose: allowShoplessLogin supports index.js by holding or executing the allow shopless login 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.
|
||||
*/
|
||||
allowShoplessLogin: false,
|
||||
/**
|
||||
* Purpose: loginShopMessage supports index.js by holding or executing the login shop 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.
|
||||
*/
|
||||
loginShopMessage: '',
|
||||
'form.shopId': ''
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: scheduleAccountLookup supports index.js by holding or executing the schedule account lookup 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.
|
||||
*/
|
||||
scheduleAccountLookup(account) {
|
||||
if (this._accountTimer) {
|
||||
clearTimeout(this._accountTimer)
|
||||
@@ -99,6 +235,10 @@ Page({
|
||||
}, 420)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: applyLoginShopSelection supports index.js by holding or executing the apply login shop selection 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.
|
||||
*/
|
||||
applyLoginShopSelection(selection) {
|
||||
const shops = Array.isArray(selection && selection.shops) ? selection.shops : []
|
||||
const allowShoplessLogin = Boolean(selection && selection.allowShoplessLogin)
|
||||
@@ -113,13 +253,29 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loginShops supports index.js by holding or executing the login shops 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.
|
||||
*/
|
||||
loginShops: shops,
|
||||
allowShoplessLogin,
|
||||
/**
|
||||
* Purpose: loginShopMessage supports index.js by holding or executing the login shop 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.
|
||||
*/
|
||||
loginShopMessage: (selection && selection.message) || '',
|
||||
loginShopIndex,
|
||||
loginShopDisplayName,
|
||||
'form.shopId': shopId,
|
||||
/**
|
||||
* Purpose: accountStatusText supports index.js by holding or executing the account status 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.
|
||||
*/
|
||||
accountStatusText: shops.length || allowShoplessLogin ? '该账号可用于后台登录' : '当前账号暂时不可用于后台登录',
|
||||
/**
|
||||
* Purpose: accountStatusType supports index.js by holding or executing the account status type 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.
|
||||
*/
|
||||
accountStatusType: shops.length || allowShoplessLogin ? 'success' : 'warning'
|
||||
})
|
||||
},
|
||||
@@ -141,18 +297,50 @@ Page({
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loginShops supports index.js by holding or executing the login shops 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.
|
||||
*/
|
||||
loginShops: [],
|
||||
/**
|
||||
* Purpose: loginShopIndex supports index.js by holding or executing the login shop index 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.
|
||||
*/
|
||||
loginShopIndex: -1,
|
||||
/**
|
||||
* Purpose: loginShopDisplayName supports index.js by holding or executing the login shop display name 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.
|
||||
*/
|
||||
loginShopDisplayName: '',
|
||||
/**
|
||||
* Purpose: allowShoplessLogin supports index.js by holding or executing the allow shopless login 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.
|
||||
*/
|
||||
allowShoplessLogin: false,
|
||||
/**
|
||||
* Purpose: loginShopMessage supports index.js by holding or executing the login shop 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.
|
||||
*/
|
||||
loginShopMessage: '',
|
||||
'form.shopId': '',
|
||||
/**
|
||||
* Purpose: accountStatusText supports index.js by holding or executing the account status 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.
|
||||
*/
|
||||
accountStatusText: error.message || '该后台账号不存在或不可登录',
|
||||
/**
|
||||
* Purpose: accountStatusType supports index.js by holding or executing the account status type 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.
|
||||
*/
|
||||
accountStatusType: 'error'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: validateForm supports index.js by holding or executing the validate form 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.
|
||||
*/
|
||||
validateForm() {
|
||||
const form = this.data.form
|
||||
if (!form.account) {
|
||||
@@ -171,38 +359,82 @@ Page({
|
||||
const errorMessage = this.validateForm()
|
||||
if (errorMessage) {
|
||||
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: errorMessage,
|
||||
/**
|
||||
* 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: 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: true
|
||||
})
|
||||
|
||||
try {
|
||||
const payload = await runWithLoading(() => authApi.login({
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: this.data.form.account,
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: this.data.form.password,
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: this.data.form.shopId || undefined
|
||||
}))
|
||||
|
||||
await getApp().setAdminSession(payload)
|
||||
|
||||
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: '登录成功',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
|
||||
await navigation.redirectAfterLogin(this.data.redirect)
|
||||
} 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 {
|
||||
this.setData({
|
||||
/**
|
||||
* 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
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,13 +1,41 @@
|
||||
/**
|
||||
* 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: permission supports index.js by holding or executing the permission 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 permission = require('../../utils/permission')
|
||||
|
||||
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: userInfo supports index.js by holding or executing the user info 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.
|
||||
*/
|
||||
userInfo: null,
|
||||
/**
|
||||
* Purpose: currentShop supports index.js by holding or executing the current shop 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.
|
||||
*/
|
||||
currentShop: null,
|
||||
/**
|
||||
* Purpose: modules supports index.js by holding or executing the modules 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.
|
||||
*/
|
||||
modules: []
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入经营模块')) {
|
||||
return
|
||||
@@ -21,10 +49,18 @@ Page({
|
||||
this.setData({
|
||||
userInfo,
|
||||
currentShop,
|
||||
/**
|
||||
* Purpose: modules supports index.js by holding or executing the modules 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.
|
||||
*/
|
||||
modules: permission.getManageModules(userInfo, permissionCodes, currentShop)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenModule supports index.js by holding or executing the handle open module 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.
|
||||
*/
|
||||
handleOpenModule(event) {
|
||||
const module = event.currentTarget.dataset.module
|
||||
if (!module) {
|
||||
@@ -33,7 +69,15 @@ Page({
|
||||
|
||||
if (!module.allowed) {
|
||||
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: module.disabledReason || '当前账号没有进入该模块的权限',
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -1,27 +1,125 @@
|
||||
/**
|
||||
* Purpose: orderApi loads full backend order detail so direct entry and message navigation can render complete data.
|
||||
* Usage: call getOrderDetail with the current route id before displaying the order detail page.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
/**
|
||||
* 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: format supports index.js by holding or executing the format 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 format = require('../../utils/format')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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 marks whether the detail endpoint is currently fetching order data.
|
||||
* Usage: bind it to loading and retry states while preserving any cached order shown on screen.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: orderId keeps the backend order id used by reload and direct-entry flows.
|
||||
* Usage: set it from route options or cached list data before calling loadOrderDetail.
|
||||
*/
|
||||
orderId: '',
|
||||
/**
|
||||
* Purpose: order supports index.js by holding or executing the order 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.
|
||||
*/
|
||||
order: null
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
const order = getTempRecord('currentOrder', null)
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const cachedOrder = getTempRecord('currentOrder', null)
|
||||
const orderId = (options && options.id) || (cachedOrder && cachedOrder.id) || ''
|
||||
this.setData({
|
||||
order: order ? {
|
||||
...order,
|
||||
displayStatusText: format.getOrderStatusText(order),
|
||||
displayCreateTime: format.formatDateTime(order.createTime)
|
||||
} : null
|
||||
orderId,
|
||||
order: cachedOrder ? this.formatOrder(cachedOrder) : null
|
||||
})
|
||||
|
||||
if (orderId) {
|
||||
this.loadOrderDetail(orderId)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: loadOrderDetail replaces list-row summary data with the authoritative admin order-detail response.
|
||||
* Usage: call it from onLoad and retry buttons with the backend order id; failures leave cached data visible.
|
||||
*/
|
||||
async loadOrderDetail(orderId) {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const detail = await orderApi.getOrderDetail(orderId)
|
||||
this.setData({
|
||||
order: this.formatOrder(detail)
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '订单详情加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: formatOrder prepares order and item fields for WXML, including review and change-request summaries.
|
||||
* Usage: run every cached or fetched order object through this method before assigning it to data.order.
|
||||
*/
|
||||
formatOrder(order) {
|
||||
const items = Array.isArray(order && order.items) ? order.items : []
|
||||
return order ? {
|
||||
...order,
|
||||
displayStatusText: format.getOrderStatusText(order),
|
||||
displayCreateTime: format.formatDateTime(order.createTime),
|
||||
displayPayAmount: format.formatPrice(order.payAmount),
|
||||
items: items.map(item => ({
|
||||
...item,
|
||||
displayAppointmentTime: item.appointmentTime ? format.formatDateTime(item.appointmentTime) : '',
|
||||
reviewStatusText: item.reviewStatusText || (item.reviewSummary ? '已评价' : '待评价'),
|
||||
changeStatusText: item.pendingArtistChangeRequest ? item.pendingArtistChangeRequest.displayText : ''
|
||||
}))
|
||||
} : null
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleRetry reloads backend detail when direct entry failed or no cached data exists.
|
||||
* Usage: bind it to the empty state action so operators can recover without returning to the list.
|
||||
*/
|
||||
handleRetry() {
|
||||
if (!this.data.orderId) {
|
||||
navigation.goBack('/pages/orders/index')
|
||||
return
|
||||
}
|
||||
this.loadOrderDetail(this.data.orderId)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentOrder')
|
||||
},
|
||||
|
||||
/**
|
||||
* 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/orders/index')
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">应付金额</text>
|
||||
<text class="meta-value">¥{{order.payAmount || '--'}}</text>
|
||||
<text class="meta-value">¥{{order.displayPayAmount || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">备注</text>
|
||||
@@ -33,9 +33,30 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:else class="empty-state">
|
||||
<view wx:if="{{order && order.items && order.items.length}}" class="surface-card">
|
||||
<text class="section-title">服务项目</text>
|
||||
<block wx:for="{{order.items}}" wx:key="id">
|
||||
<view class="detail-item">
|
||||
<view class="detail-item-head">
|
||||
<text class="detail-item-title">{{item.productTitle || '订单项目'}}</text>
|
||||
<text class="badge">{{item.reviewStatusText}}</text>
|
||||
</view>
|
||||
<text class="detail-item-line">美甲师:{{item.artistName || '--'}}</text>
|
||||
<text wx:if="{{item.displayAppointmentTime}}" class="detail-item-line">预约时间:{{item.displayAppointmentTime}}</text>
|
||||
<text wx:if="{{item.reviewSummary && item.reviewSummary.contentText}}" class="detail-item-line">评价内容:{{item.reviewSummary.contentText}}</text>
|
||||
<view wx:if="{{item.pendingArtistChangeRequest}}" class="change-box">
|
||||
<text class="change-title">改派申请</text>
|
||||
<text class="change-line">{{item.pendingArtistChangeRequest.displayText}}</text>
|
||||
<text wx:if="{{item.pendingArtistChangeRequest.reasonText}}" class="change-line">原因:{{item.pendingArtistChangeRequest.reasonText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!order}}" class="empty-state">
|
||||
<text class="empty-title">订单详情暂不可用</text>
|
||||
<text class="empty-desc">当前详情页优先复用列表页已拉取的数据。如果你是直接打开该页面,请先回到订单列表重新进入。</text>
|
||||
<text class="empty-desc">当前详情页可通过列表、消息或订单 id 打开;加载失败时可重试。</text>
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="handleRetry">重新加载</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,3 +1,55 @@
|
||||
.page-shell {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
padding: 20rpx 0;
|
||||
border-top: 1rpx solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.detail-item:first-of-type {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.detail-item-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.detail-item-title {
|
||||
color: #f6efe7;
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.detail-item-line {
|
||||
color: #9fb3ad;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.change-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
padding: 16rpx;
|
||||
border-radius: 8rpx;
|
||||
background: rgba(240, 126, 87, 0.1);
|
||||
}
|
||||
|
||||
.change-title {
|
||||
color: #f6efe7;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.change-line {
|
||||
color: #f4c7b8;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
/**
|
||||
* 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: 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: permission supports index.js by holding or executing the permission 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 permission = require('../../utils/permission')
|
||||
/**
|
||||
* Purpose: format supports index.js by holding or executing the format 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 format = require('../../utils/format')
|
||||
const { setTempRecord } = require('../../utils/storage')
|
||||
const { consumeDirty, markDirty } = require('../../utils/page-state')
|
||||
|
||||
/**
|
||||
* Purpose: STATUS_OPTIONS supports index.js by holding or executing the status 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 STATUS_OPTIONS = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待服务', value: 1 },
|
||||
@@ -12,24 +32,44 @@ const STATUS_OPTIONS = [
|
||||
{ label: '已取消', value: 0 }
|
||||
]
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
@@ -38,6 +78,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
|
||||
@@ -48,6 +92,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
|
||||
@@ -60,6 +108,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
|
||||
@@ -73,6 +125,10 @@ function buildReviewSummary(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
|
||||
@@ -86,6 +142,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) {
|
||||
@@ -95,6 +155,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()
|
||||
@@ -104,6 +168,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 pendingChangesPromise = safeCall(() => orderApi.listMyPendingArtistChangeRequests(), [])
|
||||
const orderReviewListsPromise = Promise.all(orders.map(order => (
|
||||
@@ -129,6 +197,10 @@ async function loadAssistData(orders) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: hasProductionFlag supports index.js by holding or executing the has production flag 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 hasProductionFlag(userInfo) {
|
||||
const sources = [
|
||||
userInfo && userInfo.participateProduction,
|
||||
@@ -140,6 +212,10 @@ function hasProductionFlag(userInfo) {
|
||||
return sources.some(value => value === true || Number(value) === 1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: canRequestArtistChangeForItem supports index.js by holding or executing the can request artist change for item 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 canRequestArtistChangeForItem(userInfo, order, item, pendingChange) {
|
||||
if (!userInfo || !order || !item || pendingChange || Number(order.status) !== 1) {
|
||||
return false
|
||||
@@ -156,6 +232,10 @@ function canRequestArtistChangeForItem(userInfo, order, item, pendingChange) {
|
||||
return permission.isShopManager(userInfo) && hasProductionFlag(userInfo)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatOrderItem supports index.js by holding or executing the format order item 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 formatOrderItem(order, item, userInfo, assistData) {
|
||||
const itemId = toId(item.id)
|
||||
const inlineReviewSummary = resolveRelatedRecord(item.reviewSummary || order.reviewSummary, item.id)
|
||||
@@ -174,6 +254,10 @@ function formatOrderItem(order, item, userInfo, assistData) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatOrder supports index.js by holding or executing the format order 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 formatOrder(order, userInfo, assistData) {
|
||||
const items = safeList(order.items).map(item => formatOrderItem(order, item, userInfo, assistData))
|
||||
const orderReviewSummary = buildReviewSummary(order.reviewSummary)
|
||||
@@ -188,6 +272,10 @@ function formatOrder(order, userInfo, assistData) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: selectArtist supports index.js by holding or executing the select artist 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 selectArtist(artists) {
|
||||
return new Promise(resolve => {
|
||||
wx.showActionSheet({
|
||||
@@ -198,6 +286,10 @@ function selectArtist(artists) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: promptChangeReason supports index.js by holding or executing the prompt change reason 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 promptChangeReason() {
|
||||
return new Promise(resolve => {
|
||||
wx.showModal({
|
||||
@@ -219,17 +311,57 @@ function promptChangeReason() {
|
||||
}
|
||||
|
||||
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: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: '',
|
||||
/**
|
||||
* Purpose: statusOptions supports index.js by holding or executing the status options 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.
|
||||
*/
|
||||
statusOptions: STATUS_OPTIONS,
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: total supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
total: 0,
|
||||
/**
|
||||
* 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: userInfo supports index.js by holding or executing the user info 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.
|
||||
*/
|
||||
userInfo: null,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入订单管理')) {
|
||||
return
|
||||
@@ -245,18 +377,34 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onPullDownRefresh supports index.js by holding or executing the on pull down refresh 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.
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
this.loadOrders().finally(() => {
|
||||
wx.stopPullDownRefresh()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleStatusChange supports index.js by holding or executing the handle status 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.
|
||||
*/
|
||||
handleStatusChange(event) {
|
||||
const status = event.currentTarget.dataset.status
|
||||
this.setData({
|
||||
@@ -269,14 +417,34 @@ Page({
|
||||
const requestId = (this._loadRequestId || 0) + 1
|
||||
this._loadRequestId = requestId
|
||||
this.setData({
|
||||
/**
|
||||
* 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: true
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await orderApi.listOrders({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined,
|
||||
/**
|
||||
* Purpose: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: this.data.status === '' ? undefined : this.data.status
|
||||
})
|
||||
|
||||
@@ -288,8 +456,20 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: rawList.map(item => formatOrder(item, this.data.userInfo, assistData)),
|
||||
/**
|
||||
* Purpose: total supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
total: Number(result && result.total) || 0,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -297,22 +477,42 @@ Page({
|
||||
return
|
||||
}
|
||||
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 {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* 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: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadOrders()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenOrder supports index.js by holding or executing the handle open 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.
|
||||
*/
|
||||
handleOpenOrder(event) {
|
||||
const order = event.currentTarget.dataset.order
|
||||
if (!order) {
|
||||
@@ -321,6 +521,10 @@ Page({
|
||||
|
||||
setTempRecord('currentOrder', order)
|
||||
navigation.navigate('/pages/order-detail/index', {
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: order.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
@@ -337,7 +541,15 @@ Page({
|
||||
const artists = safeList(options && options.artists)
|
||||
if (!artists.length) {
|
||||
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: '暂无可改派美甲师',
|
||||
/**
|
||||
* 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
|
||||
@@ -356,18 +568,38 @@ Page({
|
||||
await orderApi.requestArtistChange({
|
||||
orderId,
|
||||
orderItemId,
|
||||
/**
|
||||
* Purpose: requestedArtistId supports index.js by holding or executing the requested artist id 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.
|
||||
*/
|
||||
requestedArtistId: targetArtist.artistId,
|
||||
reason
|
||||
})
|
||||
markDirty('admin-workbench')
|
||||
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: '改派申请已提交',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.loadOrders()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -389,7 +621,15 @@ Page({
|
||||
]
|
||||
|
||||
wx.showActionSheet({
|
||||
/**
|
||||
* Purpose: itemList supports index.js by holding or executing the item list 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.
|
||||
*/
|
||||
itemList: options.map(item => item.label),
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
const target = options[result.tapIndex]
|
||||
if (!target) {
|
||||
@@ -400,13 +640,29 @@ Page({
|
||||
await orderApi.updateOrderStatus(order.id, target.status)
|
||||
markDirty('admin-workbench')
|
||||
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: '订单状态已更新',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.loadOrders()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
/**
|
||||
* Purpose: permissionApi supports index.js by holding or executing the permission 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 permissionApi = require('../../api/permission')
|
||||
/**
|
||||
* 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: permissionUtils supports index.js by holding or executing the permission utils 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 permissionUtils = require('../../utils/permission')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* Purpose: buildPermissionGroups supports index.js by holding or executing the build permission groups 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 buildPermissionGroups(list, checkedIds, assignableIds) {
|
||||
const groups = permissionUtils.groupPermissionsByGroup(list)
|
||||
return Object.keys(groups).map(group => ({
|
||||
@@ -17,25 +33,81 @@ function buildPermissionGroups(list, checkedIds, assignableIds) {
|
||||
}
|
||||
|
||||
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: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'definition-create',
|
||||
/**
|
||||
* 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: '',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: '',
|
||||
/**
|
||||
* Purpose: currentUser supports index.js by holding or executing the current user 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.
|
||||
*/
|
||||
currentUser: null,
|
||||
/**
|
||||
* Purpose: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: [],
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: permissionCode supports index.js by holding or executing the permission code 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.
|
||||
*/
|
||||
permissionCode: '',
|
||||
/**
|
||||
* Purpose: permissionName supports index.js by holding or executing the permission name 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.
|
||||
*/
|
||||
permissionName: '',
|
||||
/**
|
||||
* Purpose: permissionGroup supports index.js by holding or executing the permission group 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.
|
||||
*/
|
||||
permissionGroup: '',
|
||||
/**
|
||||
* Purpose: description supports index.js by holding or executing the description 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.
|
||||
*/
|
||||
description: ''
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const mode = options && options.mode ? options.mode : 'definition-create'
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: options && options.userId ? options.userId : '',
|
||||
/**
|
||||
* 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: mode === 'assign' ? '分配权限' : (mode === 'definition-edit' ? '编辑权限' : '新增权限')
|
||||
})
|
||||
|
||||
@@ -47,16 +119,40 @@ Page({
|
||||
const currentPermission = getTempRecord('currentPermission', null)
|
||||
if (mode === 'definition-edit' && currentPermission) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: permissionCode supports index.js by holding or executing the permission code 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.
|
||||
*/
|
||||
permissionCode: currentPermission.permissionCode || '',
|
||||
/**
|
||||
* Purpose: permissionName supports index.js by holding or executing the permission name 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.
|
||||
*/
|
||||
permissionName: currentPermission.permissionName || '',
|
||||
/**
|
||||
* Purpose: permissionGroup supports index.js by holding or executing the permission group 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.
|
||||
*/
|
||||
permissionGroup: currentPermission.permissionGroup || '',
|
||||
/**
|
||||
* Purpose: description supports index.js by holding or executing the description 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.
|
||||
*/
|
||||
description: currentPermission.description || ''
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentPermission')
|
||||
},
|
||||
@@ -78,16 +174,32 @@ Page({
|
||||
const normalizedAssignableIds = (Array.isArray(assignableIds) ? assignableIds : []).map(item => String(item))
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: buildPermissionGroups(allPermissions, checkedIds, normalizedAssignableIds)
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleInputChange supports index.js by holding or executing the handle input 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.
|
||||
*/
|
||||
handleInputChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -95,13 +207,29 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handlePermissionCheck supports index.js by holding or executing the handle permission check 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.
|
||||
*/
|
||||
handlePermissionCheck(event) {
|
||||
const selected = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: this.data.permissionGroups.map(group => ({
|
||||
...group,
|
||||
/**
|
||||
* Purpose: items supports index.js by holding or executing the items 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.
|
||||
*/
|
||||
items: group.items.map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: item.disabled ? item.checked : selected.includes(item.valueId)
|
||||
}))
|
||||
}))
|
||||
@@ -122,13 +250,29 @@ Page({
|
||||
try {
|
||||
await permissionApi.assignUserPermissions(this.data.userId, permissionIds)
|
||||
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: '权限已保存',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
navigation.goBack('/pages/permissions/index')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -137,7 +281,15 @@ Page({
|
||||
|
||||
if (!this.data.form.permissionCode || !this.data.form.permissionName) {
|
||||
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: '请补全权限编码和名称',
|
||||
/**
|
||||
* 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
|
||||
@@ -151,13 +303,29 @@ Page({
|
||||
await permissionApi.createPermission(this.data.form)
|
||||
}
|
||||
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: '权限定义已保存',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
navigation.goBack('/pages/permissions/index')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
/**
|
||||
* Purpose: permissionApi supports index.js by holding or executing the permission 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 permissionApi = require('../../api/permission')
|
||||
/**
|
||||
* 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 { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* Purpose: groupPermissions supports index.js by holding or executing the group permissions 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 groupPermissions(list) {
|
||||
const map = {}
|
||||
;(Array.isArray(list) ? list : []).forEach(item => {
|
||||
@@ -20,13 +36,37 @@ function groupPermissions(list) {
|
||||
}
|
||||
|
||||
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: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: [],
|
||||
/**
|
||||
* Purpose: users supports index.js by holding or executing the users 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.
|
||||
*/
|
||||
users: [],
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false,
|
||||
/**
|
||||
* Purpose: canAssign supports index.js by holding or executing the can assign 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.
|
||||
*/
|
||||
canAssign: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入权限管理')) {
|
||||
return
|
||||
@@ -34,7 +74,15 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('permission:create'),
|
||||
/**
|
||||
* Purpose: canAssign supports index.js by holding or executing the can assign 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.
|
||||
*/
|
||||
canAssign: permissionCodes.includes('permission:assign')
|
||||
})
|
||||
this.loadPageData()
|
||||
@@ -47,38 +95,86 @@ Page({
|
||||
userApi.listAllUsers().catch(() => [])
|
||||
])
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: groupPermissions(permissions),
|
||||
/**
|
||||
* Purpose: users supports index.js by holding or executing the users 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.
|
||||
*/
|
||||
users: Array.isArray(users) ? users : []
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreatePermission supports index.js by holding or executing the handle create permission 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.
|
||||
*/
|
||||
handleCreatePermission() {
|
||||
clearTempRecord('currentPermission')
|
||||
navigation.navigate('/pages/permission-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'definition-create'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEditPermission supports index.js by holding or executing the handle edit permission 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.
|
||||
*/
|
||||
handleEditPermission(event) {
|
||||
const permission = event.currentTarget.dataset.permission
|
||||
setTempRecord('currentPermission', permission)
|
||||
navigation.navigate('/pages/permission-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'definition-edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: permission.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAssignUser supports index.js by holding or executing the handle assign user 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.
|
||||
*/
|
||||
handleAssignUser(event) {
|
||||
const user = event.currentTarget.dataset.user
|
||||
setTempRecord('currentUser', user)
|
||||
navigation.navigate('/pages/permission-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'assign',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: user.id
|
||||
}).catch(() => undefined)
|
||||
}
|
||||
|
||||
@@ -1,23 +1,71 @@
|
||||
/**
|
||||
* 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: 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: 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: 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: 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: 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: format supports index.js by holding or executing the format 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 format = require('../../utils/format')
|
||||
/**
|
||||
* 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: upload supports index.js by holding or executing the upload 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 upload = require('../../utils/upload')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { getDraftValue, clearDraft, scheduleDraftSave, clearDraftTimer } = require('../../utils/form-draft')
|
||||
const { markDirty } = require('../../utils/page-state')
|
||||
const { CACHE_TTL } = require('../../utils/config')
|
||||
|
||||
/**
|
||||
* Purpose: DRAFT_KEY supports index.js by holding or executing the 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 DRAFT_KEY = 'admin-product-form'
|
||||
|
||||
/**
|
||||
* Purpose: normalizeId supports index.js by holding or executing the normalize 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 normalizeId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildCheckableList supports index.js by holding or executing the build checkable 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 buildCheckableList(list, selectedIds, labelKey) {
|
||||
return (Array.isArray(list) ? list : []).map(item => ({
|
||||
...item,
|
||||
@@ -27,41 +75,133 @@ function buildCheckableList(list, selectedIds, labelKey) {
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: syncSelectedIds supports index.js by holding or executing the sync selected ids 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 syncSelectedIds(selectedIds, list) {
|
||||
const availableIds = new Set((Array.isArray(list) ? list : []).map(item => normalizeId(item.id)))
|
||||
return (Array.isArray(selectedIds) ? selectedIds : []).filter(id => availableIds.has(normalizeId(id)))
|
||||
}
|
||||
|
||||
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: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create',
|
||||
/**
|
||||
* Purpose: productId supports index.js by holding or executing the product id 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.
|
||||
*/
|
||||
productId: '',
|
||||
/**
|
||||
* Purpose: shops supports index.js by holding or executing the shops 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.
|
||||
*/
|
||||
shops: [],
|
||||
/**
|
||||
* Purpose: shopIndex supports index.js by holding or executing the shop index 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.
|
||||
*/
|
||||
shopIndex: 0,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: '',
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: [],
|
||||
/**
|
||||
* Purpose: artists supports index.js by holding or executing the artists 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.
|
||||
*/
|
||||
artists: [],
|
||||
/**
|
||||
* Purpose: coupons supports index.js by holding or executing the coupons 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.
|
||||
*/
|
||||
coupons: [],
|
||||
/**
|
||||
* Purpose: uploading supports index.js by holding or executing the uploading 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.
|
||||
*/
|
||||
uploading: false,
|
||||
/**
|
||||
* Purpose: uploadProgress supports index.js by holding or executing the upload progress 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.
|
||||
*/
|
||||
uploadProgress: 0,
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* 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: '',
|
||||
/**
|
||||
* Purpose: description supports index.js by holding or executing the description 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.
|
||||
*/
|
||||
description: '',
|
||||
/**
|
||||
* Purpose: price supports index.js by holding or executing the price 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.
|
||||
*/
|
||||
price: '',
|
||||
/**
|
||||
* Purpose: approximateDuration supports index.js by holding or executing the approximate duration 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.
|
||||
*/
|
||||
approximateDuration: '',
|
||||
/**
|
||||
* Purpose: likeCount supports index.js by holding or executing the like 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.
|
||||
*/
|
||||
likeCount: '',
|
||||
/**
|
||||
* Purpose: collectCount supports index.js by holding or executing the collect 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.
|
||||
*/
|
||||
collectCount: '',
|
||||
/**
|
||||
* Purpose: imageFileIds supports index.js by holding or executing the image file ids 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.
|
||||
*/
|
||||
imageFileIds: [],
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: ''
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const mode = options && options.mode ? options.mode : 'create'
|
||||
const currentProduct = getTempRecord('currentProduct', null)
|
||||
const draft = getDraftValue(DRAFT_KEY, null)
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: productId supports index.js by holding or executing the product id 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.
|
||||
*/
|
||||
productId: options && options.id ? options.id : ''
|
||||
})
|
||||
|
||||
@@ -75,14 +215,50 @@ Page({
|
||||
this._selectedCouponIds = format.splitCsv(currentProduct.availableCoupons)
|
||||
this._initialShopId = currentProduct.shopId
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* 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: currentProduct.title || '',
|
||||
/**
|
||||
* Purpose: description supports index.js by holding or executing the description 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.
|
||||
*/
|
||||
description: currentProduct.description || '',
|
||||
/**
|
||||
* Purpose: price supports index.js by holding or executing the price 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.
|
||||
*/
|
||||
price: currentProduct.price || '',
|
||||
/**
|
||||
* Purpose: approximateDuration supports index.js by holding or executing the approximate duration 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.
|
||||
*/
|
||||
approximateDuration: currentProduct.approximateDuration || '',
|
||||
/**
|
||||
* Purpose: likeCount supports index.js by holding or executing the like 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.
|
||||
*/
|
||||
likeCount: currentProduct.likeCount || '',
|
||||
/**
|
||||
* Purpose: collectCount supports index.js by holding or executing the collect 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.
|
||||
*/
|
||||
collectCount: currentProduct.collectCount || '',
|
||||
/**
|
||||
* Purpose: imageFileIds supports index.js by holding or executing the image file ids 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.
|
||||
*/
|
||||
imageFileIds: format.splitCsv(currentProduct.imageFileIds),
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: currentProduct.shopId || ''
|
||||
}
|
||||
})
|
||||
@@ -94,6 +270,10 @@ Page({
|
||||
this._selectedCouponIds = Array.isArray(draft.selectedCouponIds) ? draft.selectedCouponIds : this._selectedCouponIds
|
||||
this._initialShopId = draft.form && draft.form.shopId ? draft.form.shopId : this._initialShopId
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
...this.data.form,
|
||||
...(draft.form || {})
|
||||
@@ -104,20 +284,52 @@ Page({
|
||||
this.loadDependencies()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentProduct')
|
||||
clearDraftTimer(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: scheduleProductDraft supports index.js by holding or executing the schedule product 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.
|
||||
*/
|
||||
scheduleProductDraft() {
|
||||
scheduleDraftSave(this, DRAFT_KEY, () => ({
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: this.data.mode,
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
...this.data.form,
|
||||
/**
|
||||
* Purpose: imageFileIds supports index.js by holding or executing the image file ids 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.
|
||||
*/
|
||||
imageFileIds: this.data.form.imageFileIds.slice()
|
||||
},
|
||||
/**
|
||||
* Purpose: selectedTagIds supports index.js by holding or executing the selected tag ids 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.
|
||||
*/
|
||||
selectedTagIds: this._selectedTagIds.slice(),
|
||||
/**
|
||||
* Purpose: selectedArtistIds supports index.js by holding or executing the selected artist ids 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.
|
||||
*/
|
||||
selectedArtistIds: this._selectedArtistIds.slice(),
|
||||
/**
|
||||
* Purpose: selectedCouponIds supports index.js by holding or executing the selected coupon ids 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.
|
||||
*/
|
||||
selectedCouponIds: this._selectedCouponIds.slice()
|
||||
}))
|
||||
},
|
||||
@@ -147,6 +359,10 @@ Page({
|
||||
this.setData({
|
||||
shops,
|
||||
shopIndex,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: selectedShop ? selectedShop.shopName : '',
|
||||
'form.shopId': selectedShop ? selectedShop.id : ''
|
||||
})
|
||||
@@ -154,7 +370,15 @@ Page({
|
||||
await this.loadShopScopedOptions(selectedShop ? selectedShop.id : '')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -166,8 +390,20 @@ Page({
|
||||
this._selectedArtistIds = []
|
||||
this._selectedCouponIds = []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: [],
|
||||
/**
|
||||
* Purpose: artists supports index.js by holding or executing the artists 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.
|
||||
*/
|
||||
artists: [],
|
||||
/**
|
||||
* Purpose: coupons supports index.js by holding or executing the coupons 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.
|
||||
*/
|
||||
coupons: []
|
||||
})
|
||||
return
|
||||
@@ -185,24 +421,60 @@ Page({
|
||||
this._selectedCouponIds = syncSelectedIds(this._selectedCouponIds, couponList)
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: buildCheckableList(tagList, this._selectedTagIds, 'tagName'),
|
||||
/**
|
||||
* Purpose: artists supports index.js by holding or executing the artists 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.
|
||||
*/
|
||||
artists: buildCheckableList(artistList, this._selectedArtistIds, 'nickname'),
|
||||
/**
|
||||
* Purpose: coupons supports index.js by holding or executing the coupons 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.
|
||||
*/
|
||||
coupons: buildCheckableList(couponList, this._selectedCouponIds, 'couponName')
|
||||
})
|
||||
this.scheduleProductDraft()
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: [],
|
||||
/**
|
||||
* Purpose: artists supports index.js by holding or executing the artists 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.
|
||||
*/
|
||||
artists: [],
|
||||
/**
|
||||
* Purpose: coupons supports index.js by holding or executing the coupons 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.
|
||||
*/
|
||||
coupons: []
|
||||
})
|
||||
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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleInputChange supports index.js by holding or executing the handle input 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.
|
||||
*/
|
||||
handleInputChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -211,11 +483,19 @@ Page({
|
||||
this.scheduleProductDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShopChange supports index.js by holding or executing the handle shop 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.
|
||||
*/
|
||||
handleShopChange(event) {
|
||||
const shopIndex = Number(event.detail.value)
|
||||
const selectedShop = this.data.shops[shopIndex]
|
||||
this.setData({
|
||||
shopIndex,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: selectedShop ? selectedShop.shopName : '',
|
||||
'form.shopId': selectedShop ? selectedShop.id : ''
|
||||
})
|
||||
@@ -223,33 +503,69 @@ Page({
|
||||
this.scheduleProductDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTagChange supports index.js by holding or executing the handle tag 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.
|
||||
*/
|
||||
handleTagChange(event) {
|
||||
this._selectedTagIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: this.data.tags.map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: this._selectedTagIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
this.scheduleProductDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleArtistChange supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleArtistChange(event) {
|
||||
this._selectedArtistIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: artists supports index.js by holding or executing the artists 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.
|
||||
*/
|
||||
artists: this.data.artists.map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: this._selectedArtistIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
this.scheduleProductDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCouponChange supports index.js by holding or executing the handle coupon 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.
|
||||
*/
|
||||
handleCouponChange(event) {
|
||||
this._selectedCouponIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: coupons supports index.js by holding or executing the coupons 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.
|
||||
*/
|
||||
coupons: this.data.coupons.map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: this._selectedCouponIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
@@ -260,14 +576,34 @@ Page({
|
||||
try {
|
||||
const files = await upload.chooseImageFiles({ count: 9 })
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: uploading supports index.js by holding or executing the uploading 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.
|
||||
*/
|
||||
uploading: true,
|
||||
/**
|
||||
* Purpose: uploadProgress supports index.js by holding or executing the upload progress 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.
|
||||
*/
|
||||
uploadProgress: 0
|
||||
})
|
||||
const result = await upload.uploadImageFiles({
|
||||
files,
|
||||
/**
|
||||
* Purpose: scene supports index.js by holding or executing the scene 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.
|
||||
*/
|
||||
scene: 'admin-product-image',
|
||||
/**
|
||||
* Purpose: onProgress supports index.js by holding or executing the on progress 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.
|
||||
*/
|
||||
onProgress: progress => {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: uploadProgress supports index.js by holding or executing the upload progress 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.
|
||||
*/
|
||||
uploadProgress: Math.round(progress)
|
||||
})
|
||||
}
|
||||
@@ -279,11 +615,23 @@ Page({
|
||||
this.scheduleProductDraft()
|
||||
} 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 {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: uploading supports index.js by holding or executing the uploading 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.
|
||||
*/
|
||||
uploading: false
|
||||
})
|
||||
}
|
||||
@@ -292,37 +640,105 @@ Page({
|
||||
async handleSubmit() {
|
||||
if (!this.data.form.title) {
|
||||
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: '请输入作品标题',
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
if (!this.data.form.shopId) {
|
||||
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: '请选择所属店铺',
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
if (!this.data.form.price) {
|
||||
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: '请输入作品价格',
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
const payload = {
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: this.data.form.shopId || undefined,
|
||||
/**
|
||||
* 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: this.data.form.title,
|
||||
/**
|
||||
* Purpose: description supports index.js by holding or executing the description 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.
|
||||
*/
|
||||
description: this.data.form.description || undefined,
|
||||
/**
|
||||
* Purpose: imageFileIds supports index.js by holding or executing the image file ids 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.
|
||||
*/
|
||||
imageFileIds: this.data.form.imageFileIds.join(',') || undefined,
|
||||
/**
|
||||
* Purpose: price supports index.js by holding or executing the price 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.
|
||||
*/
|
||||
price: Number(this.data.form.price),
|
||||
/**
|
||||
* Purpose: tags supports index.js by holding or executing the tags 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.
|
||||
*/
|
||||
tags: this._selectedTagIds.join(',') || undefined,
|
||||
/**
|
||||
* Purpose: likeCount supports index.js by holding or executing the like 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.
|
||||
*/
|
||||
likeCount: this.data.form.likeCount ? Number(this.data.form.likeCount) : undefined,
|
||||
/**
|
||||
* Purpose: collectCount supports index.js by holding or executing the collect 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.
|
||||
*/
|
||||
collectCount: this.data.form.collectCount ? Number(this.data.form.collectCount) : undefined,
|
||||
/**
|
||||
* Purpose: approximateDuration supports index.js by holding or executing the approximate duration 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.
|
||||
*/
|
||||
approximateDuration: this.data.form.approximateDuration || undefined,
|
||||
/**
|
||||
* Purpose: bookableArtists supports index.js by holding or executing the bookable artists 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.
|
||||
*/
|
||||
bookableArtists: this._selectedArtistIds.join(',') || undefined,
|
||||
/**
|
||||
* Purpose: availableCoupons supports index.js by holding or executing the available coupons 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.
|
||||
*/
|
||||
availableCoupons: this._selectedCouponIds.join(',') || undefined
|
||||
}
|
||||
|
||||
@@ -335,13 +751,29 @@ Page({
|
||||
clearDraft(DRAFT_KEY)
|
||||
markDirty('admin-products')
|
||||
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: this.data.mode === 'edit' ? '作品已更新' : '作品已创建',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
navigation.goBack('/pages/products/index')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,20 +1,64 @@
|
||||
/**
|
||||
* 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: 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: format supports index.js by holding or executing the format 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 format = require('../../utils/format')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { consumeDirty } = require('../../utils/page-state')
|
||||
|
||||
/**
|
||||
* Purpose: PAGE_KEY supports index.js by holding or executing the page 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 PAGE_KEY = 'admin-products'
|
||||
|
||||
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: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* 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: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入作品管理')) {
|
||||
return
|
||||
@@ -22,6 +66,10 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('product:create')
|
||||
})
|
||||
|
||||
@@ -30,12 +78,24 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadProducts()
|
||||
},
|
||||
@@ -44,13 +104,29 @@ Page({
|
||||
const requestId = (this._loadRequestId || 0) + 1
|
||||
this._loadRequestId = requestId
|
||||
this.setData({
|
||||
/**
|
||||
* 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: true
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await productApi.listProducts({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined
|
||||
})
|
||||
if (requestId !== this._loadRequestId) {
|
||||
@@ -58,13 +134,37 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(result && result.list) ? result.list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayPrice supports index.js by holding or executing the display price 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.
|
||||
*/
|
||||
displayPrice: format.formatPrice(item.price),
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: item.shopName || '当前店铺',
|
||||
/**
|
||||
* Purpose: displayDuration supports index.js by holding or executing the display duration 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.
|
||||
*/
|
||||
displayDuration: item.approximateDuration || '未设置时长',
|
||||
/**
|
||||
* Purpose: displayTagText supports index.js by holding or executing the display tag 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.
|
||||
*/
|
||||
displayTagText: Array.isArray(item.tagList) ? item.tagList.join(' / ') : (item.tags || '未设置标签')
|
||||
})),
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -72,39 +172,87 @@ Page({
|
||||
return
|
||||
}
|
||||
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 {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* 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: handleCreate supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentProduct')
|
||||
navigation.navigate('/pages/product-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const product = event.currentTarget.dataset.product
|
||||
setTempRecord('currentProduct', product)
|
||||
navigation.navigate('/pages/product-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: product.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDelete supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleDelete(event) {
|
||||
const product = event.currentTarget.dataset.product
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: '删除作品',
|
||||
/**
|
||||
* Purpose: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: `确认删除作品“${product.title}”吗?`,
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -112,13 +260,29 @@ Page({
|
||||
try {
|
||||
await productApi.deleteProduct(product.id)
|
||||
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: '作品已删除',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.loadProducts()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,17 +1,61 @@
|
||||
/**
|
||||
* 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: 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: permission supports index.js by holding or executing the permission 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 permission = require('../../utils/permission')
|
||||
|
||||
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: userInfo supports index.js by holding or executing the user info 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.
|
||||
*/
|
||||
userInfo: null,
|
||||
/**
|
||||
* Purpose: currentShop supports index.js by holding or executing the current shop 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.
|
||||
*/
|
||||
currentShop: null,
|
||||
/**
|
||||
* Purpose: permissionCodes supports index.js by holding or executing the permission codes 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.
|
||||
*/
|
||||
permissionCodes: [],
|
||||
/**
|
||||
* Purpose: roleLabel supports index.js by holding or executing the role label 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.
|
||||
*/
|
||||
roleLabel: '',
|
||||
/**
|
||||
* Purpose: shopScopeText supports index.js by holding or executing the shop scope 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.
|
||||
*/
|
||||
shopScopeText: '',
|
||||
/**
|
||||
* Purpose: currentShopText supports index.js by holding or executing the current shop 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.
|
||||
*/
|
||||
currentShopText: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入个人中心')) {
|
||||
return
|
||||
@@ -29,17 +73,37 @@ Page({
|
||||
this.setData({
|
||||
userInfo,
|
||||
currentShop,
|
||||
/**
|
||||
* Purpose: permissionCodes supports index.js by holding or executing the permission codes 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.
|
||||
*/
|
||||
permissionCodes: app.globalData.permissionCodes || [],
|
||||
/**
|
||||
* Purpose: roleLabel supports index.js by holding or executing the role label 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.
|
||||
*/
|
||||
roleLabel: userInfo ? permission.getRoleLabel(userInfo.type) : '--',
|
||||
shopScopeText,
|
||||
/**
|
||||
* Purpose: currentShopText supports index.js by holding or executing the current shop 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.
|
||||
*/
|
||||
currentShopText: currentShop ? `当前店铺:${currentShop.shopName}` : '当前为平台总览模式'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenOrders supports index.js by holding or executing the handle open orders 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.
|
||||
*/
|
||||
handleOpenOrders() {
|
||||
navigation.switchTab('/pages/orders/index').catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenManage supports index.js by holding or executing the handle open manage 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.
|
||||
*/
|
||||
handleOpenManage() {
|
||||
navigation.switchTab('/pages/manage/index').catch(() => undefined)
|
||||
},
|
||||
@@ -56,26 +120,58 @@ Page({
|
||||
const allowShoplessLogin = Boolean(result && result.allowShoplessLogin)
|
||||
if (allowShoplessLogin && permission.isPlatformAdmin(userInfo)) {
|
||||
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: '平台管理员固定为总览模式',
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
const items = shops.map(shop => ({
|
||||
/**
|
||||
* Purpose: label supports index.js by holding or executing the label 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.
|
||||
*/
|
||||
label: shop.shopName,
|
||||
/**
|
||||
* Purpose: value supports index.js by holding or executing the value 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.
|
||||
*/
|
||||
value: shop.id
|
||||
}))
|
||||
|
||||
if (!items.length) {
|
||||
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: '当前账号没有可切换的店铺',
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
wx.showActionSheet({
|
||||
/**
|
||||
* Purpose: itemList supports index.js by holding or executing the item list 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.
|
||||
*/
|
||||
itemList: items.map(item => item.label),
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async action => {
|
||||
const target = items[action.tapIndex]
|
||||
if (!target) {
|
||||
@@ -85,13 +181,29 @@ Page({
|
||||
try {
|
||||
await getApp().switchAdminShop(target.value || undefined)
|
||||
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: '店铺已切换',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.onShow()
|
||||
} 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 +211,15 @@ Page({
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -111,6 +231,10 @@ Page({
|
||||
} finally {
|
||||
getApp().clearAdminSession()
|
||||
wx.reLaunch({
|
||||
/**
|
||||
* 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/login/index'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* Purpose: auditApi reads immutable high-risk operation audit logs for admin review.
|
||||
* Usage: call listLogs with filter and pagination params from this page.
|
||||
*/
|
||||
const auditApi = require('../../api/security-audit')
|
||||
/**
|
||||
* Purpose: navigation centralizes page transitions and fallback back behavior.
|
||||
* Usage: call goBack when the custom navigation bar back event fires.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: format prepares backend timestamps for compact mini-program display.
|
||||
* Usage: call formatDateTime before assigning audit rows to page data.
|
||||
*/
|
||||
const format = require('../../utils/format')
|
||||
|
||||
/**
|
||||
* Purpose: RESULT_OPTIONS drives the audit result segmented filter.
|
||||
* Usage: keep values aligned with backend result strings accepted by /admin/security-audit/logs.
|
||||
*/
|
||||
const RESULT_OPTIONS = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '成功', value: 'SUCCESS' },
|
||||
{ label: '失败', value: 'FAIL' }
|
||||
]
|
||||
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data stores filter, pagination, and rendered audit rows for the read-only audit page.
|
||||
* Usage: WXML binds these fields and page methods update them through setData.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: loading indicates whether an audit-log query is currently in flight.
|
||||
* Usage: bind it to the search button and bottom loader to prevent duplicate requests.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: list holds formatted audit log rows returned by the backend.
|
||||
* Usage: append or replace it after listLogs responses.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: page tracks the current backend page number.
|
||||
* Usage: increment it only after a successful load-more response.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size controls how many audit rows each request asks for.
|
||||
* Usage: pass it unchanged to listLogs so paging remains stable.
|
||||
*/
|
||||
size: 10,
|
||||
/**
|
||||
* Purpose: hasMore tells the page whether another backend page is available.
|
||||
* Usage: set it from response totals and guard onReachBottom.
|
||||
*/
|
||||
hasMore: true,
|
||||
/**
|
||||
* Purpose: account filters audit logs by operator account.
|
||||
* Usage: bind it to the search input and pass non-empty values to the API.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: action filters audit logs by action code or action keyword.
|
||||
* Usage: bind it to the search input and pass non-empty values to the API.
|
||||
*/
|
||||
action: '',
|
||||
/**
|
||||
* Purpose: result filters audit logs by success or failure status.
|
||||
* Usage: update it from result chips and pass it to the backend query.
|
||||
*/
|
||||
result: '',
|
||||
/**
|
||||
* Purpose: resultOptions renders available result filter chips.
|
||||
* Usage: iterate it in WXML and compare each option value with data.result.
|
||||
*/
|
||||
resultOptions: RESULT_OPTIONS
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad performs the initial audit-log query for authorized users.
|
||||
* Usage: mini-program runtime calls it once when the page is opened from Manage.
|
||||
*/
|
||||
onLoad() {
|
||||
this.loadLogs(true)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onPullDownRefresh reloads the first audit-log page after manual refresh.
|
||||
* Usage: mini-program runtime calls it and the method stops the refresh animation after completion.
|
||||
*/
|
||||
async onPullDownRefresh() {
|
||||
await this.loadLogs(true)
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onReachBottom loads the next page when the operator scrolls to the bottom.
|
||||
* Usage: mini-program runtime calls it and the method respects loading and hasMore guards.
|
||||
*/
|
||||
onReachBottom() {
|
||||
if (!this.data.loading && this.data.hasMore) {
|
||||
this.loadLogs(false)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: buildQuery creates a clean backend query object from page filters and pagination.
|
||||
* Usage: call it before listLogs so empty filters are not sent.
|
||||
*/
|
||||
buildQuery(page) {
|
||||
const query = {
|
||||
page,
|
||||
size: this.data.size
|
||||
}
|
||||
;['account', 'action', 'result'].forEach(key => {
|
||||
const value = String(this.data[key] || '').trim()
|
||||
if (value) {
|
||||
query[key] = value
|
||||
}
|
||||
})
|
||||
return query
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: loadLogs queries audit logs and updates list pagination state.
|
||||
* Usage: pass true for a fresh search and false for infinite-scroll loading.
|
||||
*/
|
||||
async loadLogs(reset) {
|
||||
if (this.data.loading) {
|
||||
return
|
||||
}
|
||||
const nextPage = reset ? 1 : this.data.page + 1
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const response = await auditApi.listLogs(this.buildQuery(nextPage))
|
||||
const records = Array.isArray(response && response.records)
|
||||
? response.records
|
||||
: (Array.isArray(response && response.list) ? response.list : [])
|
||||
const total = Number(response && response.total) || 0
|
||||
const currentList = reset ? [] : this.data.list
|
||||
const list = currentList.concat(records.map(item => this.formatLog(item)))
|
||||
this.setData({
|
||||
list,
|
||||
page: nextPage,
|
||||
hasMore: total ? list.length < total : records.length >= this.data.size
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '审计日志加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: formatLog normalizes one backend audit row for compact display.
|
||||
* Usage: call it on every record returned from listLogs before rendering.
|
||||
*/
|
||||
formatLog(item) {
|
||||
return {
|
||||
...item,
|
||||
displayTime: format.formatDateTime(item.operateTime || item.createTime),
|
||||
resultText: item.result === 'SUCCESS' ? '成功' : '失败',
|
||||
resultClass: item.result === 'SUCCESS' ? 'success' : 'fail',
|
||||
operatorText: item.account || item.operatorAccount || '--',
|
||||
reasonText: item.reason || item.failureReason || item.errorMessage || item.remark || ''
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAccountInput updates the operator-account filter as the input changes.
|
||||
* Usage: bind it to the account input field.
|
||||
*/
|
||||
handleAccountInput(event) {
|
||||
this.setData({ account: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleActionInput updates the action-code filter as the input changes.
|
||||
* Usage: bind it to the action input field.
|
||||
*/
|
||||
handleActionInput(event) {
|
||||
this.setData({ action: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleResultChange switches between all, success, and fail filters.
|
||||
* Usage: bind it to result chips with data-result.
|
||||
*/
|
||||
handleResultChange(event) {
|
||||
this.setData({ result: event.currentTarget.dataset.result || '' })
|
||||
this.loadLogs(true)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch reloads logs using the current text filters.
|
||||
* Usage: bind it to keyboard confirm and the search button.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadLogs(true)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleReset clears filters and reloads the first audit-log page.
|
||||
* Usage: bind it to the reset button in the filter card.
|
||||
*/
|
||||
handleReset() {
|
||||
this.setData({
|
||||
account: '',
|
||||
action: '',
|
||||
result: ''
|
||||
})
|
||||
this.loadLogs(true)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBack returns to Manage when this page is opened as a standalone stack page.
|
||||
* Usage: bind it to the custom navigation bar back event.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/manage/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<navigation-bar title="审计日志" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||
|
||||
<view class="page-shell">
|
||||
<view class="page-stack">
|
||||
<view class="hero-panel">
|
||||
<text class="hero-kicker">Security Audit</text>
|
||||
<text class="hero-title">高危操作留痕</text>
|
||||
<text class="hero-desc">按账号、动作和结果查看后台关键操作记录,失败原因会保留在详情行中。</text>
|
||||
</view>
|
||||
|
||||
<view class="surface-card">
|
||||
<text class="section-title">筛选</text>
|
||||
<input class="field-input" placeholder="操作者账号" placeholder-class="placeholder" value="{{account}}" bindinput="handleAccountInput" confirm-type="search" bindconfirm="handleSearch"></input>
|
||||
<input class="field-input" placeholder="动作编码" placeholder-class="placeholder" value="{{action}}" bindinput="handleActionInput" confirm-type="search" bindconfirm="handleSearch"></input>
|
||||
<view class="chip-row">
|
||||
<block wx:for="{{resultOptions}}" wx:key="value">
|
||||
<view class="chip-btn {{result === item.value ? 'active' : ''}}" data-result="{{item.value}}" bindtap="handleResultChange">{{item.label}}</view>
|
||||
</block>
|
||||
</view>
|
||||
<view class="actions-row">
|
||||
<button class="secondary-btn" bindtap="handleReset">重置</button>
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="handleSearch">查询</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<block wx:for="{{list}}" wx:key="id">
|
||||
<view class="list-card">
|
||||
<view class="list-head">
|
||||
<view>
|
||||
<text class="list-title">{{item.action || '--'}}</text>
|
||||
<text class="list-subtitle">{{item.operatorText}} · {{item.displayTime}}</text>
|
||||
</view>
|
||||
<text class="audit-badge {{item.resultClass}}">{{item.resultText}}</text>
|
||||
</view>
|
||||
<view class="meta-grid">
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">业务类型</text>
|
||||
<text class="meta-value">{{item.businessType || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">业务 ID</text>
|
||||
<text class="meta-value">{{item.businessId || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">IP</text>
|
||||
<text class="meta-value">{{item.ipAddress || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">原因</text>
|
||||
<text class="meta-value">{{item.reasonText || '无'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||
<text class="empty-title">暂无审计日志</text>
|
||||
<text class="empty-desc">当前筛选条件下没有高危操作记录。</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{loading}}" class="loading-line">加载中...</view>
|
||||
<view wx:if="{{list.length && !hasMore}}" class="loading-line">已加载全部</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,35 @@
|
||||
.field-input {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.actions-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.audit-badge {
|
||||
flex-shrink: 0;
|
||||
padding: 8rpx 14rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 22rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.audit-badge.success {
|
||||
color: #73d99f;
|
||||
background: rgba(115, 217, 159, 0.12);
|
||||
}
|
||||
|
||||
.audit-badge.fail {
|
||||
color: #ff9b8b;
|
||||
background: rgba(255, 155, 139, 0.14);
|
||||
}
|
||||
|
||||
.loading-line {
|
||||
color: #7e8f8c;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
@@ -1,30 +1,106 @@
|
||||
/**
|
||||
* 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: 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: upload supports index.js by holding or executing the upload 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 upload = require('../../utils/upload')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { getDraftValue, clearDraft, scheduleDraftSave, clearDraftTimer } = require('../../utils/form-draft')
|
||||
const { markDirty } = require('../../utils/page-state')
|
||||
|
||||
/**
|
||||
* Purpose: DRAFT_KEY supports index.js by holding or executing the 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 DRAFT_KEY = 'admin-shop-form'
|
||||
|
||||
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: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create',
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: '',
|
||||
/**
|
||||
* Purpose: uploading supports index.js by holding or executing the uploading 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.
|
||||
*/
|
||||
uploading: false,
|
||||
/**
|
||||
* Purpose: uploadProgress supports index.js by holding or executing the upload progress 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.
|
||||
*/
|
||||
uploadProgress: 0,
|
||||
/**
|
||||
* Purpose: statusOptions supports index.js by holding or executing the status options 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.
|
||||
*/
|
||||
statusOptions: ['启用', '停用'],
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status index 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.
|
||||
*/
|
||||
statusIndex: 0,
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: shopName supports index.js by holding or executing the shop name 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.
|
||||
*/
|
||||
shopName: '',
|
||||
/**
|
||||
* Purpose: description supports index.js by holding or executing the description 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.
|
||||
*/
|
||||
description: '',
|
||||
/**
|
||||
* Purpose: address supports index.js by holding or executing the address 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.
|
||||
*/
|
||||
address: '',
|
||||
/**
|
||||
* Purpose: businessHours supports index.js by holding or executing the business hours 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.
|
||||
*/
|
||||
businessHours: '',
|
||||
/**
|
||||
* Purpose: coverImageFileId supports index.js by holding or executing the cover image file id 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.
|
||||
*/
|
||||
coverImageFileId: '',
|
||||
/**
|
||||
* Purpose: imageFileIds supports index.js by holding or executing the image file ids 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.
|
||||
*/
|
||||
imageFileIds: []
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const mode = options && options.mode ? options.mode : 'create'
|
||||
const currentShop = getTempRecord('currentShopRecord', null)
|
||||
@@ -32,50 +108,122 @@ Page({
|
||||
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: options && options.id ? options.id : ''
|
||||
})
|
||||
|
||||
if (mode === 'edit' && currentShop) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: shopName supports index.js by holding or executing the shop name 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.
|
||||
*/
|
||||
shopName: currentShop.shopName || '',
|
||||
/**
|
||||
* Purpose: description supports index.js by holding or executing the description 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.
|
||||
*/
|
||||
description: currentShop.description || '',
|
||||
/**
|
||||
* Purpose: address supports index.js by holding or executing the address 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.
|
||||
*/
|
||||
address: currentShop.address || '',
|
||||
/**
|
||||
* Purpose: businessHours supports index.js by holding or executing the business hours 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.
|
||||
*/
|
||||
businessHours: currentShop.businessHours || '',
|
||||
/**
|
||||
* Purpose: coverImageFileId supports index.js by holding or executing the cover image file id 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.
|
||||
*/
|
||||
coverImageFileId: currentShop.coverImageFileId || '',
|
||||
/**
|
||||
* Purpose: imageFileIds supports index.js by holding or executing the image file ids 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.
|
||||
*/
|
||||
imageFileIds: currentShop.imageFileIds ? String(currentShop.imageFileIds).split(',').filter(Boolean) : []
|
||||
},
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status index 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.
|
||||
*/
|
||||
statusIndex: Number(currentShop.status) === 0 ? 1 : 0
|
||||
})
|
||||
}
|
||||
|
||||
if (draft && draft.mode === mode) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
...this.data.form,
|
||||
...draft.form
|
||||
},
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status index 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.
|
||||
*/
|
||||
statusIndex: draft.statusIndex === 1 ? 1 : this.data.statusIndex
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentShopRecord')
|
||||
clearDraftTimer(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: scheduleShopDraft supports index.js by holding or executing the schedule shop 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.
|
||||
*/
|
||||
scheduleShopDraft() {
|
||||
scheduleDraftSave(this, DRAFT_KEY, () => ({
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: this.data.mode,
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status index 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.
|
||||
*/
|
||||
statusIndex: this.data.statusIndex,
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
...this.data.form,
|
||||
/**
|
||||
* Purpose: imageFileIds supports index.js by holding or executing the image file ids 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.
|
||||
*/
|
||||
imageFileIds: this.data.form.imageFileIds.slice()
|
||||
}
|
||||
}))
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleInputChange supports index.js by holding or executing the handle input 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.
|
||||
*/
|
||||
handleInputChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -84,8 +232,16 @@ Page({
|
||||
this.scheduleShopDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleStatusChange supports index.js by holding or executing the handle status 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.
|
||||
*/
|
||||
handleStatusChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status index 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.
|
||||
*/
|
||||
statusIndex: Number(event.detail.value)
|
||||
})
|
||||
this.scheduleShopDraft()
|
||||
@@ -102,17 +258,37 @@ Page({
|
||||
async handleUpload(scene, isBanner) {
|
||||
try {
|
||||
const files = await upload.chooseImageFiles({
|
||||
/**
|
||||
* Purpose: count supports index.js by holding or executing the 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.
|
||||
*/
|
||||
count: isBanner ? 1 : 9
|
||||
})
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: uploading supports index.js by holding or executing the uploading 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.
|
||||
*/
|
||||
uploading: true,
|
||||
/**
|
||||
* Purpose: uploadProgress supports index.js by holding or executing the upload progress 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.
|
||||
*/
|
||||
uploadProgress: 0
|
||||
})
|
||||
const results = await upload.uploadImageFiles({
|
||||
files,
|
||||
scene,
|
||||
/**
|
||||
* Purpose: onProgress supports index.js by holding or executing the on progress 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.
|
||||
*/
|
||||
onProgress: progress => {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: uploadProgress supports index.js by holding or executing the upload progress 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.
|
||||
*/
|
||||
uploadProgress: Math.round(progress)
|
||||
})
|
||||
}
|
||||
@@ -130,11 +306,23 @@ Page({
|
||||
this.scheduleShopDraft()
|
||||
} 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 {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: uploading supports index.js by holding or executing the uploading 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.
|
||||
*/
|
||||
uploading: false
|
||||
})
|
||||
}
|
||||
@@ -143,19 +331,55 @@ Page({
|
||||
async handleSubmit() {
|
||||
if (!this.data.form.shopName) {
|
||||
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: '请输入店铺名称',
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
const payload = {
|
||||
/**
|
||||
* Purpose: shopName supports index.js by holding or executing the shop name 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.
|
||||
*/
|
||||
shopName: this.data.form.shopName,
|
||||
/**
|
||||
* Purpose: description supports index.js by holding or executing the description 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.
|
||||
*/
|
||||
description: this.data.form.description || undefined,
|
||||
/**
|
||||
* Purpose: address supports index.js by holding or executing the address 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.
|
||||
*/
|
||||
address: this.data.form.address || undefined,
|
||||
/**
|
||||
* Purpose: businessHours supports index.js by holding or executing the business hours 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.
|
||||
*/
|
||||
businessHours: this.data.form.businessHours || undefined,
|
||||
/**
|
||||
* Purpose: coverImageFileId supports index.js by holding or executing the cover image file id 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.
|
||||
*/
|
||||
coverImageFileId: this.data.form.coverImageFileId || undefined,
|
||||
/**
|
||||
* Purpose: imageFileIds supports index.js by holding or executing the image file ids 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.
|
||||
*/
|
||||
imageFileIds: this.data.form.imageFileIds.join(',') || undefined,
|
||||
/**
|
||||
* Purpose: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: this.data.statusIndex === 1 ? 0 : 1
|
||||
}
|
||||
|
||||
@@ -169,13 +393,29 @@ Page({
|
||||
markDirty('admin-shops')
|
||||
markDirty('admin-workbench')
|
||||
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: this.data.mode === 'edit' ? '店铺已更新' : '店铺已创建',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
navigation.goBack('/pages/shops/index')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,17 +1,53 @@
|
||||
/**
|
||||
* 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: 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 { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { consumeDirty } = require('../../utils/page-state')
|
||||
|
||||
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: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* 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: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入店铺管理')) {
|
||||
return
|
||||
@@ -19,6 +55,10 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('shop:create')
|
||||
})
|
||||
|
||||
@@ -27,12 +67,24 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadShops()
|
||||
},
|
||||
@@ -41,13 +93,29 @@ Page({
|
||||
const requestId = (this._loadRequestId || 0) + 1
|
||||
this._loadRequestId = requestId
|
||||
this.setData({
|
||||
/**
|
||||
* 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: true
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await shopApi.listShops({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined
|
||||
})
|
||||
if (requestId !== this._loadRequestId) {
|
||||
@@ -55,10 +123,22 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(result && result.list) ? result.list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayStatusText supports index.js by holding or executing the display status 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.
|
||||
*/
|
||||
displayStatusText: Number(item.status) === 0 ? '已停用' : '启用中'
|
||||
})),
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -66,48 +146,100 @@ Page({
|
||||
return
|
||||
}
|
||||
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 {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* 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: handleCreate supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentShopRecord')
|
||||
navigation.navigate('/pages/shop-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const shop = event.currentTarget.dataset.shop
|
||||
setTempRecord('currentShopRecord', shop)
|
||||
navigation.navigate('/pages/shop-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: shop.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleStatus supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleStatus(event) {
|
||||
const shop = event.currentTarget.dataset.shop
|
||||
const nextStatus = Number(shop.status) === 0 ? 1 : 0
|
||||
shopApi.updateShopStatus(shop.id, nextStatus)
|
||||
.then(() => {
|
||||
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: '店铺状态已更新',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.loadShops()
|
||||
})
|
||||
.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'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,422 @@
|
||||
/**
|
||||
* Purpose: messageApi wraps admin system-message endpoints for list, publish, revoke, and target options.
|
||||
* Usage: call these methods from page event handlers instead of assembling backend URLs in the view layer.
|
||||
*/
|
||||
const messageApi = require('../../api/system-message')
|
||||
/**
|
||||
* Purpose: navigation handles custom navigation-bar back behavior.
|
||||
* Usage: call goBack when returning to the management menu.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: permission checks button-level rights for create and revoke actions.
|
||||
* Usage: pass stored permission codes into hasPermission before rendering or running guarded actions.
|
||||
*/
|
||||
const permission = require('../../utils/permission')
|
||||
/**
|
||||
* Purpose: auth exposes the current admin permission list stored after login.
|
||||
* Usage: read user info and permissions when deciding which mobile controls are available.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: format converts backend times into mini-program friendly text.
|
||||
* Usage: call formatDateTime before assigning message rows to data.list.
|
||||
*/
|
||||
const format = require('../../utils/format')
|
||||
/**
|
||||
* Purpose: actionGuard prevents duplicate publish and revoke submissions from rapid taps.
|
||||
* Usage: wrap create and revoke requests with actionGuard.run.
|
||||
*/
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
|
||||
/**
|
||||
* Purpose: TARGET_TYPE_OPTIONS defines publish target scopes supported by the backend contract.
|
||||
* Usage: render it as chips and submit the selected value as targetType.
|
||||
*/
|
||||
const TARGET_TYPE_OPTIONS = [
|
||||
{ label: '全平台', value: 'PLATFORM_ALL' },
|
||||
{ label: '指定店铺', value: 'SELECTED_SHOPS' },
|
||||
{ label: '指定用户', value: 'SELECTED_USERS' }
|
||||
]
|
||||
|
||||
/**
|
||||
* Purpose: BUSINESS_TYPE_OPTIONS lists common business navigation types used by order review and artist-change messages.
|
||||
* Usage: render it as chips and store the selected value in the publish form.
|
||||
*/
|
||||
const BUSINESS_TYPE_OPTIONS = [
|
||||
{ label: '无', value: '' },
|
||||
{ label: '订单', value: 'ORDER' },
|
||||
{ label: '评价提醒', value: 'ORDER_ARTIST_REVIEW' },
|
||||
{ label: '改派申请', value: 'ORDER_ARTIST_CHANGE' }
|
||||
]
|
||||
|
||||
/**
|
||||
* Purpose: initialForm returns a clean publish form with popup enabled by default.
|
||||
* Usage: call it when opening the form and after successful publish.
|
||||
*/
|
||||
function initialForm() {
|
||||
return {
|
||||
title: '',
|
||||
content: '',
|
||||
targetType: 'PLATFORM_ALL',
|
||||
targetId: '',
|
||||
popupEnabled: true,
|
||||
businessType: '',
|
||||
businessId: '',
|
||||
actionPath: ''
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data stores system-message list, publish form state, permissions, and picker options.
|
||||
* Usage: WXML binds these fields and event handlers update them through setData.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: loading shows whether the message list is being refreshed.
|
||||
* Usage: bind it to page loading lines and refresh controls.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: submitting shows whether publish or revoke is currently running.
|
||||
* Usage: disable action buttons while true.
|
||||
*/
|
||||
submitting: false,
|
||||
/**
|
||||
* Purpose: list contains formatted system messages visible to the current admin scope.
|
||||
* Usage: render it in WXML list cards.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: targetOptions stores backend-provided shops and users for scoped publishing.
|
||||
* Usage: resolve targetId names and validate selected target choices.
|
||||
*/
|
||||
targetOptions: { shops: [], users: [] },
|
||||
/**
|
||||
* Purpose: formVisible controls whether the mobile publish panel is shown.
|
||||
* Usage: toggle it from header and cancel buttons.
|
||||
*/
|
||||
formVisible: false,
|
||||
/**
|
||||
* Purpose: form holds publish fields sent to createMessage after validation.
|
||||
* Usage: update individual properties from inputs and chips.
|
||||
*/
|
||||
form: initialForm(),
|
||||
/**
|
||||
* Purpose: targetTypeOptions renders publish target scope choices.
|
||||
* Usage: iterate it in WXML chips.
|
||||
*/
|
||||
targetTypeOptions: TARGET_TYPE_OPTIONS,
|
||||
/**
|
||||
* Purpose: businessTypeOptions renders common business navigation choices.
|
||||
* Usage: iterate it in WXML chips.
|
||||
*/
|
||||
businessTypeOptions: BUSINESS_TYPE_OPTIONS,
|
||||
/**
|
||||
* Purpose: canCreate controls whether the publish action is visible for the current permission set.
|
||||
* Usage: derive it from message:create permission during onLoad.
|
||||
*/
|
||||
canCreate: false,
|
||||
/**
|
||||
* Purpose: canRevoke controls whether revoke buttons are visible for the current permission set.
|
||||
* Usage: derive it from message:delete permission during onLoad.
|
||||
*/
|
||||
canRevoke: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad initializes permission flags and fetches message list data.
|
||||
* Usage: mini-program runtime calls it when the operator opens the system-message page.
|
||||
*/
|
||||
onLoad() {
|
||||
const userInfo = auth.getStoredUserInfo() || {}
|
||||
const codes = userInfo.permissions || []
|
||||
this.setData({
|
||||
canCreate: permission.hasPermission(codes, 'message:create'),
|
||||
canRevoke: permission.hasPermission(codes, 'message:delete')
|
||||
})
|
||||
this.loadMessages()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onPullDownRefresh reloads system messages and target options.
|
||||
* Usage: mini-program runtime calls it after a manual refresh gesture.
|
||||
*/
|
||||
async onPullDownRefresh() {
|
||||
await this.loadMessages()
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: loadMessages refreshes list data and target options for the publish form.
|
||||
* Usage: call it on page entry, pull refresh, publish success, and revoke success.
|
||||
*/
|
||||
async loadMessages() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const [messages, targetOptions] = await Promise.all([
|
||||
messageApi.listMessages(),
|
||||
this.data.canCreate ? messageApi.getTargetOptions() : Promise.resolve(this.data.targetOptions)
|
||||
])
|
||||
this.setData({
|
||||
list: (Array.isArray(messages) ? messages : []).map(item => this.formatMessage(item)),
|
||||
targetOptions: targetOptions || { shops: [], users: [] }
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '系统消息加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: formatMessage normalizes backend message metadata for compact card display.
|
||||
* Usage: call it on every list item before assigning to data.list.
|
||||
*/
|
||||
formatMessage(item) {
|
||||
return {
|
||||
...item,
|
||||
displayTime: format.formatDateTime(item.publishTime || item.createTime),
|
||||
statusText: Number(item.status) === 1 ? '已发布' : '已撤回',
|
||||
popupText: Number(item.popupEnabled) === 1 ? '弹窗' : '不弹窗',
|
||||
businessText: item.businessType || '无业务跳转',
|
||||
actionText: item.actionPath || (item.businessId ? `业务 ID:${item.businessId}` : '无')
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShowForm opens a clean publish panel for authorized operators.
|
||||
* Usage: bind it to the publish button.
|
||||
*/
|
||||
handleShowForm() {
|
||||
this.setData({
|
||||
formVisible: true,
|
||||
form: initialForm()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleHideForm closes the publish panel without submitting.
|
||||
* Usage: bind it to cancel controls.
|
||||
*/
|
||||
handleHideForm() {
|
||||
this.setData({ formVisible: false })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: patchForm updates one field in the publish form.
|
||||
* Usage: call it from input and chip handlers with a partial form object.
|
||||
*/
|
||||
patchForm(patch) {
|
||||
this.setData({
|
||||
form: {
|
||||
...this.data.form,
|
||||
...patch
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTitleInput stores the publish title input value.
|
||||
* Usage: bind it to the title input.
|
||||
*/
|
||||
handleTitleInput(event) {
|
||||
this.patchForm({ title: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleContentInput stores the publish content textarea value.
|
||||
* Usage: bind it to the content textarea.
|
||||
*/
|
||||
handleContentInput(event) {
|
||||
this.patchForm({ content: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTargetIdInput stores selected shop or user id values.
|
||||
* Usage: bind it to the target id input when targetType is SHOP or USER.
|
||||
*/
|
||||
handleTargetIdInput(event) {
|
||||
this.patchForm({ targetId: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBusinessIdInput stores the optional business id used for message navigation.
|
||||
* Usage: bind it to the business id input.
|
||||
*/
|
||||
handleBusinessIdInput(event) {
|
||||
this.patchForm({ businessId: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleActionPathInput stores the optional frontend action path used by popup and list taps.
|
||||
* Usage: bind it to the action path input.
|
||||
*/
|
||||
handleActionPathInput(event) {
|
||||
this.patchForm({ actionPath: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTargetTypeChange changes publish target scope and clears stale target ids.
|
||||
* Usage: bind it to target type chips with data-value.
|
||||
*/
|
||||
handleTargetTypeChange(event) {
|
||||
this.patchForm({
|
||||
targetType: event.currentTarget.dataset.value,
|
||||
targetId: ''
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBusinessTypeChange changes the optional business navigation type.
|
||||
* Usage: bind it to business type chips with data-value.
|
||||
*/
|
||||
handleBusinessTypeChange(event) {
|
||||
this.patchForm({ businessType: event.currentTarget.dataset.value || '' })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handlePopupToggle flips whether recipients should see a one-time popup.
|
||||
* Usage: bind it to the popup switch control.
|
||||
*/
|
||||
handlePopupToggle(event) {
|
||||
this.patchForm({ popupEnabled: Boolean(event.detail.value) })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: buildPublishPayload validates the form and converts it to backend DTO shape.
|
||||
* Usage: call it inside handlePublish before createMessage; it returns null after showing validation errors.
|
||||
*/
|
||||
buildPublishPayload() {
|
||||
const form = this.data.form
|
||||
const title = String(form.title || '').trim()
|
||||
const content = String(form.content || '').trim()
|
||||
if (!title || !content) {
|
||||
wx.showToast({
|
||||
title: '请填写标题和内容',
|
||||
icon: 'none'
|
||||
})
|
||||
return null
|
||||
}
|
||||
|
||||
const payload = {
|
||||
title,
|
||||
content,
|
||||
targetType: form.targetType,
|
||||
popupEnabled: form.popupEnabled ? 1 : 0,
|
||||
businessType: form.businessType || undefined,
|
||||
businessId: form.businessId ? Number(form.businessId) : undefined,
|
||||
actionPath: String(form.actionPath || '').trim() || undefined
|
||||
}
|
||||
|
||||
if (form.targetType === 'SELECTED_SHOPS') {
|
||||
if (!form.targetId) {
|
||||
wx.showToast({ title: '请输入店铺 ID', icon: 'none' })
|
||||
return null
|
||||
}
|
||||
payload.shopIds = [Number(form.targetId)]
|
||||
}
|
||||
|
||||
if (form.targetType === 'SELECTED_USERS') {
|
||||
if (!form.targetId) {
|
||||
wx.showToast({ title: '请输入用户 ID', icon: 'none' })
|
||||
return null
|
||||
}
|
||||
payload.userIds = [Number(form.targetId)]
|
||||
}
|
||||
|
||||
return payload
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handlePublish submits the publish form with duplicate-tap protection.
|
||||
* Usage: bind it to the primary publish button.
|
||||
*/
|
||||
async handlePublish() {
|
||||
const payload = this.buildPublishPayload()
|
||||
if (!payload) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await actionGuard.run(this, 'system-message:publish', async () => {
|
||||
this.setData({ submitting: true })
|
||||
await messageApi.createMessage(payload)
|
||||
wx.showToast({
|
||||
title: '消息已发布',
|
||||
icon: 'none'
|
||||
})
|
||||
this.setData({
|
||||
formVisible: false,
|
||||
form: initialForm()
|
||||
})
|
||||
await this.loadMessages()
|
||||
}, {
|
||||
message: '消息发布中,请勿重复提交'
|
||||
})
|
||||
} catch (error) {
|
||||
if (actionGuard.isGuardError(error)) {
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: error.message || '消息发布失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ submitting: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleRevoke revokes one message after operator confirmation.
|
||||
* Usage: bind it to list-row revoke buttons with data-id.
|
||||
*/
|
||||
async handleRevoke(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
const confirmed = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '撤回消息',
|
||||
content: '确认撤回这条系统消息吗?',
|
||||
confirmText: '撤回',
|
||||
success: res => resolve(Boolean(res.confirm))
|
||||
})
|
||||
})
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await actionGuard.run(this, `system-message:revoke:${id}`, async () => {
|
||||
await messageApi.revokeMessage(id)
|
||||
wx.showToast({
|
||||
title: '已撤回',
|
||||
icon: 'none'
|
||||
})
|
||||
await this.loadMessages()
|
||||
}, {
|
||||
message: '消息撤回中,请勿重复操作'
|
||||
})
|
||||
} catch (error) {
|
||||
if (actionGuard.isGuardError(error)) {
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: error.message || '撤回失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBack returns to the management menu.
|
||||
* Usage: bind it to the custom navigation bar back event.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/manage/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<navigation-bar title="系统消息" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||
|
||||
<view class="page-shell">
|
||||
<view class="page-stack">
|
||||
<view class="hero-panel">
|
||||
<text class="hero-kicker">Message Center</text>
|
||||
<text class="hero-title">消息发布与弹窗配置</text>
|
||||
<text class="hero-desc">查看消息列表、弹窗开关、业务跳转和发布状态。</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{canCreate && !formVisible}}" class="primary-btn" bindtap="handleShowForm">发布消息</view>
|
||||
|
||||
<view wx:if="{{formVisible}}" class="surface-card form-card">
|
||||
<text class="section-title">发布系统消息</text>
|
||||
<input class="field-input" placeholder="标题" placeholder-class="placeholder" value="{{form.title}}" bindinput="handleTitleInput"></input>
|
||||
<textarea class="field-textarea" placeholder="消息内容" placeholder-class="placeholder" value="{{form.content}}" maxlength="2000" bindinput="handleContentInput"></textarea>
|
||||
|
||||
<text class="field-label">接收范围</text>
|
||||
<view class="chip-row">
|
||||
<block wx:for="{{targetTypeOptions}}" wx:key="value">
|
||||
<view class="chip-btn {{form.targetType === item.value ? 'active' : ''}}" data-value="{{item.value}}" bindtap="handleTargetTypeChange">{{item.label}}</view>
|
||||
</block>
|
||||
</view>
|
||||
<input wx:if="{{form.targetType !== 'PLATFORM_ALL'}}" class="field-input" placeholder="{{form.targetType === 'SELECTED_SHOPS' ? '店铺 ID' : '用户 ID'}}" placeholder-class="placeholder" value="{{form.targetId}}" bindinput="handleTargetIdInput"></input>
|
||||
<view wx:if="{{form.targetType === 'SELECTED_SHOPS' && targetOptions.shops.length}}" class="option-hint">可选店铺:{{targetOptions.shops.length}} 个,输入对应 ID 发布</view>
|
||||
<view wx:if="{{form.targetType === 'SELECTED_USERS' && targetOptions.users.length}}" class="option-hint">可选用户:{{targetOptions.users.length}} 个,输入对应 ID 发布</view>
|
||||
|
||||
<view class="switch-row">
|
||||
<text class="field-label">弹窗显示一次</text>
|
||||
<switch checked="{{form.popupEnabled}}" color="#f07e57" bindchange="handlePopupToggle"></switch>
|
||||
</view>
|
||||
|
||||
<text class="field-label">业务跳转</text>
|
||||
<view class="chip-row">
|
||||
<block wx:for="{{businessTypeOptions}}" wx:key="value">
|
||||
<view class="chip-btn {{form.businessType === item.value ? 'active' : ''}}" data-value="{{item.value}}" bindtap="handleBusinessTypeChange">{{item.label}}</view>
|
||||
</block>
|
||||
</view>
|
||||
<input class="field-input" placeholder="业务 ID,可选" placeholder-class="placeholder" value="{{form.businessId}}" bindinput="handleBusinessIdInput"></input>
|
||||
<input class="field-input" placeholder="跳转路径,如 /orders?orderId=123" placeholder-class="placeholder" value="{{form.actionPath}}" bindinput="handleActionPathInput"></input>
|
||||
|
||||
<view class="actions-row">
|
||||
<button class="secondary-btn" bindtap="handleHideForm">取消</button>
|
||||
<button class="primary-btn" loading="{{submitting}}" bindtap="handlePublish">发布</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<block wx:for="{{list}}" wx:key="id">
|
||||
<view class="list-card">
|
||||
<view class="list-head">
|
||||
<view>
|
||||
<text class="list-title">{{item.title}}</text>
|
||||
<text class="list-subtitle">{{item.publisherName || '系统'}} · {{item.displayTime}}</text>
|
||||
</view>
|
||||
<text class="badge">{{item.popupText}}</text>
|
||||
</view>
|
||||
<text wx:if="{{item.content}}" class="message-content">{{item.content}}</text>
|
||||
<view class="meta-grid">
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">状态</text>
|
||||
<text class="meta-value">{{item.statusText}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">目标</text>
|
||||
<text class="meta-value">{{item.targetTypeName || item.targetType || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">业务类型</text>
|
||||
<text class="meta-value">{{item.businessText}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">跳转</text>
|
||||
<text class="meta-value">{{item.actionText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{canRevoke && item.status === 1}}" class="card-actions">
|
||||
<view class="mini-btn" data-id="{{item.id}}" bindtap="handleRevoke">撤回</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||
<text class="empty-title">暂无系统消息</text>
|
||||
<text class="empty-desc">发布后的消息会显示弹窗配置和业务跳转信息。</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{loading}}" class="loading-line">加载中...</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,65 @@
|
||||
.form-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.field-label {
|
||||
color: #f6efe7;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.field-textarea {
|
||||
width: 100%;
|
||||
min-height: 180rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 18rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.12);
|
||||
color: #f6efe7;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.switch-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.option-hint {
|
||||
color: #9fb3ad;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.actions-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
color: #9fb3ad;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.loading-line {
|
||||
color: #7e8f8c;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
@@ -1,37 +1,121 @@
|
||||
/**
|
||||
* 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: 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: 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 { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create',
|
||||
/**
|
||||
* Purpose: tagId supports index.js by holding or executing the tag id 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.
|
||||
*/
|
||||
tagId: '',
|
||||
/**
|
||||
* Purpose: shops supports index.js by holding or executing the shops 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.
|
||||
*/
|
||||
shops: [],
|
||||
/**
|
||||
* Purpose: shopIndex supports index.js by holding or executing the shop index 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.
|
||||
*/
|
||||
shopIndex: -1,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: '',
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: tagName supports index.js by holding or executing the tag name 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.
|
||||
*/
|
||||
tagName: '',
|
||||
/**
|
||||
* Purpose: textColor supports index.js by holding or executing the text color 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.
|
||||
*/
|
||||
textColor: '#2b2b2b',
|
||||
/**
|
||||
* Purpose: bgColor supports index.js by holding or executing the bg color 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.
|
||||
*/
|
||||
bgColor: '#f6e5df',
|
||||
/**
|
||||
* Purpose: borderColor supports index.js by holding or executing the border color 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.
|
||||
*/
|
||||
borderColor: '#ef9a79'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const mode = options && options.mode ? options.mode : 'create'
|
||||
const currentTag = getTempRecord('currentTag', null)
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: tagId supports index.js by holding or executing the tag id 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.
|
||||
*/
|
||||
tagId: options && options.id ? options.id : ''
|
||||
})
|
||||
|
||||
if (mode === 'edit' && currentTag) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: tagName supports index.js by holding or executing the tag name 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.
|
||||
*/
|
||||
tagName: currentTag.tagName || '',
|
||||
/**
|
||||
* Purpose: textColor supports index.js by holding or executing the text color 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.
|
||||
*/
|
||||
textColor: currentTag.textColor || '#2b2b2b',
|
||||
/**
|
||||
* Purpose: bgColor supports index.js by holding or executing the bg color 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.
|
||||
*/
|
||||
bgColor: currentTag.bgColor || '#f6e5df',
|
||||
/**
|
||||
* Purpose: borderColor supports index.js by holding or executing the border color 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.
|
||||
*/
|
||||
borderColor: currentTag.borderColor || '#ef9a79'
|
||||
}
|
||||
})
|
||||
@@ -41,6 +125,10 @@ Page({
|
||||
this.loadShops()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentTag')
|
||||
},
|
||||
@@ -70,16 +158,32 @@ Page({
|
||||
this.setData({
|
||||
shops,
|
||||
shopIndex,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: selectedShop ? selectedShop.shopName : ''
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleInputChange supports index.js by holding or executing the handle input 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.
|
||||
*/
|
||||
handleInputChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -87,11 +191,19 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShopChange supports index.js by holding or executing the handle shop 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.
|
||||
*/
|
||||
handleShopChange(event) {
|
||||
const shopIndex = Number(event.detail.value)
|
||||
const selectedShop = this.data.shops[shopIndex]
|
||||
this.setData({
|
||||
shopIndex,
|
||||
/**
|
||||
* Purpose: shopLabel supports index.js by holding or executing the shop label 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.
|
||||
*/
|
||||
shopLabel: selectedShop ? selectedShop.shopName : ''
|
||||
})
|
||||
},
|
||||
@@ -100,14 +212,30 @@ Page({
|
||||
const selectedShop = this.data.shops[this.data.shopIndex]
|
||||
if (!this.data.form.tagName) {
|
||||
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: '请输入标签名称',
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
if (!selectedShop) {
|
||||
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: '请选择所属店铺',
|
||||
/**
|
||||
* 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
|
||||
@@ -115,6 +243,10 @@ Page({
|
||||
|
||||
const payload = {
|
||||
...this.data.form,
|
||||
/**
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id 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.
|
||||
*/
|
||||
shopId: selectedShop.id
|
||||
}
|
||||
|
||||
@@ -125,13 +257,29 @@ Page({
|
||||
await tagApi.createTag(payload)
|
||||
}
|
||||
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: this.data.mode === 'edit' ? '标签已更新' : '标签已创建',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
navigation.goBack('/pages/tags/index')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,12 +1,32 @@
|
||||
/**
|
||||
* 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: 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 { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: []
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入标签管理')) {
|
||||
return
|
||||
@@ -18,40 +38,92 @@ Page({
|
||||
try {
|
||||
const list = await tagApi.listAllTags()
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(list) ? list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: item.shopName || '当前店铺'
|
||||
}))
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentTag')
|
||||
navigation.navigate('/pages/tag-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const tag = event.currentTarget.dataset.tag
|
||||
setTempRecord('currentTag', tag)
|
||||
navigation.navigate('/pages/tag-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: tag.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDelete supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleDelete(event) {
|
||||
const tag = event.currentTarget.dataset.tag
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: '删除标签',
|
||||
/**
|
||||
* Purpose: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: `确认删除标签“${tag.tagName}”吗?`,
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -59,13 +131,29 @@ Page({
|
||||
try {
|
||||
await tagApi.deleteTag(tag.id)
|
||||
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: '标签已删除',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.loadTags()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,26 +1,94 @@
|
||||
/**
|
||||
* 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: format supports index.js by holding or executing the format 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 format = require('../../utils/format')
|
||||
const { getTempRecord, clearTempRecord, setTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* Purpose: CHANGE_SCENE_OPTIONS supports index.js by holding or executing the change scene 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 CHANGE_SCENE_OPTIONS = ['MANUAL_RECHARGE', 'MANUAL_INCREASE', 'MANUAL_DEDUCT']
|
||||
/**
|
||||
* Purpose: VIP_LEVEL_OPTIONS supports index.js by holding or executing the vip level 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 VIP_LEVEL_OPTIONS = ['普通', '青铜', '白银', '黄金']
|
||||
|
||||
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: user supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
user: null,
|
||||
/**
|
||||
* 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: null,
|
||||
/**
|
||||
* Purpose: balanceHistory supports index.js by holding or executing the balance 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.
|
||||
*/
|
||||
balanceHistory: [],
|
||||
/**
|
||||
* Purpose: changeSceneIndex supports index.js by holding or executing the change scene index 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.
|
||||
*/
|
||||
changeSceneIndex: 0,
|
||||
/**
|
||||
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level index 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.
|
||||
*/
|
||||
vipLevelIndex: 0,
|
||||
/**
|
||||
* Purpose: balanceForm supports index.js by holding or executing the balance form 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.
|
||||
*/
|
||||
balanceForm: {
|
||||
/**
|
||||
* Purpose: amount supports index.js by holding or executing the amount 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.
|
||||
*/
|
||||
amount: '',
|
||||
/**
|
||||
* Purpose: externalOrderNo supports index.js by holding or executing the external order no 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.
|
||||
*/
|
||||
externalOrderNo: '',
|
||||
/**
|
||||
* Purpose: remark supports index.js by holding or executing the remark 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.
|
||||
*/
|
||||
remark: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: vipRemark supports index.js by holding or executing the vip remark 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.
|
||||
*/
|
||||
vipRemark: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const cached = getTempRecord('currentUser', null)
|
||||
if (cached && (!options || !options.id || String(cached.id) === String(options.id))) {
|
||||
@@ -28,6 +96,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入用户详情')) {
|
||||
return
|
||||
@@ -35,6 +107,10 @@ Page({
|
||||
this.loadAssetData()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentUser')
|
||||
},
|
||||
@@ -52,36 +128,84 @@ Page({
|
||||
|
||||
this.setData({
|
||||
asset,
|
||||
/**
|
||||
* Purpose: balanceHistory supports index.js by holding or executing the balance 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.
|
||||
*/
|
||||
balanceHistory: (Array.isArray(balanceHistory) ? balanceHistory : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayChangeTime supports index.js by holding or executing the display change time 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.
|
||||
*/
|
||||
displayChangeTime: format.formatDateTime(item.changeTime),
|
||||
/**
|
||||
* Purpose: amountBadgeClass supports index.js by holding or executing the amount badge class 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.
|
||||
*/
|
||||
amountBadgeClass: Number(item.amount) >= 0 ? 'success-badge' : 'danger-badge'
|
||||
}))
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit() {
|
||||
setTempRecord('currentUser', this.data.user)
|
||||
navigation.navigate('/pages/user-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: this.data.user.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handlePermissionAssign supports index.js by holding or executing the handle permission assign 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.
|
||||
*/
|
||||
handlePermissionAssign() {
|
||||
setTempRecord('currentUser', this.data.user)
|
||||
navigation.navigate('/pages/permission-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'assign',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: this.data.user.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBalanceInput supports index.js by holding or executing the handle balance 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.
|
||||
*/
|
||||
handleBalanceInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -89,20 +213,44 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleVipRemarkInput supports index.js by holding or executing the handle vip remark 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.
|
||||
*/
|
||||
handleVipRemarkInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: vipRemark supports index.js by holding or executing the vip remark 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.
|
||||
*/
|
||||
vipRemark: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSceneChange supports index.js by holding or executing the handle scene 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.
|
||||
*/
|
||||
handleSceneChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: changeSceneIndex supports index.js by holding or executing the change scene index 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.
|
||||
*/
|
||||
changeSceneIndex: Number(event.detail.value)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleVipLevelChange supports index.js by holding or executing the handle vip level 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.
|
||||
*/
|
||||
handleVipLevelChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level index 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.
|
||||
*/
|
||||
vipLevelIndex: Number(event.detail.value)
|
||||
})
|
||||
},
|
||||
@@ -110,26 +258,74 @@ Page({
|
||||
async handleBalanceChange() {
|
||||
try {
|
||||
await userApi.changeUserBalance(this.data.user.id, {
|
||||
/**
|
||||
* Purpose: amount supports index.js by holding or executing the amount 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.
|
||||
*/
|
||||
amount: Number(this.data.balanceForm.amount),
|
||||
/**
|
||||
* Purpose: changeScene supports index.js by holding or executing the change scene 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.
|
||||
*/
|
||||
changeScene: CHANGE_SCENE_OPTIONS[this.data.changeSceneIndex],
|
||||
/**
|
||||
* Purpose: externalOrderNo supports index.js by holding or executing the external order no 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.
|
||||
*/
|
||||
externalOrderNo: this.data.balanceForm.externalOrderNo || undefined,
|
||||
/**
|
||||
* Purpose: remark supports index.js by holding or executing the remark 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.
|
||||
*/
|
||||
remark: this.data.balanceForm.remark || undefined
|
||||
})
|
||||
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: '余额已调整',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: balanceForm supports index.js by holding or executing the balance form 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.
|
||||
*/
|
||||
balanceForm: {
|
||||
/**
|
||||
* Purpose: amount supports index.js by holding or executing the amount 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.
|
||||
*/
|
||||
amount: '',
|
||||
/**
|
||||
* Purpose: externalOrderNo supports index.js by holding or executing the external order no 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.
|
||||
*/
|
||||
externalOrderNo: '',
|
||||
/**
|
||||
* Purpose: remark supports index.js by holding or executing the remark 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.
|
||||
*/
|
||||
remark: ''
|
||||
}
|
||||
})
|
||||
this.loadAssetData()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -138,17 +334,41 @@ Page({
|
||||
async handleVipOverride() {
|
||||
try {
|
||||
await userApi.overrideUserVip(this.data.user.id, {
|
||||
/**
|
||||
* 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: VIP_LEVEL_OPTIONS[this.data.vipLevelIndex],
|
||||
/**
|
||||
* Purpose: remark supports index.js by holding or executing the remark 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.
|
||||
*/
|
||||
remark: this.data.vipRemark || undefined
|
||||
})
|
||||
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: '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'
|
||||
})
|
||||
this.loadAssetData()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -158,13 +378,29 @@ Page({
|
||||
try {
|
||||
await userApi.recalculateUserVip(this.data.user.id)
|
||||
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: '已恢复自动判级',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.loadAssetData()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -174,17 +410,37 @@ Page({
|
||||
try {
|
||||
await userApi.resetPassword(this.data.user.id)
|
||||
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: '密码已重置',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleUserAction supports index.js by holding or executing the handle user action 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.
|
||||
*/
|
||||
handleUserAction(event) {
|
||||
const action = event.currentTarget.dataset.action
|
||||
if (action === 'disable') {
|
||||
@@ -204,7 +460,15 @@ Page({
|
||||
try {
|
||||
await userApi.updateUserStatus(this.data.user.id, status)
|
||||
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: '用户状态已更新',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
const user = {
|
||||
@@ -215,16 +479,40 @@ Page({
|
||||
setTempRecord('currentUser', user)
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: confirmDelete supports index.js by holding or executing the confirm 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.
|
||||
*/
|
||||
confirmDelete() {
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: '确认删除',
|
||||
/**
|
||||
* Purpose: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: '删除后该账号将不再出现在前端可见列表中,确认继续吗?',
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -232,13 +520,29 @@ Page({
|
||||
try {
|
||||
await userApi.deleteUser(this.data.user.id)
|
||||
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: '用户已删除',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
navigation.goBack('/pages/users/index')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -246,10 +550,26 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: confirmUnbind supports index.js by holding or executing the confirm unbind 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.
|
||||
*/
|
||||
confirmUnbind() {
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: '确认解绑',
|
||||
/**
|
||||
* Purpose: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: '解绑后,该用户将无法登录当前店铺,确认继续吗?',
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -257,12 +577,28 @@ Page({
|
||||
try {
|
||||
await userApi.unbindUser(this.data.user.id)
|
||||
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: '已解除当前店铺绑定',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -270,13 +606,37 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: setUser supports index.js by holding or executing the set user 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.
|
||||
*/
|
||||
setUser(user) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: user supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
user: user ? {
|
||||
...user,
|
||||
/**
|
||||
* Purpose: displayTypeText supports index.js by holding or executing the display type 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.
|
||||
*/
|
||||
displayTypeText: format.getUserTypeText(user.type),
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: format.buildShopName(user),
|
||||
/**
|
||||
* Purpose: displayStatusText supports index.js by holding or executing the display status 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.
|
||||
*/
|
||||
displayStatusText: format.getUserStatusText(user.status),
|
||||
/**
|
||||
* Purpose: displayCreateTime supports index.js by holding or executing the display create time 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.
|
||||
*/
|
||||
displayCreateTime: format.formatDateTime(user.createTime)
|
||||
} : null
|
||||
})
|
||||
|
||||
@@ -1,15 +1,47 @@
|
||||
/**
|
||||
* 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: 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: 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 { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { getDraftValue, clearDraft, scheduleDraftSave, clearDraftTimer } = require('../../utils/form-draft')
|
||||
const { markDirty } = require('../../utils/page-state')
|
||||
const { CACHE_TTL } = require('../../utils/config')
|
||||
|
||||
/**
|
||||
* Purpose: ACCOUNT_REGEX supports index.js by holding or executing the account 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 ACCOUNT_REGEX = /[^A-Za-z0-9]/g
|
||||
/**
|
||||
* Purpose: PHONE_REGEX 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 PHONE_REGEX = /[^\d]/g
|
||||
/**
|
||||
* Purpose: DRAFT_KEY supports index.js by holding or executing the 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 DRAFT_KEY = 'admin-user-form'
|
||||
/**
|
||||
* Purpose: TYPE_OPTIONS supports index.js by holding or executing the type 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 TYPE_OPTIONS = [
|
||||
{ label: '普通用户', value: 0 },
|
||||
{ label: '店长', value: 2 },
|
||||
@@ -17,28 +49,92 @@ const TYPE_OPTIONS = [
|
||||
{ label: '平台管理员', value: 4 }
|
||||
]
|
||||
|
||||
/**
|
||||
* Purpose: normalizeId supports index.js by holding or executing the normalize 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 normalizeId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
}
|
||||
|
||||
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: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: '',
|
||||
/**
|
||||
* Purpose: typeOptions supports index.js by holding or executing the type options 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.
|
||||
*/
|
||||
typeOptions: TYPE_OPTIONS,
|
||||
/**
|
||||
* Purpose: currentTypeLabel supports index.js by holding or executing the current type label 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.
|
||||
*/
|
||||
currentTypeLabel: TYPE_OPTIONS[0].label,
|
||||
/**
|
||||
* Purpose: shops supports index.js by holding or executing the shops 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.
|
||||
*/
|
||||
shops: [],
|
||||
/**
|
||||
* Purpose: selectedShopIds supports index.js by holding or executing the selected shop ids 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.
|
||||
*/
|
||||
selectedShopIds: [],
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: '',
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: 0
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load 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.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const mode = options && options.mode ? options.mode : 'create'
|
||||
const currentUser = getTempRecord('currentUser', null)
|
||||
@@ -53,18 +149,54 @@ Page({
|
||||
|
||||
const baseState = {
|
||||
mode,
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id 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.
|
||||
*/
|
||||
userId: options && options.id ? options.id : '',
|
||||
/**
|
||||
* Purpose: typeOptions supports index.js by holding or executing the type options 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.
|
||||
*/
|
||||
typeOptions: availableTypes,
|
||||
/**
|
||||
* Purpose: currentTypeLabel supports index.js by holding or executing the current type label 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.
|
||||
*/
|
||||
currentTypeLabel: availableTypes[0] ? availableTypes[0].label : ''
|
||||
}
|
||||
|
||||
if (mode === 'edit' && currentUser) {
|
||||
baseState.form = {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: currentUser.nickname || '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: currentUser.account || '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: currentUser.phone || '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: currentUser.signature || '',
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: Number(currentUser.type || 0)
|
||||
}
|
||||
baseState.selectedShopIds = Array.isArray(currentUser.shopIds) ? currentUser.shopIds.map(item => String(item)) : []
|
||||
@@ -74,11 +206,23 @@ Page({
|
||||
|
||||
if (draft && draft.mode === mode) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
...this.data.form,
|
||||
...draft.form,
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: selectedShopIds supports index.js by holding or executing the selected shop ids 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.
|
||||
*/
|
||||
selectedShopIds: Array.isArray(draft.selectedShopIds) ? draft.selectedShopIds : this.data.selectedShopIds
|
||||
})
|
||||
}
|
||||
@@ -87,21 +231,61 @@ Page({
|
||||
this.loadShops()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload 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.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentUser')
|
||||
clearDraftTimer(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: scheduleUserDraft supports index.js by holding or executing the schedule user 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.
|
||||
*/
|
||||
scheduleUserDraft() {
|
||||
scheduleDraftSave(this, DRAFT_KEY, () => ({
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: this.data.mode,
|
||||
/**
|
||||
* Purpose: form supports index.js by holding or executing the form 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.
|
||||
*/
|
||||
form: {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: this.data.form.nickname,
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: this.data.form.account,
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: this.data.form.phone,
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: this.data.form.signature,
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: Number(this.data.form.type)
|
||||
},
|
||||
/**
|
||||
* Purpose: selectedShopIds supports index.js by holding or executing the selected shop ids 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.
|
||||
*/
|
||||
selectedShopIds: this.data.selectedShopIds.slice()
|
||||
}))
|
||||
},
|
||||
@@ -115,11 +299,27 @@ Page({
|
||||
|
||||
if (Number(operator.type) !== 4 && currentShop) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: shops supports index.js by holding or executing the shops 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.
|
||||
*/
|
||||
shops: (Array.isArray(shops) ? shops : []).filter(item => normalizeId(item.id) === normalizeId(currentShop.id)).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: valueId supports index.js by holding or executing the value id 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.
|
||||
*/
|
||||
valueId: normalizeId(item.id),
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: true
|
||||
})),
|
||||
/**
|
||||
* Purpose: selectedShopIds supports index.js by holding or executing the selected shop ids 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.
|
||||
*/
|
||||
selectedShopIds: [normalizeId(currentShop.id)]
|
||||
})
|
||||
this.scheduleUserDraft()
|
||||
@@ -127,20 +327,44 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: shops supports index.js by holding or executing the shops 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.
|
||||
*/
|
||||
shops: (Array.isArray(shops) ? shops : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: valueId supports index.js by holding or executing the value id 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.
|
||||
*/
|
||||
valueId: normalizeId(item.id),
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: this.data.selectedShopIds.includes(normalizeId(item.id))
|
||||
}))
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleInputChange supports index.js by holding or executing the handle input 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.
|
||||
*/
|
||||
handleInputChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
let value = event.detail.value
|
||||
@@ -161,28 +385,52 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTypeChange supports index.js by holding or executing the handle type 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.
|
||||
*/
|
||||
handleTypeChange(event) {
|
||||
const index = Number(event.detail.value)
|
||||
const item = this.data.typeOptions[index]
|
||||
this.setData({
|
||||
'form.type': item ? item.value : 0,
|
||||
/**
|
||||
* Purpose: currentTypeLabel supports index.js by holding or executing the current type label 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.
|
||||
*/
|
||||
currentTypeLabel: item ? item.label : ''
|
||||
})
|
||||
this.scheduleUserDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShopCheck supports index.js by holding or executing the handle shop check 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.
|
||||
*/
|
||||
handleShopCheck(event) {
|
||||
const selectedShopIds = event.detail.value || []
|
||||
this.setData({
|
||||
selectedShopIds,
|
||||
/**
|
||||
* Purpose: shops supports index.js by holding or executing the shops 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.
|
||||
*/
|
||||
shops: this.data.shops.map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: checked supports index.js by holding or executing the checked 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.
|
||||
*/
|
||||
checked: selectedShopIds.includes(String(item.id))
|
||||
}))
|
||||
})
|
||||
this.scheduleUserDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: validateForm supports index.js by holding or executing the validate form 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.
|
||||
*/
|
||||
validateForm() {
|
||||
const form = this.data.form
|
||||
if (!form.nickname) {
|
||||
@@ -207,18 +455,50 @@ Page({
|
||||
const errorMessage = this.validateForm()
|
||||
if (errorMessage) {
|
||||
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: errorMessage,
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
const payload = {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: this.data.form.nickname,
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: this.data.form.account,
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: this.data.form.phone,
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: this.data.form.signature || undefined,
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: Number(this.data.form.type),
|
||||
/**
|
||||
* Purpose: shopIds supports index.js by holding or executing the shop ids 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.
|
||||
*/
|
||||
shopIds: this.data.selectedShopIds.map(item => Number(item))
|
||||
}
|
||||
|
||||
@@ -235,21 +515,45 @@ Page({
|
||||
clearDraft(DRAFT_KEY)
|
||||
markDirty('admin-users')
|
||||
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: this.data.mode === 'edit' ? '用户已更新' : '用户已创建',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
navigation.goBack('/pages/users/index')
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: syncTypeLabel supports index.js by holding or executing the sync type label 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.
|
||||
*/
|
||||
syncTypeLabel(type) {
|
||||
const target = this.data.typeOptions.find(item => Number(item.value) === Number(type))
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: currentTypeLabel supports index.js by holding or executing the current type label 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.
|
||||
*/
|
||||
currentTypeLabel: target ? target.label : ''
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
/**
|
||||
* 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: format supports index.js by holding or executing the format 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 format = require('../../utils/format')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { consumeDirty } = require('../../utils/page-state')
|
||||
|
||||
/**
|
||||
* Purpose: TYPE_OPTIONS supports index.js by holding or executing the type 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 TYPE_OPTIONS = [
|
||||
{ label: '全部角色', value: '' },
|
||||
{ label: '普通用户', value: 0 },
|
||||
@@ -13,15 +29,47 @@ const TYPE_OPTIONS = [
|
||||
]
|
||||
|
||||
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: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: '',
|
||||
/**
|
||||
* Purpose: typeOptions supports index.js by holding or executing the type options 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.
|
||||
*/
|
||||
typeOptions: TYPE_OPTIONS,
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* 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: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (!navigation.ensureLogin('进入用户管理')) {
|
||||
return
|
||||
@@ -31,18 +79,38 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadUsers()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTypeChange supports index.js by holding or executing the handle type 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.
|
||||
*/
|
||||
handleTypeChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: event.currentTarget.dataset.type
|
||||
})
|
||||
this.loadUsers()
|
||||
@@ -52,14 +120,34 @@ Page({
|
||||
const requestId = (this._loadRequestId || 0) + 1
|
||||
this._loadRequestId = requestId
|
||||
this.setData({
|
||||
/**
|
||||
* 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: true
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await userApi.listUsers({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined,
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: this.data.type === '' ? undefined : this.data.type
|
||||
})
|
||||
|
||||
@@ -68,12 +156,32 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(result && result.list) ? result.list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: format.buildShopName(item),
|
||||
/**
|
||||
* Purpose: displayTypeText supports index.js by holding or executing the display type 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.
|
||||
*/
|
||||
displayTypeText: format.getUserTypeText(item.type),
|
||||
/**
|
||||
* Purpose: displayStatusText supports index.js by holding or executing the display status 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.
|
||||
*/
|
||||
displayStatusText: format.getUserStatusText(item.status)
|
||||
})),
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -81,38 +189,78 @@ Page({
|
||||
return
|
||||
}
|
||||
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 {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* 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: handleOpenDetail supports index.js by holding or executing the handle open detail 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.
|
||||
*/
|
||||
handleOpenDetail(event) {
|
||||
const user = event.currentTarget.dataset.user
|
||||
setTempRecord('currentUser', user)
|
||||
navigation.navigate('/pages/user-detail/index', {
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: user.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const user = event.currentTarget.dataset.user
|
||||
setTempRecord('currentUser', user)
|
||||
navigation.navigate('/pages/user-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the id 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.
|
||||
*/
|
||||
id: user.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentUser')
|
||||
navigation.navigate('/pages/user-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode 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.
|
||||
*/
|
||||
mode: 'create'
|
||||
}).catch(() => undefined)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user