完成JC-ArtList与JC-Salon端侧清理和统一命名

This commit is contained in:
2026-08-25 16:21:05 +08:00
parent aa93695704
commit abce4a2787
1839 changed files with 653 additions and 50415 deletions
+31
View File
@@ -0,0 +1,31 @@
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}
+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
})
}
}
+467
View File
@@ -0,0 +1,467 @@
/**
* 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')
App({
globalData: {
userInfo: null,
isLoggedIn: false,
cartCount: 0,
currentShop: null,
permissions: [],
permissionCodes: [],
pageDirtyFlags: {},
activeSessionMode: '',
shopTheme: theme.DEFAULT_SHOP_THEME,
pendingProductFilter: null,
pendingWechatMiniLogin: null,
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,
warningMs: IDLE_WARNING_MS,
isLoggedIn: () => auth.isLoggedIn(),
onLogout: () => this.handleIdleLogout()
})
this.bootstrapSession()
if (!auth.isLoggedIn()) {
this.tryWechatMiniAutoLogin()
}
},
/**
* 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()
this.globalData.userInfo = userInfo
this.globalData.isLoggedIn = isLoggedIn
this.globalData.activeSessionMode = isLoggedIn ? 'customer' : this.globalData.activeSessionMode
this.refreshShopTheme(userInfo)
if (userInfo && userInfo.shopId) {
auth.setPreferredMiniLoginShopId(userInfo.shopId)
}
if (isLoggedIn) {
this.refreshSessionUserInfo()
this.updateCartBadge()
return
}
this.clearCartBadge()
},
async tryWechatMiniAutoLogin() {
if (auth.isLoggedIn()) {
return true
}
if (this._wechatMiniAutoLoginPromise) {
return this._wechatMiniAutoLoginPromise
}
if (typeof wx === 'undefined' || typeof wx.login !== 'function') {
return false
}
this.globalData.wechatMiniAutoLoginState = 'pending'
this._wechatMiniAutoLoginPromise = this.requestWechatMiniCode()
.then(code => authApi.wechatMiniAutoLogin({
wxCode: code,
preferredShopId: auth.getPreferredMiniLoginShopId() || undefined
}))
.then(result => this.handleWechatMiniLoginResult(result, { silent: true }))
.catch(() => false)
.finally(() => {
this._wechatMiniAutoLoginPromise = null
if (this.globalData.wechatMiniAutoLoginState === 'pending') {
this.globalData.wechatMiniAutoLoginState = 'idle'
}
})
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 : ''
if (status === 'SUCCESS') {
this.setUserSession(result)
this.clearPendingWechatMiniLogin()
this.globalData.wechatMiniAutoLoginState = 'idle'
return true
}
if (status === 'SELECT_SHOP') {
this.setPendingWechatMiniLogin(result)
this.globalData.wechatMiniAutoLoginState = 'idle'
if (!config.silent && result.message) {
wx.showToast({
title: result.message,
icon: 'none'
})
}
return false
}
this.clearPendingWechatMiniLogin()
this.globalData.wechatMiniAutoLoginState = 'idle'
if (!config.silent && result && result.message) {
wx.showToast({
title: result.message,
icon: 'none'
})
}
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({
success: res => {
if (res && res.code) {
resolve(res.code)
return
}
reject(new Error('获取微信登录凭证失败'))
},
fail: reject
})
})
},
/**
* 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()
this.globalData.isLoggedIn = auth.isLoggedIn()
this.globalData.activeSessionMode = 'customer'
this.refreshShopTheme(this.globalData.userInfo)
if (this.globalData.userInfo && this.globalData.userInfo.shopId) {
auth.setPreferredMiniLoginShopId(this.globalData.userInfo.shopId)
}
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
this.globalData.isLoggedIn = auth.isLoggedIn()
this.globalData.activeSessionMode = auth.isLoggedIn() ? 'customer' : ''
this.refreshShopTheme(userInfo)
if (userInfo && userInfo.shopId) {
auth.setPreferredMiniLoginShopId(userInfo.shopId)
}
},
/**
* 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()
if (this.globalData.activeSessionMode === 'customer') {
this.globalData.userInfo = null
this.globalData.isLoggedIn = false
this.globalData.activeSessionMode = ''
}
this.setShopTheme(null)
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
this.syncThemeToCurrentPages()
if (resolvedTheme.backgroundImageFileId) {
this.resolveShopThemeBackground(shop, resolvedTheme.backgroundImageFileId)
}
},
async resolveShopThemeBackground(shop, fileId) {
try {
const backgroundImageUrl = await file.getSignedUrl(fileId)
if (
!backgroundImageUrl
|| !this.globalData.shopTheme
|| this.globalData.shopTheme.backgroundImageFileId !== String(fileId)
) {
return
}
this.globalData.shopTheme = theme.resolveShopTheme({
...(shop || {}),
themeBackgroundImageUrl: backgroundImageUrl
})
this.syncThemeToCurrentPages()
} catch (error) {}
},
async refreshShopTheme(userInfo) {
if (!userInfo || !userInfo.shopId) {
this.setShopTheme(null)
return
}
try {
const shop = await shopApi.getShopById(userInfo.shopId)
if (this.globalData.userInfo && String(this.globalData.userInfo.shopId) === String(userInfo.shopId)) {
this.setShopTheme(shop)
}
} catch (error) {
this.setShopTheme(null)
}
},
/**
* 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)
pages.forEach(page => {
if (page && typeof page.setData === 'function') {
page.setData(data)
}
})
},
async refreshSessionUserInfo() {
if (!auth.isLoggedIn()) {
return
}
try {
const userInfo = await userApi.getUserInfo()
this.refreshUserInfo(userInfo)
} catch (error) {}
},
async handleIdleLogout() {
if (!auth.isLoggedIn()) {
return
}
try {
await authApi.logout()
} catch (error) {}
this.clearUserSession()
wx.showToast({
title: '长时间未操作,已退出登录',
icon: 'none'
})
setTimeout(() => {
wx.reLaunch({
url: '/pages/auth/index'
})
}, 260)
},
async updateCartBadge() {
if (!auth.isLoggedIn()) {
this.clearCartBadge()
return 0
}
try {
const cartList = await cartApi.getCartList()
const count = Array.isArray(cartList)
? cartList.reduce((sum, item) => sum + Number(item.quantity || 0), 0)
: 0
this.globalData.cartCount = count
if (count > 0) {
wx.setTabBarBadge({
index: 2,
text: count > 99 ? '99+' : String(count)
})
} else {
wx.removeTabBarBadge({ index: 2 })
}
return count
} catch (error) {
this.clearCartBadge()
return 0
}
},
/**
* 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({
index: 2,
fail() {}
})
}
})
+81
View File
@@ -0,0 +1,81 @@
{
"pages": [
"pages/index/index",
"pages/home/index",
"pages/products/index",
"pages/cart/index",
"pages/profile/index",
"pages/auth/index",
"pages/product-detail/index",
"pages/artist-profile/index",
"pages/shop-detail/index",
"pages/orders/index",
"pages/order-detail/index",
"pages/after-sales/index",
"pages/after-sale-apply/index",
"pages/service-progress/index",
"pages/help/index",
"pages/artist-orders/index",
"pages/artist-calendar/index",
"pages/account-settings/index",
"pages/password-settings/index",
"pages/wishlist/index",
"pages/coupons/index",
"pages/vip-center/index",
"pages/notifications/index",
"pages/settings/index"
],
"window": {
"navigationBarTextStyle": "black",
"navigationStyle": "custom",
"backgroundTextStyle": "light",
"backgroundColor": "#fff8f4"
},
"tabBar": {
"color": "#504444",
"selectedColor": "#7c5357",
"backgroundColor": "#fff8f4",
"borderStyle": "black",
"position": "bottom",
"list": [
{
"pagePath": "pages/home/index",
"text": "\u9996\u9875",
"iconPath": "assets/tabbar/home.png",
"selectedIconPath": "assets/tabbar/home-active.png"
},
{
"pagePath": "pages/products/index",
"text": "\u4f5c\u54c1",
"iconPath": "assets/tabbar/works.png",
"selectedIconPath": "assets/tabbar/works-active.png"
},
{
"pagePath": "pages/cart/index",
"text": "\u8d2d\u7269\u8f66",
"iconPath": "assets/tabbar/cart.png",
"selectedIconPath": "assets/tabbar/cart-active.png"
},
{
"pagePath": "pages/profile/index",
"text": "\u6211\u7684",
"iconPath": "assets/tabbar/profile.png",
"selectedIconPath": "assets/tabbar/profile-active.png"
}
]
},
"style": "v2",
"renderer": "skyline",
"rendererOptions": {
"skyline": {
"defaultDisplayBlock": true,
"defaultContentBox": true,
"disableABTest": true,
"sdkVersionBegin": "3.0.0",
"sdkVersionEnd": "15.255.255"
}
},
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
}
+412
View File
@@ -0,0 +1,412 @@
page {
--theme-primary: #E8B4B8;
--theme-secondary: #C5A059;
--theme-accent: #4A443F;
--theme-neutral: #4A443F;
--theme-tertiary: #FDFBF9;
--theme-primary-action: #766361;
--theme-page-bg: #FDFBF9;
--theme-card-bg: #ffffff;
--theme-border: #F9EAEC;
--theme-primary-soft: #FAEFF0;
--theme-secondary-soft: #EADCC2;
--theme-gradient: linear-gradient(135deg, #766361 0%, #C5A059 100%);
--theme-gradient-soft: linear-gradient(145deg, #ffffff 0%, #EADCC2 58%, #F5E0E0 100%);
--text-primary: #4A443F;
--text-secondary: #6B6662;
min-height: 100vh;
background: var(--theme-page-bg);
color: var(--text-primary);
font-size: 28rpx;
}
view,
text,
button,
input,
textarea,
scroll-view,
swiper,
swiper-item,
picker,
label,
image {
box-sizing: border-box;
}
image {
display: block;
}
button {
margin: 0;
padding: 0;
line-height: 1;
background: transparent;
}
button::after {
border: 0;
}
.page-shell {
min-height: 100vh;
padding-bottom: calc(env(safe-area-inset-bottom) + 48rpx);
background: var(--theme-page-bg);
}
.fingertip-designer-page {
min-height: 100vh;
padding: 28rpx 28rpx calc(env(safe-area-inset-bottom) + 96rpx);
color: var(--text-primary);
background: var(--theme-page-bg);
}
.fingertip-designer-page--no-nav {
padding-bottom: calc(env(safe-area-inset-bottom) + 36rpx);
}
.page-content {
padding: 24rpx 24rpx 44rpx;
}
.page-card {
overflow: hidden;
background: var(--theme-card-bg);
border: 1rpx solid var(--theme-border);
border-radius: 32rpx;
box-shadow: 0 22rpx 56rpx rgba(122, 67, 88, 0.1);
}
.glass-card {
background: rgba(255, 255, 255, 0.82);
border: 1rpx solid rgba(255, 255, 255, 0.9);
border-radius: 32rpx;
box-shadow: 0 22rpx 56rpx rgba(122, 67, 88, 0.08);
}
.fingertip-designer-glass-card {
overflow: hidden;
border: 1rpx solid rgba(255, 255, 255, 0.92);
border-radius: 36rpx;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 24rpx 58rpx rgba(74, 68, 63, 0.1);
}
.fingertip-designer-status-chip {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 44rpx;
padding: 0 22rpx;
border: 1rpx solid var(--theme-border);
border-radius: 999rpx;
color: var(--theme-primary-action);
background: var(--theme-primary-soft);
font-size: 22rpx;
font-weight: 700;
white-space: nowrap;
}
.fingertip-designer-bottom-action {
position: sticky;
bottom: 0;
z-index: 20;
display: flex;
gap: 18rpx;
margin: 32rpx -28rpx -28rpx;
padding: 22rpx 28rpx calc(env(safe-area-inset-bottom) + 22rpx);
border-top: 1rpx solid var(--theme-border);
background: rgba(255, 255, 255, 0.9);
}
.page-hero {
overflow: hidden;
padding: 34rpx 30rpx;
border-radius: 36rpx;
background: var(--theme-gradient-soft);
border: 1rpx solid var(--theme-border);
box-shadow: 0 28rpx 64rpx rgba(122, 67, 88, 0.1);
}
.hero-kicker {
display: block;
font-size: 22rpx;
font-weight: 700;
letter-spacing: 2rpx;
color: var(--theme-primary);
}
.hero-title {
display: block;
margin-top: 16rpx;
font-size: 46rpx;
line-height: 1.24;
font-weight: 800;
color: var(--text-primary);
}
.hero-desc {
display: block;
margin-top: 16rpx;
font-size: 25rpx;
line-height: 1.8;
color: var(--text-secondary);
}
.hero-action-row {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
margin-top: 28rpx;
}
.hero-action {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 196rpx;
height: 76rpx;
padding: 0 28rpx;
border-radius: 999rpx;
font-size: 25rpx;
font-weight: 700;
}
.hero-action.primary {
background: var(--theme-gradient);
color: #ffffff;
}
.hero-action.secondary {
background: rgba(255, 255, 255, 0.9);
color: var(--theme-primary-action);
}
.section-block {
margin-top: 32rpx;
}
.section-head {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 20rpx;
margin-bottom: 20rpx;
}
.section-copy {
flex: 1;
min-width: 0;
}
.section-kicker {
display: block;
font-size: 22rpx;
font-weight: 700;
letter-spacing: 2rpx;
color: var(--theme-primary);
}
.section-title {
display: block;
font-size: 34rpx;
font-weight: 700;
color: var(--text-primary);
}
.section-subtitle {
display: block;
margin-top: 8rpx;
font-size: 24rpx;
line-height: 1.7;
color: var(--text-secondary);
}
.section-link {
font-size: 24rpx;
color: var(--theme-primary);
font-weight: 700;
}
.summary-strip {
display: flex;
gap: 14rpx;
margin-top: 26rpx;
}
.summary-metric {
flex: 1;
min-width: 0;
padding: 22rpx 20rpx;
border-radius: 24rpx;
background: rgba(255, 255, 255, 0.82);
}
.summary-label {
display: block;
font-size: 22rpx;
color: var(--text-secondary);
}
.summary-value {
display: block;
margin-top: 10rpx;
font-size: 30rpx;
line-height: 1.35;
font-weight: 800;
color: var(--text-primary);
}
.summary-note {
display: block;
margin-top: 8rpx;
font-size: 21rpx;
line-height: 1.6;
color: var(--text-secondary);
}
.primary-btn {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 92rpx;
border-radius: 999rpx;
background: var(--theme-gradient);
color: #ffffff;
font-size: 30rpx;
font-weight: 700;
}
.secondary-btn {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 84rpx;
border-radius: 999rpx;
border: 2rpx solid var(--theme-border);
background: var(--theme-card-bg);
color: var(--theme-primary-action);
font-size: 28rpx;
font-weight: 600;
}
.ghost-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 120rpx;
height: 68rpx;
padding: 0 26rpx;
border-radius: 999rpx;
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-size: 24rpx;
font-weight: 600;
}
.field-label {
display: block;
margin-bottom: 14rpx;
font-size: 26rpx;
color: var(--text-primary);
font-weight: 600;
}
.field-input,
.field-textarea,
.field-picker {
display: flex;
align-items: center;
width: 100%;
min-height: 92rpx;
padding: 0 28rpx;
border-radius: 24rpx;
background: var(--theme-primary-soft);
border: 1rpx solid var(--theme-border);
color: var(--text-primary);
font-size: 28rpx;
}
.field-textarea {
min-height: 180rpx;
padding: 24rpx 28rpx;
}
.field-placeholder {
color: var(--text-secondary);
}
.status-text {
display: block;
margin-top: 12rpx;
font-size: 22rpx;
line-height: 1.6;
}
.status-text.success {
color: var(--theme-primary);
}
.status-text.error {
color: var(--theme-accent);
}
.hint-card {
padding: 20rpx 22rpx;
border-radius: 22rpx;
background: var(--theme-primary-soft);
color: var(--theme-accent);
font-size: 24rpx;
line-height: 1.7;
}
.empty-card {
display: flex;
flex-direction: column;
align-items: center;
gap: 18rpx;
padding: 68rpx 40rpx;
text-align: center;
}
.empty-title {
font-size: 34rpx;
font-weight: 700;
color: var(--text-primary);
}
.empty-desc {
font-size: 24rpx;
line-height: 1.8;
color: var(--text-secondary);
}
.chip,
.soft-chip {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 10rpx 20rpx;
border-radius: 999rpx;
font-size: 22rpx;
font-weight: 600;
}
.chip {
background: var(--theme-primary-soft);
color: var(--theme-primary);
}
.soft-chip {
background: var(--theme-primary-soft);
color: var(--text-secondary);
}
.divider-line {
width: 100%;
height: 2rpx;
background: var(--theme-border);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 995 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 979 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

@@ -0,0 +1,182 @@
/**
* 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({
options: {
multipleSlots: true,
},
properties: {
extClass: {
type: String,
value: '',
},
title: {
type: String,
value: '',
},
background: {
type: String,
value: '',
},
color: {
type: String,
value: '',
},
back: {
type: Boolean,
value: true,
},
showBack: {
type: Boolean,
value: true,
},
isTabPage: {
type: Boolean,
value: false,
},
fallbackPath: {
type: String,
value: '/pages/home/index',
},
loading: {
type: Boolean,
value: false,
},
homeButton: {
type: Boolean,
value: false,
},
animated: {
type: Boolean,
value: true,
},
show: {
type: Boolean,
value: true,
observer(show) {
this._showChange(show)
},
},
delta: {
type: Number,
value: 1,
},
safeAreaMode: {
type: String,
value: 'solid',
},
},
observers: {
'back, showBack, isTabPage': function () {
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()
const deviceInfo = (typeof wx.getDeviceInfo === 'function' ? wx.getDeviceInfo() : wx.getSystemInfoSync()) || {}
const windowInfo = (typeof wx.getWindowInfo === 'function' ? wx.getWindowInfo() : wx.getSystemInfoSync()) || {}
const platform = deviceInfo.platform
const isAndroid = platform === 'android'
const isDevtools = platform === 'devtools'
const safeArea = windowInfo.safeArea || {}
const top = safeArea.top || 0
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)
this.setData({
resolvedShowBack,
})
},
_showChange(show) {
const animated = this.data.animated
let displayStyle = ''
if (animated) {
displayStyle = `opacity: ${show ? '1' : '0'};transition:opacity 0.3s;`
} else {
displayStyle = `display: ${show ? '' : 'none'}`
}
this.setData({
displayStyle,
})
},
back() {
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
}
navigation.goBack(this.data.fallbackPath || '/pages/home/index')
},
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',
})
},
},
})
@@ -0,0 +1,5 @@
{
"component": true,
"styleIsolation": "apply-shared",
"usingComponents": {}
}
@@ -0,0 +1,56 @@
<view class="weui-navigation-bar {{extClass}} {{safeAreaMode === 'overlay' ? 'weui-navigation-bar--overlay' : ''}}">
<view
class="weui-navigation-bar__inner {{ios ? 'ios' : 'android'}}"
style="color: {{color}}; background: {{background}}; {{displayStyle}}; {{innerPaddingRight}}; {{safeAreaTop}};"
>
<view class="weui-navigation-bar__left" style="{{leftWidth}};">
<block wx:if="{{resolvedShowBack || homeButton}}">
<view wx:if="{{resolvedShowBack}}" class="weui-navigation-bar__buttons">
<view
bindtap="back"
class="weui-navigation-bar__action"
hover-class="weui-navigation-bar__action--active"
hover-stay-time="80"
aria-role="button"
aria-label="返回"
>
<text class="weui-navigation-bar__arrow">‹</text>
<text class="weui-navigation-bar__label">返回</text>
</view>
</view>
<view wx:if="{{homeButton}}" class="weui-navigation-bar__buttons">
<view
bindtap="home"
class="weui-navigation-bar__action"
hover-class="weui-navigation-bar__action--active"
hover-stay-time="80"
aria-role="button"
aria-label="首页"
>
<text class="weui-navigation-bar__home-dot"></text>
<text class="weui-navigation-bar__label">首页</text>
</view>
</view>
</block>
<block wx:else>
<slot name="left"></slot>
</block>
</view>
<view class="weui-navigation-bar__center">
<view wx:if="{{loading}}" class="weui-navigation-bar__loading" aria-role="alert">
<view class="weui-loading" aria-role="img" aria-label="加载中"></view>
</view>
<block wx:if="{{title}}">
<text>{{title}}</text>
</block>
<block wx:else>
<slot name="center"></slot>
</block>
</view>
<view class="weui-navigation-bar__right">
<slot name="right"></slot>
</view>
</view>
</view>
@@ -0,0 +1,141 @@
.weui-navigation-bar {
--weui-FG-0: var(--theme-neutral);
--height: 44px;
--left: 20rpx;
color: var(--weui-FG-0);
position: relative;
z-index: 30;
}
.weui-navigation-bar .android {
--height: 48px;
}
.weui-navigation-bar--overlay {
position: sticky;
top: 0;
}
.weui-navigation-bar__inner {
position: relative;
z-index: 1;
height: calc(var(--height) + env(safe-area-inset-top));
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding-top: env(safe-area-inset-top);
width: 100%;
box-sizing: border-box;
color: var(--theme-neutral);
border-bottom: 1rpx solid var(--theme-border);
backdrop-filter: blur(20rpx);
}
.weui-navigation-bar__left,
.weui-navigation-bar__right {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
height: 100%;
box-sizing: border-box;
}
.weui-navigation-bar__left {
padding-left: var(--left);
}
.weui-navigation-bar__right {
justify-content: flex-end;
min-width: 120rpx;
padding-right: 24rpx;
}
.weui-navigation-bar__buttons {
display: flex;
align-items: center;
height: 100%;
}
.weui-navigation-bar__action {
display: inline-flex;
align-items: center;
gap: 10rpx;
min-height: 64rpx;
padding: 0 18rpx 0 8rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.86);
border: 1rpx solid rgba(255, 255, 255, 0.94);
color: var(--theme-neutral);
box-shadow: 0 10rpx 28rpx rgba(74, 68, 63, 0.08);
}
.weui-navigation-bar__action--active {
opacity: 0.7;
}
.weui-navigation-bar__arrow {
font-size: 40rpx;
font-weight: 700;
line-height: 1;
}
.weui-navigation-bar__home-dot {
width: 20rpx;
height: 20rpx;
border-radius: 999rpx;
background: currentColor;
}
.weui-navigation-bar__label {
font-size: 24rpx;
font-weight: 700;
line-height: 1;
}
.weui-navigation-bar__center {
font-size: 17px;
text-align: center;
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
font-weight: 700;
flex: 1;
height: 100%;
min-width: 0;
}
.weui-navigation-bar__center text {
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.weui-navigation-bar__loading {
margin-right: 8rpx;
display: flex;
align-items: center;
}
.weui-loading {
font-size: 16px;
width: 16px;
height: 16px;
display: block;
background: transparent url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='80px' height='80px' viewBox='0 0 80 80' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' opacity='0.9'%3E%3Cg%3E%3Cpath d='M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 L40,73 C58.2253967,73 73,58.2253967 73,40 C73,21.7746033 58.2253967,7 40,7 L40,0 Z' fill='rgba(96,96,96,0.3)'/%3E%3Cpath d='M40,0 L40,7 C21.7746033,7 7,21.7746033 7,40 C7,58.2253967 21.7746033,73 40,73 L40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z' fill='%23606060'/%3E%3Ccircle fill='%23606060' cx='40.5' cy='3.5' r='3.5'%3E%3C/circle%3E%3C/g%3E%3C/g%3E%3C/svg%3E") no-repeat;
background-size: 100%;
animation: loading 1s linear infinite;
}
@keyframes loading {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@@ -0,0 +1,34 @@
Component({
properties: {
item: {
type: Object,
value: {}
},
showMeta: {
type: Boolean,
value: true
},
showStats: {
type: Boolean,
value: false
},
showQuickAdd: {
type: Boolean,
value: false
},
inCart: {
type: Boolean,
value: false
}
},
methods: {
handleTap() {
this.triggerEvent('select', this.properties.item)
},
handleQuickAdd() {
this.triggerEvent('quickadd', this.properties.item)
}
}
})
@@ -0,0 +1,3 @@
{
"component": true
}
@@ -0,0 +1,34 @@
<view class="product-card" bindtap="handleTap">
<view class="product-cover-wrap">
<image class="product-cover" src="{{item.coverUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
<view class="product-cover-shadow"></view>
<view wx:if="{{showMeta && item.metaText}}" class="product-meta-badge">{{item.metaText}}</view>
</view>
<view class="product-body">
<view class="product-title">{{item.displayTitle}}</view>
<view wx:if="{{item.shopNameText}}" class="product-shop">{{item.shopNameText}}</view>
<view wx:if="{{!showMeta && item.metaText}}" class="product-meta">{{item.metaText}}</view>
<view wx:if="{{item.tagsPreview && item.tagsPreview.length}}" class="product-tags">
<text wx:for="{{item.tagsPreview}}" wx:key="*this" class="tag-item">{{item}}</text>
</view>
<view class="product-footer">
<view class="product-price-wrap">
<text class="product-price">{{item.priceText}}</text>
<text wx:if="{{showStats}}" class="product-stats">{{item.statsText}}</text>
</view>
<view wx:if="{{showQuickAdd}}" class="product-actions">
<view wx:if="{{!inCart}}" class="product-quick-add" catchtap="handleQuickAdd">
<view class="product-quick-add-icon">
<view class="product-quick-add-handle"></view>
<view class="product-quick-add-basket"></view>
<view class="product-quick-add-wheel product-quick-add-wheel--left"></view>
<view class="product-quick-add-wheel product-quick-add-wheel--right"></view>
<view class="product-quick-add-plus product-quick-add-plus--horizontal"></view>
<view class="product-quick-add-plus product-quick-add-plus--vertical"></view>
</view>
</view>
<view wx:else class="product-in-cart">购物车已有</view>
</view>
</view>
</view>
</view>
@@ -0,0 +1,227 @@
.product-card {
display: flex;
flex-direction: column;
min-width: 0;
overflow: hidden;
border-radius: 28rpx;
background: rgba(255, 255, 255, 0.86);
border: 1rpx solid var(--theme-border);
box-shadow: 0 18rpx 42rpx rgba(74, 68, 63, 0.08);
}
.product-cover-wrap {
position: relative;
}
.product-cover {
width: 100%;
height: 288rpx;
background: var(--theme-primary-soft);
}
.product-cover-shadow {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 120rpx;
background: linear-gradient(180deg, rgba(28, 23, 26, 0), rgba(28, 23, 26, 0.28));
}
.product-meta-badge {
position: absolute;
left: 16rpx;
top: 16rpx;
max-width: calc(100% - 32rpx);
padding: 8rpx 14rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.92);
color: var(--theme-primary-action);
font-size: 19rpx;
font-weight: 700;
}
.product-body {
display: flex;
flex-direction: column;
gap: 10rpx;
min-height: 220rpx;
padding: 20rpx 20rpx 22rpx;
}
.product-title {
min-height: 74rpx;
font-size: 27rpx;
font-weight: 700;
line-height: 1.38;
color: var(--text-primary);
word-break: break-all;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.product-meta {
font-size: 22rpx;
color: var(--text-secondary);
line-height: 1.4;
}
.product-tags {
display: flex;
flex-wrap: wrap;
gap: 8rpx;
}
.tag-item {
display: inline-flex;
align-items: center;
justify-content: center;
max-width: 100%;
padding: 6rpx 14rpx;
border-radius: 999rpx;
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-size: 18rpx;
line-height: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.product-footer {
display: flex;
align-items: flex-end;
gap: 14rpx;
margin-top: auto;
}
.product-price-wrap {
flex: 1;
min-width: 0;
}
.product-actions {
display: flex;
align-items: center;
flex-shrink: 0;
}
.product-price {
display: block;
font-size: 34rpx;
line-height: 1.12;
font-weight: 800;
color: var(--theme-accent);
}
.product-stats {
display: block;
margin-top: 6rpx;
font-size: 20rpx;
line-height: 1.4;
color: var(--text-secondary);
}
.product-quick-add {
display: inline-flex;
align-items: center;
justify-content: center;
width: 64rpx;
height: 64rpx;
border-radius: 22rpx;
background: var(--theme-gradient);
box-shadow: 0 14rpx 30rpx rgba(232, 180, 184, 0.26);
}
.product-quick-add-icon {
position: relative;
width: 32rpx;
height: 28rpx;
}
.product-quick-add-handle {
position: absolute;
left: 2rpx;
top: 2rpx;
width: 12rpx;
height: 4rpx;
border-radius: 999rpx;
background: #ffffff;
transform: rotate(20deg);
transform-origin: left center;
}
.product-quick-add-basket {
position: absolute;
left: 6rpx;
top: 8rpx;
width: 18rpx;
height: 11rpx;
border: 3rpx solid #ffffff;
border-top: 0;
border-radius: 0 0 6rpx 6rpx;
}
.product-quick-add-wheel {
position: absolute;
top: 22rpx;
width: 6rpx;
height: 6rpx;
border-radius: 50%;
background: #ffffff;
}
.product-quick-add-wheel--left {
left: 10rpx;
}
.product-quick-add-wheel--right {
left: 22rpx;
}
.product-quick-add-plus {
position: absolute;
border-radius: 999rpx;
background: #ffffff;
}
.product-quick-add-plus--horizontal {
top: 2rpx;
right: 0;
width: 10rpx;
height: 3rpx;
}
.product-quick-add-plus--vertical {
top: -1rpx;
right: 4rpx;
width: 3rpx;
height: 10rpx;
}
.product-in-cart {
display: inline-flex;
align-items: center;
justify-content: center;
height: 56rpx;
padding: 0 18rpx;
border-radius: 999rpx;
background: var(--theme-primary-soft);
color: var(--theme-accent);
font-size: 20rpx;
font-weight: 700;
white-space: nowrap;
}
.product-shop {
margin-top: 6rpx;
color: var(--text-secondary);
font-size: 22rpx;
line-height: 1.45;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
@@ -0,0 +1,76 @@
const userApi = require('../../api/user')
const auth = require('../../utils/auth')
const navigation = require('../../utils/navigation')
const theme = require('../../utils/theme')
const { runWithLoading } = require('../../utils/loading')
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
loading: false,
saving: false,
isLoggedIn: false,
userInfo: null,
form: {
nickname: '',
signature: ''
}
}),
onShow() {
this.loadProfile()
},
handleBack() {
navigation.goBack('/pages/settings/index')
},
async loadProfile() {
const isLoggedIn = auth.isLoggedIn()
this.setData({ isLoggedIn })
if (!isLoggedIn) {
navigation.openAuth(navigation.getCurrentPageUrl())
return
}
this.setData({ loading: true })
try {
const userInfo = await userApi.getUserInfo()
this.setData({
userInfo,
'form.nickname': userInfo.nickname || '',
'form.signature': userInfo.signature || ''
})
} catch (error) {
wx.showToast({ title: error.message || '资料加载失败', icon: 'none' })
} finally {
this.setData({ loading: false })
}
},
handleInput(event) {
const field = event.currentTarget.dataset.field
this.setData({
[`form.${field}`]: event.detail.value
})
},
async saveProfile() {
const nickname = String(this.data.form.nickname || '').trim()
if (!nickname) {
wx.showToast({ title: '请输入昵称', icon: 'none' })
return
}
this.setData({ saving: true })
try {
await runWithLoading(() => userApi.updateUserInfo({
nickname,
signature: String(this.data.form.signature || '').trim()
}))
wx.showToast({ title: '资料已更新', icon: 'none' })
await this.loadProfile()
} catch (error) {
wx.showToast({ title: error.message || '资料更新失败', icon: 'none' })
} finally {
this.setData({ saving: false })
}
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,23 @@
<navigation-bar title="账号资料" showBack="{{true}}" fallbackPath="/pages/settings/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell" style="{{themeVars}}">
<view class="page-content">
<view class="page-hero">
<text class="hero-kicker">Account</text>
<text class="hero-title">账号资料</text>
<text class="hero-desc">维护昵称、个性签名和基础资料</text>
</view>
<view class="page-card form-card">
<view class="field-block">
<text class="field-label">昵称</text>
<input class="field-input" value="{{form.nickname}}" data-field="nickname" bindinput="handleInput" placeholder="请输入昵称" placeholder-class="field-placeholder" />
</view>
<view class="field-block">
<text class="field-label">个性签名</text>
<textarea class="field-textarea" maxlength="120" value="{{form.signature}}" data-field="signature" bindinput="handleInput" placeholder="写一句介绍自己" placeholder-class="field-placeholder"></textarea>
</view>
<button class="primary-btn" loading="{{saving}}" bindtap="saveProfile">保存资料</button>
</view>
</view>
</view>
@@ -0,0 +1,12 @@
.form-card {
margin-top: 22rpx;
padding: 28rpx;
}
.field-block + .field-block {
margin-top: 24rpx;
}
.primary-btn {
margin-top: 28rpx;
}
@@ -0,0 +1,132 @@
const orderApi = require('../../api/order')
const afterSaleApi = require('../../api/after-sale')
const auth = require('../../utils/auth')
const navigation = require('../../utils/navigation')
const theme = require('../../utils/theme')
const { formatPrice } = require('../../utils/format')
const { runWithLoading } = require('../../utils/loading')
function safeList(value) {
return Array.isArray(value) ? value : []
}
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
orderId: '',
loading: false,
submitting: false,
isLoggedIn: false,
order: null,
items: [],
typeOptions: ['退款', '售后服务'],
form: {
orderItemId: '',
type: 'REFUND',
typeIndex: 0,
reason: '',
refundAmount: ''
}
}),
onLoad(options) {
this.setData({
orderId: (options && options.orderId) || '',
'form.orderItemId': (options && options.orderItemId) || ''
})
},
onShow() {
this.loadOrder()
},
handleBack() {
navigation.goBack('/pages/orders/index')
},
async loadOrder() {
const isLoggedIn = auth.isLoggedIn()
this.setData({ isLoggedIn })
if (!isLoggedIn) {
navigation.openAuth(navigation.getCurrentPageUrl())
return
}
if (!this.data.orderId) return
this.setData({ loading: true })
try {
const order = await orderApi.getOrderDetail(this.data.orderId)
const items = safeList(order && order.items)
const selectedItem = items.find(item => String(item.id) === String(this.data.form.orderItemId)) || items[0]
this.setData({
order,
items,
'form.orderItemId': selectedItem ? selectedItem.id : '',
'form.refundAmount': String(order && (order.actualAmount || order.totalAmount || '')),
amountText: `¥${formatPrice(order && (order.actualAmount || order.totalAmount))}`
})
} catch (error) {
wx.showToast({
title: error.message || '订单信息加载失败',
icon: 'none'
})
} finally {
this.setData({ loading: false })
}
},
handleItemChange(event) {
const index = Number(event.detail.value)
const item = this.data.items[index]
this.setData({
'form.orderItemId': item ? item.id : ''
})
},
handleTypeChange(event) {
const index = Number(event.detail.value)
this.setData({
'form.typeIndex': index,
'form.type': index === 0 ? 'REFUND' : 'AFTER_SALE'
})
},
handleInput(event) {
const field = event.currentTarget.dataset.field
this.setData({
[`form.${field}`]: event.detail.value
})
},
async submit() {
if (!this.data.orderId) {
wx.showToast({ title: '缺少订单信息', icon: 'none' })
return
}
const reason = String(this.data.form.reason || '').trim()
if (!reason) {
wx.showToast({ title: '请填写售后原因', icon: 'none' })
return
}
this.setData({ submitting: true })
try {
await runWithLoading(() => afterSaleApi.applyAfterSale({
orderId: this.data.orderId,
orderItemId: this.data.form.orderItemId || undefined,
type: this.data.form.type,
reason,
refundAmount: this.data.form.refundAmount ? Number(this.data.form.refundAmount) : undefined
}), { title: '提交售后' })
wx.showToast({ title: '售后申请已提交', icon: 'none' })
wx.redirectTo({
url: `/pages/after-sales/index?orderId=${encodeURIComponent(this.data.orderId)}`
})
} catch (error) {
wx.showToast({
title: error.message || '售后申请提交失败',
icon: 'none'
})
} finally {
this.setData({ submitting: false })
}
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,41 @@
<navigation-bar title="申请售后" showBack="{{true}}" fallbackPath="/pages/orders/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell" style="{{themeVars}}">
<view class="page-content">
<view class="page-hero">
<text class="hero-kicker">售后申请</text>
<text class="hero-title">{{order && order.orderNo || '选择订单'}}</text>
<text class="hero-desc">{{order ? '可申请金额' + amountText : '从订单详情进入可自动带入订单信息'}}</text>
</view>
<view wx:if="{{!orderId}}" class="page-card empty-card">
<text class="empty-title">缺少订单信息</text>
<text class="empty-desc">请从订单详情或订单中心发起售后</text>
<view class="ghost-btn" bindtap="handleBack">返回订单</view>
</view>
<view wx:else class="page-card form-card">
<view class="field-block">
<text class="field-label">订单项目</text>
<picker mode="selector" range="{{items}}" range-key="productTitle" bindchange="handleItemChange">
<view class="field-picker">{{form.orderItemId ? '已选择项目' : '默认整单'}}</view>
</picker>
</view>
<view class="field-block">
<text class="field-label">售后类型</text>
<picker mode="selector" range="{{typeOptions}}" value="{{form.typeIndex}}" bindchange="handleTypeChange">
<view class="field-picker">{{typeOptions[form.typeIndex]}}</view>
</picker>
</view>
<view class="field-block">
<text class="field-label">退款金额</text>
<input class="field-input" type="digit" value="{{form.refundAmount}}" data-field="refundAmount" bindinput="handleInput" placeholder="可选" placeholder-class="field-placeholder" />
</view>
<view class="field-block">
<text class="field-label">原因说明</text>
<textarea class="field-textarea" maxlength="300" value="{{form.reason}}" data-field="reason" bindinput="handleInput" placeholder="请说明退款或售后原因" placeholder-class="field-placeholder"></textarea>
</view>
<button class="primary-btn" loading="{{submitting}}" bindtap="submit">提交申请</button>
</view>
</view>
</view>
@@ -0,0 +1,12 @@
.form-card {
margin-top: 22rpx;
padding: 28rpx;
}
.field-block + .field-block {
margin-top: 24rpx;
}
.primary-btn {
margin-top: 28rpx;
}
@@ -0,0 +1,96 @@
const afterSaleApi = require('../../api/after-sale')
const auth = require('../../utils/auth')
const navigation = require('../../utils/navigation')
const theme = require('../../utils/theme')
const { formatDateTime, formatPrice } = require('../../utils/format')
function safeList(value) {
if (Array.isArray(value)) return value
if (value && Array.isArray(value.list)) return value.list
if (value && Array.isArray(value.records)) return value.records
return []
}
function statusText(status) {
const value = String(status || '').toUpperCase()
if (value === 'PENDING') return '审核中'
if (value === 'APPROVED') return '已通过'
if (value === 'REJECTED') return '已拒绝'
return status || '处理中'
}
function typeText(type) {
return type === 'REFUND' ? '退款' : (type || '售后')
}
function formatRecord(item) {
return {
...item,
typeText: typeText(item.type),
statusText: statusText(item.status),
amountText: item.refundAmount === undefined || item.refundAmount === null ? '--' : `¥${formatPrice(item.refundAmount)}`,
createdText: formatDateTime(item.createTime)
}
}
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
orderId: '',
loading: false,
isLoggedIn: false,
records: []
}),
onLoad(options) {
this.setData({
orderId: (options && options.orderId) || ''
})
},
onShow() {
this.loadRecords()
},
handleBack() {
navigation.goBack('/pages/profile/index')
},
async loadRecords() {
const isLoggedIn = auth.isLoggedIn()
this.setData({ isLoggedIn })
if (!isLoggedIn) {
navigation.openAuth(navigation.getCurrentPageUrl())
return
}
this.setData({ loading: true })
try {
const payload = await afterSaleApi.getMyAfterSales({ page: 1, size: 50 })
let records = safeList(payload)
if (this.data.orderId) {
records = records.filter(item => String(item.orderId) === String(this.data.orderId))
}
this.setData({
records: records.map(formatRecord)
})
} catch (error) {
wx.showToast({
title: error.message || '售后记录加载失败',
icon: 'none'
})
} finally {
this.setData({ loading: false })
}
},
openOrder(event) {
navigation.navigate('/pages/order-detail/index', {
id: event.currentTarget.dataset.orderId
})
},
openProgress(event) {
navigation.navigate('/pages/service-progress/index', {
orderId: event.currentTarget.dataset.orderId
})
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,49 @@
<navigation-bar title="售后记录" showBack="{{true}}" fallbackPath="/pages/profile/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell" style="{{themeVars}}">
<view class="page-content">
<view class="page-hero">
<text class="hero-kicker">售后服务</text>
<text class="hero-title">{{records.length}} 条记录</text>
<text class="hero-desc">{{orderId ? '当前订单的售后进度' : '退款、售后和审核记录集中查看'}}</text>
</view>
<view wx:if="{{loading}}" class="page-card empty-card">
<text class="empty-title">正在加载售后记录</text>
</view>
<view wx:elif="{{records.length}}">
<view wx:for="{{records}}" wx:key="id" class="page-card record-card">
<view class="record-head">
<view>
<text class="record-label">{{item.typeText}}</text>
<text class="record-title">{{item.afterSaleNo || item.id}}</text>
</view>
<text class="chip">{{item.statusText}}</text>
</view>
<view class="record-grid">
<view>
<text class="summary-label">订单</text>
<text class="summary-value">{{item.orderId}}</text>
</view>
<view>
<text class="summary-label">金额</text>
<text class="summary-value">{{item.amountText}}</text>
</view>
</view>
<text wx:if="{{item.reason}}" class="record-line">原因:{{item.reason}}</text>
<text wx:if="{{item.auditReason}}" class="record-line">处理说明:{{item.auditReason}}</text>
<text class="record-line">提交时间:{{item.createdText}}</text>
<view class="record-actions">
<view class="ghost-btn" data-order-id="{{item.orderId}}" bindtap="openOrder">订单详情</view>
<view class="ghost-btn" data-order-id="{{item.orderId}}" bindtap="openProgress">服务进度</view>
</view>
</view>
</view>
<view wx:else class="page-card empty-card">
<text class="empty-title">暂无售后记录</text>
<text class="empty-desc">订单完成或支付后可以发起售后申请</text>
</view>
</view>
</view>
@@ -0,0 +1,57 @@
.record-card {
margin-top: 22rpx;
padding: 26rpx;
}
.record-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18rpx;
}
.record-label,
.record-title,
.record-line {
display: block;
}
.record-label {
color: var(--theme-primary);
font-size: 22rpx;
font-weight: 800;
}
.record-title {
margin-top: 8rpx;
color: var(--text-primary);
font-size: 30rpx;
font-weight: 800;
}
.record-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14rpx;
margin-top: 22rpx;
}
.record-grid view {
padding: 18rpx;
border-radius: 22rpx;
background: var(--theme-primary-soft);
}
.record-line {
margin-top: 14rpx;
color: #504444;
font-size: 24rpx;
line-height: 1.6;
}
.record-actions {
display: flex;
flex-wrap: wrap;
gap: 14rpx;
margin-top: 20rpx;
}
@@ -0,0 +1,76 @@
const orderApi = require('../../api/order')
const auth = require('../../utils/auth')
const navigation = require('../../utils/navigation')
const theme = require('../../utils/theme')
const { formatDateTime, formatPrice } = require('../../utils/format')
const { runWithLoading } = require('../../utils/loading')
function safeList(value) {
return Array.isArray(value) ? value : []
}
function formatClock(value) {
return value ? String(value).replace('T', ' ').slice(11, 16) : '--'
}
function formatAppointment(item) {
return {
...item,
dayText: String(item.appointmentStartTime || '').slice(5, 10),
timeText: `${formatClock(item.appointmentStartTime)}-${formatClock(item.appointmentEndTime)}`,
amountText: `¥${formatPrice(item.actualAmount || item.totalAmount)}`,
dateTimeText: formatDateTime(item.appointmentStartTime)
}
}
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
loading: false,
isLoggedIn: false,
appointments: []
}),
onShow() {
this.loadAppointments()
},
handleBack() {
navigation.goBack('/pages/artist-orders/index')
},
async loadAppointments() {
const isLoggedIn = auth.isLoggedIn()
this.setData({ isLoggedIn })
if (!isLoggedIn) {
navigation.openAuth(navigation.getCurrentPageUrl())
return
}
this.setData({ loading: true })
try {
const list = safeList(await orderApi.getArtistCalendarRecent(7))
this.setData({
appointments: list.map(formatAppointment)
})
} catch (error) {
wx.showToast({ title: error.message || '预约日历加载失败', icon: 'none' })
} finally {
this.setData({ loading: false })
}
},
openArtistOrders() {
navigation.navigate('/pages/artist-orders/index')
},
async completeOrder(event) {
const orderId = event.currentTarget.dataset.orderId
if (!orderId) return
try {
await runWithLoading(() => orderApi.completeArtistOrder(orderId))
wx.showToast({ title: '服务已完成', icon: 'none' })
await this.loadAppointments()
} catch (error) {
wx.showToast({ title: error.message || '完成服务失败', icon: 'none' })
}
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,37 @@
<navigation-bar title="预约日历" showBack="{{true}}" fallbackPath="/pages/artist-orders/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell" style="{{themeVars}}">
<view class="page-content">
<view class="page-hero">
<text class="hero-kicker">未来 7 天</text>
<text class="hero-title">{{appointments.length}} 个预约</text>
<text class="hero-desc">按时间查看即将服务的客户与项目</text>
<view class="hero-action-row">
<view class="hero-action secondary" bindtap="openArtistOrders">订单列表</view>
</view>
</view>
<view wx:if="{{loading}}" class="page-card empty-card">
<text class="empty-title">正在加载日历</text>
</view>
<view wx:elif="{{appointments.length}}">
<view wx:for="{{appointments}}" wx:key="orderItemId" class="page-card appointment-card">
<view class="day-box">
<text>{{item.dayText}}</text>
<text>{{item.timeText}}</text>
</view>
<view class="appointment-main">
<text class="appointment-title">{{item.customerNickname || '客户'}} · {{item.productTitle}}</text>
<text class="appointment-line">{{item.orderStatusText}} · {{item.shopName || '门店'}}</text>
<text class="appointment-line">{{item.amountText}}</text>
<view wx:if="{{item.orderStatus == 1}}" class="ghost-btn" data-order-id="{{item.orderId}}" bindtap="completeOrder">完成服务</view>
</view>
</view>
</view>
<view wx:else class="page-card empty-card">
<text class="empty-title">未来 7 天暂无预约</text>
</view>
</view>
</view>
@@ -0,0 +1,49 @@
.appointment-card {
display: flex;
gap: 18rpx;
margin-top: 22rpx;
padding: 24rpx;
}
.day-box {
width: 136rpx;
flex: 0 0 auto;
display: flex;
flex-direction: column;
justify-content: center;
gap: 8rpx;
padding: 20rpx 12rpx;
border-radius: 24rpx;
background: var(--theme-primary-soft);
color: var(--theme-primary);
text-align: center;
font-weight: 800;
}
.appointment-main {
flex: 1;
min-width: 0;
}
.appointment-title,
.appointment-line {
display: block;
}
.appointment-title {
color: var(--text-primary);
font-size: 29rpx;
font-weight: 800;
line-height: 1.45;
}
.appointment-line {
margin-top: 8rpx;
color: #504444;
font-size: 24rpx;
line-height: 1.6;
}
.ghost-btn {
margin-top: 16rpx;
}
@@ -0,0 +1,92 @@
const orderApi = require('../../api/order')
const auth = require('../../utils/auth')
const navigation = require('../../utils/navigation')
const theme = require('../../utils/theme')
const { resolveLegacyImage } = require('../../utils/file')
const { formatDateTime, formatPrice, getOrderStatusClass, getOrderStatusText } = require('../../utils/format')
const { runWithLoading } = require('../../utils/loading')
function safeList(value) {
return Array.isArray(value) ? value : []
}
async function formatOrder(order) {
return {
...order,
statusText: getOrderStatusText(order),
statusClass: getOrderStatusClass(order),
amountText: `¥${formatPrice(order && order.actualAmount)}`,
items: await Promise.all(safeList(order && order.items).map(async item => ({
...item,
productImageUrl: await resolveLegacyImage(item.productImage),
priceText: `¥${formatPrice(item.price)}`,
appointmentText: formatDateTime(item.appointmentTime)
})))
}
}
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
loading: false,
isLoggedIn: false,
orders: [],
focusOrderId: ''
}),
onLoad(options) {
this.setData({
focusOrderId: (options && options.orderId) || ''
})
},
onShow() {
this.loadOrders()
},
handleBack() {
navigation.goBack('/pages/profile/index')
},
async loadOrders() {
const isLoggedIn = auth.isLoggedIn()
this.setData({ isLoggedIn })
if (!isLoggedIn) {
navigation.openAuth(navigation.getCurrentPageUrl())
return
}
this.setData({ loading: true })
try {
const list = safeList(await orderApi.getArtistOrders())
const orders = await Promise.all(list.map(formatOrder))
this.setData({ orders })
} catch (error) {
wx.showToast({ title: error.message || '美甲师订单加载失败', icon: 'none' })
} finally {
this.setData({ loading: false })
}
},
openCalendar() {
navigation.navigate('/pages/artist-calendar/index')
},
async completeOrder(event) {
const orderId = event.currentTarget.dataset.orderId
if (!orderId) return
const confirmed = await new Promise(resolve => {
wx.showModal({
title: '完成服务',
content: '确认这笔订单已经完成服务吗?',
success: res => resolve(Boolean(res.confirm))
})
})
if (!confirmed) return
try {
await runWithLoading(() => orderApi.completeArtistOrder(orderId))
wx.showToast({ title: '服务已完成', icon: 'none' })
await this.loadOrders()
} catch (error) {
wx.showToast({ title: error.message || '完成订单失败', icon: 'none' })
}
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,47 @@
<navigation-bar title="美甲师订单" showBack="{{true}}" fallbackPath="/pages/profile/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell" style="{{themeVars}}">
<view class="page-content">
<view class="page-hero">
<text class="hero-kicker">服务订单</text>
<text class="hero-title">{{orders.length}} 笔相关订单</text>
<text class="hero-desc">查看客户预约、项目和服务完成状态</text>
<view class="hero-action-row">
<view class="hero-action secondary" bindtap="openCalendar">预约日历</view>
</view>
</view>
<view wx:if="{{loading}}" class="page-card empty-card">
<text class="empty-title">正在加载订单</text>
</view>
<view wx:elif="{{orders.length}}">
<view wx:for="{{orders}}" wx:key="id" class="page-card order-card {{item.id == focusOrderId ? 'focus-target' : ''}}">
<view class="order-head">
<view>
<text class="order-no">{{item.orderNo}}</text>
<text class="order-line">{{item.customerNickname || '客户'}} {{item.customerPhoneMasked || ''}}</text>
</view>
<text class="chip">{{item.statusText}}</text>
</view>
<view wx:for="{{item.items}}" wx:key="id" wx:for-item="orderItem" class="item-row">
<image class="item-thumb" src="{{orderItem.productImageUrl}}" mode="aspectFill"></image>
<view class="item-main">
<text class="item-title">{{orderItem.productTitle}}</text>
<text class="item-line">{{orderItem.priceText}} x {{orderItem.quantity}}</text>
<text wx:if="{{orderItem.appointmentText}}" class="item-line">预约:{{orderItem.appointmentText}}</text>
</view>
</view>
<view class="order-foot">
<text class="order-amount">{{item.amountText}}</text>
<view wx:if="{{item.status == 1}}" class="ghost-btn" data-order-id="{{item.id}}" bindtap="completeOrder">完成服务</view>
</view>
</view>
</view>
<view wx:else class="page-card empty-card">
<text class="empty-title">暂无相关订单</text>
<text class="empty-desc">有客户预约你服务的项目后会出现在这里</text>
</view>
</view>
</view>
@@ -0,0 +1,70 @@
.order-card {
margin-top: 22rpx;
padding: 26rpx;
}
.order-card.focus-target {
border-color: var(--theme-primary);
}
.order-head,
.order-foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18rpx;
}
.order-no,
.order-line,
.order-amount {
display: block;
}
.order-no {
color: var(--text-primary);
font-size: 28rpx;
font-weight: 800;
}
.order-line {
margin-top: 8rpx;
color: #504444;
font-size: 24rpx;
line-height: 1.6;
}
.item-row {
display: flex;
gap: 18rpx;
margin-top: 22rpx;
}
.item-thumb {
width: 116rpx;
height: 116rpx;
border-radius: 22rpx;
background: var(--theme-primary-soft);
}
.item-main {
flex: 1;
min-width: 0;
}
.item-title {
display: block;
color: var(--text-primary);
font-size: 28rpx;
font-weight: 800;
}
.order-foot {
margin-top: 24rpx;
}
.order-amount {
color: var(--text-primary);
font-size: 28rpx;
font-weight: 800;
}
@@ -0,0 +1,136 @@
const nailArtistApi = require('../../api/nail-artist')
const navigation = require('../../utils/navigation')
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
function formatPrice(price) {
const value = Number(price || 0)
return value > 0 ? `¥${value.toFixed(2)}` : '到店确认'
}
function formatDateTime(value) {
if (!value) {
return ''
}
return String(value).replace('T', ' ').slice(0, 16)
}
Page({
data: {
loading: true,
loadError: '',
artistId: '',
profile: null,
works: [],
reviews: [],
availability: [],
heroImage: DEFAULT_PRODUCT_IMAGE,
artistName: '美甲师',
artistDesc: '专注细节与稳定出品',
shopName: '门店待确认',
styleTags: [],
ratingText: '0.0',
serviceCountText: '0',
workTimeText: '到店确认'
},
onLoad(options) {
this.setData({
artistId: options && options.id ? options.id : ''
})
this.loadArtistProfile()
},
async onPullDownRefresh() {
await this.loadArtistProfile()
wx.stopPullDownRefresh()
},
async loadArtistProfile() {
if (!this.data.artistId) {
this.setData({
loading: false,
loadError: '缺少美甲师信息'
})
return
}
this.setData({
loading: true,
loadError: ''
})
try {
const [profile, availability, reviews] = await Promise.all([
nailArtistApi.getPublicProfile(this.data.artistId),
nailArtistApi.getAvailability(this.data.artistId),
nailArtistApi.listReviews(this.data.artistId)
])
const works = (profile.works || []).map(work => ({
...work,
title: work.title || '美甲作品',
coverImageUrl: work.coverImageUrl || DEFAULT_PRODUCT_IMAGE,
priceText: formatPrice(work.price)
}))
const formattedReviews = (reviews || profile.reviews || []).map(review => ({
...review,
customerName: review.customerName || '匿名用户',
content: review.content || '这位用户没有填写文字评价',
submittedAtText: formatDateTime(review.submittedAt),
ratingText: Number(review.rating || 0).toFixed(1)
}))
const start = profile.workStartTime ? String(profile.workStartTime).slice(0, 5) : ''
const end = profile.workEndTime ? String(profile.workEndTime).slice(0, 5) : ''
this.setData({
profile,
works,
reviews: formattedReviews,
availability: availability || profile.availability || [],
heroImage: (works.find(work => work.coverImageUrl) || {}).coverImageUrl || DEFAULT_PRODUCT_IMAGE,
artistName: profile.artistName || '美甲师',
artistDesc: profile.identity || profile.signature || '专注细节与稳定出品',
shopName: profile.shopName || '门店待确认',
styleTags: (profile.styleTags || []).filter(Boolean),
ratingText: Number(profile.rating || 0).toFixed(1),
serviceCountText: String(profile.serviceCount || 0),
workTimeText: start && end ? `${start}-${end}` : '到店确认'
})
} catch (error) {
this.setData({
loadError: error.message || '美甲师个人页加载失败'
})
} finally {
this.setData({
loading: false
})
}
},
handleBack() {
navigation.goBack('/pages/home/index')
},
handleRetry() {
this.loadArtistProfile()
},
handleOpenShop() {
const profile = this.data.profile
if (!profile || !profile.shopId) {
return
}
wx.navigateTo({
url: `/pages/shop-detail/index?id=${profile.shopId}`
})
},
handleOpenWork(event) {
const id = event.currentTarget.dataset.id
if (!id) {
return
}
wx.navigateTo({
url: `/pages/product-detail/index?id=${id}`
})
}
})
@@ -0,0 +1,4 @@
{
"navigationStyle": "custom",
"usingComponents": {}
}
@@ -0,0 +1,98 @@
<view class="artist-page">
<view class="page-header">
<view class="back-btn" bindtap="handleBack">‹</view>
<text class="page-title">{{artistName}}</text>
<view class="header-spacer"></view>
</view>
<view wx:if="{{loading}}" class="state-box">
<text>加载中...</text>
</view>
<view wx:elif="{{loadError}}" class="state-box">
<text class="state-title">暂时无法查看个人页</text>
<text class="state-desc">{{loadError}}</text>
<view class="primary-btn" bindtap="handleRetry">重试</view>
</view>
<scroll-view wx:else scroll-y class="content-scroll">
<view class="hero">
<image class="hero-image" src="{{heroImage}}" mode="aspectFill"></image>
<view class="hero-mask"></view>
<view class="artist-card">
<image wx:if="{{profile.avatar}}" class="avatar" src="{{profile.avatar}}" mode="aspectFill"></image>
<view wx:else class="avatar placeholder">艺</view>
<view class="artist-main">
<text class="artist-name">{{artistName}}</text>
<text class="artist-desc">{{artistDesc}}</text>
<view class="shop-link" bindtap="handleOpenShop">{{shopName}}</view>
</view>
</view>
</view>
<view class="metrics">
<view class="metric-item">
<text>评分</text>
<text class="metric-value">{{ratingText}}</text>
</view>
<view class="metric-item">
<text>服务</text>
<text class="metric-value">{{serviceCountText}}</text>
</view>
<view class="metric-item">
<text>工时</text>
<text class="metric-value">{{workTimeText}}</text>
</view>
</view>
<view class="section">
<view class="section-head">擅长风格</view>
<view class="tag-list" wx:if="{{styleTags.length}}">
<text class="tag" wx:for="{{styleTags}}" wx:key="*this">{{item}}</text>
</view>
<text wx:else class="empty-text">暂未设置风格标签</text>
</view>
<view class="section">
<view class="section-head">近期可预约</view>
<view class="slot-grid" wx:if="{{availability.length}}">
<view class="slot" wx:for="{{availability}}" wx:key="startTime">
<text>{{item.dateText}}</text>
<text class="slot-time">{{item.timeText}}</text>
</view>
</view>
<text wx:else class="empty-text">近期暂未放出可预约时间</text>
</view>
<view class="section">
<view class="section-head">作品</view>
<view class="work-grid" wx:if="{{works.length}}">
<view class="work-card" wx:for="{{works}}" wx:key="id" data-id="{{item.id}}" bindtap="handleOpenWork">
<image src="{{item.coverImageUrl}}" mode="aspectFill"></image>
<text class="work-title">{{item.title}}</text>
<text class="work-price">{{item.priceText}}</text>
</view>
</view>
<text wx:else class="empty-text">作品正在整理中</text>
</view>
<view class="section">
<view class="section-head">评价 {{reviews.length}}</view>
<view class="review-list" wx:if="{{reviews.length}}">
<view class="review-card" wx:for="{{reviews}}" wx:key="id">
<view class="review-top">
<image wx:if="{{item.customerAvatar}}" class="review-avatar" src="{{item.customerAvatar}}" mode="aspectFill"></image>
<view wx:else class="review-avatar placeholder">客</view>
<view class="review-meta">
<text>{{item.customerName}}</text>
<text>{{item.submittedAtText}}</text>
</view>
<text class="review-score">{{item.ratingText}}</text>
</view>
<text class="review-content">{{item.content}}</text>
</view>
</view>
<text wx:else class="empty-text">还没有公开评价</text>
</view>
</scroll-view>
</view>
@@ -0,0 +1,336 @@
.artist-page {
min-height: 100vh;
background: #f6f7fb;
color: #1f2933;
}
.page-header {
position: sticky;
top: 0;
z-index: 5;
display: flex;
align-items: center;
justify-content: space-between;
height: 96rpx;
padding: 0 24rpx;
background: rgba(255, 255, 255, 0.95);
border-bottom: 1rpx solid #e6e9ef;
}
.back-btn,
.header-spacer {
width: 64rpx;
height: 64rpx;
line-height: 58rpx;
text-align: center;
font-size: 48rpx;
}
.page-title {
flex: 1;
overflow: hidden;
text-align: center;
font-size: 32rpx;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
}
.content-scroll {
height: calc(100vh - 96rpx);
}
.state-box {
display: flex;
min-height: 60vh;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 20rpx;
padding: 40rpx;
color: #65717f;
}
.state-title {
color: #1f2933;
font-size: 34rpx;
font-weight: 700;
}
.state-desc {
text-align: center;
line-height: 1.6;
}
.primary-btn {
padding: 18rpx 36rpx;
color: #fff;
background: var(--theme-primary-action);
border-radius: 12rpx;
}
.hero {
position: relative;
height: 520rpx;
margin: 20rpx;
overflow: hidden;
background: #222831;
border-radius: 16rpx;
}
.hero-image,
.hero-mask {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}
.hero-mask {
background: linear-gradient(180deg, rgba(10, 14, 20, 0.08), rgba(10, 14, 20, 0.72));
}
.artist-card {
position: absolute;
right: 28rpx;
bottom: 28rpx;
left: 28rpx;
display: flex;
gap: 22rpx;
align-items: center;
color: #fff;
}
.avatar {
width: 112rpx;
height: 112rpx;
flex: 0 0 auto;
overflow: hidden;
border: 3rpx solid rgba(255, 255, 255, 0.8);
border-radius: 56rpx;
}
.placeholder {
display: flex;
align-items: center;
justify-content: center;
background: #d8dde6;
color: #5f6b7a;
font-weight: 700;
}
.artist-main {
min-width: 0;
}
.artist-name,
.artist-desc,
.shop-link {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.artist-name {
font-size: 44rpx;
font-weight: 800;
}
.artist-desc {
margin-top: 10rpx;
color: rgba(255, 255, 255, 0.88);
font-size: 26rpx;
}
.shop-link {
max-width: 440rpx;
margin-top: 16rpx;
padding: 12rpx 18rpx;
background: rgba(255, 255, 255, 0.18);
border: 1rpx solid rgba(255, 255, 255, 0.28);
border-radius: 12rpx;
}
.metrics {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16rpx;
margin: 0 20rpx 20rpx;
}
.metric-item {
display: flex;
min-height: 132rpx;
flex-direction: column;
justify-content: center;
gap: 10rpx;
padding: 20rpx;
background: #fff;
border: 1rpx solid #e6e9ef;
border-radius: 16rpx;
}
.metric-item text:first-child {
color: #65717f;
font-size: 24rpx;
}
.metric-value {
overflow-wrap: anywhere;
font-size: 34rpx;
font-weight: 800;
}
.section {
margin: 20rpx;
padding: 28rpx;
background: #fff;
border: 1rpx solid #e6e9ef;
border-radius: 16rpx;
}
.section-head {
margin-bottom: 20rpx;
font-size: 32rpx;
font-weight: 800;
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 14rpx;
}
.tag {
padding: 10rpx 18rpx;
color: #394554;
background: #eef1f5;
border-radius: 999rpx;
}
.empty-text {
color: #7b8794;
line-height: 1.6;
}
.slot-grid,
.work-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16rpx;
}
.slot {
display: flex;
min-height: 104rpx;
flex-direction: column;
justify-content: center;
gap: 8rpx;
padding: 18rpx;
background: #f6f7fb;
border: 1rpx solid #dfe4ea;
border-radius: 14rpx;
}
.slot text:first-child {
color: #65717f;
font-size: 24rpx;
}
.slot-time {
font-size: 32rpx;
font-weight: 800;
}
.work-card {
overflow: hidden;
background: #fff;
border: 1rpx solid #e6e9ef;
border-radius: 14rpx;
}
.work-card image {
width: 100%;
height: 210rpx;
background: #eef1f5;
}
.work-title,
.work-price {
display: block;
overflow: hidden;
padding: 0 16rpx;
text-overflow: ellipsis;
white-space: nowrap;
}
.work-title {
margin-top: 14rpx;
font-weight: 700;
}
.work-price {
margin: 8rpx 0 16rpx;
color: var(--theme-primary-action);
font-weight: 800;
}
.review-list {
display: flex;
flex-direction: column;
gap: 18rpx;
}
.review-card {
padding: 22rpx;
background: #f8fafc;
border: 1rpx solid #e6e9ef;
border-radius: 14rpx;
}
.review-top {
display: flex;
align-items: center;
gap: 16rpx;
}
.review-avatar {
width: 72rpx;
height: 72rpx;
border-radius: 36rpx;
}
.review-meta {
flex: 1;
min-width: 0;
}
.review-meta text {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.review-meta text:last-child {
margin-top: 4rpx;
color: #7b8794;
font-size: 22rpx;
}
.review-score {
color: var(--theme-primary-action);
font-weight: 800;
}
.review-content {
display: block;
margin-top: 18rpx;
color: #3f4a56;
line-height: 1.7;
white-space: pre-wrap;
}
File diff suppressed because it is too large Load Diff
+5
View File
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
+358
View File
@@ -0,0 +1,358 @@
<view class="auth-page-root" style="{{themeVars}}">
<navigation-bar title="账号中心" showBack="{{true}}" fallbackPath="/pages/home/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<scroll-view class="auth-scroll" scroll-y="true" enhanced="true" show-scrollbar="false">
<view class="page-shell auth-page-shell auth-page">
<view class="page-content auth-content {{keyboardVisible ? 'keyboard-active' : ''}}">
<view class="auth-brand">
<image class="auth-brand-icon" src="/assets/images/app-icon.png" mode="aspectFill"></image>
</view>
<view class="page-card auth-panel">
<view class="tab-row">
<view class="tab-item {{activeTab === 'login' ? 'active' : ''}}" data-tab="login" bindtap="handleTabChange">登录</view>
<view class="tab-item {{activeTab === 'register' ? 'active' : ''}}" data-tab="register" bindtap="handleTabChange">注册</view>
</view>
<block wx:if="{{activeTab === 'login'}}">
<view wx:if="{{!traditionalLoginExpanded}}" class="wechat-login-panel">
<view class="wechat-login-copy">
<text class="wechat-login-title">微信手机号一键登录</text>
<text class="wechat-login-desc">更快登录</text>
</view>
<button
wx:if="{{wechatMiniSupported}}"
class="primary-btn wechat-login-btn"
open-type="getPhoneNumber"
bindgetphonenumber="handleWechatMiniPhoneLogin"
loading="{{wechatMiniLoading}}"
disabled="{{wechatMiniLoading || loading}}"
>
{{wechatMiniLoading ? '正在获取微信手机号...' : '微信手机号一键登录'}}
</button>
<button
wx:else
class="secondary-btn wechat-login-btn wechat-login-btn-disabled"
bindtap="handleWechatMiniUnavailableTap"
>
微信手机号一键登录
</button>
<text class="wechat-login-hint">{{wechatMiniSupported ? '单门店可直接登录' : wechatMiniDisabledReason}}</text>
<view class="agreement-row wechat-agreement" bindtap="handleAgreementToggle">
<view class="agreement-check {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view>
<view class="agreement-copy">
<text>我已阅读并同意</text>
<text class="agreement-link" data-type="USER_TERMS" catchtap="openAgreement">《用户协议》</text>
<text>和</text>
<text class="agreement-link" data-type="PRIVACY_POLICY" catchtap="openAgreement">《隐私政策》</text>
</view>
</view>
</view>
<view wx:if="{{miniShopTicket && !showMiniShopSelector}}" class="hint-card mini-login-resume">
<text class="mini-login-resume-text">请选择登录门店</text>
<view class="ghost-btn mini-login-resume-btn" bindtap="handleResumeMiniShopSelector">继续选择门店</view>
</view>
<view wx:if="{{!traditionalLoginExpanded}}" class="traditional-entry">
<view class="secondary-btn traditional-entry-btn" bindtap="handleShowTraditionalLogin">其他登录方式</view>
</view>
<view wx:if="{{traditionalLoginExpanded}}" class="traditional-login-panel">
<view class="login-divider">
<view class="divider-line"></view>
<text class="login-divider-text">其他方式</text>
<view class="divider-line"></view>
</view>
<view class="toggle-row">
<view class="toggle-item {{loginType === 'password' ? 'active' : ''}}" data-type="password" bindtap="handleLoginTypeChange">账号密码登录</view>
<view class="toggle-item {{loginType === 'phone' ? 'active' : ''}}" data-type="phone" bindtap="handleLoginTypeChange">验证码登录</view>
</view>
</view>
</block>
<view wx:if="{{activeTab === 'register' || traditionalLoginExpanded}}" class="auth-helper">{{authHelperText}}</view>
<block wx:if="{{activeTab === 'register'}}">
<view id="auth-register-nickname-anchor" class="field-block">
<text class="field-label">昵称</text>
<input
class="field-input"
placeholder="请输入昵称"
placeholder-class="field-placeholder"
value="{{form.nickname}}"
data-field="nickname"
data-keyboard-anchor="auth-register-nickname-anchor"
bindinput="handleInputChange"
bindfocus="handleKeyboardFocus"
bindblur="handleKeyboardBlur"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
</view>
</block>
<view id="auth-account-anchor" wx:if="{{activeTab === 'register' || traditionalLoginExpanded}}" class="field-block">
<text class="field-label">账号</text>
<input
class="field-input"
placeholder="请输入账号"
placeholder-class="field-placeholder"
value="{{form.account}}"
data-field="account"
data-keyboard-anchor="auth-account-anchor"
bindinput="handleInputChange"
bindblur="handleAccountBlur"
bindfocus="handleKeyboardFocus"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
<text wx:if="{{activeTab === 'login' && loginAccountStatusText}}" class="status-text {{loginAccountStatusType}}">{{loginAccountStatusText}}</text>
<text wx:if="{{activeTab === 'register' && registerAccountStatusText}}" class="status-text {{registerAccountStatusType}}">{{registerAccountStatusText}}</text>
</view>
<view id="auth-phone-anchor" wx:if="{{activeTab === 'register' || (traditionalLoginExpanded && loginType === 'phone')}}" class="field-block">
<text class="field-label">手机号</text>
<input
class="field-input"
type="number"
placeholder="请输入手机号"
placeholder-class="field-placeholder"
value="{{form.phone}}"
data-field="phone"
data-keyboard-anchor="auth-phone-anchor"
bindinput="handleInputChange"
bindblur="handlePhoneBlur"
bindfocus="handleKeyboardFocus"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
<text wx:if="{{activeTab === 'register' && registerPhoneStatusText}}" class="status-text {{registerPhoneStatusType}}">{{registerPhoneStatusText}}</text>
</view>
<view id="auth-login-password-anchor" wx:if="{{activeTab === 'login' && traditionalLoginExpanded && loginType === 'password'}}" class="field-block">
<text class="field-label">密码</text>
<input
class="field-input"
password
placeholder="请输入密码"
placeholder-class="field-placeholder"
value="{{form.password}}"
data-field="password"
data-keyboard-anchor="auth-login-password-anchor"
bindinput="handleInputChange"
bindfocus="handleKeyboardFocus"
bindblur="handleKeyboardBlur"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
</view>
<view id="auth-code-anchor" wx:if="{{activeTab === 'register' || (traditionalLoginExpanded && loginType === 'phone')}}" class="field-block">
<text class="field-label">验证码</text>
<view class="code-row">
<input
class="field-input code-input"
type="number"
placeholder="请输入验证码"
placeholder-class="field-placeholder"
value="{{form.verificationCode}}"
data-field="verificationCode"
data-keyboard-anchor="auth-code-anchor"
bindinput="handleInputChange"
bindfocus="handleKeyboardFocus"
bindblur="handleKeyboardBlur"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
<view class="code-btn {{countdown > 0 ? 'disabled' : ''}}" bindtap="handleSendCode">{{countdown > 0 ? countdown + 's' : '发送验证码'}}</view>
</view>
</view>
<view id="auth-register-password-anchor" wx:if="{{activeTab === 'register'}}" class="field-block">
<text class="field-label">密码</text>
<input
class="field-input"
password
placeholder="请输入密码"
placeholder-class="field-placeholder"
value="{{form.password}}"
data-field="password"
data-keyboard-anchor="auth-register-password-anchor"
bindinput="handleInputChange"
bindfocus="handleKeyboardFocus"
bindblur="handleKeyboardBlur"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
</view>
<view id="auth-register-confirm-password-anchor" wx:if="{{activeTab === 'register'}}" class="field-block">
<text class="field-label">确认密码</text>
<input
class="field-input"
password
placeholder="请再次输入密码"
placeholder-class="field-placeholder"
value="{{form.confirmPassword}}"
data-field="confirmPassword"
data-keyboard-anchor="auth-register-confirm-password-anchor"
bindinput="handleInputChange"
bindfocus="handleKeyboardFocus"
bindblur="handleKeyboardBlur"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
</view>
<view wx:if="{{activeTab === 'register'}}" class="field-block">
<text class="field-label">选择门店</text>
<picker mode="selector" range="{{shops}}" range-key="shopName" value="{{registerShopIndex}}" bindchange="handleRegisterShopChange">
<view class="field-picker">{{registerShopDisplayName || '请选择门店'}}</view>
</picker>
</view>
<view wx:if="{{activeTab === 'login' && traditionalLoginExpanded && loginShops.length}}" class="field-block">
<text class="field-label">选择登录门店</text>
<picker mode="selector" range="{{loginShops}}" range-key="shopName" value="{{loginShopIndex}}" bindchange="handleLoginShopChange">
<view class="field-picker">{{loginShopDisplayName || '请选择登录门店'}}</view>
</picker>
</view>
<view wx:if="{{activeTab === 'login' && traditionalLoginExpanded && loginShopMessage}}" class="hint-card login-shop-tip">{{loginShopMessage}}</view>
<view wx:if="{{activeTab === 'login' && traditionalLoginExpanded}}" class="aux-row">
<text class="aux-link" bindtap="handleToggleResetPanel">忘记密码?</text>
</view>
<view wx:if="{{activeTab === 'register' || traditionalLoginExpanded}}" class="agreement-row" bindtap="handleAgreementToggle">
<view class="agreement-check {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view>
<view class="agreement-copy">
<text>我已阅读并同意</text>
<text class="agreement-link" data-type="USER_TERMS" catchtap="openAgreement">《用户协议》</text>
<text>和</text>
<text class="agreement-link" data-type="PRIVACY_POLICY" catchtap="openAgreement">《隐私政策》</text>
</view>
</view>
<view wx:if="{{activeTab === 'register' || traditionalLoginExpanded}}" class="primary-btn submit-btn {{agreementAccepted ? '' : 'disabled'}}" bindtap="handleSubmit">{{activeTab === 'login' ? '立即登录' : '完成注册'}}</view>
</view>
<view wx:if="{{showResetPanel}}" class="page-card reset-card">
<view class="section-title">重置密码</view>
<view class="section-subtitle">短信验证后重置密码</view>
<view id="auth-reset-phone-anchor" class="field-block">
<text class="field-label">手机号</text>
<input
class="field-input"
type="number"
placeholder="请输入绑定手机号"
placeholder-class="field-placeholder"
value="{{resetForm.phone}}"
data-field="phone"
data-keyboard-anchor="auth-reset-phone-anchor"
bindinput="handleResetInputChange"
bindfocus="handleKeyboardFocus"
bindblur="handleKeyboardBlur"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
</view>
<view id="auth-reset-code-anchor" class="field-block">
<text class="field-label">验证码</text>
<view class="code-row">
<input
class="field-input code-input"
type="number"
placeholder="请输入验证码"
placeholder-class="field-placeholder"
value="{{resetForm.verificationCode}}"
data-field="verificationCode"
data-keyboard-anchor="auth-reset-code-anchor"
bindinput="handleResetInputChange"
bindfocus="handleKeyboardFocus"
bindblur="handleKeyboardBlur"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
<view class="code-btn {{forgotCountdown > 0 ? 'disabled' : ''}}" bindtap="handleSendForgotCode">{{forgotCountdown > 0 ? forgotCountdown + 's' : '发送验证码'}}</view>
</view>
</view>
<view id="auth-reset-password-anchor" class="field-block">
<text class="field-label">新密码</text>
<input
class="field-input"
password
placeholder="请输入新密码"
placeholder-class="field-placeholder"
value="{{resetForm.newPassword}}"
data-field="newPassword"
data-keyboard-anchor="auth-reset-password-anchor"
bindinput="handleResetInputChange"
bindfocus="handleKeyboardFocus"
bindblur="handleKeyboardBlur"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
></input>
</view>
<view class="primary-btn submit-btn" bindtap="handleResetPassword">确认重置密码</view>
</view>
</view>
<view wx:if="{{keyboardVisible}}" class="keyboard-spacer" style="height: {{keyboardInsetRpx}}rpx;"></view>
</view>
</scroll-view>
<view wx:if="{{showMiniShopSelector}}" class="mini-shop-mask" catchtouchmove="noop">
<view class="page-card mini-shop-modal">
<text class="mini-shop-kicker">{{miniShopNewUser ? '首次微信登录' : '确认本次登录门店'}}</text>
<text class="mini-shop-title">{{miniShopNewUser ? '先选门店' : '选择登录门店'}}</text>
<text class="mini-shop-desc">{{miniShopMessage || '选择后继续登录'}}</text>
<view class="field-block mini-shop-field">
<text class="field-label">登录门店</text>
<picker mode="selector" range="{{miniShops}}" range-key="shopName" value="{{miniShopIndex}}" bindchange="handleMiniShopChange">
<view class="field-picker">{{miniShopDisplayName || '请选择门店'}}</view>
</picker>
</view>
<view wx:if="{{miniShopNewUser}}" class="hint-card mini-shop-note">首次登录会自动注册并绑定手机号。</view>
<view class="agreement-row mini-shop-agreement" bindtap="handleAgreementToggle">
<view class="agreement-check {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view>
<view class="agreement-copy">
<text>我已阅读并同意</text>
<text class="agreement-link" data-type="USER_TERMS" catchtap="openAgreement">《用户协议》</text>
<text>和</text>
<text class="agreement-link" data-type="PRIVACY_POLICY" catchtap="openAgreement">《隐私政策》</text>
</view>
</view>
<view class="mini-shop-actions">
<view class="secondary-btn mini-shop-action" bindtap="handleCloseMiniShopSelector">稍后再选</view>
<view class="primary-btn mini-shop-action" bindtap="handleConfirmMiniShopLogin">{{miniShopSubmitting ? '确认中...' : '确认登录'}}</view>
</view>
</view>
</view>
<view wx:if="{{agreementModalVisible}}" class="agreement-mask" catchtouchmove="noop">
<view class="agreement-modal">
<view class="agreement-modal-title">{{selectedAgreement.title || '协议详情'}}</view>
<view class="agreement-modal-meta">版本:{{selectedAgreement.version || '-'}}</view>
<scroll-view class="agreement-modal-body" scroll-y="true">
<text>{{selectedAgreement.content || '暂无协议内容'}}</text>
</scroll-view>
<view class="primary-btn agreement-modal-close" bindtap="closeAgreementModal">我知道了</view>
</view>
</view>
</view>
+425
View File
@@ -0,0 +1,425 @@
.auth-page-root {
min-height: 100vh;
overflow: visible;
}
.auth-scroll {
height: 100vh;
box-sizing: border-box;
}
.auth-page-shell {
min-height: 100%;
}
.auth-page {
background: var(--theme-page-bg);
}
.auth-content {
min-height: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
padding: 24rpx 24rpx calc(80rpx + env(safe-area-inset-bottom));
}
.auth-content.keyboard-active {
justify-content: flex-start;
align-items: stretch;
}
.auth-brand {
display: flex;
justify-content: center;
width: 100%;
margin: 16rpx 0 20rpx;
}
.auth-brand-icon {
width: 112rpx;
height: 112rpx;
border-radius: 30rpx;
background: var(--theme-primary-soft);
box-shadow: 0 18rpx 40rpx rgba(122, 67, 88, 0.14);
}
.auth-panel,
.reset-card {
width: 100%;
max-width: 680rpx;
padding: 30rpx 28rpx;
}
.auth-panel {
margin-top: 0;
}
.reset-card {
margin-top: 18rpx;
margin-left: auto;
margin-right: auto;
}
.tab-row,
.toggle-row {
display: flex;
align-items: center;
gap: 12rpx;
}
.tab-row {
margin-bottom: 20rpx;
}
.toggle-row {
margin-bottom: 14rpx;
padding: 10rpx;
border-radius: 999rpx;
background: var(--theme-primary-soft);
}
.tab-item,
.toggle-item {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
height: 76rpx;
border-radius: 999rpx;
color: var(--text-secondary);
font-size: 26rpx;
font-weight: 600;
}
.tab-item.active,
.toggle-item.active {
background: var(--theme-primary-soft);
color: var(--theme-primary);
}
.wechat-login-panel {
padding: 24rpx 22rpx;
border-radius: 28rpx;
background: var(--theme-gradient-soft);
border: 1rpx solid var(--theme-border);
box-shadow: 0 18rpx 38rpx rgba(74, 68, 63, 0.1);
}
.wechat-login-copy {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.wechat-login-title {
display: block;
font-size: 29rpx;
font-weight: 700;
color: var(--text-primary);
}
.wechat-login-desc {
display: block;
font-size: 24rpx;
line-height: 1.6;
color: var(--text-secondary);
}
.wechat-login-btn {
margin-top: 18rpx;
}
.wechat-login-btn.primary-btn {
background: var(--theme-gradient);
box-shadow: 0 16rpx 36rpx rgba(74, 68, 63, 0.16);
}
.wechat-login-btn-disabled {
color: var(--theme-accent);
border-color: var(--theme-border);
background: var(--theme-card-bg);
}
.wechat-login-hint {
display: block;
margin-top: 14rpx;
font-size: 22rpx;
line-height: 1.6;
color: var(--theme-accent);
}
.mini-login-resume {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18rpx;
margin-top: 18rpx;
}
.mini-login-resume-text {
flex: 1;
min-width: 0;
}
.mini-login-resume-btn {
flex-shrink: 0;
}
.traditional-entry {
margin-top: 18rpx;
}
.traditional-entry-btn {
color: var(--theme-primary-action);
background: var(--theme-card-bg);
}
.traditional-login-panel {
margin-top: 18rpx;
}
.login-divider {
display: flex;
align-items: center;
gap: 18rpx;
margin: 0 0 16rpx;
}
.login-divider-text {
flex-shrink: 0;
font-size: 22rpx;
color: var(--text-secondary);
}
.auth-helper {
margin-bottom: 4rpx;
font-size: 22rpx;
line-height: 1.6;
color: var(--text-secondary);
}
.field-block {
margin-top: 16rpx;
}
.code-row {
display: flex;
align-items: center;
gap: 14rpx;
}
.code-input {
flex: 1;
}
.code-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 180rpx;
height: 92rpx;
padding: 0 18rpx;
border-radius: 24rpx;
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-size: 24rpx;
font-weight: 700;
}
.code-btn.disabled {
background: var(--theme-secondary-soft);
color: var(--text-secondary);
}
.aux-row {
display: flex;
justify-content: flex-end;
margin-top: 16rpx;
}
.aux-link {
font-size: 24rpx;
color: var(--theme-primary);
font-weight: 600;
}
.login-shop-tip {
margin-top: 16rpx;
}
.submit-btn {
margin-top: 24rpx;
}
.submit-btn.disabled {
opacity: 0.52;
}
.agreement-row {
display: flex;
align-items: flex-start;
gap: 14rpx;
margin-top: 22rpx;
color: var(--text-secondary);
font-size: 23rpx;
line-height: 1.6;
}
.agreement-check {
display: flex;
align-items: center;
justify-content: center;
width: 34rpx;
height: 34rpx;
margin-top: 2rpx;
border: 2rpx solid var(--theme-border);
border-radius: 10rpx;
color: var(--theme-card-bg);
font-size: 22rpx;
font-weight: 800;
flex-shrink: 0;
}
.agreement-check.checked {
border-color: var(--theme-primary);
background: var(--theme-primary);
}
.agreement-copy {
flex: 1;
min-width: 0;
}
.agreement-link {
color: var(--theme-primary);
font-weight: 700;
}
.mini-shop-agreement {
margin-top: 22rpx;
}
.wechat-agreement {
width: 100%;
margin-top: 18rpx;
text-align: left;
}
.agreement-mask {
position: fixed;
inset: 0;
z-index: 80;
display: flex;
align-items: center;
justify-content: center;
padding: 28rpx;
background: rgba(74, 68, 63, 0.42);
}
.agreement-modal {
width: 100%;
max-width: 690rpx;
max-height: 82vh;
padding: 30rpx 28rpx;
border-radius: 32rpx;
background: var(--theme-card-bg);
}
.agreement-modal-title {
font-size: 32rpx;
line-height: 1.35;
font-weight: 800;
color: var(--text-primary);
}
.agreement-modal-meta {
margin-top: 10rpx;
font-size: 22rpx;
color: var(--text-secondary);
}
.agreement-modal-body {
height: 640rpx;
max-height: 56vh;
margin-top: 22rpx;
padding: 20rpx;
border-radius: 22rpx;
background: var(--theme-primary-soft);
color: var(--text-primary);
font-size: 24rpx;
line-height: 1.85;
box-sizing: border-box;
}
.agreement-modal-close {
margin-top: 22rpx;
}
.mini-shop-mask {
position: fixed;
inset: 0;
z-index: 60;
display: flex;
align-items: center;
justify-content: center;
padding: 24rpx;
background: rgba(74, 68, 63, 0.34);
}
.mini-shop-modal {
width: 100%;
max-width: 680rpx;
padding: 30rpx 28rpx;
border-radius: 36rpx;
background: var(--theme-card-bg);
}
.mini-shop-kicker {
display: block;
font-size: 22rpx;
font-weight: 700;
letter-spacing: 2rpx;
color: var(--theme-primary);
}
.mini-shop-title {
display: block;
margin-top: 16rpx;
font-size: 34rpx;
line-height: 1.35;
font-weight: 700;
color: var(--text-primary);
}
.mini-shop-desc {
display: block;
margin-top: 14rpx;
font-size: 24rpx;
line-height: 1.75;
color: var(--text-secondary);
}
.mini-shop-field {
margin-top: 26rpx;
}
.mini-shop-note {
margin-top: 20rpx;
}
.mini-shop-actions {
display: flex;
gap: 16rpx;
margin-top: 24rpx;
}
.mini-shop-action {
flex: 1;
}
.keyboard-spacer {
width: 100%;
flex-shrink: 0;
}
+830
View File
@@ -0,0 +1,830 @@
/**
* 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: 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')
const { runWithLoading } = require('../../utils/loading')
const { clearBuyNowContext, isBuyNowCartItem, readBuyNowContext } = require('../../utils/buy-now')
const { buildRecoveryState, clearRecoveryState } = require('../../utils/recovery')
const {
buildAppointmentValue,
formatDateTime,
formatPrice,
getMinDateText,
isPastAppointment,
parseAppointmentParts
} = require('../../utils/format')
function buildClientRequestId(prefix) {
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`
}
/**
* 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 (coupon && coupon.displayText) {
return coupon.displayText
}
if (Number(coupon.couponType) === 1) {
return `${coupon.couponName} ${coupon.discountValue} 折`
}
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.
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
*/
if (!coupon || amount <= 0) {
return 0
}
if (coupon.discountAmount !== undefined && coupon.discountAmount !== null) {
return Number(coupon.discountAmount || 0)
}
if (Number(coupon.couponType) === 1) {
const discountValue = Number(coupon.discountValue || 0)
return discountValue ? amount - amount * discountValue / 10 : 0
}
if (Number(coupon.couponType) === 2) {
return Number(coupon.reduceAmount || 0)
}
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)
/**
* `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 (!selectedItems.length) {
issues.push('请先勾选要结算的作品')
return issues
}
const missingArtist = selectedItems.find(item => !item.artistId)
/**
* `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 (missingArtist) {
issues.push(`请先为“${missingArtist.productTitle}”选择美甲师`)
}
const missingTime = selectedItems.find(item => !item.appointmentValue)
/**
* `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 (missingTime) {
issues.push(`请先为“${missingTime.productTitle}”选择预约时间`)
}
const expiredTime = selectedItems.find(item => item.appointmentValue && isPastAppointment(item.appointmentValue))
/**
* `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 (expiredTime) {
issues.push(`“${expiredTime.productTitle}”的预约时间已过,请重新选择`)
}
const shopIds = Array.from(new Set(selectedItems.map(item => item.shopId).filter(Boolean)))
/**
* `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 (shopIds.length > 1) {
issues.push('跨门店作品请分开结算')
}
const artistIds = Array.from(new Set(selectedItems.map(item => item.artistId).filter(Boolean)))
/**
* `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 (artistIds.length > 1) {
issues.push('不同美甲师的项目请分开结算')
}
return issues
}
/**
* cart page logic.
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
*/
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
isLoggedIn: false,
loading: false,
minDate: getMinDateText(),
cartItems: [],
availableCoupons: [],
unavailableCoupons: [],
checkoutPreview: null,
vipTip: '',
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,
isBuyNowMode: false,
heroKicker: '结算准备',
heroTitle: '已选 0 个预约项目',
heroDesc: '确认美甲师和时间后再下单。',
totalQuantity: 0,
subtotalAmount: 0,
subtotalText: '¥0.00',
discountAmountText: '¥0.00',
totalAmountText: '¥0.00',
checkoutIssues: [],
submittingOrder: false,
recoveryState: clearRecoveryState()
}),
/**
* `onShow` 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.
*/
onShow() {
this.loadCartItems()
},
async onPullDownRefresh() {
await this.loadCartItems()
wx.stopPullDownRefresh()
},
/**
* `getSelectedItems` 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.
*/
getSelectedItems() {
return this.data.cartItems.filter(item => item.selected)
},
/**
* `getSelectedCoupon` 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.
*/
getSelectedCoupon() {
return this.data.availableCoupons.find(item => item.key === this.data.selectedCouponKey) || null
},
/**
* `refreshSummary` 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.
*/
refreshSummary() {
const selectedItems = this.getSelectedItems()
const selectedCoupon = this.getSelectedCoupon()
const selectedCount = selectedItems.length
const totalQuantity = selectedItems.reduce((sum, item) => sum + Number(item.quantity || 0), 0)
const localSubtotalAmount = selectedItems.reduce((sum, item) => sum + Number(item.price || 0) * Number(item.quantity || 0), 0)
const preview = this.data.checkoutPreview || {}
const subtotalAmount = preview.subtotalAmount !== undefined ? Number(preview.subtotalAmount || 0) : localSubtotalAmount
const discountAmount = preview.savedAmount !== undefined ? Number(preview.savedAmount || 0) : calculateCouponDiscount(selectedCoupon, subtotalAmount)
const totalAmount = preview.payableAmount !== undefined ? Number(preview.payableAmount || 0) : Math.max(0, subtotalAmount - discountAmount)
const checkoutIssues = buildCheckoutIssues(this.data.cartItems)
const isBuyNowMode = Boolean(this.data.isBuyNowMode)
this.setData({
selectedCount,
heroKicker: isBuyNowMode ? '确认订单' : '结算准备',
heroTitle: isBuyNowMode ? '确认本次预约' : `已选 ${selectedCount} 个预约项目`,
heroDesc: isBuyNowMode ? '本次只会提交刚刚选择的作品,不会混入购物车其他项目。' : '确认美甲师和时间后再下单。',
totalQuantity,
subtotalAmount,
subtotalText: `¥${formatPrice(subtotalAmount)}`,
discountAmountText: `¥${formatPrice(discountAmount)}`,
totalAmountText: `¥${formatPrice(totalAmount)}`,
checkoutIssues
})
},
async loadCartItems() {
const isLoggedIn = auth.isLoggedIn()
const buyNowContext = isLoggedIn ? readBuyNowContext() : null
const buyNowProductId = buyNowContext && buyNowContext.productId ? String(buyNowContext.productId) : ''
this.setData({
isLoggedIn,
isBuyNowMode: Boolean(buyNowProductId),
loading: isLoggedIn,
recoveryState: clearRecoveryState()
})
/**
* `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 (!isLoggedIn) {
this.setData({
cartItems: [],
availableCoupons: [],
unavailableCoupons: [],
checkoutPreview: null,
vipTip: '',
selectedCouponKey: NO_COUPON_KEY,
couponSelectionTouched: false,
loading: false,
recoveryState: clearRecoveryState()
})
this.refreshSummary()
return
}
try {
const cartItems = await cartApi.getCartList()
const list = Array.isArray(cartItems) ? cartItems : []
const formattedItems = await Promise.all(list.map(async item => {
const appointmentParts = parseAppointmentParts(item.appointmentTime)
const productImageUrl = await resolveLegacyImage(item.productImage)
const availableArtists = Array.isArray(item.availableArtists) ? item.availableArtists.map(artist => ({
id: artist.id,
name: artist.name,
avatar: artist.avatar,
userType: artist.userType,
roleLabel: artist.roleLabel,
participateProduction: artist.participateProduction
})) : []
const artist = availableArtists.find(current => String(current.id) === String(item.artistId || ''))
return {
...item,
productImageUrl,
priceText: `¥${formatPrice(item.price)}`,
selected: buyNowProductId ? isBuyNowCartItem(item, buyNowProductId) : true,
artistId: item.artistId || '',
artistName: artist ? artist.name : '',
availableArtists,
appointmentDate: appointmentParts.date,
appointmentClock: appointmentParts.clock,
appointmentValue: buildAppointmentValue(appointmentParts.date, appointmentParts.clock)
}
}))
this.setData({
cartItems: formattedItems,
selectedCouponKey: NO_COUPON_KEY,
couponSelectionTouched: false,
recoveryState: clearRecoveryState()
})
if (buyNowProductId) {
clearBuyNowContext()
}
await this.loadAvailableCoupons()
} catch (error) {
this.setData({
cartItems: [],
recoveryState: buildRecoveryState({
title: '购物车加载失败',
message: error,
fallbackMessage: '购物车暂时没有加载出来,请重试或先去逛作品。',
actions: [
{ key: 'retryCartLoad', text: '重试' },
{ key: 'products', text: '去逛作品' },
{ key: 'contact', text: '联系客服' }
]
})
})
} finally {
this.setData({
loading: false
})
this.refreshSummary()
}
},
async loadAvailableCoupons() {
const selectedItems = this.getSelectedItems()
/**
* `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 (!selectedItems.length) {
this.setData({
availableCoupons: [],
unavailableCoupons: [],
checkoutPreview: null,
vipTip: '',
selectedCouponKey: NO_COUPON_KEY,
couponSelectionTouched: false
})
this.refreshSummary()
return
}
try {
const selectedCoupon = this.getSelectedCoupon()
const preview = await orderApi.checkoutPreview({
couponId: selectedCoupon ? selectedCoupon.id : undefined,
couponSourceType: selectedCoupon ? selectedCoupon.sourceType : (this.data.couponSelectionTouched && this.data.selectedCouponKey === NO_COUPON_KEY ? NO_COUPON_KEY : undefined),
items: selectedItems.map(item => ({
productId: item.productId,
quantity: item.quantity,
artistId: item.artistId,
appointmentTime: item.appointmentValue
}))
})
const list = Array.isArray(preview && preview.availableCoupons) ? preview.availableCoupons.map(item => ({
...item,
key: getCouponKey(item),
displayText: getCouponDisplay(item)
})) : []
const unavailableCoupons = Array.isArray(preview && preview.unavailableCoupons) ? preview.unavailableCoupons.map(item => ({
...item,
key: getCouponKey(item),
displayText: getCouponDisplay(item)
})) : []
let selectedCouponKey = this.data.selectedCouponKey
if (selectedCouponKey !== NO_COUPON_KEY && !list.find(item => item.key === selectedCouponKey)) {
selectedCouponKey = NO_COUPON_KEY
}
const previewSubtotalAmount = Number((preview && preview.subtotalAmount) || this.data.subtotalAmount || 0)
/**
* `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 && !this.data.couponSelectionTouched) {
const bestCoupons = list
.sort((left, right) => calculateCouponDiscount(right, previewSubtotalAmount) - calculateCouponDiscount(left, previewSubtotalAmount))
/**
* `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 (bestCoupons.length) {
selectedCouponKey = bestCoupons[0].key
}
}
this.setData({
availableCoupons: list,
unavailableCoupons,
checkoutPreview: preview || null,
vipTip: preview && preview.vipTip ? preview.vipTip : '',
selectedCouponKey
})
} catch (error) {
this.setData({
availableCoupons: [],
unavailableCoupons: [],
checkoutPreview: null,
vipTip: '',
selectedCouponKey: NO_COUPON_KEY,
couponSelectionTouched: false
})
} finally {
this.refreshSummary()
}
},
/**
* `handleOpenAuth` 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.
*/
handleOpenAuth() {
navigation.openAuth('/pages/cart/index')
},
/**
* `handleBrowseProducts` 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.
*/
handleBrowseProducts() {
navigation.switchTab('/pages/products/index')
},
handleRecoveryAction(event) {
const key = event.currentTarget.dataset.key
if (key === 'retryCartLoad') {
this.setData({ recoveryState: clearRecoveryState() })
this.loadCartItems()
return
}
if (key === 'retryCheckout') {
this.setData({ recoveryState: clearRecoveryState() })
this.handleCheckout()
return
}
if (key === 'contact') {
this.handleContactSupport()
return
}
if (key === 'cart') {
this.setData({ recoveryState: clearRecoveryState() })
return
}
const actions = this.data.recoveryState.actions || []
const action = actions.find(item => item.key === key)
if (action && action.route) {
this.openRecoveryRoute(action.route)
}
},
openRecoveryRoute(route) {
const pureRoute = String(route || '').split('?')[0]
if (!pureRoute) {
return
}
if (navigation.isTabPage(pureRoute)) {
navigation.switchTab(pureRoute)
return
}
navigation.navigate(route)
},
handleContactSupport() {
wx.showModal({
title: '联系客服',
content: '请截图保留失败提示;如果担心重复下单,请先查看订单。也可以前往“我的”页联系门店或平台客服。',
confirmText: '去我的',
cancelText: '留在本页',
success: res => {
if (res.confirm) {
navigation.switchTab('/pages/profile/index')
}
}
})
},
async handleToggleSelect(event) {
const index = Number(event.currentTarget.dataset.index)
const cartItems = this.data.cartItems.slice()
const item = cartItems[index]
/**
* `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 (!item) {
return
}
item.selected = !item.selected
this.setData({
cartItems
})
if (cartItems.some(current => current.selected)) {
await runWithLoading(() => this.loadAvailableCoupons())
return
}
await this.loadAvailableCoupons()
},
async handleChangeQuantity(event) {
const index = Number(event.currentTarget.dataset.index)
const delta = Number(event.currentTarget.dataset.delta)
const cartItems = this.data.cartItems.slice()
const item = cartItems[index]
/**
* `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 (!item) {
return
}
const nextQuantity = Number(item.quantity || 0) + delta
/**
* `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 (nextQuantity < 1 || nextQuantity > 99) {
return
}
item.quantity = nextQuantity
this.setData({
cartItems
})
this.refreshSummary()
try {
await runWithLoading(async () => {
await cartApi.updateCartQuantity({
productId: item.productId,
quantity: nextQuantity
})
await this.loadAvailableCoupons()
})
await getApp().updateCartBadge()
} catch (error) {
item.quantity -= delta
this.setData({
cartItems
})
this.refreshSummary()
wx.showToast({
title: error.message || '数量更新失败',
icon: 'none'
})
}
},
async handleRemoveItem(event) {
const index = Number(event.currentTarget.dataset.index)
const cartItems = this.data.cartItems.slice()
const item = cartItems[index]
/**
* `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 (!item) {
return
}
const confirmed = await new Promise(resolve => {
wx.showModal({
title: '移除作品',
content: '确认从购物车移除这件作品吗?',
success: res => resolve(Boolean(res.confirm))
})
})
/**
* `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 (!confirmed) {
return
}
try {
await runWithLoading(() => cartApi.removeFromCart(item.productId))
wx.showToast({
title: '已移出购物车',
icon: 'none'
})
await getApp().updateCartBadge()
this.loadCartItems()
} catch (error) {
wx.showToast({
title: error.message || '移除失败',
icon: 'none'
})
}
},
/**
* `handleOpenProduct` 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.
*/
handleOpenProduct(event) {
const productId = event.currentTarget.dataset.productId
/**
* `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 (!productId) {
return
}
navigation.navigate('/pages/product-detail/index', {
id: productId
})
},
async handleChooseArtist(event) {
const index = Number(event.currentTarget.dataset.index)
const cartItems = this.data.cartItems.slice()
const item = cartItems[index]
/**
* `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 (!item) {
return
}
/**
* `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 (!item.availableArtists.length) {
wx.showToast({
title: '当前作品暂时没有可预约美甲师',
icon: 'none'
})
return
}
const tapIndex = await new Promise(resolve => {
wx.showActionSheet({
itemList: item.availableArtists.map(artist => artist.roleLabel ? `${artist.name}(${artist.roleLabel})` : artist.name),
success: res => resolve(res.tapIndex),
fail: () => resolve(-1)
})
})
/**
* `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 (tapIndex < 0 || tapIndex >= item.availableArtists.length) {
return
}
const artist = item.availableArtists[tapIndex]
item.artistId = artist.id
item.artistName = artist.roleLabel ? `${artist.name}(${artist.roleLabel})` : artist.name
this.setData({
cartItems
})
this.refreshSummary()
},
/**
* `handleDateChange` 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.
*/
handleDateChange(event) {
const index = Number(event.currentTarget.dataset.index)
const cartItems = this.data.cartItems.slice()
const item = cartItems[index]
/**
* `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 (!item) {
return
}
item.appointmentDate = event.detail.value
item.appointmentValue = buildAppointmentValue(item.appointmentDate, item.appointmentClock)
this.setData({
cartItems
})
this.refreshSummary()
},
/**
* `handleTimeChange` 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.
*/
handleTimeChange(event) {
const index = Number(event.currentTarget.dataset.index)
const cartItems = this.data.cartItems.slice()
const item = cartItems[index]
/**
* `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 (!item) {
return
}
item.appointmentClock = event.detail.value
item.appointmentValue = buildAppointmentValue(item.appointmentDate, item.appointmentClock)
this.setData({
cartItems
})
this.refreshSummary()
},
/**
* `handleCouponChange` 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.
*/
handleCouponChange(event) {
this.setData({
selectedCouponKey: event.detail.value,
couponSelectionTouched: true
})
this.loadAvailableCoupons()
},
async handleCheckout() {
/**
* `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 (this.data.submittingOrder) {
return
}
const selectedItems = this.getSelectedItems()
const checkoutIssues = buildCheckoutIssues(this.data.cartItems)
/**
* `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 (checkoutIssues.length) {
wx.showToast({
title: checkoutIssues[0],
icon: 'none'
})
return
}
this.setData({
submittingOrder: true
})
try {
const selectedCoupon = this.getSelectedCoupon()
await runWithLoading(() => orderApi.createOrder({
couponId: selectedCoupon ? selectedCoupon.id : undefined,
couponSourceType: selectedCoupon ? selectedCoupon.sourceType : (this.data.selectedCouponKey === NO_COUPON_KEY ? NO_COUPON_KEY : undefined),
clientRequestId: buildClientRequestId('mini-order'),
items: selectedItems.map(item => ({
productId: item.productId,
quantity: item.quantity,
artistId: item.artistId,
appointmentTime: item.appointmentValue
}))
}))
let successToast = '订单创建成功'
try {
await getApp().updateCartBadge()
await this.loadCartItems()
} catch (followupError) {
console.error('订单创建后刷新页面失败:', followupError)
successToast = '订单已创建,但页面刷新失败,请前往订单页查看'
}
try {
await navigation.navigate('/pages/orders/index')
} catch (navigationError) {
console.error('订单创建后跳转订单页失败:', navigationError)
successToast = '订单已创建,但跳转订单页失败,请手动前往订单页查看'
}
wx.showToast({
title: successToast,
icon: 'none'
})
} catch (error) {
this.setData({
recoveryState: buildRecoveryState({
title: '下单失败',
message: error,
fallbackMessage: '订单创建失败,请重试;如果担心重复下单,请先查看订单。',
actions: [
{ key: 'retryCheckout', text: '重试下单' },
{ key: 'orders', text: '查看订单' },
{ key: 'contact', text: '联系客服' },
{ key: 'cart', text: '返回购物车' }
]
})
})
} finally {
this.setData({
submittingOrder: false
})
}
}
})
+6
View File
@@ -0,0 +1,6 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
},
"enablePullDownRefresh": true
}
+197
View File
@@ -0,0 +1,197 @@
<navigation-bar title="购物车" showBack="{{false}}" isTabPage="{{true}}" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell cart-page" style="{{themeVars}}">
<view class="page-content cart-content">
<view wx:if="{{!isLoggedIn}}" class="page-card empty-card">
<text class="empty-title">登录后查看购物车</text>
<text class="empty-desc">登录后管理预约内容。</text>
<view class="ghost-btn" bindtap="handleOpenAuth">去登录</view>
</view>
<block wx:elif="{{cartItems.length}}">
<view wx:if="{{recoveryState.visible}}" class="page-card recovery-card">
<text class="recovery-title">{{recoveryState.title}}</text>
<text class="recovery-desc">{{recoveryState.message}}</text>
<view class="recovery-actions">
<view
wx:for="{{recoveryState.actions}}"
wx:key="key"
class="recovery-btn {{item.primary ? 'primary' : ''}}"
data-key="{{item.key}}"
bindtap="handleRecoveryAction"
>{{item.text}}</view>
</view>
</view>
<view class="page-hero cart-hero">
<text class="hero-kicker">{{heroKicker}}</text>
<text class="hero-title">{{heroTitle}}</text>
<text class="hero-desc">{{heroDesc}}</text>
<view class="summary-strip">
<view class="summary-metric">
<text class="summary-label">选中项目</text>
<text class="summary-value">{{selectedCount}} 项</text>
<text class="summary-note">可分批结算</text>
</view>
<view class="summary-metric">
<text class="summary-label">数量合计</text>
<text class="summary-value">{{totalQuantity}} 件</text>
<text class="summary-note">可改数量</text>
</view>
<view class="summary-metric">
<text class="summary-label">待支付</text>
<text class="summary-value">{{totalAmountText}}</text>
<text class="summary-note">已算优惠</text>
</view>
</view>
</view>
<view wx:if="{{checkoutIssues.length}}" class="issue-card">
<view class="issue-title">下单前还需要完善</view>
<view wx:for="{{checkoutIssues}}" wx:key="*this" class="issue-item">{{index + 1}}. {{item}}</view>
</view>
<view wx:for="{{cartItems}}" wx:key="id" class="page-card cart-item-card">
<view class="cart-item-top">
<view class="select-dot {{item.selected ? 'active' : ''}}" data-index="{{index}}" bindtap="handleToggleSelect"></view>
<image class="cart-thumb" src="{{item.productImageUrl}}" mode="aspectFill" data-product-id="{{item.productId}}" bindtap="handleOpenProduct" lazy-load="{{true}}"></image>
<view class="cart-main">
<view class="cart-title-row">
<view class="cart-title" data-product-id="{{item.productId}}" bindtap="handleOpenProduct">{{item.productTitle}}</view>
<view class="cart-price">{{item.priceText}}</view>
</view>
<view class="cart-meta-row">
<text class="meta-chip">{{item.selected ? '已选中' : '未选中'}}</text>
<text wx:if="{{item.approximateDuration}}" class="cart-meta">预计时长 {{item.approximateDuration}}</text>
</view>
</view>
</view>
<view class="selector-group">
<view class="selector-row {{item.selected && !item.artistId ? 'issue' : ''}}" data-index="{{index}}" bindtap="handleChooseArtist">
<text class="selector-label">美甲师</text>
<text class="selector-value">{{item.artistName || '请选择美甲师'}}</text>
</view>
<view class="time-grid">
<picker mode="date" value="{{item.appointmentDate}}" start="{{minDate}}" data-index="{{index}}" bindchange="handleDateChange">
<view class="selector-row compact {{item.selected && !item.appointmentDate ? 'issue' : ''}}">
<text class="selector-label">日期</text>
<text class="selector-value">{{item.appointmentDate || '选择日期'}}</text>
</view>
</picker>
<picker mode="time" value="{{item.appointmentClock}}" data-index="{{index}}" bindchange="handleTimeChange">
<view class="selector-row compact {{item.selected && !item.appointmentClock ? 'issue' : ''}}">
<text class="selector-label">时间</text>
<text class="selector-value">{{item.appointmentClock || '选择时间'}}</text>
</view>
</picker>
</view>
<view wx:if="{{item.appointmentValue}}" class="appointment-preview">
当前预约:{{item.appointmentValue}}
</view>
</view>
<view class="cart-item-foot">
<view class="qty-box">
<view class="qty-btn" data-index="{{index}}" data-delta="-1" bindtap="handleChangeQuantity">-</view>
<text class="qty-value">{{item.quantity}}</text>
<view class="qty-btn" data-index="{{index}}" data-delta="1" bindtap="handleChangeQuantity">+</view>
</view>
<view class="remove-btn" data-index="{{index}}" bindtap="handleRemoveItem">移除</view>
</view>
</view>
<view wx:if="{{selectedCount}}" class="page-card coupon-card">
<view class="section-title">优惠方式</view>
<view class="section-subtitle">{{vipTip || '系统会优先匹配 VIP 优惠。'}}</view>
<radio-group bindchange="handleCouponChange">
<label class="coupon-option">
<radio value="NONE" checked="{{selectedCouponKey === 'NONE'}}" color="{{navThemeColor || '#E8B4B8'}}"></radio>
<view class="coupon-texts">
<view class="coupon-name">不使用优惠</view>
</view>
</label>
<label wx:for="{{availableCoupons}}" wx:key="key" wx:for-item="coupon" class="coupon-option {{selectedCouponKey === coupon.key ? 'active' : ''}}">
<radio value="{{coupon.key}}" checked="{{selectedCouponKey === coupon.key}}" color="{{navThemeColor || '#E8B4B8'}}"></radio>
<view class="coupon-texts">
<view class="coupon-name">{{coupon.displayText}}</view>
<view class="coupon-desc">{{coupon.savingText || (coupon.sourceType === 'SYSTEM_VIP' ? 'VIP 自动折扣' : '用户优惠券')}}</view>
</view>
<view class="coupon-tag">{{coupon.sourceType === 'SYSTEM_VIP' ? '推荐' : '手动选择'}}</view>
</label>
</radio-group>
<view wx:if="{{unavailableCoupons.length}}" class="unavailable-coupon-list">
<view class="unavailable-title">本单暂不可用</view>
<view wx:for="{{unavailableCoupons}}" wx:key="key" wx:for-item="coupon" class="unavailable-coupon">
<text>{{coupon.displayText}}</text>
<text>{{coupon.unavailableReason || '本单暂不可用'}}</text>
</view>
</view>
</view>
<view class="page-card summary-card">
<view wx:if="{{checkoutPreview && checkoutPreview.summaryText}}" class="summary-preview">{{checkoutPreview.summaryText}}</view>
<view wx:if="{{vipTip}}" class="summary-vip">{{vipTip}}</view>
<view class="summary-row">
<text>选中项目</text>
<text>{{selectedCount}} 项</text>
</view>
<view class="summary-row">
<text>作品数量</text>
<text>{{totalQuantity}} 件</text>
</view>
<view class="summary-row">
<text>商品小计</text>
<text>{{subtotalText}}</text>
</view>
<view class="summary-row">
<text>已省</text>
<text>-{{discountAmountText}}</text>
</view>
<view class="summary-row total">
<text>合计</text>
<text>{{totalAmountText}}</text>
</view>
</view>
</block>
<view wx:elif="{{loading}}" class="page-card empty-card">
<text class="empty-title">正在加载购物车</text>
</view>
<view wx:elif="{{recoveryState.visible}}" class="page-card recovery-card">
<text class="recovery-title">{{recoveryState.title}}</text>
<text class="recovery-desc">{{recoveryState.message}}</text>
<view class="recovery-actions">
<view
wx:for="{{recoveryState.actions}}"
wx:key="key"
class="recovery-btn {{item.primary ? 'primary' : ''}}"
data-key="{{item.key}}"
bindtap="handleRecoveryAction"
>{{item.text}}</view>
</view>
</view>
<view wx:else class="page-card empty-card">
<text class="empty-title">购物车还是空的</text>
<text class="empty-desc">先加购,再预约。</text>
<view class="ghost-btn" bindtap="handleBrowseProducts">去逛作品</view>
</view>
</view>
<view wx:if="{{isLoggedIn && cartItems.length}}" class="checkout-bar">
<view class="checkout-copy">
<view class="checkout-total">{{totalAmountText}}</view>
<view class="checkout-meta">已选 {{selectedCount}} 项</view>
</view>
<view class="checkout-btn" bindtap="handleCheckout">提交订单</view>
</view>
</view>
+422
View File
@@ -0,0 +1,422 @@
.cart-page {
padding-bottom: calc(env(safe-area-inset-bottom) + 150rpx);
background: var(--theme-page-bg);
}
.cart-content {
padding-bottom: 20rpx;
}
.cart-hero {
background: var(--theme-gradient-soft);
}
.issue-card {
margin-top: 20rpx;
margin-bottom: 20rpx;
padding: 22rpx 24rpx;
border-radius: 24rpx;
background: var(--theme-primary-soft);
color: var(--theme-neutral);
}
.issue-title {
font-size: 28rpx;
font-weight: 700;
}
.issue-item {
margin-top: 10rpx;
font-size: 24rpx;
line-height: 1.7;
}
.recovery-card {
display: flex;
flex-direction: column;
gap: 14rpx;
margin-bottom: 20rpx;
padding: 26rpx;
border: 2rpx solid var(--theme-border);
}
.recovery-title {
font-size: 30rpx;
font-weight: 800;
color: var(--text-primary);
}
.recovery-desc {
font-size: 24rpx;
line-height: 1.6;
color: var(--text-secondary);
}
.recovery-actions {
display: flex;
flex-wrap: wrap;
gap: 14rpx;
}
.recovery-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 136rpx;
height: 60rpx;
padding: 0 20rpx;
border-radius: 999rpx;
background: var(--theme-card-bg);
border: 2rpx solid var(--theme-border);
color: var(--theme-neutral);
font-size: 24rpx;
font-weight: 700;
}
.recovery-btn.primary {
background: var(--theme-primary);
border-color: var(--theme-primary);
color: var(--theme-tertiary);
}
.cart-item-card + .cart-item-card,
.coupon-card,
.summary-card {
margin-top: 20rpx;
}
.cart-item-card {
padding: 24rpx;
}
.cart-item-top {
display: flex;
align-items: flex-start;
gap: 16rpx;
}
.select-dot {
width: 34rpx;
height: 34rpx;
margin-top: 8rpx;
border-radius: 50%;
border: 4rpx solid var(--theme-border);
}
.select-dot.active {
border-color: var(--theme-primary);
background: var(--theme-primary);
}
.cart-thumb {
width: 140rpx;
height: 140rpx;
border-radius: 22rpx;
background: var(--theme-primary-soft);
}
.cart-main {
flex: 1;
}
.cart-title-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16rpx;
}
.cart-title {
flex: 1;
min-width: 0;
font-size: 30rpx;
font-weight: 700;
line-height: 1.5;
color: var(--text-primary);
}
.cart-price {
font-size: 30rpx;
font-weight: 700;
color: var(--theme-primary-action);
}
.cart-meta-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12rpx;
margin-top: 12rpx;
}
.meta-chip {
display: inline-flex;
align-items: center;
justify-content: center;
height: 42rpx;
padding: 0 16rpx;
border-radius: 999rpx;
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-size: 20rpx;
font-weight: 700;
}
.cart-meta {
font-size: 24rpx;
color: var(--text-secondary);
}
.selector-group {
margin-top: 24rpx;
}
.selector-row {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 76rpx;
padding: 0 22rpx;
border-radius: 20rpx;
background: var(--theme-primary-soft);
}
.selector-row.compact {
min-height: 72rpx;
}
.selector-row.issue {
background: var(--theme-secondary-soft);
}
.selector-label {
font-size: 24rpx;
color: var(--text-secondary);
}
.selector-value {
font-size: 24rpx;
color: var(--text-primary);
font-weight: 600;
}
.time-grid {
display: flex;
gap: 14rpx;
margin-top: 14rpx;
}
.time-grid picker {
flex: 1;
}
.appointment-preview {
margin-top: 14rpx;
font-size: 24rpx;
color: var(--text-secondary);
}
.cart-item-foot {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 24rpx;
}
.qty-box {
display: flex;
align-items: center;
gap: 16rpx;
}
.qty-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: var(--theme-primary-soft);
color: var(--theme-primary-action);
font-size: 34rpx;
}
.qty-value {
min-width: 48rpx;
text-align: center;
font-size: 28rpx;
font-weight: 700;
color: var(--text-primary);
}
.remove-btn {
font-size: 24rpx;
color: var(--theme-primary-action);
font-weight: 700;
}
.coupon-card,
.summary-card {
padding: 26rpx;
}
.coupon-option {
display: flex;
align-items: center;
gap: 18rpx;
margin-top: 20rpx;
padding: 20rpx 0;
border-top: 2rpx solid var(--theme-border);
}
.coupon-option:first-child {
border-top: 0;
padding-top: 10rpx;
}
.coupon-option.active {
color: var(--theme-primary);
}
.coupon-texts {
flex: 1;
}
.coupon-name {
font-size: 26rpx;
font-weight: 700;
color: var(--text-primary);
}
.coupon-desc {
margin-top: 8rpx;
font-size: 22rpx;
color: var(--text-secondary);
}
.coupon-tag {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 92rpx;
height: 44rpx;
padding: 0 14rpx;
border-radius: 999rpx;
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-size: 20rpx;
font-weight: 700;
}
.unavailable-coupon-list {
margin-top: 22rpx;
padding-top: 18rpx;
border-top: 2rpx solid var(--theme-border);
}
.unavailable-title {
font-size: 24rpx;
font-weight: 700;
color: var(--text-secondary);
}
.unavailable-coupon {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18rpx;
margin-top: 14rpx;
font-size: 22rpx;
color: var(--text-secondary);
}
.unavailable-coupon text:first-child {
flex: 1;
min-width: 0;
color: var(--theme-neutral);
}
.unavailable-coupon text:last-child {
max-width: 260rpx;
text-align: right;
}
.summary-preview,
.summary-vip {
margin-bottom: 14rpx;
padding: 16rpx 18rpx;
border-radius: 18rpx;
background: var(--theme-primary-soft);
color: var(--theme-neutral);
font-size: 24rpx;
line-height: 1.6;
}
.summary-vip {
color: var(--theme-primary);
font-weight: 700;
}
.summary-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 0;
font-size: 26rpx;
color: var(--theme-neutral);
}
.summary-row.total {
margin-top: 10rpx;
padding-top: 18rpx;
border-top: 2rpx solid var(--theme-border);
font-size: 30rpx;
font-weight: 700;
color: var(--text-primary);
}
.checkout-bar {
position: fixed;
left: 24rpx;
right: 24rpx;
bottom: calc(env(safe-area-inset-bottom) + 20rpx);
z-index: 20;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
padding: 18rpx 20rpx;
border-radius: 30rpx;
background: rgba(255, 255, 255, 0.98);
box-shadow: 0 18rpx 50rpx rgba(122, 67, 88, 0.12);
}
.checkout-copy {
flex: 1;
}
.checkout-total {
font-size: 36rpx;
font-weight: 800;
color: var(--theme-primary-action);
}
.checkout-meta {
margin-top: 8rpx;
font-size: 22rpx;
color: var(--text-secondary);
}
.checkout-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 220rpx;
height: 84rpx;
padding: 0 26rpx;
border-radius: 999rpx;
background: var(--theme-gradient);
color: var(--theme-tertiary);
font-size: 28rpx;
font-weight: 700;
}
+168
View File
@@ -0,0 +1,168 @@
/**
* 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} 折`
}
return `满 ${coupon.minAmount} 减 ${coupon.reduceAmount}`
}
/**
* coupons page logic.
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
*/
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
loading: false,
isLoggedIn: false,
coupons: [],
filteredCoupons: [],
activeFilter: 'all',
filterOptions: [
{ value: 'all', label: '全部' },
{ value: 'available', label: '未使用' },
{ value: 'used', label: '已使用' },
{ value: 'expired', label: '已过期' }
]
}),
/**
* `onShow` 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.
*/
onShow() {
this.loadCoupons()
},
async loadCoupons() {
const isLoggedIn = auth.isLoggedIn()
this.setData({
isLoggedIn,
loading: isLoggedIn
})
/**
* `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 (!isLoggedIn) {
this.setData({
coupons: [],
filteredCoupons: [],
activeFilter: 'all',
loading: false
})
return
}
try {
const coupons = await couponApi.listUserCoupons()
const list = Array.isArray(coupons) ? coupons.map(item => ({
...item,
benefitText: getBenefitText(item),
periodText: `${String(item.startTime || '').slice(0, 10)} - ${String(item.endTime || '').slice(0, 10)}`,
sourceText: item.sourceType === 'SYSTEM_VIP' ? 'VIP 自动匹配' : '用户优惠券'
})) : []
this.setData({
coupons: list
})
this.applyFilter(this.data.activeFilter, list)
} catch (error) {
this.setData({
coupons: [],
filteredCoupons: []
})
wx.showToast({
title: error.message || '优惠券加载失败',
icon: 'none'
})
} finally {
this.setData({
loading: false
})
}
},
/**
* `applyFilter` 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.
*/
applyFilter(filterValue, sourceCoupons) {
const activeFilter = filterValue || 'all'
const coupons = Array.isArray(sourceCoupons) ? sourceCoupons : this.data.coupons
let filteredCoupons = coupons
/**
* `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 (activeFilter === 'available') {
filteredCoupons = coupons.filter(item => Number(item.status) === 1)
} else if (activeFilter === 'used') {
filteredCoupons = coupons.filter(item => Number(item.status) === 2)
} else if (activeFilter === 'expired') {
filteredCoupons = coupons.filter(item => Number(item.status) === 3)
}
this.setData({
activeFilter,
filteredCoupons
})
},
/**
* `handleFilterChange` 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.
*/
handleFilterChange(event) {
const value = event.currentTarget.dataset.value
/**
* `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 (!value || value === this.data.activeFilter) {
return
}
this.applyFilter(value)
},
/**
* `handleOpenAuth` 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.
*/
handleOpenAuth() {
navigation.openAuth('/pages/coupons/index')
},
/**
* `handleBack` 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.
*/
handleBack() {
navigation.goBack('/pages/profile/index')
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,59 @@
<navigation-bar title="我的优惠券" showBack="{{true}}" fallbackPath="/pages/profile/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell coupons-page" style="{{themeVars}}">
<view class="page-content">
<view wx:if="{{!isLoggedIn}}" class="page-card empty-card">
<text class="empty-title">登录后查看优惠券</text>
<text class="empty-desc">登录后查看可用优惠。</text>
<view class="ghost-btn" bindtap="handleOpenAuth">去登录</view>
</view>
<block wx:elif="{{coupons.length}}">
<view class="page-hero coupons-hero">
<text class="hero-kicker">优惠资产</text>
<text class="hero-title">当前有 {{coupons.length}} 张</text>
<text class="hero-desc">下单前可查看可用优惠。</text>
</view>
<view class="coupon-filter-row">
<view
wx:for="{{filterOptions}}"
wx:key="value"
class="coupon-filter-chip {{activeFilter === item.value ? 'active' : ''}}"
data-value="{{item.value}}"
bindtap="handleFilterChange"
>
{{item.label}}
</view>
</view>
<block wx:if="{{filteredCoupons.length}}">
<view wx:for="{{filteredCoupons}}" wx:key="id" class="page-card coupon-card">
<view class="coupon-top">
<view>
<view class="coupon-title">{{item.couponName}}</view>
<view class="coupon-source">{{item.sourceText}}</view>
</view>
<view class="coupon-status">{{item.statusName || '待使用'}}</view>
</view>
<view class="coupon-benefit">{{item.benefitText}}</view>
<view class="coupon-period">{{item.periodText}}</view>
</view>
</block>
<view wx:else class="page-card empty-card">
<text class="empty-title">当前筛选下暂无优惠券</text>
<text class="empty-desc">换个筛选试试。</text>
</view>
</block>
<view wx:elif="{{loading}}" class="page-card empty-card">
<text class="empty-title">正在加载优惠内容</text>
</view>
<view wx:else class="page-card empty-card">
<text class="empty-title">你还没有优惠券</text>
<text class="empty-desc">下单前会自动匹配可用优惠。</text>
</view>
</view>
</view>
@@ -0,0 +1,86 @@
.coupons-hero {
margin-bottom: 20rpx;
}
.coupon-filter-row {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
margin-bottom: 20rpx;
}
.coupon-filter-chip {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 120rpx;
height: 60rpx;
padding: 0 24rpx;
border-radius: 999rpx;
background: var(--theme-card-bg);
border: 1rpx solid var(--theme-border);
color: var(--text-secondary);
font-size: 24rpx;
font-weight: 600;
}
.coupon-filter-chip.active {
background: var(--theme-gradient);
border-color: transparent;
color: #ffffff;
}
.coupon-card + .coupon-card {
margin-top: 20rpx;
}
.coupon-card {
padding: 26rpx 28rpx;
background: var(--theme-gradient-soft);
}
.coupon-top {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20rpx;
}
.coupon-title {
font-size: 30rpx;
font-weight: 700;
color: var(--text-primary);
}
.coupon-source {
margin-top: 10rpx;
font-size: 22rpx;
color: var(--text-secondary);
}
.coupon-status {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 140rpx;
height: 52rpx;
padding: 0 18rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.8);
color: var(--theme-primary);
font-size: 22rpx;
font-weight: 700;
}
.coupon-benefit {
margin-top: 26rpx;
font-size: 42rpx;
font-weight: 800;
color: var(--theme-primary);
}
.coupon-period {
margin-top: 18rpx;
font-size: 24rpx;
color: var(--text-secondary);
}
+42
View File
@@ -0,0 +1,42 @@
const userApi = require('../../api/user')
const navigation = require('../../utils/navigation')
const theme = require('../../utils/theme')
const { BRAND_CONFIG } = require('../../utils/config')
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
loading: false,
contact: null,
brandSupportName: `${BRAND_CONFIG.appNameEn} Support`
}),
onShow() {
this.loadContact()
},
handleBack() {
navigation.goBack('/pages/profile/index')
},
async loadContact() {
this.setData({ loading: true })
try {
const contact = await userApi.getPlatformContact()
this.setData({ contact })
} catch (error) {
this.setData({ contact: null })
} finally {
this.setData({ loading: false })
}
},
openRoute(event) {
const route = event.currentTarget.dataset.route
const pureRoute = String(route || '').split('?')[0]
if (navigation.isTabPage(pureRoute)) {
navigation.switchTab(pureRoute)
return
}
navigation.navigate(route)
}
})
+5
View File
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
+41
View File
@@ -0,0 +1,41 @@
<navigation-bar title="帮助与客服" showBack="{{true}}" fallbackPath="/pages/profile/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell" style="{{themeVars}}">
<view class="page-content">
<view class="page-hero">
<text class="hero-kicker">{{brandSupportName}}</text>
<text class="hero-title">帮助与客服</text>
<text class="hero-desc">订单、预约、售后和账号问题都可以从这里继续处理</text>
</view>
<view class="page-card contact-card">
<text class="section-title">平台联系信息</text>
<block wx:if="{{contact}}">
<text wx:if="{{contact.contactName}}" class="contact-line">{{contact.contactName}} {{contact.roleLabel || ''}}</text>
<text wx:if="{{contact.phoneAvailable && contact.phone}}" class="contact-line">电话:{{contact.phone}}</text>
<text wx:if="{{contact.wechatAvailable && contact.wechatId}}" class="contact-line">微信:{{contact.wechatId}}</text>
<text wx:if="{{contact.platformContactText}}" class="contact-line">{{contact.platformContactText}}</text>
</block>
<text wx:else class="contact-line">暂无可展示的客服信息,请稍后重试或从订单详情联系服务人员</text>
</view>
<view class="quick-grid">
<view class="page-card quick-card" data-route="/pages/orders/index" bindtap="openRoute">
<text class="quick-title">订单中心</text>
<text class="quick-desc">查看预约、支付和评价</text>
</view>
<view class="page-card quick-card" data-route="/pages/after-sales/index" bindtap="openRoute">
<text class="quick-title">售后记录</text>
<text class="quick-desc">查看退款和处理进度</text>
</view>
<view class="page-card quick-card" data-route="/pages/notifications/index" bindtap="openRoute">
<text class="quick-title">消息中心</text>
<text class="quick-desc">查看系统通知</text>
</view>
<view class="page-card quick-card" data-route="/pages/settings/index" bindtap="openRoute">
<text class="quick-title">账号设置</text>
<text class="quick-desc">修改资料、手机号和密码</text>
</view>
</view>
</view>
</view>
+42
View File
@@ -0,0 +1,42 @@
.contact-card {
margin-top: 22rpx;
padding: 26rpx;
}
.contact-line,
.quick-title,
.quick-desc {
display: block;
}
.contact-line {
margin-top: 12rpx;
color: #504444;
font-size: 25rpx;
line-height: 1.6;
}
.quick-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18rpx;
margin-top: 22rpx;
}
.quick-card {
min-height: 180rpx;
padding: 24rpx;
}
.quick-title {
color: var(--text-primary);
font-size: 29rpx;
font-weight: 800;
}
.quick-desc {
margin-top: 12rpx;
color: #504444;
font-size: 23rpx;
line-height: 1.6;
}
+470
View File
@@ -0,0 +1,470 @@
/**
* 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')
const { DEFAULT_SHOP_IMAGE, CACHE_TTL, BRAND_CONFIG } = require('../../utils/config')
const {
createKeyboardSafeData,
attachKeyboardSafe,
detachKeyboardSafe,
handleKeyboardFocus,
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')
/**
* home page logic.
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
*/
Page({
data: Object.assign(createKeyboardSafeData({
cursorSpacing: 96
}), theme.pageThemeData(getApp().globalData.shopTheme), {
initialized: false,
loading: false,
loadingMore: false,
isLoggedIn: false,
userInfo: null,
navTitle: '游客模式',
greeting: `欢迎来到 ${BRAND_CONFIG.appTitle}`,
guestBrandName: `${BRAND_CONFIG.appNameEn} 小程序`,
displayName: '先看看门店和作品',
searchKeyword: '',
bannerImages: [],
featuredItems: [],
popularItems: [],
announcements: [],
popularPage: 1,
pageSize: 6,
hasMore: false,
popularTotal: 0
}),
/**
* `onLoad` 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.
*/
onLoad() {
this.homeRequestId = 0
this.ensureKeyboardSafe()
this.loadHomeData()
},
/**
* `onShow` 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.
*/
onShow() {
this.ensureKeyboardSafe()
this.syncUserState()
/**
* `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 (this.data.initialized && this.data.isLoggedIn) {
this.loadUserProfile()
}
},
/**
* `onHide` 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.
*/
onHide() {
resetKeyboardSafe(this)
detachKeyboardSafe(this)
},
/**
* `onUnload` 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.
*/
onUnload() {
resetKeyboardSafe(this)
detachKeyboardSafe(this)
},
async onPullDownRefresh() {
cache.removeByPrefix('home:')
await this.loadHomeData()
wx.stopPullDownRefresh()
},
/**
* `onReachBottom` 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.
*/
onReachBottom() {
/**
* `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 (!this.data.hasMore || this.data.loadingMore) {
return
}
this.loadPopularProducts(false)
},
/**
* `ensureKeyboardSafe` 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.
*/
ensureKeyboardSafe() {
attachKeyboardSafe(this, {
cursorSpacing: 96,
spacerExtraRpx: 24
})
},
/**
* `syncUserState` 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.
*/
syncUserState() {
const app = getApp()
const userInfo = auth.getStoredUserInfo()
const isLoggedIn = auth.isLoggedIn()
const navTitle = userInfo && String(userInfo.shopName || '').trim()
? String(userInfo.shopName).trim()
: '游客模式'
/**
* `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 (app) {
app.globalData.userInfo = userInfo
app.globalData.isLoggedIn = isLoggedIn
}
this.setData({
isLoggedIn,
userInfo,
navTitle,
greeting: isLoggedIn ? '欢迎回来' : '游客模式',
displayName: isLoggedIn
? ((userInfo && userInfo.nickname) || 'Yumi 用户')
: '先逛逛喜欢的款式和门店',
bannerImages: isLoggedIn ? [] : this.data.bannerImages
})
},
async loadUserProfile() {
if (!auth.isLoggedIn()) {
this.syncUserState()
return
}
try {
const userInfo = await userApi.getUserInfo()
getApp().refreshUserInfo(userInfo)
this.syncUserState()
} catch (error) {}
},
async loadAnnouncements() {
if (!auth.isLoggedIn()) {
this.setData({ announcements: [] })
return
}
try {
const list = await userApi.listMyAnnouncements()
this.setData({
announcements: Array.isArray(list) ? list.map(item => ({
...item,
displayText: `${item.publisherName || '平台'}:${item.content || ''}`
})) : []
})
} catch (error) {
this.setData({ announcements: [] })
}
},
async loadHomeData() {
const requestId = ++this.homeRequestId
this.setData({ loading: true })
this.syncUserState()
try {
const loggedIn = auth.isLoggedIn()
await Promise.all([
this.loadUserProfile(),
this.loadAnnouncements(),
loggedIn ? Promise.resolve() : this.loadBannerImages(requestId),
this.loadFeaturedProducts(requestId),
this.loadPopularProducts(true, requestId)
])
/**
* `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 (requestId === this.homeRequestId) {
this.setData({
initialized: true
})
}
} catch (error) {
wx.showToast({
title: error.message || '首页加载失败',
icon: 'none'
})
} finally {
/**
* `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 (requestId === this.homeRequestId) {
this.setData({ loading: false })
}
}
},
async loadBannerImages(requestId) {
const banners = await cache.remember('home:banners', CACHE_TTL.banner, async () => {
const shops = await shopApi.getPublicShops()
const list = Array.isArray(shops) ? shops : []
const resolved = await Promise.all(list.slice(0, 6).map(async (shop, index) => {
const imageIds = shop.coverImageFileId || shop.imageFileIds
const urls = await resolveImageList(imageIds, DEFAULT_SHOP_IMAGE)
return {
id: `${shop.id}-${index}`,
shopId: shop.id,
shopName: shop.shopName,
businessHours: shop.businessHours || '欢迎到店体验',
imageUrl: urls[0]
}
}))
return resolved.filter(item => item.imageUrl)
})
/**
* `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 (requestId === this.homeRequestId) {
this.setData({
bannerImages: Array.isArray(banners) ? banners : []
})
}
},
async loadFeaturedProducts(requestId) {
const items = await cache.remember('home:featured', CACHE_TTL.homeList, async () => {
const result = await productApi.getProductPage({
page: 1,
size: 6,
tag: '精选'
})
return buildProductCards(result && result.list ? result.list : [])
})
/**
* `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 (requestId === this.homeRequestId) {
this.setData({
featuredItems: Array.isArray(items) ? items : []
})
}
},
async loadPopularProducts(reset, requestId) {
const currentRequestId = requestId || this.homeRequestId
const nextPage = reset ? 1 : this.data.popularPage + 1
const loadingState = reset ? { loading: true } : { loadingMore: true }
this.setData(loadingState)
try {
const result = await productApi.getProductPage({
page: nextPage,
size: this.data.pageSize,
tag: '热门'
})
const cards = await buildProductCards(result && result.list ? result.list : [])
/**
* `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 (currentRequestId !== this.homeRequestId) {
return
}
const mergedItems = reset ? cards : this.data.popularItems.concat(cards)
const total = Number(result && result.total) || 0
this.setData({
popularItems: mergedItems,
popularPage: nextPage,
popularTotal: total,
hasMore: mergedItems.length < total
})
} catch (error) {
/**
* `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 (currentRequestId !== this.homeRequestId) {
return
}
wx.showToast({
title: error.message || '热门作品加载失败',
icon: 'none'
})
} finally {
/**
* `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 (currentRequestId === this.homeRequestId) {
this.setData({
loadingMore: false
})
}
}
},
/**
* `handleSearchInput` 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.
*/
handleSearchInput(event) {
this.setData({
searchKeyword: event.detail.value
})
},
/**
* `handleSearchFocus` 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.
*/
handleSearchFocus(event) {
handleKeyboardFocus(this, event)
},
/**
* `handleSearchBlur` 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.
*/
handleSearchBlur() {
handleKeyboardBlur(this)
},
/**
* `handleSearchConfirm` 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.
*/
handleSearchConfirm() {
resetKeyboardSafe(this)
navigation.openProducts({
keyword: this.data.searchKeyword.trim()
})
},
/**
* `handleBannerTap` 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.
*/
handleBannerTap(event) {
const shopId = event.currentTarget.dataset.shopId
/**
* `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 (!shopId) {
return
}
navigation.navigate('/pages/shop-detail/index', {
id: shopId,
returnTo: navigation.getCurrentPageUrl()
})
},
/**
* `handleProfileTap` 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.
*/
handleProfileTap() {
/**
* `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 (this.data.isLoggedIn) {
navigation.switchTab('/pages/profile/index')
return
}
navigation.openAuth()
},
/**
* `handleProductSelect` 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.
*/
handleProductSelect(event) {
const product = event.detail || {}
/**
* `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 (!product.id) {
return
}
navigation.navigate('/pages/product-detail/index', {
id: product.id
})
},
/**
* `handleSeeAllFeatured` 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.
*/
handleSeeAllFeatured() {
navigation.openProducts({
tag: '精选'
})
},
/**
* `handleSeeAllPopular` 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.
*/
handleSeeAllPopular() {
navigation.openProducts({
tag: '热门'
})
}
})
+7
View File
@@ -0,0 +1,7 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar",
"product-card": "/components/product-card/product-card"
},
"enablePullDownRefresh": true
}
+152
View File
@@ -0,0 +1,152 @@
<view class="home-page-root fingertip-designer-page" style="{{themeVars}}">
<navigation-bar title="{{navTitle}}" showBack="{{false}}" isTabPage="{{true}}" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="home-scroll">
<view class="page-shell home-page {{keyboardVisible ? 'keyboard-active' : ''}}">
<view class="page-content">
<view class="page-hero home-hero">
<text class="hero-kicker">{{isLoggedIn ? greeting : guestBrandName}}</text>
<text class="hero-title">{{displayName}}</text>
<text class="hero-desc">先选喜欢的作品。</text>
<view class="hero-action-row">
<view class="hero-action primary" bindtap="handleProfileTap">{{isLoggedIn ? '进入个人中心' : '立即登录'}}</view>
<view class="hero-action secondary" bindtap="handleSeeAllPopular">看看热门作品</view>
</view>
<view id="home-search-anchor" class="search-box">
<input
class="search-input"
placeholder="搜索作品、风格或门店"
placeholder-class="field-placeholder"
value="{{searchKeyword}}"
bindinput="handleSearchInput"
bindconfirm="handleSearchConfirm"
bindfocus="handleSearchFocus"
bindblur="handleSearchBlur"
data-keyboard-anchor="home-search-anchor"
adjust-position="false"
cursor-spacing="{{keyboardCursorSpacing}}"
confirm-type="search"
/>
<view class="search-btn" bindtap="handleSearchConfirm">搜索</view>
</view>
<swiper wx:if="{{announcements.length}}" class="announcement-strip" autoplay circular vertical interval="2600">
<swiper-item wx:for="{{announcements}}" wx:key="id">
<view class="announcement-item">{{item.displayText}}</view>
</swiper-item>
</swiper>
<view class="summary-strip">
<view wx:if="{{!isLoggedIn}}" class="summary-metric">
<text class="summary-label">门店橱窗</text>
<text class="summary-value">{{bannerImages.length ? bannerImages.length : 0}} 家</text>
<text class="summary-note">看环境</text>
</view>
<view class="summary-metric">
<text class="summary-label">精选作品</text>
<text class="summary-value">{{featuredItems.length ? featuredItems.length : 0}} 款</text>
<text class="summary-note">找灵感</text>
</view>
<view class="summary-metric">
<text class="summary-label">热门推荐</text>
<text class="summary-value">{{popularItems.length ? popularItems.length : 0}} 条</text>
<text class="summary-note">热门款</text>
</view>
</view>
<view wx:if="{{!isLoggedIn}}" class="guest-tip">
登录后可同步收藏和预约记录。
</view>
</view>
<view wx:if="{{!isLoggedIn}}" class="section-block">
<view class="section-head">
<view class="section-copy">
<text class="section-kicker">门店氛围</text>
<text class="section-title">先看看线下环境</text>
<text class="section-subtitle">看店铺环境</text>
</view>
</view>
<view wx:if="{{bannerImages.length}}" class="banner-box page-card fingertip-designer-glass-card">
<swiper class="banner-swiper" indicator-dots autoplay circular interval="3200">
<swiper-item wx:for="{{bannerImages}}" wx:key="id">
<view class="banner-item" data-shop-id="{{item.shopId}}" bindtap="handleBannerTap">
<image class="banner-image" src="{{item.imageUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
<view class="banner-mask">
<view class="banner-badge">门店实拍</view>
<view class="banner-title">{{item.shopName}}</view>
<view class="banner-desc">{{item.businessHours}}</view>
</view>
</view>
</swiper-item>
</swiper>
</view>
<view wx:else class="page-card fingertip-designer-glass-card empty-card">
<text class="empty-title">门店内容正在补充中</text>
<text class="empty-desc">先看看作品。</text>
</view>
</view>
<view class="section-block">
<view class="section-head">
<view class="section-copy">
<text class="section-kicker">快速入门</text>
<text class="section-title">精选作品</text>
<text class="section-subtitle">先看热门款</text>
</view>
<view class="section-link" bindtap="handleSeeAllFeatured">查看全部</view>
</view>
<view wx:if="{{featuredItems.length}}" class="featured-panel">
<scroll-view class="featured-scroll" scroll-x enable-flex>
<view class="featured-list">
<view wx:for="{{featuredItems}}" wx:key="id" class="featured-card">
<product-card item="{{item}}" bindselect="handleProductSelect"></product-card>
</view>
</view>
</scroll-view>
</view>
<view wx:else class="page-card fingertip-designer-glass-card empty-card">
<text class="empty-title">精选作品正在整理中</text>
<text class="empty-desc">稍后再来看看。</text>
</view>
</view>
<view class="section-block">
<view class="section-head">
<view class="section-copy">
<text class="section-kicker">热门预约</text>
<text class="section-title">最近大家都在看</text>
<text class="section-subtitle">热门款式</text>
</view>
<view class="section-link" bindtap="handleSeeAllPopular">查看全部</view>
</view>
<view wx:if="{{popularItems.length}}" class="popular-grid">
<view wx:for="{{popularItems}}" wx:key="id" class="popular-card">
<product-card item="{{item}}" show-stats="{{true}}" bindselect="handleProductSelect"></product-card>
</view>
</view>
<view wx:if="{{popularItems.length && (loadingMore || !hasMore)}}" class="section-load-state">
<text class="section-load-text">{{loadingMore ? '正在加载更多热门作品...' : '已经到底了'}}</text>
</view>
<view wx:elif="{{loading}}" class="page-card fingertip-designer-glass-card empty-card">
<text class="empty-title">正在加载首页内容</text>
</view>
<view wx:else class="page-card fingertip-designer-glass-card empty-card">
<text class="empty-title">还没有热门作品</text>
<text class="empty-desc">稍后再来看看。</text>
</view>
</view>
</view>
<view wx:if="{{keyboardVisible}}" class="keyboard-light-spacer" style="height: {{keyboardInsetRpx}}rpx;"></view>
</view>
</view>
</view>
+218
View File
@@ -0,0 +1,218 @@
.home-page-root {
min-height: 100vh;
padding: 0;
color: var(--text-primary);
background: var(--theme-page-bg);
}
.home-scroll {
min-height: 100%;
}
.home-page {
min-height: 100%;
background: var(--theme-page-bg);
}
.home-page.keyboard-active {
padding-bottom: 0;
}
.home-hero {
background: var(--theme-gradient-soft);
box-shadow: 0 28rpx 64rpx rgba(74, 68, 63, 0.1);
}
.home-hero .hero-kicker,
.section-kicker {
color: var(--theme-secondary);
}
.home-hero .hero-title,
.section-title,
.summary-value,
.empty-title {
color: var(--text-primary);
}
.home-hero .hero-desc,
.section-subtitle,
.summary-label,
.summary-note,
.empty-desc,
.field-placeholder {
color: var(--text-secondary);
}
.home-hero .hero-action.secondary {
border: 1rpx solid var(--theme-border);
background: rgba(255, 255, 255, 0.9);
color: var(--theme-primary-action);
}
.search-box {
display: flex;
align-items: center;
gap: 16rpx;
margin-top: 30rpx;
padding: 10rpx;
border: 1rpx solid var(--theme-border);
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.92);
box-shadow: 0 18rpx 42rpx rgba(74, 68, 63, 0.08);
}
.search-input {
flex: 1;
height: 72rpx;
padding: 0 24rpx;
font-size: 28rpx;
color: var(--text-primary);
}
.search-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 150rpx;
height: 72rpx;
border-radius: 999rpx;
background: var(--theme-gradient);
color: #ffffff;
font-size: 26rpx;
font-weight: 700;
}
.guest-tip {
margin-top: 24rpx;
padding: 20rpx 24rpx;
border-radius: 22rpx;
background: rgba(255, 255, 255, 0.86);
border: 1rpx solid var(--theme-border);
color: var(--text-secondary);
font-size: 24rpx;
line-height: 1.7;
}
.banner-box {
overflow: hidden;
border-radius: 34rpx;
}
.banner-swiper,
.banner-item {
width: 100%;
height: 396rpx;
}
.banner-item {
position: relative;
}
.banner-image {
width: 100%;
height: 100%;
}
.banner-mask {
position: absolute;
left: 24rpx;
right: 24rpx;
bottom: 24rpx;
padding: 22rpx 24rpx;
border-radius: 24rpx;
border: 1rpx solid rgba(255, 255, 255, 0.92);
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 18rpx 42rpx rgba(74, 68, 63, 0.1);
}
.announcement-strip {
height: 58rpx;
margin-top: 18rpx;
border-radius: 16rpx;
background: var(--theme-primary-soft);
border: 1rpx solid var(--theme-border);
overflow: hidden;
}
.announcement-item {
height: 58rpx;
line-height: 58rpx;
padding: 0 22rpx;
font-size: 24rpx;
color: var(--theme-neutral);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.banner-badge {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 8rpx 18rpx;
border-radius: 999rpx;
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-size: 22rpx;
font-weight: 700;
}
.banner-title {
margin-top: 14rpx;
font-size: 34rpx;
font-weight: 700;
color: var(--text-primary);
}
.banner-desc {
margin-top: 8rpx;
font-size: 24rpx;
color: var(--text-secondary);
}
.featured-panel {
padding: 2rpx 0 4rpx;
}
.featured-scroll {
width: 100%;
white-space: nowrap;
}
.featured-list {
display: inline-flex;
gap: 18rpx;
padding: 4rpx 2rpx 12rpx;
}
.featured-card {
width: 332rpx;
}
.popular-grid {
display: flex;
flex-wrap: wrap;
gap: 18rpx;
padding-top: 2rpx;
}
.popular-card {
width: calc(50% - 9rpx);
}
.section-load-state {
display: flex;
justify-content: center;
padding-top: 18rpx;
}
.section-load-text {
font-size: 22rpx;
color: var(--text-secondary);
}
.keyboard-light-spacer {
width: 100%;
flex-shrink: 0;
}
+60
View File
@@ -0,0 +1,60 @@
/**
* 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')
/**
* index 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: 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: '游客模式'
},
/**
* `onLoad` 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.
*/
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'
})
},
/**
* `onShow` 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.
*/
onShow() {
this.syncNavTitle()
},
/**
* `syncNavTitle` 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.
*/
syncNavTitle() {
const userInfo = auth.getStoredUserInfo()
const navTitle = userInfo && String(userInfo.shopName || '').trim()
? String(userInfo.shopName).trim()
: '游客模式'
this.setData({
navTitle
})
}
})
+5
View File
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
+7
View File
@@ -0,0 +1,7 @@
<navigation-bar title="{{navTitle}}" showBack="{{false}}" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="redirect-page">
<view class="redirect-card">
<view class="redirect-title">正在进入首页</view>
<view class="redirect-desc">即将进入首页</view>
</view>
</view>
+33
View File
@@ -0,0 +1,33 @@
page {
min-height: 100vh;
background: var(--theme-page-bg);
}
.redirect-page {
min-height: calc(100vh - 88rpx);
display: flex;
align-items: center;
justify-content: center;
padding: 32rpx;
}
.redirect-card {
width: 100%;
padding: 40rpx 32rpx;
border-radius: 28rpx;
background: #ffffff;
box-shadow: 0 18rpx 50rpx rgba(122, 67, 88, 0.08);
}
.redirect-title {
font-size: 34rpx;
font-weight: 700;
color: var(--text-primary);
}
.redirect-desc {
margin-top: 18rpx;
font-size: 24rpx;
line-height: 1.7;
color: var(--text-secondary);
}
@@ -0,0 +1,218 @@
/**
* 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
},
/**
* `onShow` 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.
*/
onShow() {
this.loadMessages()
},
async loadMessages() {
if (!navigation.ensureLogin('查看消息通知')) {
return
}
this.setData({ loading: true })
try {
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 {
this.setData({ loading: false })
}
},
async handleOpenMessage(event) {
const id = event.currentTarget.dataset.id
const item = this.data.messages.find(message => String(message.id) === String(id))
/**
* `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 (!item) {
return
}
const actionTarget = navigation.buildMessageActionPath(item)
if (actionTarget) {
try {
if (item.readStatus !== 1) {
await userApi.markMessageRead(item.id)
}
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
})
/**
* `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 (item.readStatus !== 1) {
try {
await userApi.markMessageRead(item.id)
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'
})
}
}
},
/**
* `handleCloseDetail` 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.
*/
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
})
},
/**
* `handlePreviewImage` 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.
*/
handlePreviewImage() {
const imageUrl = this.data.currentMessage && this.data.currentMessage.imageUrl
/**
* `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 (!imageUrl) {
return
}
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() {},
/**
* `handleBack` 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.
*/
handleBack() {
navigation.goBack('/pages/profile/index')
}
})
@@ -0,0 +1,6 @@
{
"navigationStyle": "custom",
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,50 @@
<navigation-bar title="消息通知" showBack="{{true}}" fallbackPath="/pages/profile/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="notifications-page">
<view class="summary-card">
<view class="summary-title">消息通知</view>
<view class="summary-desc">{{unreadCount}} 条未读消息</view>
</view>
<view wx:if="{{messages.length}}" class="message-list">
<view
wx:for="{{messages}}"
wx:key="id"
class="message-item {{item.readStatus === 1 ? '' : 'unread'}}"
data-id="{{item.id}}"
bindtap="handleOpenMessage"
>
<view class="message-dot"></view>
<view class="message-copy">
<view class="message-title">{{item.title}}</view>
<view class="message-meta">{{item.publisherName || '系统消息'}} · {{item.publishTime || item.createTime}}</view>
<view wx:if="{{item.imageUrl}}" class="message-badge">含图片</view>
</view>
<view class="message-arrow">></view>
</view>
</view>
<view wx:else class="empty-card">
暂无消息
</view>
<view wx:if="{{detailVisible && currentMessage}}" class="detail-mask" bindtap="handleCloseDetail">
<view class="detail-panel" catchtap="noop">
<view class="detail-header">
<view>
<view class="detail-title">{{currentMessage.title}}</view>
<view class="detail-meta">{{currentMessage.publisherName || '系统消息'}} · {{currentMessage.publishTime || currentMessage.createTime}}</view>
</view>
<button class="detail-close" size="mini" bindtap="handleCloseDetail">关闭</button>
</view>
<view wx:if="{{currentMessage.content}}" class="detail-content">{{currentMessage.content}}</view>
<image
wx:if="{{currentMessage.imageUrl}}"
class="detail-image"
src="{{currentMessage.imageUrl}}"
mode="aspectFit"
bindtap="handlePreviewImage"
/>
</view>
</view>
</view>
@@ -0,0 +1,152 @@
.notifications-page {
min-height: 100vh;
padding: 176rpx 28rpx 40rpx;
background: var(--theme-page-bg);
box-sizing: border-box;
}
.summary-card,
.message-item,
.empty-card {
border-radius: 18rpx;
background: #ffffff;
box-shadow: 0 16rpx 40rpx rgba(150, 82, 105, 0.08);
}
.summary-card {
padding: 34rpx;
margin-bottom: 22rpx;
}
.summary-title {
color: var(--text-primary);
font-size: 38rpx;
font-weight: 800;
}
.summary-desc {
margin-top: 8rpx;
color: #927f88;
font-size: 26rpx;
}
.message-list {
display: flex;
flex-direction: column;
gap: 18rpx;
}
.message-item {
display: flex;
align-items: center;
gap: 18rpx;
padding: 28rpx;
}
.message-dot {
width: 16rpx;
height: 16rpx;
border-radius: 50%;
background: #d7c9cf;
}
.message-item.unread .message-dot {
background: #ff5c8a;
}
.message-copy {
flex: 1;
min-width: 0;
}
.message-title {
color: var(--text-primary);
font-size: 30rpx;
font-weight: 700;
}
.message-meta {
margin-top: 8rpx;
color: #9b8d94;
font-size: 24rpx;
}
.message-badge {
display: inline-block;
margin-top: 10rpx;
padding: 4rpx 16rpx;
border-radius: 999rpx;
background: #fff0f4;
color: #d74270;
font-size: 22rpx;
}
.message-arrow {
color: #c3aab4;
}
.empty-card {
padding: 60rpx;
color: #9b8d94;
text-align: center;
}
.detail-mask {
position: fixed;
inset: 0;
z-index: 1000;
display: flex;
align-items: flex-end;
background: rgba(26, 18, 24, 0.45);
}
.detail-panel {
width: 100%;
max-height: 82vh;
padding: 34rpx 30rpx 46rpx;
border-radius: 28rpx 28rpx 0 0;
background: #fff;
box-sizing: border-box;
overflow-y: auto;
}
.detail-header {
display: flex;
gap: 20rpx;
align-items: flex-start;
justify-content: space-between;
}
.detail-title {
color: var(--text-primary);
font-size: 34rpx;
font-weight: 800;
}
.detail-meta {
margin-top: 8rpx;
color: #9b8d94;
font-size: 24rpx;
}
.detail-close {
margin: 0;
border-radius: 999rpx;
}
.detail-content {
margin-top: 28rpx;
color: #4b4048;
font-size: 28rpx;
line-height: 1.8;
white-space: pre-wrap;
}
.detail-image {
width: 100%;
min-height: 320rpx;
max-height: 760rpx;
margin-top: 24rpx;
border-radius: 18rpx;
background: var(--theme-page-bg);
}
@@ -0,0 +1,151 @@
const orderApi = require('../../api/order')
const afterSaleApi = require('../../api/after-sale')
const userApi = require('../../api/user')
const auth = require('../../utils/auth')
const navigation = require('../../utils/navigation')
const theme = require('../../utils/theme')
const { resolveLegacyImage } = require('../../utils/file')
const { formatDateTime, formatPrice, getOrderStatusClass, getOrderStatusText } = require('../../utils/format')
const { runWithLoading } = require('../../utils/loading')
function safeList(value) {
return Array.isArray(value) ? value : []
}
function sameId(left, right) {
return left !== undefined && left !== null && right !== undefined && right !== null && String(left) === String(right)
}
function formatMoney(value) {
return `¥${formatPrice(value)}`
}
function buildTimeline(order, reviews, changes, afterSales) {
const items = safeList(order && order.items)
const firstAppointment = items.map(item => item && item.appointmentTime).find(Boolean)
const status = Number(order && order.status)
return [
{ key: 'created', title: '已创建', text: formatDateTime(order && order.createTime) || '已提交', done: true, active: false },
{ key: 'appointment', title: '预约时间', text: formatDateTime(firstAppointment) || '待确认', done: Boolean(firstAppointment), active: status === 1 },
{ key: 'service', title: status === 3 ? '已取消' : '服务完成', text: formatDateTime(order && (order.completeTime || order.cancelTime || order.updateTime)) || '等待服务', done: status === 2 || status === 3, active: status === 2 || status === 3 },
{ key: 'change', title: '改派记录', text: changes.length ? `${changes.length} 条记录` : '暂无改派', done: changes.length > 0, active: changes.some(item => String(item.status || '').toUpperCase() === 'PENDING') },
{ key: 'after-sale', title: '售后/评价', text: afterSales.length ? `${afterSales.length} 条售后` : (reviews.length ? `${reviews.length} 条评价` : '暂无记录'), done: afterSales.length > 0 || reviews.length > 0, active: afterSales.some(item => String(item.status || '').toUpperCase() === 'PENDING') }
]
}
async function formatOrder(order, reviews, changes, afterSales) {
const items = await Promise.all(safeList(order && order.items).map(async item => ({
...item,
productImageUrl: await resolveLegacyImage(item.productImage),
priceText: formatMoney(item.price),
appointmentText: formatDateTime(item.appointmentTime)
})))
return {
...order,
items,
statusText: getOrderStatusText(order),
statusClass: getOrderStatusClass(order),
amountText: formatMoney(order && (order.actualAmount || order.totalAmount)),
canApplyAfterSale: Number(order && order.status) === 2 || String(order && order.paymentStatus || '').toUpperCase() === 'PAID',
timeline: buildTimeline(order, reviews, changes, afterSales)
}
}
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
id: '',
loading: false,
order: null,
reviews: [],
changes: [],
afterSales: [],
contact: null,
isLoggedIn: false
}),
onLoad(options) {
this.setData({
id: (options && (options.id || options.orderId)) || ''
})
},
onShow() {
this.loadOrder()
},
handleBack() {
navigation.goBack('/pages/orders/index')
},
async loadOrder() {
const isLoggedIn = auth.isLoggedIn()
this.setData({ isLoggedIn })
if (!isLoggedIn) {
navigation.openAuth(navigation.getCurrentPageUrl())
return
}
if (!this.data.id) {
return
}
this.setData({ loading: true })
try {
const [order, reviews, changes, afterSalePage, contact] = await Promise.all([
orderApi.getOrderDetail(this.data.id),
orderApi.listOrderReviews(this.data.id).catch(() => []),
orderApi.listOrderArtistChangeRequests(this.data.id).catch(() => []),
afterSaleApi.getMyAfterSales({ page: 1, size: 50 }).catch(() => ({ list: [] })),
userApi.getOrderArtistContact(this.data.id).catch(() => null)
])
const afterSales = safeList(afterSalePage && afterSalePage.list).filter(item => sameId(item.orderId, this.data.id))
this.setData({
order: await formatOrder(order, reviews || [], changes || [], afterSales),
reviews: reviews || [],
changes: changes || [],
afterSales,
contact
})
} catch (error) {
wx.showToast({
title: error.message || '订单详情加载失败',
icon: 'none'
})
} finally {
this.setData({ loading: false })
}
},
openProgress() {
navigation.navigate('/pages/service-progress/index', { orderId: this.data.id })
},
openAfterSaleApply(event) {
const orderItemId = event.currentTarget.dataset.itemId || ''
navigation.navigate('/pages/after-sale-apply/index', {
orderId: this.data.id,
orderItemId
})
},
openAfterSales() {
navigation.navigate('/pages/after-sales/index', { orderId: this.data.id })
},
async handleCancelOrder() {
const confirmed = await new Promise(resolve => {
wx.showModal({
title: '取消订单',
content: '确认取消这笔订单吗?',
success: res => resolve(Boolean(res.confirm))
})
})
if (!confirmed) return
try {
await runWithLoading(() => orderApi.cancelOrder(this.data.id))
wx.showToast({ title: '订单已取消', icon: 'none' })
await this.loadOrder()
} catch (error) {
wx.showToast({ title: error.message || '取消订单失败', icon: 'none' })
}
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,71 @@
<navigation-bar title="订单详情" showBack="{{true}}" fallbackPath="/pages/orders/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell detail-page" style="{{themeVars}}">
<view class="page-content">
<view wx:if="{{!isLoggedIn}}" class="page-card empty-card">
<text class="empty-title">登录后查看订单</text>
<text class="empty-desc">订单详情需要先登录</text>
</view>
<view wx:elif="{{loading}}" class="page-card empty-card">
<text class="empty-title">正在加载订单</text>
</view>
<block wx:elif="{{order}}">
<view class="page-hero">
<text class="hero-kicker">预约订单</text>
<text class="hero-title">{{order.orderNo}}</text>
<text class="hero-desc">{{order.shopName || '当前门店'}} · {{order.statusText}}</text>
<view class="summary-strip">
<view class="summary-metric">
<text class="summary-label">订单金额</text>
<text class="summary-value">{{order.amountText}}</text>
</view>
<view class="summary-metric">
<text class="summary-label">项目数</text>
<text class="summary-value">{{order.items.length}}</text>
</view>
</view>
</view>
<view class="page-card timeline-card">
<view wx:for="{{order.timeline}}" wx:key="key" class="timeline-node {{item.done ? 'done' : ''}} {{item.active ? 'active' : ''}}">
<text class="timeline-title">{{item.title}}</text>
<text class="timeline-text">{{item.text}}</text>
</view>
</view>
<view class="page-card detail-card">
<view wx:for="{{order.items}}" wx:key="id" class="item-row">
<image class="item-thumb" src="{{item.productImageUrl}}" mode="aspectFill"></image>
<view class="item-main">
<text class="item-title">{{item.productTitle}}</text>
<text class="item-line">{{item.priceText}} x {{item.quantity}}</text>
<text wx:if="{{item.artistName}}" class="item-line">美甲师:{{item.artistName}}</text>
<text wx:if="{{item.appointmentText}}" class="item-line">预约:{{item.appointmentText}}</text>
<view wx:if="{{order.canApplyAfterSale}}" class="soft-chip" data-item-id="{{item.id}}" bindtap="openAfterSaleApply">申请售后</view>
</view>
</view>
</view>
<view wx:if="{{contact}}" class="page-card contact-card">
<text class="section-title">联系信息</text>
<text class="contact-line">{{contact.contactName || contact.roleLabel || '服务联系人'}}</text>
<text wx:if="{{contact.phoneAvailable && contact.phone}}" class="contact-line">电话:{{contact.phone}}</text>
<text wx:if="{{contact.wechatAvailable && contact.wechatId}}" class="contact-line">微信:{{contact.wechatId}}</text>
<text wx:if="{{contact.platformContactText}}" class="contact-line">{{contact.platformContactText}}</text>
</view>
<view class="action-row">
<view class="secondary-btn" bindtap="openProgress">服务进度</view>
<view class="secondary-btn" bindtap="openAfterSales">售后记录</view>
<view wx:if="{{order.status == 1}}" class="secondary-btn danger" bindtap="handleCancelOrder">取消订单</view>
</view>
</block>
<view wx:else class="page-card empty-card">
<text class="empty-title">未找到订单</text>
<text class="empty-desc">请从订单中心重新进入</text>
</view>
</view>
</view>
@@ -0,0 +1,103 @@
.timeline-card,
.detail-card,
.contact-card {
margin-top: 22rpx;
padding: 24rpx;
}
.timeline-card {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 8rpx;
}
.timeline-node {
min-width: 0;
padding: 12rpx 8rpx;
border-radius: 14rpx;
background: var(--theme-primary-soft);
color: #504444;
}
.timeline-node.done,
.timeline-node.active {
color: var(--theme-primary);
}
.timeline-title,
.timeline-text,
.contact-line {
display: block;
}
.timeline-title,
.timeline-text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.timeline-title {
font-size: 21rpx;
font-weight: 800;
}
.timeline-text {
margin-top: 6rpx;
font-size: 20rpx;
}
.item-row {
display: flex;
gap: 18rpx;
padding: 20rpx 0;
border-top: 2rpx solid var(--theme-border);
}
.item-row:first-child {
padding-top: 0;
border-top: 0;
}
.item-thumb {
width: 132rpx;
height: 132rpx;
border-radius: 24rpx;
background: var(--theme-primary-soft);
}
.item-main {
flex: 1;
min-width: 0;
}
.item-title {
display: block;
color: var(--text-primary);
font-size: 29rpx;
font-weight: 800;
line-height: 1.45;
}
.item-line,
.contact-line {
display: block;
margin-top: 10rpx;
color: #504444;
font-size: 24rpx;
line-height: 1.6;
}
.soft-chip {
margin-top: 16rpx;
}
.action-row {
display: grid;
gap: 16rpx;
margin-top: 24rpx;
}
.secondary-btn.danger {
color: var(--theme-accent);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
+159
View File
@@ -0,0 +1,159 @@
<navigation-bar title="我的订单" showBack="{{true}}" fallbackPath="/pages/profile/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell orders-page" style="{{themeVars}}">
<view class="page-content">
<view wx:if="{{!isLoggedIn}}" class="page-card empty-card">
<text class="empty-title">登录后查看订单</text>
<text class="empty-desc">登录后查看预约记录。</text>
<view class="ghost-btn" bindtap="handleOpenAuth">去登录</view>
</view>
<block wx:elif="{{orders.length}}">
<view class="page-hero orders-hero">
<text class="hero-kicker">预约记录</text>
<text class="hero-title">共 {{orders.length}} 笔订单</text>
<text class="hero-desc">查看订单状态和预约时间。</text>
</view>
<view wx:for="{{orders}}" wx:key="id" class="page-card order-card {{item.focusTarget ? 'focus-target' : ''}}">
<view class="order-head">
<view class="order-head-copy">
<text class="order-label">订单号</text>
<text class="order-no">{{item.orderNo}}</text>
</view>
<text class="order-status {{item.statusClass}}">{{item.statusText}}</text>
</view>
<view wx:if="{{item.shopNameText}}" class="order-shop">{{item.shopNameText}}</view>
<view class="payment-panel">
<view class="payment-copy">
<text class="assist-label">支付状态</text>
<text class="assist-main">{{item.paymentInfo.statusText}}</text>
<text wx:if="{{item.paymentInfo.payNoText}}" class="assist-desc">支付单:{{item.paymentInfo.payNoText}}</text>
</view>
<view class="payment-amount">
<text>{{item.paymentInfo.amountText}}</text>
<text wx:if="{{item.paymentInfo.isPaid}}">实付 {{item.paymentInfo.paidAmountText}}</text>
</view>
</view>
<view wx:if="{{item.afterSaleSummary}}" class="after-sale-summary">
<text class="assist-label">售后进度</text>
<text class="assist-main">{{item.afterSaleSummary.typeText}} · {{item.afterSaleSummary.statusText}}</text>
<text wx:if="{{item.afterSaleSummary.amountText}}" class="assist-desc">申请金额:{{item.afterSaleSummary.amountText}}</text>
<text wx:if="{{item.afterSaleSummary.reasonText}}" class="assist-desc">原因:{{item.afterSaleSummary.reasonText}}</text>
<text wx:if="{{item.afterSaleSummary.auditReasonText}}" class="assist-desc">处理说明:{{item.afterSaleSummary.auditReasonText}}</text>
</view>
<view wx:if="{{item.timeline && item.timeline.length}}" class="order-timeline">
<view
wx:for="{{item.timeline}}"
wx:key="key"
wx:for-item="node"
class="timeline-node {{node.done ? 'done' : ''}} {{node.active ? 'active' : ''}}"
>
<text class="timeline-title">{{node.title}}</text>
<text class="timeline-text">{{node.text}}</text>
<text wx:if="{{node.subText}}" class="timeline-sub">{{node.subText}}</text>
</view>
</view>
<view wx:for="{{item.items}}" wx:key="id" wx:for-item="orderItem" class="order-item {{orderItem.focusTarget ? 'focus-target' : ''}}">
<image class="order-thumb" src="{{orderItem.productImageUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
<view class="order-main">
<view class="order-title">{{orderItem.productTitle}}</view>
<view class="order-line">{{orderItem.priceText}} x {{orderItem.quantity}}</view>
<view wx:if="{{orderItem.artistName}}" class="order-line">美甲师:{{orderItem.artistName}}</view>
<view wx:if="{{orderItem.appointmentText}}" class="order-line">预约时间:{{orderItem.appointmentText}}</view>
<view wx:if="{{orderItem.reviewSummary}}" class="review-summary">
<text class="assist-label">评价状态</text>
<text class="assist-main">{{orderItem.reviewSummary.displayText}}</text>
<text wx:if="{{orderItem.reviewSummary.contentText}}" class="assist-desc">{{orderItem.reviewSummary.contentText}}</text>
</view>
<view wx:elif="{{orderItem.pendingReview}}" class="review-panel">
<view class="review-panel-head">
<text class="assist-label">评价美甲师</text>
<text class="assist-desc">评分必填,文字可选</text>
</view>
<view class="score-row">
<view
wx:for="{{reviewScoreOptions}}"
wx:key="*this"
wx:for-item="score"
class="score-chip {{orderItem.reviewDraft.rating == score ? 'active' : ''}}"
data-review-id="{{orderItem.pendingReview.id}}"
data-score="{{score}}"
bindtap="handleSelectReviewScore"
>{{score}}</view>
</view>
<textarea
class="review-textarea"
maxlength="200"
placeholder="写下这次服务体验,可不填"
placeholder-class="textarea-placeholder"
value="{{orderItem.reviewDraft.content}}"
data-review-id="{{orderItem.pendingReview.id}}"
bindinput="handleReviewContentInput"
></textarea>
<view class="review-submit-btn" data-review-id="{{orderItem.pendingReview.id}}" bindtap="handleSubmitReview">提交评价</view>
</view>
<view wx:if="{{orderItem.pendingArtistChangeRequest}}" class="change-panel">
<text class="assist-label">待确认改派</text>
<text class="assist-main">{{orderItem.pendingArtistChangeRequest.originalArtistText}}</text>
<text class="assist-main">{{orderItem.pendingArtistChangeRequest.requestedArtistText}}</text>
<text wx:if="{{orderItem.pendingArtistChangeRequest.reasonText}}" class="assist-desc">原因:{{orderItem.pendingArtistChangeRequest.reasonText}}</text>
<view class="impact-list">
<text
wx:for="{{orderItem.pendingArtistChangeRequest.impactLines}}"
wx:key="*this"
wx:for-item="impactLine"
class="impact-line"
>{{impactLine}}</text>
</view>
<view class="change-actions">
<view class="change-btn primary" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" data-confirm-text="{{orderItem.pendingArtistChangeRequest.confirmText}}" bindtap="handleApproveArtistChange">同意改派</view>
<view class="change-btn" data-request-id="{{orderItem.pendingArtistChangeRequest.id}}" data-confirm-text="{{orderItem.pendingArtistChangeRequest.confirmText}}" bindtap="handleRejectArtistChange">拒绝</view>
</view>
</view>
</view>
</view>
<view class="order-foot">
<text class="order-amount">总计:{{item.actualAmountText}}</text>
<view class="order-actions">
<view wx:if="{{item.paymentInfo.canPay}}" class="pay-btn" data-order-id="{{item.id}}" bindtap="handlePayOrder">去支付</view>
<view wx:if="{{item.canApplyAfterSale}}" class="after-sale-btn" data-order-id="{{item.id}}" bindtap="handleApplyAfterSale">申请售后</view>
<view wx:if="{{item.canRebook}}" class="rebook-btn" data-order-id="{{item.id}}" bindtap="handleRebookOrder">复刻同款</view>
<view wx:if="{{item.status == 1}}" class="cancel-btn" data-order-id="{{item.id}}" bindtap="handleCancelOrder">取消订单</view>
</view>
</view>
</view>
</block>
<view wx:elif="{{loading}}" class="page-card empty-card">
<text class="empty-title">正在加载订单</text>
</view>
<view wx:elif="{{recoveryState.visible}}" class="page-card recovery-card">
<text class="recovery-title">{{recoveryState.title}}</text>
<text class="recovery-desc">{{recoveryState.message}}</text>
<view class="recovery-actions">
<view
wx:for="{{recoveryState.actions}}"
wx:key="key"
class="recovery-btn {{item.primary ? 'primary' : ''}}"
data-key="{{item.key}}"
bindtap="handleRecoveryAction"
>{{item.text}}</view>
</view>
</view>
<view wx:else class="page-card empty-card">
<text class="empty-title">你还没有订单</text>
<text class="empty-desc">先去预约喜欢的款式。</text>
</view>
</view>
</view>
+447
View File
@@ -0,0 +1,447 @@
.orders-hero {
margin-bottom: 20rpx;
}
.recovery-card {
display: flex;
flex-direction: column;
gap: 14rpx;
padding: 26rpx;
border: 2rpx solid var(--theme-border);
}
.recovery-title {
font-size: 30rpx;
font-weight: 800;
color: var(--text-primary);
}
.recovery-desc {
font-size: 24rpx;
line-height: 1.6;
color: var(--text-secondary);
}
.recovery-actions {
display: flex;
flex-wrap: wrap;
gap: 14rpx;
}
.recovery-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 136rpx;
height: 60rpx;
padding: 0 20rpx;
border-radius: 999rpx;
background: var(--theme-card-bg);
border: 2rpx solid var(--theme-border);
color: var(--theme-primary-action);
font-size: 24rpx;
font-weight: 700;
}
.recovery-btn.primary {
background: var(--theme-primary);
border-color: var(--theme-primary);
color: var(--theme-neutral);
}
.order-card + .order-card {
margin-top: 20rpx;
}
.order-card {
padding: 26rpx;
}
.order-card.focus-target {
border-color: var(--theme-primary);
box-shadow: 0 18rpx 48rpx rgba(197, 160, 89, 0.18);
}
.order-head,
.order-foot {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18rpx;
}
.order-head {
padding-bottom: 18rpx;
border-bottom: 2rpx solid var(--theme-border);
}
.order-shop {
margin: 14rpx 0 0;
color: var(--text-secondary);
font-size: 24rpx;
line-height: 1.5;
}
.payment-panel {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18rpx;
margin-top: 18rpx;
padding: 18rpx 20rpx;
border-radius: 18rpx;
background: var(--theme-primary-soft);
}
.payment-copy {
flex: 1;
min-width: 0;
}
.payment-amount {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 6rpx;
color: var(--text-primary);
font-size: 26rpx;
font-weight: 800;
}
.payment-amount text:last-child {
color: var(--text-secondary);
font-size: 22rpx;
font-weight: 600;
}
.after-sale-summary {
margin-top: 16rpx;
padding: 18rpx 20rpx;
border-radius: 18rpx;
background: var(--theme-secondary-soft);
border: 2rpx solid var(--theme-border);
}
.order-timeline {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 10rpx;
margin-top: 18rpx;
}
.timeline-node {
min-width: 0;
padding: 12rpx 10rpx;
border-radius: 12rpx;
background: var(--theme-primary-soft);
color: var(--text-secondary);
}
.timeline-node.done {
color: var(--theme-primary);
}
.timeline-node.active {
outline: 2rpx solid var(--theme-primary);
}
.timeline-title,
.timeline-text,
.timeline-sub {
display: block;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.timeline-title {
font-size: 21rpx;
font-weight: 800;
color: var(--text-primary);
}
.timeline-text,
.timeline-sub {
margin-top: 4rpx;
font-size: 20rpx;
}
.order-head-copy {
flex: 1;
min-width: 0;
}
.order-label {
display: block;
font-size: 22rpx;
color: var(--text-secondary);
}
.order-no {
display: block;
margin-top: 10rpx;
font-size: 24rpx;
line-height: 1.6;
color: var(--theme-primary-action);
}
.order-status {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 120rpx;
height: 48rpx;
padding: 0 16rpx;
border-radius: 999rpx;
font-size: 22rpx;
font-weight: 700;
}
.order-status.pending {
background: var(--theme-primary-soft);
color: var(--theme-tertiary);
}
.order-status.completed {
background: var(--theme-primary-soft);
color: var(--theme-primary);
}
.order-status.cancelled {
background: var(--theme-primary-soft);
color: var(--theme-tertiary);
}
.order-item {
display: flex;
gap: 18rpx;
margin-top: 22rpx;
}
.order-item.focus-target {
padding: 12rpx;
border-radius: 18rpx;
background: var(--theme-primary-soft);
outline: 2rpx solid var(--theme-primary);
}
.order-thumb {
width: 132rpx;
height: 132rpx;
border-radius: 20rpx;
background: var(--theme-primary-soft);
}
.order-main {
flex: 1;
min-width: 0;
}
.order-title {
font-size: 28rpx;
font-weight: 700;
color: var(--text-primary);
line-height: 1.5;
}
.order-line {
margin-top: 10rpx;
font-size: 24rpx;
color: var(--text-secondary);
line-height: 1.6;
}
.order-foot {
margin-top: 24rpx;
align-items: center;
}
.order-actions {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 14rpx;
}
.order-amount {
font-size: 28rpx;
font-weight: 700;
color: var(--text-primary);
}
.pay-btn,
.after-sale-btn,
.cancel-btn,
.rebook-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 144rpx;
height: 60rpx;
padding: 0 18rpx;
border-radius: 999rpx;
font-size: 24rpx;
font-weight: 700;
}
.pay-btn {
background: var(--theme-primary);
color: var(--theme-neutral);
}
.after-sale-btn {
background: var(--theme-card-bg);
border: 2rpx solid var(--theme-border);
color: var(--theme-primary-action);
}
.rebook-btn {
background: var(--theme-primary);
color: var(--theme-neutral);
}
.cancel-btn {
background: var(--theme-primary-soft);
color: var(--theme-tertiary);
}
.review-summary,
.review-panel,
.change-panel {
margin-top: 18rpx;
padding: 20rpx;
border-radius: 18rpx;
background: var(--theme-secondary-soft);
border: 2rpx solid var(--theme-border);
}
.review-panel-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.assist-label,
.assist-main,
.assist-desc {
display: block;
}
.assist-label {
font-size: 22rpx;
color: var(--text-secondary);
line-height: 1.5;
}
.assist-main {
margin-top: 8rpx;
font-size: 26rpx;
font-weight: 700;
color: var(--text-primary);
line-height: 1.5;
}
.assist-desc {
margin-top: 8rpx;
font-size: 24rpx;
color: var(--text-secondary);
line-height: 1.6;
}
.impact-list {
display: flex;
flex-direction: column;
gap: 8rpx;
margin-top: 12rpx;
}
.impact-line {
font-size: 24rpx;
font-weight: 700;
color: var(--theme-primary);
line-height: 1.5;
}
.score-row {
display: flex;
flex-wrap: wrap;
gap: 12rpx;
margin-top: 16rpx;
}
.score-chip {
display: inline-flex;
align-items: center;
justify-content: center;
width: 72rpx;
height: 52rpx;
border-radius: 999rpx;
background: var(--theme-card-bg);
border: 2rpx solid var(--theme-border);
color: var(--theme-primary-action);
font-size: 24rpx;
font-weight: 700;
}
.score-chip.active {
background: var(--theme-primary);
border-color: var(--theme-primary);
color: var(--theme-neutral);
}
.review-textarea {
width: 100%;
min-height: 136rpx;
box-sizing: border-box;
margin-top: 16rpx;
padding: 16rpx;
border-radius: 16rpx;
background: var(--theme-card-bg);
border: 2rpx solid var(--theme-border);
color: var(--text-primary);
font-size: 24rpx;
line-height: 1.6;
}
.textarea-placeholder {
color: var(--text-secondary);
}
.review-submit-btn,
.change-btn {
display: inline-flex;
align-items: center;
justify-content: center;
height: 58rpx;
padding: 0 22rpx;
border-radius: 999rpx;
font-size: 24rpx;
font-weight: 700;
}
.review-submit-btn {
margin-top: 16rpx;
background: var(--theme-primary);
color: var(--theme-neutral);
}
.change-actions {
display: flex;
flex-wrap: wrap;
gap: 14rpx;
margin-top: 16rpx;
}
.change-btn {
background: var(--theme-card-bg);
border: 2rpx solid var(--theme-border);
color: var(--theme-primary-action);
}
.change-btn.primary {
background: var(--theme-primary);
border-color: var(--theme-primary);
color: var(--theme-neutral);
}

Some files were not shown because too many files have changed in this diff Show More