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,U as a,B 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,k as p,I as y,V as _,a4 as g,x as P,j as b}from"./index-ae8bbb19.js";import{_ as S}from"./u-modal.b5d074c6.js";import{r as I}from"./uni-app.es.ee1d5b08.js";import{P as T,p as C,a as v,e as x,b as w,c as U,d as k}from"./wechat.1e2bf9bf.js";import{_ as A}from"./_plugin-vue_export-helper.1b428a4d.js";import"./u-loading.01f91c7b.js";import"./u-popup.d74d5514.js";import"./u-icon.b463ad8a.js";const D="recharge/center",M="recharge/submit",V="recharge/tradeQuery";const E={[T.WECHAT.value]:"icon-wechat-pay",[T.ALIPAY.value]:"icon-alipay"},L={[T.WECHAT.value]:"微信",[T.ALIPAY.value]:"支付宝"};const N=A({data:()=>({isLoading:!0,disabled:!1,PayMethodEnum:T,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===T.ALIPAY.value?x():e===T.WECHAT.value?w():{},onSubmitCallback(e){const a=this,t=a.curPaymentItem.method,l=e.data.payment;t===T.BALANCE.value&&a.onShowSuccess(e),t===T.ALIPAY.value&&(console.log("paymentData",l),U(l).then((e=>a.onPaySuccess(e))).catch((e=>a.onPayFail(e)))),t===T.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,T,C,v){const x=p,w=c,U=y,k=_,A=g,D=I(P("u-modal"),S);return C.personal.user_id?(l(),n(w,{key:0,class:"container",style:o(e.appThemeStyle)},{default:s((()=>[u(w,{class:"account-panel dis-flex flex-y-center"},{default:s((()=>[u(w,{class:"panel-lable"},{default:s((()=>[u(x,null,{default:s((()=>[d("账户余额")])),_:1})])),_:1}),u(w,{class:"panel-balance flex-box"},{default:s((()=>[u(x,null,{default:s((()=>[d("¥"+m(C.personal.balance),1)])),_:1})])),_:1})])),_:1}),u(w,{class:"recharge-panel"},{default:s((()=>[u(w,{class:"recharge-label"},{default:s((()=>[u(x,null,{default:s((()=>[d("充值金额")])),_:1})])),_:1}),u(w,{class:"recharge-plan clearfi