diff --git a/WeChatProgram/api/auth.js b/WeChatProgram/api/auth.js index f304e537..43d4e2a1 100644 --- a/WeChatProgram/api/auth.js +++ b/WeChatProgram/api/auth.js @@ -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', diff --git a/WeChatProgram/api/cart.js b/WeChatProgram/api/cart.js index cd6469a7..cc402acd 100644 --- a/WeChatProgram/api/cart.js +++ b/WeChatProgram/api/cart.js @@ -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', diff --git a/WeChatProgram/api/comment.js b/WeChatProgram/api/comment.js index e5e25f8f..2786adeb 100644 --- a/WeChatProgram/api/comment.js +++ b/WeChatProgram/api/comment.js @@ -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}`, diff --git a/WeChatProgram/api/coupon.js b/WeChatProgram/api/coupon.js index ff845f85..adc1e587 100644 --- a/WeChatProgram/api/coupon.js +++ b/WeChatProgram/api/coupon.js @@ -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', diff --git a/WeChatProgram/api/file.js b/WeChatProgram/api/file.js index 72df1890..e2c6fbb1 100644 --- a/WeChatProgram/api/file.js +++ b/WeChatProgram/api/file.js @@ -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}`, diff --git a/WeChatProgram/api/order.js b/WeChatProgram/api/order.js index 72ac197b..b35a5bd4 100644 --- a/WeChatProgram/api/order.js +++ b/WeChatProgram/api/order.js @@ -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}`, diff --git a/WeChatProgram/api/product-like.js b/WeChatProgram/api/product-like.js index 12094240..980aa9ad 100644 --- a/WeChatProgram/api/product-like.js +++ b/WeChatProgram/api/product-like.js @@ -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}` diff --git a/WeChatProgram/api/product.js b/WeChatProgram/api/product.js index 3db0bc7a..c4717a67 100644 --- a/WeChatProgram/api/product.js +++ b/WeChatProgram/api/product.js @@ -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', diff --git a/WeChatProgram/api/shop.js b/WeChatProgram/api/shop.js index 7efbdf4a..904012b0 100644 --- a/WeChatProgram/api/shop.js +++ b/WeChatProgram/api/shop.js @@ -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}` diff --git a/WeChatProgram/api/tag.js b/WeChatProgram/api/tag.js index 451139f2..41d68c61 100644 --- a/WeChatProgram/api/tag.js +++ b/WeChatProgram/api/tag.js @@ -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' diff --git a/WeChatProgram/api/user.js b/WeChatProgram/api/user.js index 9b203ea9..4c468316 100644 --- a/WeChatProgram/api/user.js +++ b/WeChatProgram/api/user.js @@ -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', diff --git a/WeChatProgram/api/wishlist.js b/WeChatProgram/api/wishlist.js index 800f6bcb..b480e9f0 100644 --- a/WeChatProgram/api/wishlist.js +++ b/WeChatProgram/api/wishlist.js @@ -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' diff --git a/WeChatProgram/app.js b/WeChatProgram/app.js index fbd0dd02..500f1cea 100644 --- a/WeChatProgram/app.js +++ b/WeChatProgram/app.js @@ -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({ diff --git a/WeChatProgram/components/navigation-bar/navigation-bar.js b/WeChatProgram/components/navigation-bar/navigation-bar.js index f38f7589..b71a6314 100644 --- a/WeChatProgram/components/navigation-bar/navigation-bar.js +++ b/WeChatProgram/components/navigation-bar/navigation-bar.js @@ -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', }) }, diff --git a/WeChatProgram/pages/auth/index.js b/WeChatProgram/pages/auth/index.js index 7b3545e2..4ee58d20 100644 --- a/WeChatProgram/pages/auth/index.js +++ b/WeChatProgram/pages/auth/index.js @@ -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, diff --git a/WeChatProgram/pages/cart/index.js b/WeChatProgram/pages/cart/index.js index ee93b02a..09ab8072 100644 --- a/WeChatProgram/pages/cart/index.js +++ b/WeChatProgram/pages/cart/index.js @@ -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() }, diff --git a/WeChatProgram/pages/coupons/index.js b/WeChatProgram/pages/coupons/index.js index a1533243..6151a1b9 100644 --- a/WeChatProgram/pages/coupons/index.js +++ b/WeChatProgram/pages/coupons/index.js @@ -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} 折` diff --git a/WeChatProgram/pages/home/index.js b/WeChatProgram/pages/home/index.js index 231fbbec..dfa8813e 100644 --- a/WeChatProgram/pages/home/index.js +++ b/WeChatProgram/pages/home/index.js @@ -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') /** diff --git a/WeChatProgram/pages/index/index.js b/WeChatProgram/pages/index/index.js index aede9054..e490dbf9 100644 --- a/WeChatProgram/pages/index/index.js +++ b/WeChatProgram/pages/index/index.js @@ -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' }) }, diff --git a/WeChatProgram/pages/notifications/index.js b/WeChatProgram/pages/notifications/index.js index 2cf5c92c..5d274ddc 100644 --- a/WeChatProgram/pages/notifications/index.js +++ b/WeChatProgram/pages/notifications/index.js @@ -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() {}, /** diff --git a/WeChatProgram/pages/orders/index.js b/WeChatProgram/pages/orders/index.js index 80b2fe31..48a2d457 100644 --- a/WeChatProgram/pages/orders/index.js +++ b/WeChatProgram/pages/orders/index.js @@ -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) { diff --git a/WeChatProgram/pages/orders/index.wxml b/WeChatProgram/pages/orders/index.wxml index fb5bd97c..5a5cf97f 100644 --- a/WeChatProgram/pages/orders/index.wxml +++ b/WeChatProgram/pages/orders/index.wxml @@ -15,7 +15,7 @@ 查看订单状态和预约时间。 - + 订单号 @@ -32,50 +32,50 @@ {{orderItem.priceText}} x {{orderItem.quantity}} 美甲师:{{orderItem.artistName}} 预约时间:{{orderItem.appointmentText}} - - - - 评价状态 - {{orderItem.reviewSummary.displayText}} - {{orderItem.reviewSummary.contentText}} - + + 评价状态 + {{orderItem.reviewSummary.displayText}} + {{orderItem.reviewSummary.contentText}} + - - - 评价美甲师 - 评分必填,文字可选 - - - {{score}} - - - 提交评价 - + + + 评价美甲师 + 评分必填,文字可选 + + + {{score}} + + + 提交评价 + - - 待确认改派 - {{orderItem.pendingArtistChangeRequest.displayText}} - 原因:{{orderItem.pendingArtistChangeRequest.reasonText}} - - 同意改派 - 拒绝 + + 待确认改派 + {{orderItem.pendingArtistChangeRequest.displayText}} + 原因:{{orderItem.pendingArtistChangeRequest.reasonText}} + + 同意改派 + 拒绝 + + diff --git a/WeChatProgram/pages/orders/index.wxss b/WeChatProgram/pages/orders/index.wxss index 947cb20c..f74c203e 100644 --- a/WeChatProgram/pages/orders/index.wxss +++ b/WeChatProgram/pages/orders/index.wxss @@ -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 { diff --git a/WeChatProgram/pages/product-detail/index.js b/WeChatProgram/pages/product-detail/index.js index b22706a9..030bd4a1 100644 --- a/WeChatProgram/pages/product-detail/index.js +++ b/WeChatProgram/pages/product-detail/index.js @@ -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' + }) + } }) }, diff --git a/WeChatProgram/pages/product-detail/index.wxml b/WeChatProgram/pages/product-detail/index.wxml index 57690132..80460e73 100644 --- a/WeChatProgram/pages/product-detail/index.wxml +++ b/WeChatProgram/pages/product-detail/index.wxml @@ -67,6 +67,8 @@ 收藏 {{product.collectCount || 0}} + + 复制路径 diff --git a/WeChatProgram/pages/product-detail/index.wxss b/WeChatProgram/pages/product-detail/index.wxss index 52e03be3..fd302048 100644 --- a/WeChatProgram/pages/product-detail/index.wxss +++ b/WeChatProgram/pages/product-detail/index.wxss @@ -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 { diff --git a/WeChatProgram/pages/products/index.js b/WeChatProgram/pages/products/index.js index 022ccdc1..fddb0325 100644 --- a/WeChatProgram/pages/products/index.js +++ b/WeChatProgram/pages/products/index.js @@ -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' /** diff --git a/WeChatProgram/pages/profile/index.js b/WeChatProgram/pages/profile/index.js index 488c99e7..b8113b6d 100644 --- a/WeChatProgram/pages/profile/index.js +++ b/WeChatProgram/pages/profile/index.js @@ -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 } diff --git a/WeChatProgram/pages/settings/index.js b/WeChatProgram/pages/settings/index.js index b5dbe7b8..882b0571 100644 --- a/WeChatProgram/pages/settings/index.js +++ b/WeChatProgram/pages/settings/index.js @@ -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' /** diff --git a/WeChatProgram/pages/shop-detail/index.js b/WeChatProgram/pages/shop-detail/index.js index 417e40af..044b1575 100644 --- a/WeChatProgram/pages/shop-detail/index.js +++ b/WeChatProgram/pages/shop-detail/index.js @@ -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 '' diff --git a/WeChatProgram/pages/shop-detail/index.wxml b/WeChatProgram/pages/shop-detail/index.wxml index d44d080d..5445c24b 100644 --- a/WeChatProgram/pages/shop-detail/index.wxml +++ b/WeChatProgram/pages/shop-detail/index.wxml @@ -49,9 +49,17 @@ 复制地址 + + 联系店长 + + {{managerContact.contactName || '店长'}} · {{managerContact.phoneAvailable ? managerContact.phone : (managerContact.platformContactText || '暂无电话')}} + + + 查看地图位置 复制高德导航链接 + 复制备用导航 diff --git a/WeChatProgram/pages/shop-detail/index.wxss b/WeChatProgram/pages/shop-detail/index.wxss index beb7ad14..adc9ec2a 100644 --- a/WeChatProgram/pages/shop-detail/index.wxss +++ b/WeChatProgram/pages/shop-detail/index.wxss @@ -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; diff --git a/WeChatProgram/pages/vip-center/index.js b/WeChatProgram/pages/vip-center/index.js index 2e268344..2d609354 100644 --- a/WeChatProgram/pages/vip-center/index.js +++ b/WeChatProgram/pages/vip-center/index.js @@ -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' }) } diff --git a/WeChatProgram/pages/wishlist/index.js b/WeChatProgram/pages/wishlist/index.js index 2be861cc..49ec5316 100644 --- a/WeChatProgram/pages/wishlist/index.js +++ b/WeChatProgram/pages/wishlist/index.js @@ -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') diff --git a/WeChatProgram/utils/action-guard.js b/WeChatProgram/utils/action-guard.js index c4f11ce8..367b9c17 100644 --- a/WeChatProgram/utils/action-guard.js +++ b/WeChatProgram/utils/action-guard.js @@ -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) } diff --git a/WeChatProgram/utils/auth.js b/WeChatProgram/utils/auth.js index bfd25ae8..0e8239b1 100644 --- a/WeChatProgram/utils/auth.js +++ b/WeChatProgram/utils/auth.js @@ -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) diff --git a/WeChatProgram/utils/cache.js b/WeChatProgram/utils/cache.js index 63400cf8..5c2d9358 100644 --- a/WeChatProgram/utils/cache.js +++ b/WeChatProgram/utils/cache.js @@ -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) { diff --git a/WeChatProgram/utils/config.js b/WeChatProgram/utils/config.js index 086af937..e5e78ae2 100644 --- a/WeChatProgram/utils/config.js +++ b/WeChatProgram/utils/config.js @@ -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']) diff --git a/WeChatProgram/utils/crypto.js b/WeChatProgram/utils/crypto.js index ce4e850a..33e0970d 100644 --- a/WeChatProgram/utils/crypto.js +++ b/WeChatProgram/utils/crypto.js @@ -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)}` } diff --git a/WeChatProgram/utils/device.js b/WeChatProgram/utils/device.js index 2076bfcf..8dc37b9e 100644 --- a/WeChatProgram/utils/device.js +++ b/WeChatProgram/utils/device.js @@ -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) { diff --git a/WeChatProgram/utils/file.js b/WeChatProgram/utils/file.js index 4397938e..de70a239 100644 --- a/WeChatProgram/utils/file.js +++ b/WeChatProgram/utils/file.js @@ -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]) diff --git a/WeChatProgram/utils/form-draft.js b/WeChatProgram/utils/form-draft.js index 374cddbf..5e2c4918 100644 --- a/WeChatProgram/utils/form-draft.js +++ b/WeChatProgram/utils/form-draft.js @@ -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) diff --git a/WeChatProgram/utils/format.js b/WeChatProgram/utils/format.js index c3ff1dbe..f8ed3c7e 100644 --- a/WeChatProgram/utils/format.js +++ b/WeChatProgram/utils/format.js @@ -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) { diff --git a/WeChatProgram/utils/idle-session.js b/WeChatProgram/utils/idle-session.js index 793b5d8a..a5adc4bf 100644 --- a/WeChatProgram/utils/idle-session.js +++ b/WeChatProgram/utils/idle-session.js @@ -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() diff --git a/WeChatProgram/utils/keyboard-safe.js b/WeChatProgram/utils/keyboard-safe.js index 585e32a6..da3cb01c 100644 --- a/WeChatProgram/utils/keyboard-safe.js +++ b/WeChatProgram/utils/keyboard-safe.js @@ -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) { diff --git a/WeChatProgram/utils/loading.js b/WeChatProgram/utils/loading.js index 217aa0b5..1642dc69 100644 --- a/WeChatProgram/utils/loading.js +++ b/WeChatProgram/utils/loading.js @@ -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) diff --git a/WeChatProgram/utils/navigation.js b/WeChatProgram/utils/navigation.js index 44f5cca1..0bd7a339 100644 --- a/WeChatProgram/utils/navigation.js +++ b/WeChatProgram/utils/navigation.js @@ -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 || {} diff --git a/WeChatProgram/utils/product.js b/WeChatProgram/utils/product.js index 124b9554..f386c0e1 100644 --- a/WeChatProgram/utils/product.js +++ b/WeChatProgram/utils/product.js @@ -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))) diff --git a/WeChatProgram/utils/request.js b/WeChatProgram/utils/request.js index e6fee63c..83787e28 100644 --- a/WeChatProgram/utils/request.js +++ b/WeChatProgram/utils/request.js @@ -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) diff --git a/WeChatProgram/utils/storage.js b/WeChatProgram/utils/storage.js index 160e452b..2301f65c 100644 --- a/WeChatProgram/utils/storage.js +++ b/WeChatProgram/utils/storage.js @@ -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) } diff --git a/WeChatProgram/utils/theme.js b/WeChatProgram/utils/theme.js index 8cc0b624..62e7c600 100644 --- a/WeChatProgram/utils/theme.js +++ b/WeChatProgram/utils/theme.js @@ -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 diff --git a/WeChatProgram/utils/theme.test.js b/WeChatProgram/utils/theme.test.js index 2f6a1e50..0d727637 100644 --- a/WeChatProgram/utils/theme.test.js +++ b/WeChatProgram/utils/theme.test.js @@ -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' diff --git a/YumiNail-Admin-Program/api/auth.js b/YumiNail-Admin-Program/api/auth.js index f34e4214..85102bcd 100644 --- a/YumiNail-Admin-Program/api/auth.js +++ b/YumiNail-Admin-Program/api/auth.js @@ -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', diff --git a/YumiNail-Admin-Program/api/comment.js b/YumiNail-Admin-Program/api/comment.js index f157fddc..fc348fc9 100644 --- a/YumiNail-Admin-Program/api/comment.js +++ b/YumiNail-Admin-Program/api/comment.js @@ -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}`, diff --git a/YumiNail-Admin-Program/api/coupon.js b/YumiNail-Admin-Program/api/coupon.js index 2acd648c..caf8af3b 100644 --- a/YumiNail-Admin-Program/api/coupon.js +++ b/YumiNail-Admin-Program/api/coupon.js @@ -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', diff --git a/YumiNail-Admin-Program/api/dashboard.js b/YumiNail-Admin-Program/api/dashboard.js index 37940f51..19d1d4de 100644 --- a/YumiNail-Admin-Program/api/dashboard.js +++ b/YumiNail-Admin-Program/api/dashboard.js @@ -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' diff --git a/YumiNail-Admin-Program/api/file.js b/YumiNail-Admin-Program/api/file.js index 5c370dab..d9235031 100644 --- a/YumiNail-Admin-Program/api/file.js +++ b/YumiNail-Admin-Program/api/file.js @@ -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}` diff --git a/YumiNail-Admin-Program/api/nail-artist.js b/YumiNail-Admin-Program/api/nail-artist.js index 47698e5e..533ef813 100644 --- a/YumiNail-Admin-Program/api/nail-artist.js +++ b/YumiNail-Admin-Program/api/nail-artist.js @@ -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', diff --git a/YumiNail-Admin-Program/api/order.js b/YumiNail-Admin-Program/api/order.js index f322190d..871f5079 100644 --- a/YumiNail-Admin-Program/api/order.js +++ b/YumiNail-Admin-Program/api/order.js @@ -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}`, diff --git a/YumiNail-Admin-Program/api/permission.js b/YumiNail-Admin-Program/api/permission.js index 1e77147c..0ab021f2 100644 --- a/YumiNail-Admin-Program/api/permission.js +++ b/YumiNail-Admin-Program/api/permission.js @@ -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}`, diff --git a/YumiNail-Admin-Program/api/product.js b/YumiNail-Admin-Program/api/product.js index 4c3bbc46..1fc4ff4b 100644 --- a/YumiNail-Admin-Program/api/product.js +++ b/YumiNail-Admin-Program/api/product.js @@ -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}`, diff --git a/YumiNail-Admin-Program/api/security-audit.js b/YumiNail-Admin-Program/api/security-audit.js new file mode 100644 index 00000000..b291d409 --- /dev/null +++ b/YumiNail-Admin-Program/api/security-audit.js @@ -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 + }) + } +} diff --git a/YumiNail-Admin-Program/api/shop.js b/YumiNail-Admin-Program/api/shop.js index d240507a..78785af4 100644 --- a/YumiNail-Admin-Program/api/shop.js +++ b/YumiNail-Admin-Program/api/shop.js @@ -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}`, diff --git a/YumiNail-Admin-Program/api/system-message.js b/YumiNail-Admin-Program/api/system-message.js new file mode 100644 index 00000000..d6f1cff8 --- /dev/null +++ b/YumiNail-Admin-Program/api/system-message.js @@ -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' + }) + } +} diff --git a/YumiNail-Admin-Program/api/tag.js b/YumiNail-Admin-Program/api/tag.js index 4f9835a8..9b82ea2d 100644 --- a/YumiNail-Admin-Program/api/tag.js +++ b/YumiNail-Admin-Program/api/tag.js @@ -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}`, diff --git a/YumiNail-Admin-Program/api/user.js b/YumiNail-Admin-Program/api/user.js index de246f5e..3830c64c 100644 --- a/YumiNail-Admin-Program/api/user.js +++ b/YumiNail-Admin-Program/api/user.js @@ -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`, diff --git a/YumiNail-Admin-Program/app.js b/YumiNail-Admin-Program/app.js index 6c490f14..fd4d5355 100644 --- a/YumiNail-Admin-Program/app.js +++ b/YumiNail-Admin-Program/app.js @@ -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 diff --git a/YumiNail-Admin-Program/app.json b/YumiNail-Admin-Program/app.json index 42c54c85..972c258b 100644 --- a/YumiNail-Admin-Program/app.json +++ b/YumiNail-Admin-Program/app.json @@ -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": { diff --git a/YumiNail-Admin-Program/components/navigation-bar/navigation-bar.js b/YumiNail-Admin-Program/components/navigation-bar/navigation-bar.js index a162c1c6..f02fea99 100644 --- a/YumiNail-Admin-Program/components/navigation-bar/navigation-bar.js +++ b/YumiNail-Admin-Program/components/navigation-bar/navigation-bar.js @@ -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', {}, {}) diff --git a/YumiNail-Admin-Program/pages/artist-form/index.js b/YumiNail-Admin-Program/pages/artist-form/index.js index 11187312..3c90e614 100644 --- a/YumiNail-Admin-Program/pages/artist-form/index.js +++ b/YumiNail-Admin-Program/pages/artist-form/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/artists/index.js b/YumiNail-Admin-Program/pages/artists/index.js index 2d074a6a..09cea75e 100644 --- a/YumiNail-Admin-Program/pages/artists/index.js +++ b/YumiNail-Admin-Program/pages/artists/index.js @@ -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) } diff --git a/YumiNail-Admin-Program/pages/comments/index.js b/YumiNail-Admin-Program/pages/comments/index.js index b1633482..88e15779 100644 --- a/YumiNail-Admin-Program/pages/comments/index.js +++ b/YumiNail-Admin-Program/pages/comments/index.js @@ -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 diff --git a/YumiNail-Admin-Program/pages/coupon-form/index.js b/YumiNail-Admin-Program/pages/coupon-form/index.js index 3f3f8fdf..74dbc619 100644 --- a/YumiNail-Admin-Program/pages/coupon-form/index.js +++ b/YumiNail-Admin-Program/pages/coupon-form/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/coupons/index.js b/YumiNail-Admin-Program/pages/coupons/index.js index 826a38b7..5465828d 100644 --- a/YumiNail-Admin-Program/pages/coupons/index.js +++ b/YumiNail-Admin-Program/pages/coupons/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/login/index.js b/YumiNail-Admin-Program/pages/login/index.js index 0f2f6727..c88a56ce 100644 --- a/YumiNail-Admin-Program/pages/login/index.js +++ b/YumiNail-Admin-Program/pages/login/index.js @@ -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 }) } diff --git a/YumiNail-Admin-Program/pages/manage/index.js b/YumiNail-Admin-Program/pages/manage/index.js index 88e9eae8..e2f8b7de 100644 --- a/YumiNail-Admin-Program/pages/manage/index.js +++ b/YumiNail-Admin-Program/pages/manage/index.js @@ -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 diff --git a/YumiNail-Admin-Program/pages/order-detail/index.js b/YumiNail-Admin-Program/pages/order-detail/index.js index b38a11df..83d03940 100644 --- a/YumiNail-Admin-Program/pages/order-detail/index.js +++ b/YumiNail-Admin-Program/pages/order-detail/index.js @@ -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') } diff --git a/YumiNail-Admin-Program/pages/order-detail/index.wxml b/YumiNail-Admin-Program/pages/order-detail/index.wxml index 290a780b..0b661cb8 100644 --- a/YumiNail-Admin-Program/pages/order-detail/index.wxml +++ b/YumiNail-Admin-Program/pages/order-detail/index.wxml @@ -24,7 +24,7 @@ 应付金额 - ¥{{order.payAmount || '--'}} + ¥{{order.displayPayAmount || '--'}} 备注 @@ -33,9 +33,30 @@ - + + 服务项目 + + + + {{item.productTitle || '订单项目'}} + {{item.reviewStatusText}} + + 美甲师:{{item.artistName || '--'}} + 预约时间:{{item.displayAppointmentTime}} + 评价内容:{{item.reviewSummary.contentText}} + + 改派申请 + {{item.pendingArtistChangeRequest.displayText}} + 原因:{{item.pendingArtistChangeRequest.reasonText}} + + + + + + 订单详情暂不可用 - 当前详情页优先复用列表页已拉取的数据。如果你是直接打开该页面,请先回到订单列表重新进入。 + 当前详情页可通过列表、消息或订单 id 打开;加载失败时可重试。 + diff --git a/YumiNail-Admin-Program/pages/order-detail/index.wxss b/YumiNail-Admin-Program/pages/order-detail/index.wxss index 09b20ffe..d55502d3 100644 --- a/YumiNail-Admin-Program/pages/order-detail/index.wxss +++ b/YumiNail-Admin-Program/pages/order-detail/index.wxss @@ -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; +} diff --git a/YumiNail-Admin-Program/pages/orders/index.js b/YumiNail-Admin-Program/pages/orders/index.js index 880aa11e..6dd1159c 100644 --- a/YumiNail-Admin-Program/pages/orders/index.js +++ b/YumiNail-Admin-Program/pages/orders/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/permission-form/index.js b/YumiNail-Admin-Program/pages/permission-form/index.js index 707160ea..0c76e1e9 100644 --- a/YumiNail-Admin-Program/pages/permission-form/index.js +++ b/YumiNail-Admin-Program/pages/permission-form/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/permissions/index.js b/YumiNail-Admin-Program/pages/permissions/index.js index f803a83c..62d56530 100644 --- a/YumiNail-Admin-Program/pages/permissions/index.js +++ b/YumiNail-Admin-Program/pages/permissions/index.js @@ -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) } diff --git a/YumiNail-Admin-Program/pages/product-form/index.js b/YumiNail-Admin-Program/pages/product-form/index.js index 15b0b60f..a53a8305 100644 --- a/YumiNail-Admin-Program/pages/product-form/index.js +++ b/YumiNail-Admin-Program/pages/product-form/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/products/index.js b/YumiNail-Admin-Program/pages/products/index.js index d5401687..6c9a73ae 100644 --- a/YumiNail-Admin-Program/pages/products/index.js +++ b/YumiNail-Admin-Program/pages/products/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/profile/index.js b/YumiNail-Admin-Program/pages/profile/index.js index 78c72776..239e742f 100644 --- a/YumiNail-Admin-Program/pages/profile/index.js +++ b/YumiNail-Admin-Program/pages/profile/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/security-audit/index.js b/YumiNail-Admin-Program/pages/security-audit/index.js new file mode 100644 index 00000000..7feda3c7 --- /dev/null +++ b/YumiNail-Admin-Program/pages/security-audit/index.js @@ -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') + } +}) diff --git a/YumiNail-Admin-Program/pages/security-audit/index.json b/YumiNail-Admin-Program/pages/security-audit/index.json new file mode 100644 index 00000000..8632c9b0 --- /dev/null +++ b/YumiNail-Admin-Program/pages/security-audit/index.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "navigation-bar": "/components/navigation-bar/navigation-bar" + } +} diff --git a/YumiNail-Admin-Program/pages/security-audit/index.wxml b/YumiNail-Admin-Program/pages/security-audit/index.wxml new file mode 100644 index 00000000..de0d6588 --- /dev/null +++ b/YumiNail-Admin-Program/pages/security-audit/index.wxml @@ -0,0 +1,64 @@ + + + + + + Security Audit + 高危操作留痕 + 按账号、动作和结果查看后台关键操作记录,失败原因会保留在详情行中。 + + + + 筛选 + + + + + {{item.label}} + + + + + + + + + + + + + {{item.action || '--'}} + {{item.operatorText}} · {{item.displayTime}} + + {{item.resultText}} + + + + 业务类型 + {{item.businessType || '--'}} + + + 业务 ID + {{item.businessId || '--'}} + + + IP + {{item.ipAddress || '--'}} + + + 原因 + {{item.reasonText || '无'}} + + + + + + + 暂无审计日志 + 当前筛选条件下没有高危操作记录。 + + + 加载中... + 已加载全部 + + diff --git a/YumiNail-Admin-Program/pages/security-audit/index.wxss b/YumiNail-Admin-Program/pages/security-audit/index.wxss new file mode 100644 index 00000000..c0065c9b --- /dev/null +++ b/YumiNail-Admin-Program/pages/security-audit/index.wxss @@ -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; +} diff --git a/YumiNail-Admin-Program/pages/shop-form/index.js b/YumiNail-Admin-Program/pages/shop-form/index.js index 0114bb33..3a5de602 100644 --- a/YumiNail-Admin-Program/pages/shop-form/index.js +++ b/YumiNail-Admin-Program/pages/shop-form/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/shops/index.js b/YumiNail-Admin-Program/pages/shops/index.js index acebff86..86611894 100644 --- a/YumiNail-Admin-Program/pages/shops/index.js +++ b/YumiNail-Admin-Program/pages/shops/index.js @@ -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' }) }) diff --git a/YumiNail-Admin-Program/pages/system-messages/index.js b/YumiNail-Admin-Program/pages/system-messages/index.js new file mode 100644 index 00000000..e7fb92b2 --- /dev/null +++ b/YumiNail-Admin-Program/pages/system-messages/index.js @@ -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') + } +}) diff --git a/YumiNail-Admin-Program/pages/system-messages/index.json b/YumiNail-Admin-Program/pages/system-messages/index.json new file mode 100644 index 00000000..8632c9b0 --- /dev/null +++ b/YumiNail-Admin-Program/pages/system-messages/index.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "navigation-bar": "/components/navigation-bar/navigation-bar" + } +} diff --git a/YumiNail-Admin-Program/pages/system-messages/index.wxml b/YumiNail-Admin-Program/pages/system-messages/index.wxml new file mode 100644 index 00000000..a6b17a17 --- /dev/null +++ b/YumiNail-Admin-Program/pages/system-messages/index.wxml @@ -0,0 +1,89 @@ + + + + + + Message Center + 消息发布与弹窗配置 + 查看消息列表、弹窗开关、业务跳转和发布状态。 + + + 发布消息 + + + 发布系统消息 + + + + 接收范围 + + + {{item.label}} + + + + 可选店铺:{{targetOptions.shops.length}} 个,输入对应 ID 发布 + 可选用户:{{targetOptions.users.length}} 个,输入对应 ID 发布 + + + 弹窗显示一次 + + + + 业务跳转 + + + {{item.label}} + + + + + + + + + + + + + + + + {{item.title}} + {{item.publisherName || '系统'}} · {{item.displayTime}} + + {{item.popupText}} + + {{item.content}} + + + 状态 + {{item.statusText}} + + + 目标 + {{item.targetTypeName || item.targetType || '--'}} + + + 业务类型 + {{item.businessText}} + + + 跳转 + {{item.actionText}} + + + + 撤回 + + + + + + 暂无系统消息 + 发布后的消息会显示弹窗配置和业务跳转信息。 + + + 加载中... + + diff --git a/YumiNail-Admin-Program/pages/system-messages/index.wxss b/YumiNail-Admin-Program/pages/system-messages/index.wxss new file mode 100644 index 00000000..652eb4ba --- /dev/null +++ b/YumiNail-Admin-Program/pages/system-messages/index.wxss @@ -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; +} diff --git a/YumiNail-Admin-Program/pages/tag-form/index.js b/YumiNail-Admin-Program/pages/tag-form/index.js index be33cb27..2b9eece5 100644 --- a/YumiNail-Admin-Program/pages/tag-form/index.js +++ b/YumiNail-Admin-Program/pages/tag-form/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/tags/index.js b/YumiNail-Admin-Program/pages/tags/index.js index bf702a89..2ba6b9ee 100644 --- a/YumiNail-Admin-Program/pages/tags/index.js +++ b/YumiNail-Admin-Program/pages/tags/index.js @@ -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' }) } diff --git a/YumiNail-Admin-Program/pages/user-detail/index.js b/YumiNail-Admin-Program/pages/user-detail/index.js index d809f579..840be0c5 100644 --- a/YumiNail-Admin-Program/pages/user-detail/index.js +++ b/YumiNail-Admin-Program/pages/user-detail/index.js @@ -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 }) diff --git a/YumiNail-Admin-Program/pages/user-form/index.js b/YumiNail-Admin-Program/pages/user-form/index.js index 276e6565..ea1acafc 100644 --- a/YumiNail-Admin-Program/pages/user-form/index.js +++ b/YumiNail-Admin-Program/pages/user-form/index.js @@ -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 : '' }) } diff --git a/YumiNail-Admin-Program/pages/users/index.js b/YumiNail-Admin-Program/pages/users/index.js index a198ba7f..5539b818 100644 --- a/YumiNail-Admin-Program/pages/users/index.js +++ b/YumiNail-Admin-Program/pages/users/index.js @@ -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) } diff --git a/YumiNail-Admin-Program/pages/workbench/index.js b/YumiNail-Admin-Program/pages/workbench/index.js index eb7512b8..8f286df0 100644 --- a/YumiNail-Admin-Program/pages/workbench/index.js +++ b/YumiNail-Admin-Program/pages/workbench/index.js @@ -1,24 +1,88 @@ +/** + * Purpose: dashboardApi supports index.js by holding or executing the dashboard 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 dashboardApi = require('../../api/dashboard') +/** + * 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: 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 { CACHE_TTL } = require('../../utils/config') 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: 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: permissionCount supports index.js by holding or executing the permission 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. + */ permissionCount: 0, + /** + * Purpose: shortcutModules supports index.js by holding or executing the shortcut 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. + */ shortcutModules: [], + /** + * Purpose: stats supports index.js by holding or executing the stats page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ stats: null, + /** + * Purpose: pendingOrders supports index.js by holding or executing the pending orders page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ pendingOrders: 0, + /** + * Purpose: shoplessAdmin supports index.js by holding or executing the shopless admin page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ shoplessAdmin: false, + /** + * 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 @@ -28,11 +92,19 @@ Page({ const dirty = consumeDirty('admin-workbench') if (!this.data.initialized || dirty) { this.loadDashboard({ + /** + * Purpose: force supports index.js by holding or executing the force page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ force: dirty }) } }, + /** + * Purpose: syncGlobalState supports index.js by holding or executing the sync global 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. + */ syncGlobalState() { const app = getApp() const userInfo = app.globalData.userInfo @@ -43,8 +115,20 @@ Page({ this.setData({ userInfo, currentShop, + /** + * Purpose: permissionCount supports index.js by holding or executing the permission 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. + */ permissionCount: permissionCodes.length, + /** + * Purpose: shortcutModules supports index.js by holding or executing the shortcut 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. + */ shortcutModules: modules.filter(item => item.allowed).slice(0, 4), + /** + * Purpose: shoplessAdmin supports index.js by holding or executing the shopless admin page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ shoplessAdmin: permission.isPlatformAdmin(userInfo) && !currentShop }) }, @@ -60,15 +144,35 @@ Page({ const pendingCacheKey = `workbench:pending:${currentShopId}` 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 }) if (this.data.shoplessAdmin) { if (requestId === this._loadRequestId) { this.setData({ + /** + * Purpose: stats supports index.js by holding or executing the stats page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ stats: null, + /** + * Purpose: pendingOrders supports index.js by holding or executing the pending orders page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ pendingOrders: 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: 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 }) } @@ -88,8 +192,20 @@ Page({ } this.setData({ stats, + /** + * Purpose: pendingOrders supports index.js by holding or executing the pending orders page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ pendingOrders: Number(stats && stats.todayOrders) || 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: 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 }) return @@ -103,30 +219,86 @@ Page({ } const result = force ? 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: 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: 1 }) : await cache.remember(pendingCacheKey, CACHE_TTL.workbench, () => 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: 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: 1 })) if (requestId !== this._loadRequestId) { return } this.setData({ + /** + * Purpose: stats supports index.js by holding or executing the stats page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ stats: null, + /** + * Purpose: pendingOrders supports index.js by holding or executing the pending orders page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ pendingOrders: Number(result && result.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: 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) { if (requestId === this._loadRequestId) { this.setData({ + /** + * Purpose: stats supports index.js by holding or executing the stats page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ stats: null, + /** + * Purpose: pendingOrders supports index.js by holding or executing the pending orders page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ pendingOrders: 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: 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 }) } @@ -136,14 +308,34 @@ Page({ if (requestId === this._loadRequestId) { this.setData({ + /** + * Purpose: stats supports index.js by holding or executing the stats page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ stats: null, + /** + * Purpose: pendingOrders supports index.js by holding or executing the pending orders page or API role. + * Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow. + */ pendingOrders: 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: 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 }) } }, + /** + * 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 path = event.currentTarget.dataset.path if (!path) { @@ -158,10 +350,18 @@ Page({ navigation.navigate(path).catch(() => undefined) }, + /** + * Purpose: handleOpenShops supports index.js by holding or executing the handle open 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. + */ handleOpenShops() { navigation.navigate('/pages/shops/index').catch(() => undefined) }, + /** + * 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) } diff --git a/YumiNail-Admin-Program/utils/action-guard.js b/YumiNail-Admin-Program/utils/action-guard.js index c4f11ce8..367b9c17 100644 --- a/YumiNail-Admin-Program/utils/action-guard.js +++ b/YumiNail-Admin-Program/utils/action-guard.js @@ -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) } diff --git a/YumiNail-Admin-Program/utils/auth.js b/YumiNail-Admin-Program/utils/auth.js index d73c6d96..8f86cd68 100644 --- a/YumiNail-Admin-Program/utils/auth.js +++ b/YumiNail-Admin-Program/utils/auth.js @@ -1,29 +1,57 @@ const { STORAGE_KEYS, getStorage, removeStorage, setStorage } = require('./storage') +/** + * 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() { return getStorage(STORAGE_KEYS.USER_INFO, null) } +/** + * Purpose: getStoredPermissions supports auth.js by holding or executing the get stored 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 getStoredPermissions() { return getStorage(STORAGE_KEYS.PERMISSIONS, []) } +/** + * Purpose: getCurrentShop supports auth.js by holding or executing the get 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 getCurrentShop() { return getStorage(STORAGE_KEYS.CURRENT_SHOP, null) } +/** + * 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 @@ -46,6 +74,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) @@ -55,14 +87,26 @@ function updateStoredUserInfo(userInfo) { setStorage(STORAGE_KEYS.USER_INFO, userInfo) } +/** + * Purpose: setPermissions supports auth.js by holding or executing the set 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 setPermissions(permissions) { setStorage(STORAGE_KEYS.PERMISSIONS, Array.isArray(permissions) ? permissions : []) } +/** + * Purpose: clearPermissions supports auth.js by holding or executing the clear 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 clearPermissions() { removeStorage(STORAGE_KEYS.PERMISSIONS) } +/** + * Purpose: setCurrentShop supports auth.js by holding or executing the set 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 setCurrentShop(shop) { if (!shop || !shop.id) { removeStorage(STORAGE_KEYS.CURRENT_SHOP) @@ -75,6 +119,10 @@ function setCurrentShop(shop) { }) } +/** + * 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) diff --git a/YumiNail-Admin-Program/utils/cache.js b/YumiNail-Admin-Program/utils/cache.js index 379a6dbc..cdd451af 100644 --- a/YumiNail-Admin-Program/utils/cache.js +++ b/YumiNail-Admin-Program/utils/cache.js @@ -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 = 'adminMiniCache:' +/** + * 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: 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: 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: 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 @@ -33,6 +57,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 @@ -48,6 +76,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 @@ -58,6 +90,10 @@ function removeCache(key) { } catch (error) {} } +/** + * 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) { diff --git a/YumiNail-Admin-Program/utils/config.js b/YumiNail-Admin-Program/utils/config.js index e50e43ad..663da997 100644 --- a/YumiNail-Admin-Program/utils/config.js +++ b/YumiNail-Admin-Program/utils/config.js @@ -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' @@ -24,6 +32,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' @@ -39,11 +51,19 @@ 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() 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}`) @@ -54,11 +74,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', @@ -67,13 +107,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']) diff --git a/YumiNail-Admin-Program/utils/crypto.js b/YumiNail-Admin-Program/utils/crypto.js index ce4e850a..33e0970d 100644 --- a/YumiNail-Admin-Program/utils/crypto.js +++ b/YumiNail-Admin-Program/utils/crypto.js @@ -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)}` } diff --git a/YumiNail-Admin-Program/utils/device.js b/YumiNail-Admin-Program/utils/device.js index 45cfad05..9a634dd2 100644 --- a/YumiNail-Admin-Program/utils/device.js +++ b/YumiNail-Admin-Program/utils/device.js @@ -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 `admin-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) { diff --git a/YumiNail-Admin-Program/utils/form-draft.js b/YumiNail-Admin-Program/utils/form-draft.js index f2544502..f56168cb 100644 --- a/YumiNail-Admin-Program/utils/form-draft.js +++ b/YumiNail-Admin-Program/utils/form-draft.js @@ -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 = 'adminMiniDraft:' +/** + * 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: 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) { if (!key) { return defaultValue @@ -19,6 +31,10 @@ function getDraftValue(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 @@ -31,6 +47,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 @@ -40,6 +60,10 @@ function clearDraft(key) { } catch (error) {} } +/** + * 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 @@ -52,6 +76,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) diff --git a/YumiNail-Admin-Program/utils/format.js b/YumiNail-Admin-Program/utils/format.js index 802e2227..e0c7f7c1 100644 --- a/YumiNail-Admin-Program/utils/format.js +++ b/YumiNail-Admin-Program/utils/format.js @@ -1,11 +1,23 @@ +/** + * Purpose: toIdString supports format.js by holding or executing the to id string page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function toIdString(value) { return value === undefined || value === null ? '' : String(value) } +/** + * 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 toIdString(left) === toIdString(right) } +/** + * 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: 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: 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 '' @@ -25,10 +45,18 @@ function formatDateTime(value) { return String(value).replace('T', ' ').slice(0, 16) } +/** + * Purpose: formatDate supports format.js by holding or executing the format date page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function formatDate(value) { return formatDateTime(value).slice(0, 10) } +/** + * Purpose: maskPhone supports format.js by holding or executing the mask phone page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function maskPhone(phone) { const value = String(phone || '') if (value.length !== 11) { @@ -37,6 +65,10 @@ function maskPhone(phone) { return `${value.slice(0, 3)}****${value.slice(7)}` } +/** + * Purpose: truncateText supports format.js by holding or executing the truncate 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 truncateText(value, limit) { const text = String(value || '') if (!limit || text.length <= limit) { @@ -45,6 +77,10 @@ function truncateText(value, limit) { return `${text.slice(0, limit)}...` } +/** + * Purpose: buildShopName supports format.js by holding or executing the build shop name page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function buildShopName(record) { if (!record) { return '未绑定店铺' @@ -61,10 +97,18 @@ function buildShopName(record) { return '未绑定店铺' } +/** + * Purpose: getUserStatusText supports format.js by holding or executing the get user 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 getUserStatusText(status) { return Number(status) === 0 ? '已停用' : '正常' } +/** + * Purpose: getUserTypeText supports format.js by holding or executing the get user type 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 getUserTypeText(type) { const value = Number(type) if (value === 4) { @@ -79,6 +123,10 @@ function getUserTypeText(type) { return '普通用户' } +/** + * 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 @@ -94,10 +142,18 @@ function getOrderStatusText(order) { return '已取消' } +/** + * Purpose: getCouponTypeText supports format.js by holding or executing the get coupon type 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 getCouponTypeText(type) { return Number(type) === 1 ? '折扣券' : '满减券' } +/** + * Purpose: getCouponValueText supports format.js by holding or executing the get coupon value 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 getCouponValueText(coupon) { if (Number(coupon && coupon.couponType) === 1) { return `${coupon && coupon.discountValue ? coupon.discountValue : '--'} 折` @@ -105,6 +161,10 @@ function getCouponValueText(coupon) { return `满 ${formatPrice(coupon && coupon.minAmount)} 减 ${formatPrice(coupon && coupon.reduceAmount)}` } +/** + * Purpose: parseDateTimeToPicker supports format.js by holding or executing the parse date time to picker page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function parseDateTimeToPicker(value) { const text = formatDateTime(value) if (!text) { @@ -121,6 +181,10 @@ function parseDateTimeToPicker(value) { } } +/** + * Purpose: buildDateTime supports format.js by holding or executing the build 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 buildDateTime(date, time) { if (!date || !time) { return '' diff --git a/YumiNail-Admin-Program/utils/idle-session.js b/YumiNail-Admin-Program/utils/idle-session.js index 793b5d8a..a5adc4bf 100644 --- a/YumiNail-Admin-Program/utils/idle-session.js +++ b/YumiNail-Admin-Program/utils/idle-session.js @@ -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() diff --git a/YumiNail-Admin-Program/utils/loading.js b/YumiNail-Admin-Program/utils/loading.js index 441097ce..4161864a 100644 --- a/YumiNail-Admin-Program/utils/loading.js +++ b/YumiNail-Admin-Program/utils/loading.js @@ -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) diff --git a/YumiNail-Admin-Program/utils/navigation.js b/YumiNail-Admin-Program/utils/navigation.js index a5829c06..50bf8095 100644 --- a/YumiNail-Admin-Program/utils/navigation.js +++ b/YumiNail-Admin-Program/utils/navigation.js @@ -1,6 +1,14 @@ +/** + * 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: 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] !== '') @@ -10,6 +18,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] @@ -20,11 +32,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({ @@ -35,6 +55,10 @@ function navigate(path, params) { }) } +/** + * Purpose: redirect supports navigation.js by holding or executing the redirect page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function redirect(path, params) { return new Promise((resolve, reject) => { wx.redirectTo({ @@ -45,6 +69,10 @@ function redirect(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({ @@ -55,6 +83,10 @@ function switchTab(path) { }) } +/** + * 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) { @@ -71,6 +103,10 @@ function goBack(fallbackPath) { wx.redirectTo({ url: target }) } +/** + * 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 || '') @@ -89,6 +125,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(redirectValue) { const target = redirectValue ? decodeRedirectValue(redirectValue) : '' if (!target) { @@ -109,12 +149,20 @@ function redirectAfterLogin(redirectValue) { }) } +/** + * Purpose: openLogin supports navigation.js by holding or executing the open 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 openLogin(redirectPath) { return navigate('/pages/login/index', { redirect: redirectPath || getCurrentPageUrl() }) } +/** + * 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 diff --git a/YumiNail-Admin-Program/utils/page-state.js b/YumiNail-Admin-Program/utils/page-state.js index a1e9a7ad..92eb45f6 100644 --- a/YumiNail-Admin-Program/utils/page-state.js +++ b/YumiNail-Admin-Program/utils/page-state.js @@ -1,9 +1,17 @@ +/** + * Purpose: ensureStore supports page-state.js by holding or executing the ensure store page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function ensureStore() { const app = getApp() app.globalData.pageDirtyFlags = app.globalData.pageDirtyFlags || {} return app.globalData.pageDirtyFlags } +/** + * Purpose: markDirty supports page-state.js by holding or executing the mark dirty page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function markDirty(key) { if (!key) { return @@ -12,6 +20,10 @@ function markDirty(key) { store[key] = true } +/** + * Purpose: consumeDirty supports page-state.js by holding or executing the consume dirty page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function consumeDirty(key) { if (!key) { return false diff --git a/YumiNail-Admin-Program/utils/permission.js b/YumiNail-Admin-Program/utils/permission.js index 88cbfa47..a686ea7f 100644 --- a/YumiNail-Admin-Program/utils/permission.js +++ b/YumiNail-Admin-Program/utils/permission.js @@ -1,3 +1,7 @@ +/** + * Purpose: MANAGE_MODULES supports permission.js by holding or executing the manage modules page or API role. + * Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow. + */ const MANAGE_MODULES = [ { key: 'users', @@ -62,9 +66,29 @@ const MANAGE_MODULES = [ path: '/pages/permissions/index', permissionCodes: ['permission:view'], requiresShopContext: false + }, + { + key: 'systemMessages', + title: '系统消息', + description: '发布消息、查看弹窗配置和业务跳转信息', + path: '/pages/system-messages/index', + permissionCodes: ['message:view'], + requiresShopContext: false + }, + { + key: 'securityAudit', + title: '审计日志', + description: '查看高危操作的成功、失败原因与操作者', + path: '/pages/security-audit/index', + permissionCodes: ['security:audit:view'], + requiresShopContext: false } ] +/** + * Purpose: getPermissionCodes supports permission.js by holding or executing the get permission codes page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function getPermissionCodes(source) { const list = Array.isArray(source) ? source : [] @@ -78,6 +102,10 @@ function getPermissionCodes(source) { .filter(Boolean) } +/** + * Purpose: hasPermission supports permission.js by holding or executing the has permission page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function hasPermission(source, permissionCode) { if (!permissionCode) { return true @@ -87,6 +115,10 @@ function hasPermission(source, permissionCode) { return codes.includes(permissionCode) } +/** + * Purpose: hasAnyPermission supports permission.js by holding or executing the has any permission page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function hasAnyPermission(source, permissionCodes) { const codes = Array.isArray(permissionCodes) ? permissionCodes : [] if (!codes.length) { @@ -96,6 +128,10 @@ function hasAnyPermission(source, permissionCodes) { return codes.some(code => hasPermission(source, code)) } +/** + * Purpose: hasAllPermissions supports permission.js by holding or executing the has all 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 hasAllPermissions(source, permissionCodes) { const codes = Array.isArray(permissionCodes) ? permissionCodes : [] if (!codes.length) { @@ -105,18 +141,34 @@ function hasAllPermissions(source, permissionCodes) { return codes.every(code => hasPermission(source, code)) } +/** + * Purpose: isPlatformAdmin supports permission.js by holding or executing the is platform admin page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function isPlatformAdmin(userInfo) { return Number(userInfo && userInfo.type) === 4 } +/** + * Purpose: isShopManager supports permission.js by holding or executing the is shop manager page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function isShopManager(userInfo) { return Number(userInfo && userInfo.type) === 2 } +/** + * Purpose: isNailArtist supports permission.js by holding or executing the is nail 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 isNailArtist(userInfo) { return Number(userInfo && userInfo.type) === 3 } +/** + * Purpose: getRoleLabel supports permission.js by holding or executing the get role label page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function getRoleLabel(type) { const value = Number(type) if (value === 4) { @@ -131,6 +183,10 @@ function getRoleLabel(type) { return '用户' } +/** + * Purpose: groupPermissionsByGroup supports permission.js by holding or executing the group permissions by group page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function groupPermissionsByGroup(permissions) { return (Array.isArray(permissions) ? permissions : []).reduce((result, item) => { const group = item && item.permissionGroup ? item.permissionGroup : '未分组' @@ -142,6 +198,10 @@ function groupPermissionsByGroup(permissions) { }, {}) } +/** + * Purpose: checkModuleAccess supports permission.js by holding or executing the check module access page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function checkModuleAccess(module, userInfo, permissionCodes, currentShop) { if (!hasAnyPermission(permissionCodes, module.permissionCodes)) { return { @@ -171,6 +231,10 @@ function checkModuleAccess(module, userInfo, permissionCodes, currentShop) { } } +/** + * Purpose: getManageModules supports permission.js by holding or executing the get manage modules page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function getManageModules(userInfo, permissionCodes, currentShop) { return MANAGE_MODULES.map(module => { const access = checkModuleAccess(module, userInfo, permissionCodes, currentShop) diff --git a/YumiNail-Admin-Program/utils/request.js b/YumiNail-Admin-Program/utils/request.js index 0bdf9b26..d195500b 100644 --- a/YumiNail-Admin-Program/utils/request.js +++ b/YumiNail-Admin-Program/utils/request.js @@ -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 { ADMIN_API_BASE_URL, REQUEST_TIMEOUT, ENABLE_REQUEST_SIGNING } = require('./config') const { getDeviceId } = require('./device') const { sha256Hex, hmacSha256Hex, buildCanonicalParams, buildJsonPayload, randomNonce } = require('./crypto') +/** + * 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: 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: 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: redirectingToLogin supports request.js by holding or executing the redirecting to login 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 redirectingToLogin = 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: extractPath supports request.js by holding or executing the extract 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 extractPath(value) { const target = String(value || '') if (!target) { @@ -39,6 +95,10 @@ function extractPath(value) { return target.split('?')[0] || '' } +/** + * Purpose: toBackendRequestPath supports request.js by holding or executing the to backend request 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 toBackendRequestPath(url) { const path = extractPath(url).replace(/\/+$/, '') || '/' if (path === '/admin/api') { @@ -59,6 +119,10 @@ function toBackendRequestPath(url) { return path.startsWith('/') ? `/admin${path}` : `/admin/${path}` } +/** + * Purpose: isAuthFreePath supports request.js by holding or executing the is auth free 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 isAuthFreePath(url) { return [ '/auth/login', @@ -67,6 +131,10 @@ function isAuthFreePath(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 @@ -74,6 +142,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) => { @@ -85,6 +157,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({ @@ -95,6 +171,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 = [] @@ -108,6 +188,10 @@ function flushQueue(error) { }) } +/** + * Purpose: redirectToLogin supports request.js by holding or executing the redirect to 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 redirectToLogin() { if (redirectingToLogin) { return @@ -143,6 +227,10 @@ function redirectToLogin() { }, 240) } +/** + * 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() @@ -180,6 +268,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) { @@ -215,6 +307,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 (options._retry || isAuthFreePath(options.url)) { const app = getApp() @@ -257,6 +353,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(response, options) { idleSession.markActive() @@ -291,6 +391,10 @@ async function unwrapResponse(response, 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 '' @@ -304,10 +408,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) @@ -318,6 +430,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 (path.includes('/auth/login')) { @@ -353,6 +469,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 @@ -365,6 +485,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) diff --git a/YumiNail-Admin-Program/utils/storage.js b/YumiNail-Admin-Program/utils/storage.js index 6df795d8..2127b6eb 100644 --- a/YumiNail-Admin-Program/utils/storage.js +++ b/YumiNail-Admin-Program/utils/storage.js @@ -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: 'adminAccessToken', REFRESH_TOKEN: 'adminRefreshToken', @@ -7,8 +11,16 @@ const STORAGE_KEYS = { DEVICE_ID: 'adminMiniDeviceId' } +/** + * Purpose: TEMP_RECORD_PREFIX supports storage.js by holding or executing the temp record 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 TEMP_RECORD_PREFIX = 'adminTempRecord:' +/** + * 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) @@ -18,22 +30,42 @@ 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) } +/** + * Purpose: setTempRecord supports storage.js by holding or executing the set temp 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 setTempRecord(name, value) { setStorage(`${TEMP_RECORD_PREFIX}${name}`, value) } +/** + * Purpose: getTempRecord supports storage.js by holding or executing the get temp 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 getTempRecord(name, defaultValue) { return getStorage(`${TEMP_RECORD_PREFIX}${name}`, defaultValue) } +/** + * Purpose: clearTempRecord supports storage.js by holding or executing the clear temp 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 clearTempRecord(name) { removeStorage(`${TEMP_RECORD_PREFIX}${name}`) } diff --git a/YumiNail-Admin-Program/utils/upload.js b/YumiNail-Admin-Program/utils/upload.js index 12c7023a..f32466d3 100644 --- a/YumiNail-Admin-Program/utils/upload.js +++ b/YumiNail-Admin-Program/utils/upload.js @@ -1,9 +1,21 @@ +/** + * Purpose: fileApi supports upload.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') +/** + * Purpose: getFileSystemManager supports upload.js by holding or executing the get file system manager page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function getFileSystemManager() { return wx.getFileSystemManager() } +/** + * Purpose: getFileInfo supports upload.js by holding or executing the get file 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 getFileInfo(filePath) { return new Promise((resolve, reject) => { wx.getFileInfo({ @@ -14,6 +26,10 @@ function getFileInfo(filePath) { }) } +/** + * Purpose: readFileBuffer supports upload.js by holding or executing the read file buffer page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function readFileBuffer(filePath) { return new Promise((resolve, reject) => { getFileSystemManager().readFile({ @@ -24,6 +40,10 @@ function readFileBuffer(filePath) { }) } +/** + * Purpose: writeChunkFile supports upload.js by holding or executing the write chunk file page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function writeChunkFile(filePath, data) { return new Promise((resolve, reject) => { getFileSystemManager().writeFile({ @@ -36,6 +56,10 @@ function writeChunkFile(filePath, data) { }) } +/** + * Purpose: removeFile supports upload.js by holding or executing the remove file page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function removeFile(filePath) { return new Promise(resolve => { getFileSystemManager().unlink({ @@ -46,6 +70,10 @@ function removeFile(filePath) { }) } +/** + * Purpose: normalizeSelectedFiles supports upload.js by holding or executing the normalize selected files page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function normalizeSelectedFiles(files) { return (Array.isArray(files) ? files : []).map((item, index) => { if (typeof item === 'string') { @@ -62,6 +90,10 @@ function normalizeSelectedFiles(files) { }).filter(item => item.tempFilePath) } +/** + * Purpose: createFingerprint supports upload.js by holding or executing the create 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 createFingerprint(seed) { let hash = 0 const text = String(seed || '') @@ -74,6 +106,10 @@ function createFingerprint(seed) { return `mini-${Math.abs(hash)}` } +/** + * Purpose: resolveContentType supports upload.js by holding or executing the resolve content type page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function resolveContentType(fileName) { const value = String(fileName || '').toLowerCase() if (value.endsWith('.png')) { @@ -88,6 +124,10 @@ function resolveContentType(fileName) { return 'image/jpeg' } +/** + * Purpose: uploadSingleFile supports upload.js by holding or executing the upload single file page 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 uploadSingleFile(file, scene, onProgress) { const fileInfo = await getFileInfo(file.tempFilePath) const buffer = await readFileBuffer(file.tempFilePath) @@ -155,6 +195,10 @@ async function uploadSingleFile(file, scene, onProgress) { return result } +/** + * Purpose: uploadImageFiles supports upload.js by holding or executing the upload image files page 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 uploadImageFiles(options) { const files = normalizeSelectedFiles(options && options.files) const scene = options && options.scene ? options.scene : 'admin-product-image' @@ -176,6 +220,10 @@ async function uploadImageFiles(options) { return results } +/** + * Purpose: chooseImageFiles supports upload.js by holding or executing the choose image files page or API role. + * Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow. + */ function chooseImageFiles(options) { const config = options || {}