feat(escort): 微信支付入口与取消状态展示
- 下单改为提交预约后弹窗选择支付方式,默认微信支付 - 预约详情支持发起微信支付、查单确认与待支付期间切换支付方式 - 预约列表展示支付渠道、待支付/超时状态并提供去支付入口 - 取消状态与 status 解耦,展示状态优先取 cancelStatus - 详情页医院选择回传字段同步移除 manual
This commit is contained in:
+117
-24
@@ -22,7 +22,7 @@ Page({
|
||||
provinces: [],
|
||||
hospital: '',
|
||||
hospitalOptions: [],
|
||||
hospitalManual: false,
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
minAppointmentDate: '',
|
||||
@@ -34,6 +34,9 @@ Page({
|
||||
remark: '',
|
||||
shippingAddress: '',
|
||||
requiresAddress: false,
|
||||
payChannel: 'online_wechat',
|
||||
// 点击「提交预约」后弹出支付方式选择,默认微信支付
|
||||
showPayPopup: false,
|
||||
gender: '不限',
|
||||
genderIndex: 0,
|
||||
genderOptions: ['不限', '男', '女']
|
||||
@@ -72,12 +75,9 @@ Page({
|
||||
|
||||
const app = getApp()
|
||||
// 启动时 app 已在预取,这里只等它落定后用最新列表刷新下拉;
|
||||
// 没有可用医院时退回手动输入,避免下拉是空的还阻断下单
|
||||
// 列表为空时组件内的「其他医院」入口仍可手填,不会阻断下单
|
||||
app.loadHospitals().then(() => {
|
||||
this.refreshHospitalOptions()
|
||||
if (!this.data.hospitalOptions.length && !this.data.hospitalManual) {
|
||||
this.setData({ hospitalManual: true })
|
||||
}
|
||||
})
|
||||
await app.waitForAuth()
|
||||
if (app.globalData.user?._id) this.loadProfiles()
|
||||
@@ -122,7 +122,7 @@ Page({
|
||||
province: provinces[0] || '',
|
||||
provinceIndex: 0,
|
||||
hospital: '',
|
||||
hospitalManual: false,
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
shippingAddress: '',
|
||||
@@ -209,7 +209,7 @@ Page({
|
||||
provinceIndex: index,
|
||||
province,
|
||||
hospital: '',
|
||||
hospitalManual: false
|
||||
hospitalCustom: false
|
||||
}, () => this.refreshHospitalOptions(province))
|
||||
},
|
||||
|
||||
@@ -218,7 +218,8 @@ Page({
|
||||
const hospitalOptions = getApp().getHospitalsByProvince(province)
|
||||
let hospital = ''
|
||||
|
||||
if (this.data.hospitalManual) {
|
||||
if (this.data.hospitalCustom) {
|
||||
// 「其他医院」手填的名称不在库内,刷新列表时原样保留
|
||||
hospital = this.data.hospital
|
||||
} else {
|
||||
const selected = hospitalOptions.find((item) => item._id === this.selectedHospitalId)
|
||||
@@ -233,11 +234,11 @@ Page({
|
||||
this.setData({ hospitalOptions, hospital })
|
||||
},
|
||||
|
||||
// 医院选择组件回传:name 为最终值,manual 表示是否手动输入,hospital 为库内记录
|
||||
// 医院选择组件回传:name 为最终值,manual 表示是否为「其他医院」手填,hospital 为库内记录
|
||||
onHospitalChange(e) {
|
||||
const { name, manual, hospital } = e.detail
|
||||
this.selectedHospitalId = hospital?._id || ''
|
||||
this.setData({ hospital: name, hospitalManual: manual })
|
||||
this.setData({ hospital: name, hospitalCustom: manual })
|
||||
},
|
||||
|
||||
onDateChange(e) {
|
||||
@@ -263,6 +264,13 @@ Page({
|
||||
this.setData({ remark: e.detail.value })
|
||||
},
|
||||
|
||||
onPayChannelChange(e) {
|
||||
const channel = e.currentTarget.dataset.channel
|
||||
if (!['online_wechat', 'offline'].includes(channel)) return
|
||||
if (this.data.submitting) return
|
||||
this.setData({ payChannel: channel })
|
||||
},
|
||||
|
||||
onShippingAddressChange(e) {
|
||||
this.setData({ shippingAddress: e.detail.value })
|
||||
},
|
||||
@@ -270,7 +278,9 @@ Page({
|
||||
validateOrder() {
|
||||
const data = this.data
|
||||
if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人'
|
||||
if (!data.hospital.trim()) return data.hospitalManual ? '请输入就诊医院' : '请选择就诊医院'
|
||||
if (!data.hospital.trim()) {
|
||||
return data.hospitalOptions.length ? '请选择就诊医院' : '请填写就诊医院名称'
|
||||
}
|
||||
if (!data.appointmentDate) return '请选择预约日期'
|
||||
if (!data.appointmentTime) return '请选择预约时间'
|
||||
if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址'
|
||||
@@ -282,7 +292,26 @@ Page({
|
||||
|
||||
async submitOrder() {
|
||||
if (this.data.submitting) return
|
||||
this.setData({ submitting: true })
|
||||
// 先做一次表单校验,避免用户选完支付方式才发现信息没填全
|
||||
const error = this.validateOrder()
|
||||
if (error) {
|
||||
wx.showToast({ title: error, icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ showPayPopup: true, payChannel: 'online_wechat' })
|
||||
},
|
||||
|
||||
onClosePayPopup() {
|
||||
if (this.data.submitting) return
|
||||
this.setData({ showPayPopup: false })
|
||||
},
|
||||
|
||||
/**
|
||||
* 确认支付方式后真正提交订单
|
||||
*/
|
||||
async onConfirmPay() {
|
||||
if (this.data.submitting) return
|
||||
this.setData({ submitting: true, showPayPopup: false })
|
||||
try {
|
||||
const loggedIn = await this.ensureLogin()
|
||||
if (loggedIn === null) return
|
||||
@@ -298,9 +327,36 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
const payChannel = this.data.payChannel
|
||||
const orderData = this.buildOrderData()
|
||||
|
||||
// 网络重试沿用同一幂等键,服务端只创建一笔订单。
|
||||
const res = await API.escort.createRecord(orderData)
|
||||
if (res.code !== 0) throw new Error(res.msg || '下单失败')
|
||||
const record = res.data?.record
|
||||
this.resetForm()
|
||||
|
||||
if (payChannel === 'offline') {
|
||||
wx.showToast({ title: '线下支付,请联系平台收款', icon: 'none' })
|
||||
wx.navigateTo({ url: '/pages/escort/recordlist?tab=ongoing' })
|
||||
return
|
||||
}
|
||||
|
||||
// 选微信支付:下单成功后立即拉起收银台,支付结果以后端查单为准
|
||||
if (record?._id) await this.startWechatPay(record._id)
|
||||
else wx.navigateTo({ url: '/pages/escort/recordlist?tab=ongoing' })
|
||||
} catch (err) {
|
||||
console.log('下单失败', err)
|
||||
wx.showToast({ title: err.message || '网络请求失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ submitting: false })
|
||||
}
|
||||
},
|
||||
|
||||
buildOrderData() {
|
||||
const data = this.data
|
||||
const sexMap = { 男: 'male', 女: 'female' }
|
||||
const orderData = {
|
||||
return {
|
||||
idempotencyKey: this.idempotencyKey,
|
||||
healthProfileId: data.selectedProfileId,
|
||||
escort: {
|
||||
@@ -316,20 +372,57 @@ Page({
|
||||
startTime: data.appointmentTime
|
||||
},
|
||||
shippingAddress: { address: data.shippingAddress.trim() },
|
||||
notes: { patientNote: data.remark.trim() }
|
||||
notes: { patientNote: data.remark.trim() },
|
||||
payment: { payChannel: data.payChannel }
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 发起微信支付:payOrder → requestPayment → 查单确认
|
||||
* 支付按钮防抖(this.paying),前端回调只作提示,最终状态以 getPayStatus 为准
|
||||
*/
|
||||
async startWechatPay(recordId) {
|
||||
if (this.paying) return
|
||||
this.paying = true
|
||||
let paid = false
|
||||
try {
|
||||
const res = await API.escort.payOrder(recordId)
|
||||
if (res.code !== 0 || !res.data?.payParams) {
|
||||
wx.showToast({ title: res.msg || '支付发起失败,请稍后重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
// 网络重试沿用同一幂等键,服务端只创建一笔订单。
|
||||
const res = await API.escort.createRecord(orderData)
|
||||
if (res.code !== 0) throw new Error(res.msg || '下单失败')
|
||||
wx.showToast({ title: '下单成功', icon: 'success' })
|
||||
this.resetForm()
|
||||
wx.navigateTo({ url: '/pages/escort/recordlist?tab=ongoing' })
|
||||
const payResult = await new Promise((resolve) => {
|
||||
wx.requestPayment({
|
||||
...res.data.payParams,
|
||||
success: () => resolve({ ok: true }),
|
||||
fail: (err) => resolve({ ok: false, err })
|
||||
})
|
||||
})
|
||||
|
||||
if (!payResult.ok) {
|
||||
const errMsg = payResult.err?.errMsg || ''
|
||||
if (/cancel/i.test(errMsg)) {
|
||||
wx.showToast({ title: '已取消支付', icon: 'none' })
|
||||
return
|
||||
}
|
||||
// 非取消失败可能是网络中断但支付已成功:先查单兜底
|
||||
}
|
||||
|
||||
const statusRes = await API.escort.getPayStatus(recordId).catch(() => null)
|
||||
paid = statusRes?.code === 0 && statusRes.data?.paymentStatus === 'paid'
|
||||
wx.showToast({
|
||||
title: paid ? '支付成功' : '支付结果确认中',
|
||||
icon: paid ? 'success' : 'none'
|
||||
})
|
||||
} catch (err) {
|
||||
console.log('下单失败', err)
|
||||
wx.showToast({ title: err.message || '网络请求失败,请重试', icon: 'none' })
|
||||
console.log('发起支付失败', err)
|
||||
wx.showToast({ title: '支付发起失败,请稍后重试', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ submitting: false })
|
||||
this.paying = false
|
||||
setTimeout(() => {
|
||||
wx.navigateTo({ url: `/pages/escort/recorddetail?id=${recordId}` })
|
||||
}, paid ? 600 : 0)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -344,7 +437,7 @@ Page({
|
||||
province: provinces[0] || '',
|
||||
provinceIndex: 0,
|
||||
hospital: '',
|
||||
hospitalManual: false,
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
sessionIndex: 0,
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
<view class="patient-chip {{selectedProfileId === item._id ? 'active' : ''}}" wx:for="{{profiles}}" wx:key="_id"
|
||||
data-id="{{item._id}}" bindtap="onSelectProfile">
|
||||
<text class="patient-chip-name">{{item.name}}</text>
|
||||
<text class="patient-chip-phone">{{item.mobile}}</text>
|
||||
</view>
|
||||
<view class="patient-chip patient-chip-add" bindtap="goToAddProfile">
|
||||
<text class="patient-chip-name">+ 添加就诊人</text>
|
||||
<view class="patient-chip patient-chip-add" bindtap="goToAddProfile" aria-role="button" aria-label="增加就诊人">
|
||||
<t-icon name="add" size="28rpx" color="#9B4508" />
|
||||
<text class="patient-chip-name">增加</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -70,7 +70,6 @@
|
||||
<hospital-select
|
||||
label="就诊医院"
|
||||
value="{{hospital}}"
|
||||
manual="{{hospitalManual}}"
|
||||
options="{{hospitalOptions}}"
|
||||
placeholder="请选择就诊医院"
|
||||
disabled="{{submitting}}"
|
||||
@@ -136,4 +135,48 @@
|
||||
<text class="page-state-text">{{pageError}}</text>
|
||||
<button class="page-retry" bindtap="retryLoad">重新加载</button>
|
||||
</view>
|
||||
|
||||
<!-- 支付方式选择弹窗:点击「提交预约」后出现,默认微信支付 -->
|
||||
<view class="popup-mask {{showPayPopup ? 'show' : ''}}" bindtap="onClosePayPopup"></view>
|
||||
<view class="popup-content {{showPayPopup ? 'show' : ''}}">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">选择支付方式</text>
|
||||
<view class="popup-close" aria-role="button" aria-label="关闭弹窗" bindtap="onClosePayPopup">
|
||||
<t-icon name="close" size="40rpx" color="#6F655C" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="popup-body">
|
||||
<view class="pay-channel-options">
|
||||
<view
|
||||
class="pay-channel-option {{payChannel === 'online_wechat' ? 'active' : ''}}"
|
||||
data-channel="online_wechat"
|
||||
bindtap="onPayChannelChange"
|
||||
>
|
||||
<view class="pay-channel-text">
|
||||
<text class="pay-channel-title">微信支付</text>
|
||||
<text class="pay-channel-desc">提交后立即拉起收银台</text>
|
||||
</view>
|
||||
<view class="pay-channel-radio {{payChannel === 'online_wechat' ? 'checked' : ''}}"></view>
|
||||
</view>
|
||||
<view
|
||||
class="pay-channel-option {{payChannel === 'offline' ? 'active' : ''}}"
|
||||
data-channel="offline"
|
||||
bindtap="onPayChannelChange"
|
||||
>
|
||||
<view class="pay-channel-text">
|
||||
<text class="pay-channel-title">线下支付</text>
|
||||
<text class="pay-channel-desc">平台收款后确认订单</text>
|
||||
</view>
|
||||
<view class="pay-channel-radio {{payChannel === 'offline' ? 'checked' : ''}}"></view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="pay-popup-tip">微信支付可立即完成付款;线下支付由平台收款后再确认订单。</text>
|
||||
</view>
|
||||
<view class="popup-footer">
|
||||
<view class="popup-btn popup-btn-ghost" bindtap="onClosePayPopup">取消</view>
|
||||
<view class="popup-btn popup-btn-primary" bindtap="onConfirmPay">
|
||||
{{submitting ? '提交中...' : '确认提交'}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
+176
-7
@@ -212,8 +212,11 @@ page {
|
||||
.patient-chip {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
min-width: 180rpx;
|
||||
/* 140rpx:只显示姓名,胶囊按名字长度收紧,不再为手机号预留宽度 */
|
||||
min-width: 140rpx;
|
||||
padding: 16rpx 24rpx;
|
||||
border: 2rpx solid var(--line);
|
||||
border-radius: 16rpx;
|
||||
@@ -242,14 +245,15 @@ page {
|
||||
color: var(--brand-ink);
|
||||
}
|
||||
|
||||
.patient-chip-phone {
|
||||
margin-top: 6rpx;
|
||||
color: var(--ink-2);
|
||||
font-size: var(--fs-28);
|
||||
}
|
||||
|
||||
.patient-chip-add {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4rpx;
|
||||
/* 虚线描边 + 白底:与「已选就诊人」的实心浅橙底区分开,
|
||||
一眼看出这是动作入口而不是某个就诊人 */
|
||||
background: var(--white);
|
||||
border: 2rpx dashed var(--brand-line);
|
||||
}
|
||||
|
||||
.add-profile-tip {
|
||||
@@ -375,6 +379,171 @@ page {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* 支付方式:两张可选卡片,选中态沿用品牌橙 */
|
||||
.pay-channel-options {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.pay-channel-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 24rpx;
|
||||
border: 2rpx solid var(--line);
|
||||
border-radius: 18rpx;
|
||||
background: var(--paper);
|
||||
}
|
||||
|
||||
.pay-channel-option.active {
|
||||
border-color: var(--brand-line);
|
||||
background: var(--brand-soft);
|
||||
}
|
||||
|
||||
.pay-channel-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
}
|
||||
|
||||
.pay-channel-title {
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.pay-channel-desc {
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-24);
|
||||
}
|
||||
|
||||
.pay-channel-radio {
|
||||
flex-shrink: 0;
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
border: 2rpx solid var(--line);
|
||||
border-radius: 50%;
|
||||
background: var(--white);
|
||||
}
|
||||
|
||||
.pay-channel-radio.checked {
|
||||
border-color: var(--brand-strong);
|
||||
background: var(--brand-strong);
|
||||
}
|
||||
|
||||
.pay-popup-tip {
|
||||
display: block;
|
||||
margin-top: 20rpx;
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-24);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* ===== 支付方式底部弹窗 ===== */
|
||||
.popup-mask {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 200;
|
||||
background: rgba(43, 37, 33, 0.45);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 0.3s ease, visibility 0.3s ease;
|
||||
}
|
||||
|
||||
.popup-mask.show {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 201;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 70vh;
|
||||
background: var(--white);
|
||||
border-radius: 32rpx 32rpx 0 0;
|
||||
transform: translateY(100%);
|
||||
transition: transform 0.3s ease-out;
|
||||
}
|
||||
|
||||
.popup-content.show {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-shrink: 0;
|
||||
padding: 28rpx 32rpx;
|
||||
border-bottom: 2rpx solid var(--line);
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-32);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.popup-close {
|
||||
padding: 8rpx;
|
||||
margin: -8rpx;
|
||||
}
|
||||
|
||||
.popup-close:active {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.popup-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20rpx 32rpx 28rpx;
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
flex-shrink: 0;
|
||||
padding: 20rpx 32rpx;
|
||||
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
|
||||
border-top: 2rpx solid var(--line);
|
||||
}
|
||||
|
||||
.popup-btn {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 22rpx 0;
|
||||
border-radius: 999rpx;
|
||||
font-size: var(--fs-30);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.popup-btn:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.popup-btn-ghost {
|
||||
border: 3rpx solid var(--sep);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.popup-btn-primary {
|
||||
background: var(--brand-strong);
|
||||
color: var(--white);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.patient-chip,
|
||||
.add-profile-tip,
|
||||
|
||||
+137
-21
@@ -1,7 +1,7 @@
|
||||
const API = require('../../utils/api.js')
|
||||
|
||||
const { parseDate, formatDate, formatDateTime, calcAge } = require('../../utils/date.js')
|
||||
const { STATUS_MAP, PAYMENT_STATUS_MAP } = require('../../utils/order.js')
|
||||
const { STATUS_MAP, PAYMENT_STATUS_MAP, resolveOrderStatus } = require('../../utils/order.js')
|
||||
const { maskIdNumber, maskOrderId } = require('../../utils/privacy.js')
|
||||
|
||||
const SEX_MAP = {
|
||||
@@ -178,18 +178,44 @@ Page({
|
||||
|
||||
formatRecord(item) {
|
||||
const status = item.status
|
||||
const cancelStatus = item.cancelStatus || 'none'
|
||||
// 展示状态:取消状态优先于服务状态(后端 status 不再包含取消值)
|
||||
const displayStatus = resolveOrderStatus(item)
|
||||
const paymentStatus = item.payment?.status || 'unpaid'
|
||||
const statusInfo = STATUS_MAP[status] || STATUS_MAP.pending
|
||||
const statusInfo = STATUS_MAP[displayStatus] || STATUS_MAP.pending
|
||||
const paymentInfo = PAYMENT_STATUS_MAP[paymentStatus] || PAYMENT_STATUS_MAP.unpaid
|
||||
|
||||
// 未支付按渠道与支付窗口区分:线上可去支付、超时仅可改线下或取消、线下等平台收款
|
||||
const payChannel = item.payment?.payChannel || 'offline'
|
||||
const windowEnd = item.paymentWindowEnd ? new Date(item.paymentWindowEnd) : null
|
||||
const paymentExpired = paymentStatus === 'unpaid'
|
||||
&& payChannel === 'online_wechat'
|
||||
&& windowEnd instanceof Date
|
||||
&& !Number.isNaN(windowEnd.getTime())
|
||||
&& Date.now() > windowEnd.getTime()
|
||||
let paymentStatusText = paymentInfo.text
|
||||
if (paymentStatus === 'unpaid') {
|
||||
if (payChannel === 'offline') paymentStatusText = '待收款'
|
||||
else if (paymentExpired) paymentStatusText = '支付已超时'
|
||||
else paymentStatusText = '待支付'
|
||||
} else if (paymentStatus === 'paid' && item.payment?.method === 'online_wechat') {
|
||||
paymentStatusText = '已支付(微信)'
|
||||
}
|
||||
|
||||
// 底栏与「修改」入口的口径在这里算一次,WXML 只读结果,不再重复一串状态判断。
|
||||
// 用户只能取消:未确认且未收款的取消后订单即被删除;已确认/已收款的转为取消申请
|
||||
const canCancel = status === 'pending' || status === 'confirmed'
|
||||
const canRebook = (status === 'completed' || status === 'cancelled') && item.escort?.serviceId > 0
|
||||
const canCancel = cancelStatus === 'none' && (status === 'pending' || status === 'confirmed')
|
||||
const canRebook = (displayStatus === 'completed' || displayStatus === 'cancelled') && item.escort?.serviceId > 0
|
||||
// 终态单据只读:医院预约与陪诊需求不允许回改(就诊人「档案」跳的是档案页,不在此列)
|
||||
// 进行中服务已开始:排期与医院不允许用户单方变更,仅保留就诊人备注(与后端字段白名单一致)
|
||||
const canEditBooking = status === 'pending' || status === 'confirmed'
|
||||
const canEditBooking = cancelStatus === 'none' && (status === 'pending' || status === 'confirmed')
|
||||
const canEditNote = canEditBooking || status === 'in_progress'
|
||||
// 待支付且未超时才能去支付;支付方式仅待支付期间可切换
|
||||
const canPay = paymentStatus === 'unpaid'
|
||||
&& payChannel === 'online_wechat'
|
||||
&& !paymentExpired
|
||||
&& canEditBooking
|
||||
const canSwitchPayChannel = paymentStatus === 'unpaid' && canEditBooking
|
||||
|
||||
// 就诊人字段先落到局部变量:摘要姓名与展开区资料都从同一批值派生,
|
||||
// 口径不在 WXML 与 JS 两处各写一份
|
||||
@@ -242,15 +268,20 @@ Page({
|
||||
paidFee: (item.payment?.paidFee || 0).toFixed(2),
|
||||
showPaidFee: Number(item.payment?.paidFee) > 0,
|
||||
paymentStatus,
|
||||
paymentStatusText: paymentInfo.text,
|
||||
paymentStatusText,
|
||||
paymentStatusColor: paymentInfo.color,
|
||||
paymentStatusBg: paymentInfo.bg,
|
||||
paymentStatusBorder: paymentInfo.border,
|
||||
paymentMethodText: PAYMENT_METHOD_MAP[item.payment?.method] || '',
|
||||
payChannel,
|
||||
payChannelText: payChannel === 'online_wechat' ? '微信支付' : '线下支付',
|
||||
paymentExpired,
|
||||
canPay,
|
||||
canSwitchPayChannel,
|
||||
patientNote: item.notes?.patientNote || '',
|
||||
escortNote: item.notes?.escortNote || '',
|
||||
medicalSummary: item.notes?.medicalSummary || '',
|
||||
status,
|
||||
status: displayStatus,
|
||||
statusText: statusInfo.text,
|
||||
statusColor: statusInfo.color,
|
||||
statusBg: statusInfo.bg,
|
||||
@@ -261,7 +292,7 @@ Page({
|
||||
canEditBooking,
|
||||
canEditNote,
|
||||
// 底栏只在确实有按钮时出现,避免无动作状态空留一条白栏
|
||||
showBottomBar: canCancel || canRebook,
|
||||
showBottomBar: canCancel || canRebook || canPay,
|
||||
createTime: item.meta?.createtime ? formatDateTime(item.meta.createtime) : '',
|
||||
updateTime: item.meta?.updatetime ? formatDateTime(item.meta.updatetime) : ''
|
||||
}
|
||||
@@ -313,6 +344,98 @@ Page({
|
||||
this.setData({ showAllDetails: !this.data.showAllDetails })
|
||||
},
|
||||
|
||||
// ===== 微信支付 =====
|
||||
|
||||
onPayOrder() {
|
||||
if (this.paying) return
|
||||
this.paying = true
|
||||
this.startWechatPay(this.data.recordId)
|
||||
},
|
||||
|
||||
/**
|
||||
* 发起微信支付:payOrder → requestPayment → 查单确认
|
||||
* 前端回调只作提示,最终状态以后端 getPayStatus / 支付回调为准
|
||||
*/
|
||||
async startWechatPay(recordId) {
|
||||
let paid = false
|
||||
try {
|
||||
const res = await API.escort.payOrder(recordId)
|
||||
if (res.code !== 0 || !res.data?.payParams) {
|
||||
wx.showToast({ title: res.msg || '支付发起失败,请稍后重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const payResult = await new Promise((resolve) => {
|
||||
wx.requestPayment({
|
||||
...res.data.payParams,
|
||||
success: () => resolve({ ok: true }),
|
||||
fail: (err) => resolve({ ok: false, err })
|
||||
})
|
||||
})
|
||||
|
||||
if (!payResult.ok && /cancel/i.test(payResult.err?.errMsg || '')) {
|
||||
wx.showToast({ title: '已取消支付', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
// 支付成功或非取消失败都查单兜底(可能已支付但前端网络中断)
|
||||
const statusRes = await API.escort.getPayStatus(recordId).catch(() => null)
|
||||
paid = statusRes?.code === 0 && statusRes.data?.paymentStatus === 'paid'
|
||||
wx.showToast({
|
||||
title: paid ? '支付成功' : '支付结果确认中',
|
||||
icon: paid ? 'success' : 'none'
|
||||
})
|
||||
} catch (err) {
|
||||
console.log('发起支付失败', err)
|
||||
wx.showToast({ title: '支付发起失败,请稍后重试', icon: 'none' })
|
||||
} finally {
|
||||
this.paying = false
|
||||
setTimeout(() => {
|
||||
if (recordId) this.loadRecord(recordId)
|
||||
}, paid ? 600 : 0)
|
||||
}
|
||||
},
|
||||
|
||||
// ===== 修改支付方式(仅待支付) =====
|
||||
|
||||
onSwitchPayChannel() {
|
||||
if (this.switchingPayChannel) return
|
||||
const current = this.data.record.payChannel
|
||||
wx.showActionSheet({
|
||||
itemList: ['微信支付', '线下支付'],
|
||||
success: (res) => {
|
||||
const channel = res.tapIndex === 0 ? 'online_wechat' : 'offline'
|
||||
if (channel === current) return
|
||||
this.updatePayChannel(channel)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
updatePayChannel(channel) {
|
||||
if (this.switchingPayChannel) return
|
||||
this.switchingPayChannel = true
|
||||
wx.showLoading({ title: '保存中...' })
|
||||
API.escort.updateRecord(this.data.recordId, {
|
||||
'payment.payChannel': channel
|
||||
})
|
||||
.then((res) => {
|
||||
wx.hideLoading()
|
||||
if (res.code === 0) {
|
||||
wx.showToast({ title: '支付方式已更新', icon: 'success' })
|
||||
this.loadRecord(this.data.recordId)
|
||||
} else {
|
||||
wx.showToast({ title: res.msg || '修改失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
wx.hideLoading()
|
||||
wx.showToast({ title: '网络请求失败,请重试', icon: 'none' })
|
||||
})
|
||||
.finally(() => {
|
||||
this.switchingPayChannel = false
|
||||
})
|
||||
},
|
||||
|
||||
// ===== 陪诊需求编辑(底部弹窗) =====
|
||||
|
||||
onEditPatientNote() {
|
||||
@@ -371,9 +494,6 @@ Page({
|
||||
|
||||
const hospitalOptions = getApp().getHospitalsByProvince(province)
|
||||
const name = r.hospitalName || ''
|
||||
const matched = hospitalOptions.find(item => item.name === name)
|
||||
// 历史订单的医院可能已不在库中:自动退回手动输入并保留原值,保证仍能保存
|
||||
const hospitalManual = !hospitalOptions.length || (!!name.trim() && !matched)
|
||||
|
||||
this.setData({
|
||||
showHospitalPopup: true,
|
||||
@@ -388,8 +508,7 @@ Page({
|
||||
medicalRecordNo: r.medicalRecordNo || '',
|
||||
scheduleDate: r.scheduleDate || '',
|
||||
startTime: r.scheduleStartTime || '',
|
||||
sessionIndex,
|
||||
hospitalManual
|
||||
sessionIndex
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -409,18 +528,14 @@ Page({
|
||||
'editHospital.provinceIndex': index,
|
||||
'editHospital.province': province,
|
||||
'editHospital.name': '',
|
||||
'editHospital.hospitalManual': false,
|
||||
hospitalOptions
|
||||
})
|
||||
},
|
||||
|
||||
// 医院选择组件回传:库内医院同时带出地址,手动输入保持用户填写
|
||||
// 医院选择组件回传:库内医院同时带出地址,手动填写的保持用户填写
|
||||
onHospitalSelectChange(e) {
|
||||
const { name, manual, hospital } = e.detail
|
||||
const patch = {
|
||||
'editHospital.name': name,
|
||||
'editHospital.hospitalManual': manual
|
||||
}
|
||||
const { name, hospital } = e.detail
|
||||
const patch = { 'editHospital.name': name }
|
||||
if (hospital?.address) patch['editHospital.address'] = hospital.address
|
||||
this.setData(patch)
|
||||
},
|
||||
@@ -449,7 +564,8 @@ Page({
|
||||
onSaveHospital() {
|
||||
const form = this.data.editHospital
|
||||
if (!form.name || !form.name.trim()) {
|
||||
wx.showToast({ title: form.hospitalManual ? '请输入就诊医院' : '请选择就诊医院', icon: 'none' })
|
||||
const tip = this.data.hospitalOptions.length ? '请选择就诊医院' : '请填写就诊医院名称'
|
||||
wx.showToast({ title: tip, icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.scheduleDate) {
|
||||
|
||||
@@ -119,6 +119,20 @@
|
||||
不再在卡内挂一行「请联系客服…」:那句话只对未支付状态成立,
|
||||
却长期占着卡内一条常驻行位 -->
|
||||
|
||||
<!-- 支付渠道:仅待支付期间可切换;线下支付由平台收款后补记实际方式 -->
|
||||
<view
|
||||
class="pay-switch"
|
||||
wx:if="{{record.canSwitchPayChannel}}"
|
||||
aria-role="button"
|
||||
aria-label="切换支付方式"
|
||||
bindtap="onSwitchPayChannel"
|
||||
>
|
||||
<text class="pay-switch-label">支付方式</text>
|
||||
<text class="pay-switch-value">{{record.payChannelText}}</text>
|
||||
<text class="pay-switch-action">切换</text>
|
||||
<t-icon name="chevron-right" size="24rpx" color="#6F655C" />
|
||||
</view>
|
||||
|
||||
<view class="cancel-summary" wx:if="{{record.status === 'cancelled' && record.cancelReason}}">
|
||||
<text class="cancel-summary-label">取消原因</text>
|
||||
<text class="cancel-summary-value">{{record.cancelReason}}</text>
|
||||
@@ -248,6 +262,11 @@
|
||||
>
|
||||
<view class="home-icon"></view>
|
||||
</view>
|
||||
<view
|
||||
class="action-btn action-primary"
|
||||
wx:if="{{record.canPay}}"
|
||||
bindtap="onPayOrder"
|
||||
>去支付</view>
|
||||
<view
|
||||
class="action-btn action-ghost"
|
||||
wx:if="{{record.canCancel}}"
|
||||
@@ -286,7 +305,6 @@
|
||||
<hospital-select
|
||||
label="就诊医院"
|
||||
value="{{editHospital.name}}"
|
||||
manual="{{editHospital.hospitalManual}}"
|
||||
options="{{hospitalOptions}}"
|
||||
placeholder="请选择医院"
|
||||
compact="{{true}}"
|
||||
|
||||
@@ -130,9 +130,8 @@ page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-left: 20rpx;
|
||||
/* 28rpx 降到 26rpx:说明退到「次强」档,与 32rpx 的胶囊拉开一档差,
|
||||
抬头内部才有焦点;此前两者同为 28rpx,只靠字重区分,谁都不是主角 */
|
||||
font-size: var(--fs-26);
|
||||
/* 说明保持比 32rpx 的胶囊低一档,抬头内部才有焦点 */
|
||||
font-size: var(--fs-28);
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
letter-spacing: 1rpx;
|
||||
@@ -184,9 +183,8 @@ page {
|
||||
不靠颜色——颜色留给底栏主按钮 */
|
||||
.section-link-text {
|
||||
margin-right: 4rpx;
|
||||
/* 26rpx 与图标同档:入口降为中性的同时留一点体量,
|
||||
避免和卡片正文(26rpx)拉开层级后又退到看不清 */
|
||||
font-size: var(--fs-26);
|
||||
/* 与图标同档:入口降为中性的同时留一点体量 */
|
||||
font-size: var(--fs-28);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -364,10 +362,10 @@ page {
|
||||
}
|
||||
|
||||
/* 地址:医院行下的副行,换行独占。
|
||||
尺寸与颜色同主值(26rpx / --ink-2):老人靠它找到地方,不能压成浅灰小字 */
|
||||
颜色用 --ink-2:老人靠它找到地方,不能压成浅灰小字 */
|
||||
.appt-sub {
|
||||
flex-basis: 100%;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--ink-2);
|
||||
letter-spacing: 1rpx;
|
||||
line-height: 1.6;
|
||||
@@ -413,7 +411,7 @@ page {
|
||||
.cancel-summary-value {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--ink-2);
|
||||
line-height: 1.5;
|
||||
}
|
||||
@@ -447,7 +445,7 @@ page {
|
||||
|
||||
.detail-group-title {
|
||||
display: block;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -473,7 +471,7 @@ page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-left: 24rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--ink-2);
|
||||
line-height: 1.5;
|
||||
text-align: right;
|
||||
@@ -482,7 +480,7 @@ page {
|
||||
.shipping-recipient {
|
||||
display: block;
|
||||
margin-top: 16rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -490,7 +488,7 @@ page {
|
||||
.shipping-address {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--ink-2);
|
||||
line-height: 1.6;
|
||||
}
|
||||
@@ -598,7 +596,7 @@ page {
|
||||
|
||||
.note-add-text {
|
||||
margin-left: 8rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--brand-ink);
|
||||
}
|
||||
|
||||
@@ -619,7 +617,7 @@ page {
|
||||
|
||||
.form-label {
|
||||
flex-shrink: 0;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -627,7 +625,7 @@ page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-left: 24rpx;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink);
|
||||
text-align: right;
|
||||
}
|
||||
@@ -913,3 +911,30 @@ page {
|
||||
color: var(--white);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* 支付方式切换:待支付期间才出现,轻量一行,不额外占卡片高度 */
|
||||
.pay-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
margin-top: 16rpx;
|
||||
padding-top: 18rpx;
|
||||
border-top: 2rpx solid var(--line);
|
||||
}
|
||||
|
||||
.pay-switch-label {
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-26);
|
||||
}
|
||||
|
||||
.pay-switch-value {
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-26);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.pay-switch-action {
|
||||
margin-left: auto;
|
||||
color: var(--brand-strong);
|
||||
font-size: var(--fs-24);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const API = require('../../utils/api.js')
|
||||
const { formatDate } = require('../../utils/date.js')
|
||||
const { STATUS_MAP, PAYMENT_STATUS_MAP } = require('../../utils/order.js')
|
||||
const { STATUS_MAP, PAYMENT_STATUS_MAP, resolveOrderStatus } = require('../../utils/order.js')
|
||||
|
||||
// 左右滑动切换状态页的手势参数(单位 px)
|
||||
const SWIPE_THRESHOLD = 50
|
||||
@@ -58,7 +58,12 @@ Page({
|
||||
if (!app.globalData.user?._id) throw new Error('请先登录后查看预约记录')
|
||||
|
||||
const params = { page, pageSize: this.data.pageSize }
|
||||
if (this.data.statusFilter === 'ongoing') params.status = ONGOING_STATUS_QUERY
|
||||
if (this.data.statusFilter === 'ongoing') {
|
||||
params.status = ONGOING_STATUS_QUERY
|
||||
} else {
|
||||
// 全部预约需要包含已取消订单;默认列表会隐藏已取消
|
||||
params.includeCancelled = 1
|
||||
}
|
||||
|
||||
const res = await API.escort.getMyRecords(params)
|
||||
if (res.code !== 0) throw new Error(res.msg || '预约记录加载失败')
|
||||
@@ -101,13 +106,34 @@ Page({
|
||||
},
|
||||
|
||||
formatRecord(item) {
|
||||
const statusInfo = STATUS_MAP[item.status] || STATUS_MAP.pending
|
||||
const displayStatus = resolveOrderStatus(item)
|
||||
const statusInfo = STATUS_MAP[displayStatus] || STATUS_MAP.pending
|
||||
const paymentStatusInfo = PAYMENT_STATUS_MAP[item.payment?.status] || PAYMENT_STATUS_MAP.unpaid
|
||||
const fee = Number(item.payment?.totalFee) || 0
|
||||
const appointmentTime = item.schedule?.date
|
||||
? `${formatDate(item.schedule.date, '--')} ${item.schedule.startTime || ''}`.trim()
|
||||
: '--'
|
||||
|
||||
// 未支付的展示按渠道与支付窗口区分:线上可去支付、超时仅可改线下或取消、线下等平台收款
|
||||
const paymentStatus = item.payment?.status || 'unpaid'
|
||||
const payChannel = item.payment?.payChannel || 'offline'
|
||||
const windowEnd = item.paymentWindowEnd ? new Date(item.paymentWindowEnd) : null
|
||||
const paymentExpired = paymentStatus === 'unpaid'
|
||||
&& payChannel === 'online_wechat'
|
||||
&& windowEnd instanceof Date
|
||||
&& !Number.isNaN(windowEnd.getTime())
|
||||
&& Date.now() > windowEnd.getTime()
|
||||
let paymentStatusText = paymentStatusInfo.text
|
||||
if (paymentStatus === 'unpaid') {
|
||||
if (payChannel === 'offline') paymentStatusText = '线下支付'
|
||||
else if (paymentExpired) paymentStatusText = '支付已超时'
|
||||
else paymentStatusText = '待支付'
|
||||
}
|
||||
const canPay = paymentStatus === 'unpaid'
|
||||
&& payChannel === 'online_wechat'
|
||||
&& !paymentExpired
|
||||
&& ['pending', 'confirmed'].includes(displayStatus)
|
||||
|
||||
return {
|
||||
_id: item._id,
|
||||
patientName: item.patient?.name || '--',
|
||||
@@ -120,7 +146,11 @@ Page({
|
||||
statusBorder: statusInfo.border,
|
||||
appointmentTime,
|
||||
fee: fee.toFixed(2),
|
||||
paymentStatusText: paymentStatusInfo.text,
|
||||
payChannel,
|
||||
payChannelText: payChannel === 'online_wechat' ? '微信支付' : '线下支付',
|
||||
paymentExpired,
|
||||
canPay,
|
||||
paymentStatusText,
|
||||
paymentStatusColor: paymentStatusInfo.color,
|
||||
paymentStatusBg: paymentStatusInfo.bg,
|
||||
paymentStatusBorder: paymentStatusInfo.border
|
||||
@@ -190,6 +220,13 @@ Page({
|
||||
wx.navigateTo({ url: `/pages/escort/recorddetail?id=${id}` })
|
||||
},
|
||||
|
||||
// 列表「去支付」只作为入口:真正发起支付在详情页,避免列表与详情两套支付逻辑
|
||||
onPayRecord(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
if (!id) return
|
||||
wx.navigateTo({ url: `/pages/escort/recorddetail?id=${id}` })
|
||||
},
|
||||
|
||||
// 回首页:首页是 tabBar 页,必须走 switchTab,navigateTo 跳不过去
|
||||
onGoHome() {
|
||||
wx.switchTab({ url: '/pages/home/index' })
|
||||
|
||||
@@ -83,6 +83,12 @@
|
||||
class="pay-chip"
|
||||
style="background: {{item.paymentStatusBg}}; color: {{item.paymentStatusColor}}; border-color: {{item.paymentStatusBorder}};"
|
||||
>{{item.paymentStatusText}}</view>
|
||||
<view
|
||||
class="pay-entry"
|
||||
wx:if="{{item.canPay}}"
|
||||
catchtap="onPayRecord"
|
||||
data-id="{{item._id}}"
|
||||
>去支付</view>
|
||||
<t-icon class="record-chevron" name="chevron-right" size="28rpx" color="#6F655C" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -322,6 +322,22 @@ page {
|
||||
box-shadow: var(--shadow-card);
|
||||
}
|
||||
|
||||
/* 列表「去支付」:只在待支付且未超时时出现,点击进入详情完成支付 */
|
||||
.pay-entry {
|
||||
margin-right: 12rpx;
|
||||
padding: 8rpx 22rpx;
|
||||
border-radius: 999rpx;
|
||||
background: var(--brand-soft);
|
||||
color: var(--brand-strong);
|
||||
font-size: var(--fs-24);
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.pay-entry:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.home-fab:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ const API = {
|
||||
updateRecord: (id, data) => request.put(`/health/escort-record/${id}`, data),
|
||||
updateStatus: (id, data) => request.patch(`/health/escort-record/${id}/status`, data),
|
||||
deleteRecord: (id) => request.delete(`/health/escort-record/${id}`),
|
||||
// 微信支付:发起支付返回调起收银台参数;支付结果以后端查单为准
|
||||
payOrder: (id) => request.post(`/health/escort-record/${id}/pay`),
|
||||
getPayStatus: (id) => request.get(`/health/escort-record/${id}/pay/status`),
|
||||
// 陪诊师公示列表(公开接口,后端已做脱敏)
|
||||
getAttendants: (params) => request.get('/health/attendant', params),
|
||||
// 单个陪诊师详情,同一份白名单数据
|
||||
|
||||
+13
-2
@@ -8,8 +8,18 @@ const STATUS_MAP = {
|
||||
cancelled: { text: '已取消', color: '#B4231A', bg: '#FCF0EE', border: '#F2D6D1', desc: '该订单已取消' }
|
||||
}
|
||||
|
||||
// 取消与 status 解耦:展示层优先按 cancelStatus 映射为「待取消/已取消」,
|
||||
// 其余情况仍按服务状态展示,status 本身不再写入取消值。
|
||||
function resolveOrderStatus(item) {
|
||||
const cancelStatus = item?.cancelStatus || 'none'
|
||||
if (cancelStatus === 'cancelled') return 'cancelled'
|
||||
if (cancelStatus === 'requested') return 'cancel_requested'
|
||||
return item?.status || 'pending'
|
||||
}
|
||||
|
||||
const PAYMENT_STATUS_MAP = {
|
||||
unpaid: { text: '未支付', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2', hint: '请联系客服完成支付' },
|
||||
// 未支付的展示文案由页面按 payChannel / 支付窗口派生,这里不再固定「联系客服」
|
||||
unpaid: { text: '未支付', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2' },
|
||||
partial: { text: '部分支付', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2', hint: '请联系客服补齐剩余费用' },
|
||||
paid: { text: '已支付', color: '#1F7A4D', bg: '#EAF6EE', border: '#CDE9D7' },
|
||||
refunding: { text: '退款中', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2', hint: '退款处理中,如需了解进度请联系客服' },
|
||||
@@ -18,5 +28,6 @@ const PAYMENT_STATUS_MAP = {
|
||||
|
||||
module.exports = {
|
||||
STATUS_MAP,
|
||||
PAYMENT_STATUS_MAP
|
||||
PAYMENT_STATUS_MAP,
|
||||
resolveOrderStatus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user