修复订单显示bug
This commit is contained in:
@@ -86,6 +86,17 @@
|
||||
<text class="exception-update-time">状态更新时间:{{ consumerViewState.statusUpdatedAt }}</text>
|
||||
</view>
|
||||
|
||||
<view v-if="consumerViewState.showExceptionPanel" class="exception-panel">
|
||||
<text class="exception-title">{{ consumerViewState.exceptionTitle }}</text>
|
||||
<text class="exception-desc">{{ consumerViewState.exceptionDesc }}</text>
|
||||
<view v-if="consumerViewState.exceptionReason != ''" class="exception-reason">
|
||||
<text class="exception-reason-label">异常原因:</text>
|
||||
<text class="exception-reason-value">{{ consumerViewState.exceptionReason }}</text>
|
||||
</view>
|
||||
<text class="exception-update-time">状态更新时间:{{ consumerViewState.statusUpdatedAt }}</text>
|
||||
</view>
|
||||
|
||||
|
||||
<view v-if="isServicePaymentExpired" class="action-row">
|
||||
<view class="secondary-btn" @click="goHome">返回首页</view>
|
||||
<view class="primary-btn" @click="bookAgain">再次预约</view>
|
||||
@@ -105,6 +116,8 @@
|
||||
<script setup lang="uts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import ServiceInfoList from '@/components/homeService/ServiceInfoList.uvue'
|
||||
import ServicePanel from '@/components/homeService/ServicePanel.uvue'
|
||||
@@ -200,75 +213,6 @@ function contactService() {
|
||||
uni.showToast({ title: '即将接入专属客服入口', icon: 'none' })
|
||||
}
|
||||
|
||||
function goHome() {
|
||||
uni.navigateTo({ url: '/pages/mall/consumer/home-service/index' })
|
||||
}
|
||||
|
||||
function getPayExpireMs(caseDetail: HomeServiceCaseType): number {
|
||||
if (caseDetail.payExpireAt == null || caseDetail.payExpireAt == '') {
|
||||
return 0
|
||||
}
|
||||
const parsed = Date.parse(caseDetail.payExpireAt)
|
||||
return isNaN(parsed) ? 0 : parsed
|
||||
}
|
||||
|
||||
function isPaymentTimeExpired(caseDetail: HomeServiceCaseType): boolean {
|
||||
if (caseDetail.paymentStatus != 1 || caseDetail.status != 'created') {
|
||||
return false
|
||||
}
|
||||
const expireMs = getPayExpireMs(caseDetail)
|
||||
if (expireMs <= 0) {
|
||||
return false
|
||||
}
|
||||
return expireMs <= Date.now()
|
||||
}
|
||||
|
||||
const isServicePaymentExpired = computed<boolean>(() => {
|
||||
if (detail.value == null) {
|
||||
return false
|
||||
}
|
||||
return isPaymentTimeExpired(detail.value)
|
||||
})
|
||||
|
||||
let isRetryDispatching = false
|
||||
|
||||
function retryDispatch() {
|
||||
if (isRetryDispatching || detail.value == null) {
|
||||
return
|
||||
}
|
||||
const currentId = detail.value.id
|
||||
isRetryDispatching = true
|
||||
uni.showLoading({ title: '正在重新派单', mask: true })
|
||||
dispatchPaidHomecareOrder(currentId).then((result) => {
|
||||
uni.hideLoading()
|
||||
if (result.success) {
|
||||
uni.showToast({ title: '派单成功', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
showHomecareDispatchFailureModal(currentId, result, (id: string) => {
|
||||
retryDispatch()
|
||||
})
|
||||
}).catch((e) => {
|
||||
uni.hideLoading()
|
||||
console.error('[retryDispatch] 重新派单异常:', e)
|
||||
uni.showModal({
|
||||
title: '派单服务异常',
|
||||
content: '派单服务暂时异常,请稍后重试',
|
||||
showCancel: true,
|
||||
cancelText: '稍后再试',
|
||||
confirmText: '重新派单',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
retryDispatch()
|
||||
}
|
||||
}
|
||||
})
|
||||
}).finally(() => {
|
||||
isRetryDispatching = false
|
||||
})
|
||||
}
|
||||
|
||||
function getLatestTimelineRemark(caseDetail: HomeServiceCaseType): string {
|
||||
if (caseDetail.timeline.length > 0) {
|
||||
return caseDetail.timeline[0].description
|
||||
@@ -298,20 +242,7 @@ const consumerViewState = computed(() => {
|
||||
const remark = getLatestTimelineRemark(detail.value)
|
||||
const result = { ...defaultState }
|
||||
|
||||
if (isPaymentTimeExpired(detail.value)) {
|
||||
result.showExceptionPanel = true
|
||||
result.exceptionTitle = '订单已超时未支付'
|
||||
result.exceptionDesc = '支付时间已结束,请返回首页重新预约或刷新查看最新状态。'
|
||||
result.statusUpdatedAt = detail.value.payExpireAt != null && detail.value.payExpireAt != '' ? detail.value.payExpireAt : detail.value.serviceTime
|
||||
return result
|
||||
}
|
||||
|
||||
if (detail.value.statusText == '派单未成功') {
|
||||
result.showExceptionPanel = true
|
||||
result.exceptionTitle = '派单未成功'
|
||||
result.exceptionDesc = detail.value.summary != '' ? detail.value.summary : '当前暂无匹配的服务人员,请稍后重试或联系客服。'
|
||||
result.statusUpdatedAt = detail.value.serviceTime
|
||||
} else if (status == 'created' || status == 'assigned') {
|
||||
if (status == 'created' || status == 'assigned') {
|
||||
result.exceptionTitle = '正在安排服务人员'
|
||||
result.exceptionDesc = '您的预约申请已提交,平台正在为您匹配可上门的服务人员,请耐心等待。'
|
||||
result.statusUpdatedAt = detail.value.serviceTime
|
||||
@@ -360,15 +291,6 @@ const consumerViewState = computed(() => {
|
||||
return result
|
||||
})
|
||||
|
||||
const canPayServiceOrder = computed<boolean>(() => {
|
||||
if (detail.value == null) {
|
||||
return false
|
||||
}
|
||||
return detail.value.paymentStatus == 1
|
||||
&& detail.value.status == 'created'
|
||||
&& !isPaymentTimeExpired(detail.value)
|
||||
})
|
||||
|
||||
let detailRefreshTimerId: number = 0
|
||||
|
||||
function startDetailRefreshTimer(): void {
|
||||
@@ -584,20 +506,4 @@ onUnload(() => {
|
||||
font-size: 22rpx;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.dispatch-fail-banner {
|
||||
margin-top: 18rpx;
|
||||
padding: 18rpx 24rpx;
|
||||
background: #fff7ed;
|
||||
border-radius: 16rpx;
|
||||
border-width: 1rpx;
|
||||
border-style: solid;
|
||||
border-color: #fed7aa;
|
||||
}
|
||||
|
||||
.dispatch-fail-text {
|
||||
font-size: 26rpx;
|
||||
color: #c2410c;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user