project:强制覆盖代码,更新.gitignore文件内容
This commit is contained in:
+49
-32
@@ -134,6 +134,7 @@ class OrderMonitor {
|
||||
*/
|
||||
async checkOrderStatus(orderId) {
|
||||
try {
|
||||
const currentTime = new Date();
|
||||
console.log(`检查订单 ${orderId} 的状态`)
|
||||
const result = await queryById(orderId)
|
||||
|
||||
@@ -151,41 +152,57 @@ class OrderMonitor {
|
||||
// 检查订单是否已完成
|
||||
if (orderData.orderStatus === 'used_done' || orderData.orderStatus === 'used_down') {
|
||||
console.log(`订单 ${orderId} 已完成!`)
|
||||
|
||||
// 检查endTime与当前时间的差异
|
||||
let shouldNotify = true;
|
||||
|
||||
// 触发全局事件
|
||||
uni.$emit('orderCompleted', orderData)
|
||||
if (orderData.endTime) {
|
||||
const endTime = new Date(orderData.endTime);
|
||||
const timeDiff = Math.abs(currentTime - endTime) / (1000 * 60); // 时间差(分钟)
|
||||
|
||||
// 如果时间差超过1分钟,不进行提醒
|
||||
if (timeDiff > 3) {
|
||||
console.log(`订单 ${orderId} 完成时间与当前时间相差${timeDiff.toFixed(2)}分钟,超过3分钟,不进行提醒`);
|
||||
shouldNotify = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 显示全局通知
|
||||
uni.showToast({
|
||||
title: '风扇归还成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
|
||||
// 播放通知声音(如果需要)
|
||||
const innerAudioContext = uni.createInnerAudioContext()
|
||||
innerAudioContext.src = '/static/audio/return_success.mp3'
|
||||
innerAudioContext.play()
|
||||
|
||||
// 完成的订单不再需要监控
|
||||
this.removeOrder({orderId})
|
||||
|
||||
// 如果用户不在归还页面,则显示归还成功弹窗
|
||||
setTimeout(() => {
|
||||
uni.showModal({
|
||||
title: '归还成功',
|
||||
content: '风扇已归还成功,剩余押金将退还到您的账户',
|
||||
confirmText: '查看详情',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 跳转到归还成功页面查看详情
|
||||
uni.redirectTo({
|
||||
url: `/pages/order/return-success?orderId=${orderId}`
|
||||
})
|
||||
}
|
||||
}
|
||||
if (shouldNotify) {
|
||||
// 触发全局事件
|
||||
uni.$emit('orderCompleted', orderData)
|
||||
|
||||
// 显示全局通知
|
||||
uni.showToast({
|
||||
title: '风扇归还成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}, 500)
|
||||
|
||||
// 播放通知声音(如果需要)
|
||||
// const innerAudioContext = uni.createInnerAudioContext()
|
||||
// innerAudioContext.src = '/static/audio/return_success.mp3'
|
||||
// innerAudioContext.play()
|
||||
|
||||
// 如果用户不在归还页面,则显示归还成功弹窗
|
||||
setTimeout(() => {
|
||||
uni.showModal({
|
||||
title: '归还成功',
|
||||
content: '风扇已归还成功,剩余押金将退还到您的账户',
|
||||
confirmText: '查看详情',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 跳转到归还成功页面查看详情
|
||||
uni.redirectTo({
|
||||
url: `/pages/order/return-success?orderId=${orderId}`
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 无论是否提醒,完成的订单都不再需要监控
|
||||
this.removeOrder({orderId})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user