You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/public/assets/pages-wallet-recharge-index...

2 lines
7.0 KiB

11 months ago
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 clearfi