"use strict";const e=require("../../common/vendor.js"),t=require("../../config/user.js"),r=require("../../config/url.js"),o={data:()=>({orderId:"",orderInfo:{orderNo:"",deviceNo:"",usedTime:"",currentFee:"0.00",deposit:"99.00",refundAmount:"99.00",endTime:"",withdrawStatus:"waiting",isWithdrawn:!1}}),onLoad(t){t&&t.orderId?(this.orderId=t.orderId,this.loadOrderInfo()):(e.index.showToast({title:"订单ID不能为空",icon:"none"}),setTimeout((()=>{this.goToHome()}),1500))},methods:{getWithdrawStatusText(){return{waiting:"待申请",processing:"处理中",success:"已退款",failed:"退款失败"}[this.orderInfo.withdrawStatus]||"待申请"},async loadOrderInfo(){try{e.index.showLoading({title:"加载中"});const o=await t.queryById(this.orderId);if(200!==o.code||!o.data)throw new Error(o.msg||"获取订单信息失败");{const e=o.data;let t=60,n=0,d=0,i="0.00",a="0.00";if(e.remark)try{const r=e.remark,o=r.match(/使用时长:(\d+)分钟/);o&&o[1]&&(d=parseInt(o[1]));const s=r.match(/套餐时长:(\d+)分钟/);s&&s[1]&&(t=parseInt(s[1]));const c=r.match(/超出时长:(\d+)分钟/);c&&c[1]&&(n=parseInt(c[1]));const h=r.match(/套餐费用:([\d.]+)元/);h&&h[1]&&(i=h[1]);const u=r.match(/超时费用:([\d.]+)元/);u&&u[1]&&(a=u[1]),console.log("从remark解析到的信息:",{usedMinutes:d,packageMinutes:t,extraMinutes:n,packagePrice:i,extraFee:a})}catch(r){console.error("解析remark字段失败:",r)}this.orderInfo={orderNo:e.orderNo||"",deviceNo:e.deviceNo||"",usedTime:d+"分钟",packageTime:t+"分钟",extraTime:n+"分钟",packagePrice:i,extraFee:a,currentFee:e.actualDeviceAmount||"0.00",deposit:e.depositAmount||"99.00",refundAmount:e.residueAmount||"99.00",endTime:e.endTime||"",withdrawStatus:e.withdrawStatus||"waiting",isWithdrawn:"success"===e.withdrawStatus}}}catch(o){console.error("加载订单信息错误:",o),e.index.showToast({title:o.message||"获取订单信息失败",icon:"none"})}finally{e.index.hideLoading()}},async handleWithdraw(){try{e.index.showLoading({title:"处理中"});const t=await e.index.request({url:`${r.URL||"http://127.0.0.1:8080"}/app/withdraw/add/${this.orderInfo.orderNo}`,method:"GET",header:{"Content-Type":"application/json",Authorization:"Bearer "+e.index.getStorageSync("token"),Clientid:e.index.getStorageSync("client_id")}});if(200!==t.statusCode||200!==t.data.code)throw new Error(t.data.msg||"退款申请失败");e.index.showToast({title:"退款申请成功",icon:"success"}),this.orderInfo.withdrawStatus="processing",this.orderInfo.isWithdrawn=!0,setTimeout((()=>{this.loadOrderInfo()}),1500)}catch(t){console.error("退款申请错误:",t),e.index.showToast({title:t.message||"退款申请失败",icon:"none"})}finally{e.index.hideLoading()}},goToHome(){e.index.reLaunch({url:"/pages/index/index"})}}};const n=e._export_sfc(o,[["render",function(t,r,o,n,d,i){return e.e({a:e.t(d.orderInfo.orderNo||"-"),b:e.t(d.orderInfo.deviceNo||"-"),c:e.t(d.orderInfo.usedTime||"-"),d:e.t(d.orderInfo.packageTime||"1小时"),e:e.t(d.orderInfo.extraTime||"0分钟"),f:e.t(d.orderInfo.endTime||"-"),g:e.t(d.orderInfo.packagePrice||"0.00"),h:e.t(d.orderInfo.extraFee||"0.00"),i:e.t(d.orderInfo.currentFee||"0.00"),j:e.t(d.orderInfo.deposit||"99.00"),k:e.t(d.orderInfo.refundAmount||"99.00"),l:e.t(i.getWithdrawStatusText()),m:e.n(d.orderInfo.withdrawStatus||"waiting"),n:!d.orderInfo.isWithdrawn&&d.orderInfo.refundAmount>0},!d.orderInfo.isWithdrawn&&d.orderInfo.refundAmount>0?{o:e.o(((...e)=>i.handleWithdraw&&i.handleWithdraw(...e)))}:{},{p:e.o(((...e)=>i.goToHome&&i.goToHome(...e)))})}],["__scopeId","data-v-ef3c1c80"]]);wx.createPage(n);
