fix:修复bug

This commit is contained in:
2026-02-03 17:47:55 +08:00
parent 9f66ee9658
commit 5a13803743
12 changed files with 1181 additions and 854 deletions
+83 -10
View File
@@ -114,7 +114,7 @@
<view class="action-btn secondary" @click="onDeleteOrder">
删除订单
</view>
<view class="action-btn primary" @click="onReorder">
<view class="action-btn primary" @click="onReorder(orderDetail.productId)">
再次定制
</view>
</template>
@@ -124,7 +124,7 @@
<view class="action-btn secondary" @click="onContactService">
联系客服
</view>
<view class="action-btn primary" @click="onReorder">
<view class="action-btn primary" @click="onReorder(orderDetail.productId)">
再次定制
</view>
</template>
@@ -133,7 +133,7 @@
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
import { ref, computed, onMounted, onUnmounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import {
queryById,
@@ -149,6 +149,8 @@
const orderDetail = ref({});
const orderId = ref('');
const countdownText = ref('');
let countdownTimer = null;
// 订单状态文本
const statusText = computed(() => {
@@ -234,6 +236,10 @@
if (status === 0 || status === '0') {
title = '待付款';
// 如果有倒计时文本,添加到标题中
if (countdownText.value) {
title = `${title} ${countdownText.value}`;
}
} else if (status === 1 || status === '1') {
title = '待发货';
} else if (status === 2 || status === '2') {
@@ -251,6 +257,66 @@
});
};
// 启动倒计时
const startCountdown = () => {
// 清除之前的定时器
if (countdownTimer) {
clearInterval(countdownTimer);
countdownTimer = null;
}
const status = orderDetail.value.status;
const expireTime = orderDetail.value.expireTime;
// 只有待付款状态且有过期时间才显示倒计时
if ((status === 0 || status === '0') && expireTime) {
// 计算倒计时
const updateCountdown = () => {
const now = new Date().getTime();
const expireTimestamp = new Date(expireTime).getTime();
const diff = expireTimestamp - now;
if (diff > 0) {
// 计算总分钟数和秒数
const totalMinutes = Math.floor(diff / (1000 * 60));
const seconds = Math.floor((diff % (1000 * 60)) / 1000);
// 格式化为 MM:SS
const minutesStr = String(totalMinutes).padStart(2, '0');
const secondsStr = String(seconds).padStart(2, '0');
countdownText.value = `${minutesStr}:${secondsStr}`;
updatePageTitle();
} else {
// 倒计时结束
countdownText.value = '';
if (countdownTimer) {
clearInterval(countdownTimer);
countdownTimer = null;
}
// 重新加载订单详情(订单可能已自动取消)
loadOrderDetail();
}
};
// 立即执行一次
updateCountdown();
// 每秒更新一次
countdownTimer = setInterval(updateCountdown, 1000);
} else {
countdownText.value = '';
updatePageTitle();
}
};
// 组件卸载时清除定时器
onUnmounted(() => {
if (countdownTimer) {
clearInterval(countdownTimer);
countdownTimer = null;
}
});
// 加载订单详情
const loadOrderDetail = async () => {
try {
@@ -269,6 +335,7 @@
outTradeNo: data.outTradeNo,
userId: data.userId,
// 状态信息
status: data.status,
payStatus: data.payStatus,
@@ -282,6 +349,7 @@
createTime: data.createTime,
updateTime: data.updateTime,
payTime: data.payTime,
expireTime: data.expireTime, // 订单自动取消时间
// 收货信息
receiverName: data.receiverName,
@@ -300,6 +368,7 @@
pictureUrl: data.pictureUrl,
color: data.color,
quantity: data.quantity,
productId:data.productId,
// 兼容旧字段
orderId: data.id,
@@ -315,8 +384,8 @@
productImage: data.pictureUrl || data.productImage || ''
};
// 根据订单状态更新页面标题
updatePageTitle();
// 启动倒计时
startCountdown();
}
uni.hideLoading();
@@ -528,9 +597,13 @@
// 再次定制
const onReorder = (order) => {
uni.navigateTo({
url: `/pages/device/goods?productId=${order.productId}`
});
if(order){
uni.navigateTo({
url: `/pages/device/goods?productId=${order}`
});
}
// console.log(order);
};
</script>
@@ -622,8 +695,8 @@
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
font-size: 26rpx;
height: 40rpx;
font-size: 28rpx;
height: 50rpx;
&:last-child {
margin-bottom: 0;