功能:重建指尖管理师规划系统
This commit is contained in:
@@ -0,0 +1,199 @@
|
||||
/**
|
||||
* Purpose: orderApi loads full backend order detail so direct entry and message navigation can render complete data.
|
||||
* Usage: call getOrderDetail with the current route id before displaying the order detail page.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
const paymentApi = require('../../api/payment')
|
||||
const permission = require('../../utils/permission')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: format supports index.js by holding or executing the format page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const format = require('../../utils/format')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { markDirty } = require('../../utils/page-state')
|
||||
|
||||
function getPaymentStatusText(status) {
|
||||
if (status === 'PAID') {
|
||||
return '已支付'
|
||||
}
|
||||
if (status === 'PAYING') {
|
||||
return '支付中'
|
||||
}
|
||||
if (status === 'REFUNDED') {
|
||||
return '已退款'
|
||||
}
|
||||
return '未支付'
|
||||
}
|
||||
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: loading marks whether the detail endpoint is currently fetching order data.
|
||||
* Usage: bind it to loading and retry states while preserving any cached order shown on screen.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: orderId keeps the backend order id used by reload and direct-entry flows.
|
||||
* Usage: set it from route options or cached list data before calling loadOrderDetail.
|
||||
*/
|
||||
orderId: '',
|
||||
/**
|
||||
* Purpose: order supports index.js by holding or executing the order page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
order: null,
|
||||
canManualConfirmPay: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad supports index.js by holding or executing the on load page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
const cachedOrder = getTempRecord('currentOrder', null)
|
||||
const orderId = (options && options.id) || (cachedOrder && cachedOrder.id) || ''
|
||||
this.setData({
|
||||
orderId,
|
||||
order: cachedOrder ? this.formatOrder(cachedOrder) : null,
|
||||
canManualConfirmPay: permission.hasPermission(permissionCodes, 'payment:manage')
|
||||
})
|
||||
|
||||
if (orderId) {
|
||||
this.loadOrderDetail(orderId)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: loadOrderDetail replaces list-row summary data with the authoritative admin order-detail response.
|
||||
* Usage: call it from onLoad and retry buttons with the backend order id; failures leave cached data visible.
|
||||
*/
|
||||
async loadOrderDetail(orderId) {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const detail = await orderApi.getOrderDetail(orderId)
|
||||
this.setData({
|
||||
order: this.formatOrder(detail)
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '订单详情加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: formatOrder prepares order and item fields for WXML, including review and change-request summaries.
|
||||
* Usage: run every cached or fetched order object through this method before assigning it to data.order.
|
||||
*/
|
||||
formatOrder(order) {
|
||||
const items = Array.isArray(order && order.items) ? order.items : []
|
||||
const paymentStatus = order && order.paymentStatus ? order.paymentStatus : 'UNPAID'
|
||||
return order ? {
|
||||
...order,
|
||||
displayStatusText: format.getOrderStatusText(order),
|
||||
displayPaymentStatusText: getPaymentStatusText(paymentStatus),
|
||||
displayCreateTime: format.formatDateTime(order.createTime),
|
||||
displayPayAmount: format.formatPrice(order.payAmount || order.actualAmount),
|
||||
displayPaidAmount: format.formatPrice(order.paidAmount),
|
||||
displayPayTime: format.formatDateTime(order.payTime),
|
||||
canManualConfirmPay: paymentStatus !== 'PAID' && paymentStatus !== 'REFUNDED',
|
||||
items: items.map(item => ({
|
||||
...item,
|
||||
displayAppointmentTime: item.appointmentTime ? format.formatDateTime(item.appointmentTime) : '',
|
||||
reviewStatusText: item.reviewStatusText || (item.reviewSummary ? '已评价' : '待评价'),
|
||||
changeStatusText: item.pendingArtistChangeRequest ? item.pendingArtistChangeRequest.displayText : ''
|
||||
}))
|
||||
} : null
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleRetry reloads backend detail when direct entry failed or no cached data exists.
|
||||
* Usage: bind it to the empty state action so operators can recover without returning to the list.
|
||||
*/
|
||||
handleRetry() {
|
||||
if (!this.data.orderId) {
|
||||
navigation.goBack('/pages/orders/index')
|
||||
return
|
||||
}
|
||||
this.loadOrderDetail(this.data.orderId)
|
||||
},
|
||||
|
||||
async handleManualConfirmPay() {
|
||||
if (!this.data.canManualConfirmPay) {
|
||||
wx.showToast({
|
||||
title: '当前账号没有确认支付权限',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const order = this.data.order
|
||||
if (!order) {
|
||||
return
|
||||
}
|
||||
const remark = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '手动确认支付',
|
||||
content: `确认将订单 ${order.orderNo || order.id} 标记为已支付?`,
|
||||
editable: true,
|
||||
placeholderText: '备注,可留空',
|
||||
confirmText: '确认',
|
||||
success: result => {
|
||||
if (!result.confirm) {
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
resolve(String(result.content || '').trim())
|
||||
},
|
||||
fail: () => resolve(null)
|
||||
})
|
||||
})
|
||||
if (remark === null) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await paymentApi.manualConfirmOrder(order.id, remark)
|
||||
markDirty('admin-orders')
|
||||
markDirty('admin-workbench')
|
||||
wx.showToast({
|
||||
title: '支付已确认',
|
||||
icon: 'none'
|
||||
})
|
||||
this.loadOrderDetail(order.id)
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '确认支付失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
onUnload() {
|
||||
clearTempRecord('currentOrder')
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBack supports index.js by holding or executing the handle back page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/orders/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/admin/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<navigation-bar title="订单详情" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||
|
||||
<view class="page-shell">
|
||||
<view class="page-stack">
|
||||
<view wx:if="{{order}}" class="surface-card">
|
||||
<text class="section-title">{{order.orderNo}}</text>
|
||||
<text class="section-desc">{{order.displayStatusText}} · {{order.displayCreateTime}}</text>
|
||||
<view class="meta-grid">
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">用户昵称</text>
|
||||
<text class="meta-value">{{order.customerNickname || order.userNickname || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">脱敏手机号</text>
|
||||
<text class="meta-value">{{order.customerPhoneMasked || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">所属店铺</text>
|
||||
<text class="meta-value">{{order.shopName || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">美甲师</text>
|
||||
<text class="meta-value">{{order.artistName || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">应付金额</text>
|
||||
<text class="meta-value">¥{{order.displayPayAmount || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">支付状态</text>
|
||||
<text class="meta-value">{{order.displayPaymentStatusText}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">已付金额</text>
|
||||
<text class="meta-value">¥{{order.displayPaidAmount}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">支付时间</text>
|
||||
<text class="meta-value">{{order.displayPayTime || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">备注</text>
|
||||
<text class="meta-value">{{order.remark || '暂无备注'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{canManualConfirmPay && order.canManualConfirmPay}}" class="action-row">
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="handleManualConfirmPay">手动确认支付</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{order && order.items && order.items.length}}" class="surface-card">
|
||||
<text class="section-title">服务项目</text>
|
||||
<block wx:for="{{order.items}}" wx:key="id">
|
||||
<view class="detail-item">
|
||||
<view class="detail-item-head">
|
||||
<text class="detail-item-title">{{item.productTitle || '订单项目'}}</text>
|
||||
<text class="badge">{{item.reviewStatusText}}</text>
|
||||
</view>
|
||||
<text class="detail-item-line">美甲师:{{item.artistName || '--'}}</text>
|
||||
<text wx:if="{{item.displayAppointmentTime}}" class="detail-item-line">预约时间:{{item.displayAppointmentTime}}</text>
|
||||
<text wx:if="{{item.reviewSummary && item.reviewSummary.contentText}}" class="detail-item-line">评价内容:{{item.reviewSummary.contentText}}</text>
|
||||
<view wx:if="{{item.pendingArtistChangeRequest}}" class="change-box">
|
||||
<text class="change-title">改派申请</text>
|
||||
<text class="change-line">{{item.pendingArtistChangeRequest.displayText}}</text>
|
||||
<text wx:if="{{item.pendingArtistChangeRequest.reasonText}}" class="change-line">原因:{{item.pendingArtistChangeRequest.reasonText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!order}}" class="empty-state">
|
||||
<text class="empty-title">订单详情暂不可用</text>
|
||||
<text class="empty-desc">当前详情页可通过列表、消息或订单 id 打开;加载失败时可重试。</text>
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="handleRetry">重新加载</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,56 @@
|
||||
@import "../../app.wxss";
|
||||
.page-shell {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
padding: 20rpx 0;
|
||||
border-top: 1rpx solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.detail-item:first-of-type {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.detail-item-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.detail-item-title {
|
||||
color: #f6efe7;
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.detail-item-line {
|
||||
color: #9fb3ad;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.change-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
padding: 16rpx;
|
||||
border-radius: 8rpx;
|
||||
background: rgba(240, 126, 87, 0.1);
|
||||
}
|
||||
|
||||
.change-title {
|
||||
color: #f6efe7;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.change-line {
|
||||
color: #f4c7b8;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
Reference in New Issue
Block a user