"use strict";const e=require("../../common/vendor.js");require("../../common/libraries/request.js");const o=require("../../common/store/useWeAppAuthStore.js"),l=require("../../common/store/useWorkStore.js"),a=require("./model.js"),u=require("../../gen/Apis.js"),d=require("../../common/libraries/apiLoading.js"),s=require("../../common/libraries/pay.js"),n=require("../../common/libraries/naviHelper.js");o.useWeAppAuthStore(),l.useWorkStore();const i={loadShow:()=>{var o,l;console.log("定时器",null==(l=null==(o=a.useModel)?void 0:o.loadingShowNumber)?void 0:l.value),a.useModel.timer.value=setInterval((()=>{var o,l,d,s,i;if((null==(l=null==(o=a.useModel)?void 0:o.loadingShowNumber)?void 0:l.value)>2&&"Pending"===(null==(i=null==(s=null==(d=a.useModel)?void 0:d.orderShow)?void 0:s.value)?void 0:i.payment_status))return a.useModel.payDisabled.value=!1,e.index.hideLoading(),void clearInterval(a.useModel.timer.value);a.useModel.loadingShowNumber.value<=2&&(e=>{var o,l,d;u.Apis.HouseOrder.HousePrepayments.GetPayments({house_prepayment_payments_id:null==(d=null==(l=null==(o=a.useModel)?void 0:o.housePrepaymentPayment)?void 0:l.value)?void 0:d.id}).then((o=>{var l;console.log("获取支付状态",null==o?void 0:o.data),a.useModel.loadingShowNumber.value+=1,a.useModel.orderShow.value=null==o?void 0:o.data,"Paid"===(null==(l=null==o?void 0:o.data)?void 0:l.payment_status)&&(clearInterval(e),a.useModel.formData.value.amount=void 0,a.useModel.payDisabled.value=!1,n.showToast("支付成功"))}))})(a.useModel.timer.value)}),1e3)},handlePay(){var o,l;a.useModel.payDisabled.value=!0,d.getApiLoading(u.Apis.HouseOrder.HousePrepayments.Payment,null==(l=null==(o=a.useModel)?void 0:o.formData)?void 0:l.value).then((o=>{var l,u;a.useModel.housePrepaymentPayment.value=null==(l=null==o?void 0:o.data)?void 0:l.house_prepayment_payment,e.index.showLoading({title:"正在支付...",mask:!0}),s.tongLianPay(null==(u=null==o?void 0:o.data)?void 0:u.pay_info,(()=>{a.useModel.loadingShowNumber.value=-1,console.log("支付成功")}),(()=>{a.useModel.payDisabled.value=!1,e.index.hideLoading()})),console.log(o)})).catch((()=>{a.useModel.payDisabled.value=!1})),console.log("e")}};exports.method=i;
