重构项目文件夹目录

This commit is contained in:
2026-06-15 15:53:55 +08:00
parent 8093e07190
commit 7cbe5b3de5
1098 changed files with 34 additions and 4441 deletions
+18
View File
@@ -0,0 +1,18 @@
const request = require('../utils/request')
module.exports = {
applyAfterSale(data) {
return request({
url: '/after-sale/apply',
method: 'POST',
data
})
},
getMyAfterSales(params) {
return request({
url: '/after-sale/my',
params
})
}
}
+137
View File
@@ -0,0 +1,137 @@
/**
* Mini program API wrapper for this module.
* 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')
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',
method: 'POST',
data
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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',
method: 'POST'
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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',
method: 'GET'
})
}
}
+63
View File
@@ -0,0 +1,63 @@
/**
* Mini program API wrapper for this module.
* 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')
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',
method: 'POST',
data
})
},
/**
* 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}`,
method: 'DELETE'
})
},
/**
* 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',
method: 'PUT',
data
})
},
/**
* 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',
method: 'DELETE'
})
}
}
+40
View File
@@ -0,0 +1,40 @@
/**
* Mini program API wrapper for this module.
* 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')
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',
method: 'POST',
data
})
},
/**
* 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}`,
method: 'DELETE'
})
}
}
+35
View File
@@ -0,0 +1,35 @@
/**
* Mini program API wrapper for this module.
* 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')
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',
params: {
status
}
})
},
/**
* 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',
params: {
productTags,
productPrice,
shopId
}
})
}
}
+20
View File
@@ -0,0 +1,20 @@
/**
* Mini program API wrapper for this module.
* 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')
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}`,
params: {
expiryTimeInMinutes
}
})
}
}
+9
View File
@@ -0,0 +1,9 @@
const request = require('../utils/request')
module.exports = {
getGrowthSummary() {
return request({
url: '/growth/summary'
})
}
}
+24
View File
@@ -0,0 +1,24 @@
/**
* Mini program API wrapper for public nail artist pages.
*/
const request = require('../utils/request')
module.exports = {
getPublicProfile(artistId) {
return request({
url: `/nail-artist/profile/${artistId}`
})
},
getAvailability(artistId) {
return request({
url: `/nail-artist/${artistId}/availability`
})
},
listReviews(artistId) {
return request({
url: `/nail-artist/${artistId}/reviews`
})
}
}
+186
View File
@@ -0,0 +1,186 @@
/**
* Mini program API wrapper for this module.
* 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')
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',
method: 'POST',
data
})
},
checkoutPreview(data) {
return request({
url: '/order/checkout-preview',
method: 'POST',
data
})
},
/**
* 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'
})
},
getOrderDetail(orderId) {
return request({
url: `/order/detail/${orderId}`
})
},
/**
* 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: listOrderArtistChangeRequests loads every change request attached to one order for timeline display.
* Usage: call it from the order page after loading the order list; callers may fall back to an empty list.
*/
listOrderArtistChangeRequests(orderId) {
return request({
url: `/order/${orderId}/artist-change/requests`
})
},
/**
* 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`,
method: 'POST',
data
})
},
/**
* 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`,
params: {
orderItemId
}
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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`,
method: 'PUT',
data: {}
})
},
/**
* 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`,
method: 'PUT',
data: data || {}
})
},
/**
* 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}`,
method: 'PUT'
})
},
getArtistOrders() {
return request({
url: '/order/artist/list'
})
},
completeArtistOrder(orderId) {
return request({
url: `/order/artist/complete/${orderId}`,
method: 'PUT'
})
},
getArtistCalendarRecent(days) {
return request({
url: '/order/artist/calendar/recent',
params: {
days: days || 7
}
})
},
getArtistCalendarDay(date) {
return request({
url: '/order/artist/calendar/day',
params: {
date
}
})
}
}
+19
View File
@@ -0,0 +1,19 @@
const request = require('../utils/request')
module.exports = {
prepareOrderPayment(orderId) {
return request({
url: `/payment/order/${orderId}/prepare`,
method: 'POST',
data: {}
})
},
mockOrderPaymentSuccess(orderId) {
return request({
url: `/payment/order/${orderId}/mock-success`,
method: 'POST',
data: {}
})
}
}
+39
View File
@@ -0,0 +1,39 @@
/**
* Mini program API wrapper for this module.
* 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')
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}`,
method: 'POST'
})
},
/**
* 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}`,
method: 'POST'
})
},
/**
* 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}`
})
}
}
+61
View File
@@ -0,0 +1,61 @@
/**
* Mini program API wrapper for this module.
* 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')
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',
params
})
},
/**
* 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',
params: {
keyword
}
})
}
}
+47
View File
@@ -0,0 +1,47 @@
/**
* Mini program API wrapper for this module.
* 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')
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}`
})
},
/**
* Purpose: getTrustProfile loads public trust signals for the shop detail page.
* Usage: render ratings, recent reviews, environment images, and booking hints.
*/
getTrustProfile(id) {
return request({
url: `/shop/trust-profile/${id}`
})
}
}
+28
View File
@@ -0,0 +1,28 @@
/**
* Mini program API wrapper for this module.
* 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')
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'
})
},
/**
* Purpose: getFilterOptions loads grouped public tag filters for scene-based browsing.
* Usage: call it from product list pages, then pass selected tag ids to getProductPage.
*/
getFilterOptions(shopId) {
return request({
url: '/tag/list/filter-options',
params: shopId ? { shopId } : undefined
})
}
}
+338
View File
@@ -0,0 +1,338 @@
/**
* Mini program API wrapper for this module.
* 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('头像上传失败')
}
if (response.statusCode === 401) {
throw new Error('登录已过期,请重新登录')
}
if (response.statusCode >= 400) {
throw new Error('头像上传失败')
}
let payload = response.data
if (typeof payload === 'string') {
try {
payload = JSON.parse(payload)
} catch (error) {}
}
if (payload && typeof payload === 'object' && Object.prototype.hasOwnProperty.call(payload, 'code')) {
if (payload.code === 200) {
return payload.data
}
throw new Error(payload.message || '头像上传失败')
}
return payload
}
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'
})
},
// 我的页常用数据:
// 资产、余额流水、消息、公告、VIP 充值档位和所属关系都从这里拿。
getMyAsset() {
return request({
url: '/user/asset/me'
})
},
/**
* 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`,
method: 'PUT',
data: {}
})
},
/**
* 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`,
method: 'PUT',
data: {}
})
},
/**
* 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'
})
},
// 这里只是“展示型充值档位”,不发起支付、不改余额。
listMyVipRechargePlans() {
return request({
url: '/vip-recharge-plan/my/list'
})
},
/**
* 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`,
params: artistId ? { artistId } : {}
})
},
getPlatformContact() {
return request({
url: '/contact-info/platform'
})
},
/**
* 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',
method: 'PUT',
data
})
},
/**
* 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',
method: 'PUT',
data
})
},
/**
* 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',
method: 'POST',
data
})
},
/**
* 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',
method: 'PUT',
data
})
},
/**
* 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',
method: 'DELETE'
})
},
/**
* 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',
method: 'POST',
formData: {}
})
return actionGuard.run(null, `POST:/user/upload-avatar:${filePath || ''}`, () => new Promise((resolve, reject) => {
wx.uploadFile({
url: `${API_BASE_URL}/user/upload-avatar`,
filePath,
name: 'file',
timeout: REQUEST_TIMEOUT,
header: signedHeaders,
success: response => {
try {
resolve(normalizeUploadResponse(response))
} catch (error) {
reject(error)
}
},
fail: error => {
reject(new Error(error.errMsg || '头像上传失败'))
}
})
}), {
message: '上传处理中,请勿重复操作'
})
},
/**
* 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',
method: 'POST',
data
})
}
}
+50
View File
@@ -0,0 +1,50 @@
const assert = require('assert')
const Module = require('module')
const calls = []
const originalLoad = Module._load
Module._load = function mockRequestModule(request, parent, isMain) {
if (request === '../utils/request') {
return options => {
calls.push(options)
return Promise.resolve(options)
}
}
return originalLoad.apply(this, arguments)
}
const paymentApi = require('./payment')
const afterSaleApi = require('./after-sale')
const growthApi = require('./growth')
paymentApi.prepareOrderPayment(12)
paymentApi.mockOrderPaymentSuccess(12)
afterSaleApi.applyAfterSale({ orderId: 12, reason: 'need refund' })
afterSaleApi.getMyAfterSales({ page: 2, size: 5 })
growthApi.getGrowthSummary()
Module._load = originalLoad
assert.deepStrictEqual(calls[0], {
url: '/payment/order/12/prepare',
method: 'POST',
data: {}
})
assert.deepStrictEqual(calls[1], {
url: '/payment/order/12/mock-success',
method: 'POST',
data: {}
})
assert.deepStrictEqual(calls[2], {
url: '/after-sale/apply',
method: 'POST',
data: { orderId: 12, reason: 'need refund' }
})
assert.deepStrictEqual(calls[3], {
url: '/after-sale/my',
params: { page: 2, size: 5 }
})
assert.deepStrictEqual(calls[4], {
url: '/growth/summary'
})
+86
View File
@@ -0,0 +1,86 @@
/**
* Mini program API wrapper for this module.
* 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')
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',
method: 'POST',
data: {
productId
}
})
},
/**
* 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',
method: 'POST',
data: {
productId
}
})
},
/**
* 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',
params: {
productId
}
})
},
/**
* 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'
})
},
getGroups() {
return request({
url: '/wishlist/groups'
})
},
getInspiration() {
return request({
url: '/wishlist/inspiration'
})
},
addWithGroup(data) {
return request({
url: '/wishlist/add-with-group',
method: 'POST',
data
})
},
moveWishlist(data) {
return request({
url: '/wishlist/move',
method: 'POST',
data
})
}
}