import{$ as e,T as a,C as t,o as l,c as n,w as s,n as o,e as i,i as c,a as u,f as d,t as m,b as r,d as f,F as h,l as p,I as y,U as _,a4 as g,y as P,k as b}from"./index-4ddb689d.js";import{_ as S}from"./u-modal.9219359e.js";import{r as T}from"./uni-app.es.24af5d4f.js";import{P as I,p as C,a as v,e as w,b as x,c as U,d as k}from"./wechat.58479240.js";import{_ as A}from"./_plugin-vue_export-helper.1b428a4d.js";import"./u-loading.7bd69747.js";import"./u-popup.37b3343e.js";import"./u-icon.e981d1c2.js";const D="recharge/center",M="recharge/submit",V="recharge/tradeQuery";const E={[I.WECHAT.value]:"icon-wechat-pay",[I.ALIPAY.value]:"icon-alipay"},L={[I.WECHAT.value]:"微信",[I.ALIPAY.value]:"支付宝"};const N=A({data:()=>({isLoading:!0,disabled:!1,PayMethodEnum:I,PayMethodIconEnum:E,PayMethodClientNameEnum:L,personal:{balance:"0.00"},setting:{},planList:[],methods:[],selectedPlanId:0,inputValue:"",curPaymentItem:null,showConfirmModal:!1,tempUnifyData:{outTradeNo:"",method:""}}),onLoad(e){this.getPageData()},methods:{onSelectPlan(e){this.selectedPlanId=e,this.inputValue=""},onChangeMoney({detail:e}){this.inputValue=e.value,this.selectedPlanId=0},handleSelectPayType(e){this.curPaymentItem=this.methods[e]},getPageData(){const a=this;return a.isLoading=!0,new Promise(((t,l)=>{var n;(n={client:a.platform},e.get(D,n)).then((e=>{a.setting=e.data.setting,a.personal=e.data.personal,a.planList=e.data.planList,a.methods=e.data.paymentMethods,a.isLoading=!1,a.handleSelectPayType(0),this.performance()}))}))},performance(){this.alipayPerformance(),this.wechatPerformance()},alipayPerformance(){const e=this;e.tempUnifyData=C(),e.tempUnifyData&&e.onTradeQuery(e.tempUnifyData.outTradeNo,e.tempUnifyData.method)},wechatPerformance(){const e=this;e.tempUnifyData=v("recharge"),console.log("wechatPerformance",e.tempUnifyData),e.tempUnifyData&&(e.showConfirmModal=!0)},onSubmit(a){const t=this;var l;t.curPaymentItem?t.disabled||(t.disabled=!0,(l={planId:t.selectedPlanId,customMoney:t.inputValue?t.inputValue:"",method:t.curPaymentItem.method,client:t.platform,extra:t.getExtraAsUnify(t.curPaymentItem.method)},e.post(M,{form:l})).then((e=>t.onSubmitCallback(e))).finally((e=>{setTimeout((()=>t.disabled=!1),10)}))):t.$toast("您还没有选择支付方式")},getExtraAsUnify:e=>e===I.ALIPAY.value?w():e===I.WECHAT.value?x():{},onSubmitCallback(e){const a=this,t=a.curPaymentItem.method,l=e.data.payment;t===I.BALANCE.value&&a.onShowSuccess(e),t===I.ALIPAY.value&&(console.log("paymentData",l),U(l).then((e=>a.onPaySuccess(e))).catch((e=>a.onPayFail(e)))),t===I.WECHAT.value&&(console.log("paymentData",l),k({orderKey:"recharge",...l}).then((e=>a.onPaySuccess(e))).catch((e=>a.onPayFail(e))))},onPaySuccess({res:e,option:{isRequireQuery:a,outTradeNo:t,method:l}}){if(a)return this.onTradeQuery(t,l),!0;this.onShowSuccess(e)},onShowSuccess({message:e}){this.$toast(e||"订单支付成功"),this.onSuccessNav()},onPayFail(e){console.log("onPayFail",e);const a=e.message||"订单未支付";this.$error(a)},onTradeQuery(a,t){const l=this;var n;(n={outTradeNo:a,method:t,client:l.platform},e.get(V,n)).then((e=>e.data.isPay?l.onShowSuccess(e):l.onPayFail(e))).finally((()=>l.showConfirmModal=!1))},onSuccessNav(){const e=a(),l=e.length<2?null:e[e.length-2];l&&t(l.route,["pages/wallet/index"])?setTimeout((()=>uni.navigateBack()),1e3):setTimeout((()=>{this.$navTo("pages/wallet/index",{},"redirectTo")}),1200)}}},[["render",function(e,a,t,I,C,v){const w=p,x=c,U=y,k=_,A=g,D=T(P("u-modal"),S);return C.personal.user_id?(l(),n(x,{key:0,class:"container",style:o(e.appThemeStyle)},{default:s((()=>[u(x,{class:"account-panel dis-flex flex-y-center"},{default:s((()=>[u(x,{class:"panel-lable"},{default:s((()=>[u(w,null,{default:s((()=>[d("账户余额")])),_:1})])),_:1}),u(x,{class:"panel-balance flex-box"},{default:s((()=>[u(w,null,{default:s((()=>[d("¥"+m(C.personal.balance),1)])),_:1})])),_:1})])),_:1}),u(x,{class:"recharge-panel"},{default:s((()=>[u(x,{class:"recharge-label"},{default:s((()=>[u(w,null,{default:s((()=>[d("充值金额")])),_:1})])),_:1}),u(x,{class:"recharge-plan clearfix"},{default:s((()=>[(l(!0),r(h,null,f(C.planList,((e,a)=>(l(),n(x,{key:a,class:b(["recharge-plan_item",{active:C.selectedPlanId==e.plan_id}]),onClick:a=>v.onSelectPlan(e.plan_id)},{default:s((()=>[u(x,{class:"plan_money"},{default:s((()=>[u(w,null,{default:s((()=>[d(m(e.money),1)])),_:2},1024)])),_:2},1024),e.gift_money>0?(l(),n(x,{key:0,class:"plan_gift"},{default:s((()=>[u(w,null,{default:s((()=>[d("送"+m(e.gift_money),1)])),_:2},1024)])),_:2},1024)):i("",!0)])),_:2},1032,["class","onClick"])))),128))])),_:1}),1==C.setting.is_custom?(l(),n(x,{key:0,class:"recharge-input"},{default:s((()=>[u(U,{class:"input",type:"digit",placeholder:"可输入自定义充值金额",modelValue:C.inputValue,"onUpdate:modelValue":a[0]||(a[0]=e=>C.inputValue=e),onInput:v.onChangeMoney},null,8,["modelValue","onInput"])])),_:1})):i("",!0),u(x,{class:"recharge-label m-top60"},{default:s((()=>[u(w,null,{default:s((()=>[d("支付方式")])),_:1})])),_:1}),u(x,{class:"payment-method"},{default:s((()=>[(l(!0),r(h,null,f(C.methods,((e,a)=>(l(),n(x,{key:a,class:"pay-item dis-flex flex-x-between",onClick:e=>v.handleSelectPayType(a)},{default:s((()=>[u(x,{class:"item-left dis-flex flex-y-center"},{default:s((()=>[u(x,{class:b(["item-left_icon",[e.method]])},{default:s((()=>[u(w,{class:b(["iconfont",[C.PayMethodIconEnum[e.method]]])},null,8,["class"])])),_:2},1032,["class"]),u(x,{class:"item-left_text"},{default:s((()=>[u(w,null,{default:s((()=>[d(m(C.PayMethodEnum[e.method].name),1)])),_:2},1024)])),_:2},1024)])),_:2},1024),C.curPaymentItem&&C.curPaymentItem.method==e.method?(l(),n(x,{key:0,class:"item-right col-m"},{default:s((()=>[u(w,{class:"iconfont icon-check"})])),_:1})):i("",!0)])),_:2},1032,["onClick"])))),128))])),_:1}),u(x,{class:"recharge-submit btn-submit"},{default:s((()=>[u(A,{onSubmit:v.onSubmit},{default:s((()=>[u(k,{class:"button",formType:"submit",disabled:C.disabled},{default:s((()=>[d("立即充值")])),_:1},8,["disabled"])])),_:1},8,["onSubmit"])])),_:1})])),_:1}),u(x,{class:"describe-panel"},{default:s((()=>[u(x,{class:"recharge-label"},{default:s((()=>[u(w,null,{default:s((()=>[d("充值说明")])),_:1})])),_:1}),u(x,{class:"content"},{default:s((()=>[u(w,{space:"ensp"},{default:s((()=>[d(m(C.setting.describe),1)])),_:1})])),_:1})])),_:1}),C.tempUnifyData?(l(),n(D,{key:0,modelValue:C.showConfirmModal,"onUpdate:modelValue":a[1]||(a[1]=e=>C.showConfirmModal=e),title:"支付确认","show-cancel-button":"","confirm-text":"已完成支付","confirm-color":e.appTheme.mainBg,"negative-top":"100",asyncClose:!0,onConfirm:a[2]||(a[2]=e=>v.onTradeQuery(C.tempUnifyData.outTradeNo,C.tempUnifyData.method))},{default:s((()=>[u(x,{class:"modal-content"},{default:s((()=>[u(w,null,{default:s((()=>[d("请在"+m(C.PayMethodClientNameEnum[C.tempUnifyData.method])+"内完成支付,如果您已经支付成功,请点击“已完成支付”按钮",1)])),_:1})])),_:1})])),_:1},8,["modelValue","confirm-color"])):i("",!0)])),_:1},8,["style"])):i("",!0)}],["__scopeId","data-v-8c7f5fdc"]]);export{N as default};