project:强制覆盖代码,更新.gitignore文件内容

This commit is contained in:
2025-09-16 17:23:51 +08:00
parent ab9a7279f5
commit 5ad77a857c
97 changed files with 2295 additions and 1751 deletions
+1 -1
View File
@@ -1 +1 @@
"use strict";const e=require("../common/vendor.js"),r=require("../config/user.js");const t=new class{constructor(){this.activeOrders=new Map,this.timer=null,this.checkInterval=1e4,this.isRunning=!1,this.currentPage=null}addOrder(e,r="return"){e&&e.orderId?(console.log(`添加订单到监控队列: ${e.orderId}, 页面: ${r}`),this.activeOrders.set(e.orderId,{...e,pageName:r}),this.isRunning||this.start()):console.error("添加订单监控失败:无效的订单数据")}removeOrder(e){if(e){if(e.orderId&&this.activeOrders.has(e.orderId))console.log("从监控队列移除订单:",e.orderId),this.activeOrders.delete(e.orderId);else if(e.pageName){console.log("从监控队列移除页面相关订单:",e.pageName);for(const[r,t]of this.activeOrders.entries())t.pageName===e.pageName&&this.activeOrders.delete(r)}0===this.activeOrders.size&&this.stop()}}setActivePage(e){this.currentPage=e,console.log("设置当前活跃页面:",e)}start(){this.isRunning||(console.log("启动订单监控服务"),this.isRunning=!0,this.checkOrders(),this.timer=setInterval((()=>{this.checkOrders()}),this.checkInterval))}stop(){this.isRunning&&(console.log("停止订单监控服务"),this.isRunning=!1,this.timer&&(clearInterval(this.timer),this.timer=null))}async checkOrders(){if(0!==this.activeOrders.size){console.log(`检查 ${this.activeOrders.size} 个活跃订单状态, 当前页面: ${this.currentPage}`);for(const[r,t]of this.activeOrders.entries())try{t.pageName&&"return"!==t.pageName||"return"!==this.currentPage&&null!==this.currentPage||await this.checkOrderStatus(r)}catch(e){}}}async checkOrderStatus(t){try{console.log(`检查订单 ${t} 的状态`);const s=await r.queryById(t);if(200===s.code&&s.data){const r=s.data,i=this.activeOrders.get(t),o=i?i.pageName:null;if(this.activeOrders.set(t,{...r,pageName:o}),"used_done"===r.orderStatus||"used_down"===r.orderStatus){console.log(`订单 ${t} 已完成!`),e.index.$emit("orderCompleted",r),e.index.showToast({title:"风扇归还成功",icon:"success",duration:2e3});const s=e.index.createInnerAudioContext();s.src="/static/audio/return_success.mp3",s.play(),this.removeOrder({orderId:t}),setTimeout((()=>{e.index.showModal({title:"归还成功",content:"风扇已归还成功,剩余押金将退还到您的账户",confirmText:"查看详情",success:r=>{r.confirm&&e.index.redirectTo({url:`/pages/order/return-success?orderId=${t}`})}})}),500)}}}catch(s){console.error(`检查订单 ${t} 状态出错:`,s)}}};e.index.onAppRoute((e=>{const r=e.path||"",s=r.split("/"),i=s[s.length-1];t.setActivePage(i||null),console.log("页面切换:",r,"当前活跃页面:",i)}));(()=>{const r=e.index.getStorageSync("activeOrderId");if(r){const e={orderId:r};t.addOrder(e,"return")}})(),exports.orderMonitor=t;
"use strict";const e=require("../common/vendor.js"),t=require("../config/user.js");const r=new class{constructor(){this.activeOrders=new Map,this.timer=null,this.checkInterval=1e4,this.isRunning=!1,this.currentPage=null}addOrder(e,t="return"){e&&e.orderId?(console.log(`添加订单到监控队列: ${e.orderId}, 页面: ${t}`),this.activeOrders.set(e.orderId,{...e,pageName:t}),this.isRunning||this.start()):console.error("添加订单监控失败:无效的订单数据")}removeOrder(e){if(e){if(e.orderId&&this.activeOrders.has(e.orderId))console.log("从监控队列移除订单:",e.orderId),this.activeOrders.delete(e.orderId);else if(e.pageName){console.log("从监控队列移除页面相关订单:",e.pageName);for(const[t,r]of this.activeOrders.entries())r.pageName===e.pageName&&this.activeOrders.delete(t)}0===this.activeOrders.size&&this.stop()}}setActivePage(e){this.currentPage=e,console.log("设置当前活跃页面:",e)}start(){this.isRunning||(console.log("启动订单监控服务"),this.isRunning=!0,this.checkOrders(),this.timer=setInterval((()=>{this.checkOrders()}),this.checkInterval))}stop(){this.isRunning&&(console.log("停止订单监控服务"),this.isRunning=!1,this.timer&&(clearInterval(this.timer),this.timer=null))}async checkOrders(){if(0!==this.activeOrders.size){console.log(`检查 ${this.activeOrders.size} 个活跃订单状态, 当前页面: ${this.currentPage}`);for(const[t,r]of this.activeOrders.entries())try{r.pageName&&"return"!==r.pageName||"return"!==this.currentPage&&null!==this.currentPage||await this.checkOrderStatus(t)}catch(e){}}}async checkOrderStatus(r){try{const s=new Date;console.log(`检查订单 ${r} 的状态`);const i=await t.queryById(r);if(200===i.code&&i.data){const t=i.data,o=this.activeOrders.get(r),n=o?o.pageName:null;if(this.activeOrders.set(r,{...t,pageName:n}),"used_done"===t.orderStatus||"used_down"===t.orderStatus){console.log(`订单 ${r} 已完成!`);let i=!0;if(t.endTime){const e=new Date(t.endTime),o=Math.abs(s-e)/6e4;o>3&&(console.log(`订单 ${r} 完成时间与当前时间相差${o.toFixed(2)}分钟,超过3分钟,不进行提醒`),i=!1)}i&&(e.index.$emit("orderCompleted",t),e.index.showToast({title:"风扇归还成功",icon:"success",duration:2e3}),setTimeout((()=>{e.index.showModal({title:"归还成功",content:"风扇已归还成功,剩余押金将退还到您的账户",confirmText:"查看详情",success:t=>{t.confirm&&e.index.redirectTo({url:`/pages/order/return-success?orderId=${r}`})}})}),500)),this.removeOrder({orderId:r})}}}catch(s){console.error(`检查订单 ${r} 状态出错:`,s)}}};e.index.onAppRoute((e=>{const t=e.path||"",s=t.split("/"),i=s[s.length-1];r.setActivePage(i||null),console.log("页面切换:",t,"当前活跃页面:",i)}));(()=>{const t=e.index.getStorageSync("activeOrderId");if(t){const e={orderId:t};r.addOrder(e,"return")}})(),exports.orderMonitor=r;