"use strict";const e=require("../../../common/vendor.js"),o=require("../../../config/user.js"),d={data:()=>({}),async onLoad(d){console.log("bagCheck onLoad option:",d);try{if(e.index.showLoading({title:"处理中...",mask:!0}),!d||!d.deviceNo)throw new Error("未识别到设备编号");const r=d.deviceNo,i=["in_used","waiting_for_payment"],t=await o.checkOrdersByStatus(r,i);if(200===t.code&&t.data&&t.data.length>0){const o=t.data[0];if("in_used"===o.orderStatus)console.log("检测到使用中订单，跳转归还页:",o.orderId),e.index.redirectTo({url:`/pages/device/return?orderId=${o.orderId}`});else if("waiting_for_payment"===o.orderStatus){console.log("检测到待支付订单，跳转支付页:",o.orderId);const d=o.packageTime||60,r=(d/60).toFixed(1),i=o.packagePrice||"0.00",t=(parseFloat(i)/(d/60)).toFixed(2),a=o.depositAmount||"99.00",s=(parseFloat(a)+parseFloat(i)).toFixed(2);e.index.redirectTo({url:`/pages/order/payment?orderId=${o.orderId}&packageTimeHours=${r}&packagePrice=${i}&hourlyRate=${t}&totalAmount=${s}&depositAmount=${a}`})}else console.log("检测到其他状态订单，跳转详情页:",o.orderId),e.index.redirectTo({url:`/pages/device/detail?deviceNo=${r}`})}else console.log("未检测到相关订单，跳转详情页"),e.index.redirectTo({url:`/pages/device/detail?deviceNo=${r}`})}catch(r){r.message&&(r.message.includes("未识别到设备编号")||r.message.includes("网络请求失败")||r.message.includes("服务器错误"))?(console.error("扫码检查订单失败:",r),e.index.showToast({title:r.message||"处理失败，请稍后重试",icon:"none",duration:2e3})):console.log("没有找到符合条件的订单或发生其他错误，直接跳转详情页"),setTimeout((()=>{d&&d.deviceNo?e.index.redirectTo({url:`/pages/device/detail?deviceNo=${d.deviceNo}`}):e.index.switchTab({url:"/pages/index/index"})}),2e3)}finally{e.index.hideLoading()}},methods:{}};const r=e._export_sfc(d,[["render",function(e,o,d,r,i,t){return{}}]]);wx.createPage(r);
