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.
1 lines
6.2 KiB
1 lines
6.2 KiB
import{$ as e,U as a,B as t,o,c as s,w as n,n as r,e as l,i as d,a as i,f as c,t as m,b as u,d as h,F as f,j as y,k as p,r as P,x as _}from"./index-ae8bbb19.js";import{_ as I}from"./u-modal.b5d074c6.js";import{r as C}from"./uni-app.es.ee1d5b08.js";import{P as S,p as g,a as T,e as b,b as v,c as x,d as w}from"./wechat.1e2bf9bf.js";import{C as A}from"./index.002ef29d.js";import{P as E}from"./OrderType.fdcce3af.js";import{_ as D}from"./_plugin-vue_export-helper.1b428a4d.js";import"./u-loading.01f91c7b.js";import"./u-popup.d74d5514.js";import"./u-icon.b463ad8a.js";const k="cashier/orderInfo",N="cashier/orderPay",U="cashier/tradeQuery";const M={[S.WECHAT.value]:"icon-wechat-pay",[S.ALIPAY.value]:"icon-alipay",[S.BALANCE.value]:"icon-balance-pay"},L={[S.WECHAT.value]:"微信",[S.ALIPAY.value]:"支付宝"};const j=D({components:{CountDown:A},data:()=>({isLoading:!0,disabled:!1,PayMethodEnum:S,PayMethodIconEnum:M,PayMethodClientNameEnum:L,curPaymentItem:null,orderId:null,order:{},personal:{balance:"0.00"},methods:[],showConfirmModal:!1,tempUnifyData:{outTradeNo:"",method:""}}),onLoad({orderId:e}){this.orderId=Number(e),this.getCashierInfo()},methods:{getCashierInfo(){const a=this;var t,o;a.isLoading=!0,(t=a.orderId,o={client:a.platform},e.get(k,{orderId:t,...o})).then((e=>{a.order=e.data.order,a.personal=e.data.personal,a.methods=e.data.paymentMethods,a.isLoading=!1,a.setDefaultPayType(),a.checkOrderPayStatus(),this.performance()}))},setDefaultPayType(){const e=this;if(e.disabled)return;const a=e.methods.findIndex((e=>1==e.is_default));a>-1&&e.handleSelectPayType(a)},checkOrderPayStatus(){const e=this;e.order.pay_status==E.SUCCESS.value&&(e.$toast("恭喜您,订单已付款成功"),e.onSuccessNav())},handleSelectPayType(e){this.curPaymentItem=this.methods[e]},performance(){const e=this;e.order.pay_status==E.PENDING.value&&(e.alipayPerformance(),e.wechatPerformance())},alipayPerformance(){const e=this;e.tempUnifyData=g(),e.tempUnifyData&&e.onTradeQuery(e.tempUnifyData.outTradeNo,e.tempUnifyData.method)},wechatPerformance(){const e=this;e.tempUnifyData=T(e.orderId),e.tempUnifyData&&(e.showConfirmModal=!0)},handleSubmit(){const a=this;var t,o;a.curPaymentItem?a.disabled||(a.disabled=!0,(t=a.orderId,o={method:a.curPaymentItem.method,client:a.platform,extra:a.getExtraAsUnify(a.curPaymentItem.method)},e.post(N,{orderId:t,...o})).then((e=>a.onSubmitCallback(e))).finally((e=>setTimeout((()=>a.disabled=!1),10)))):a.$toast("您还没有选择支付方式")},getExtraAsUnify:e=>e===S.ALIPAY.value?b():e===S.WECHAT.value?v():{},onSubmitCallback(e){const a=this,t=a.curPaymentItem.method,o=e.data.payment;t===S.BALANCE.value&&a.onShowSuccess(e),t===S.ALIPAY.value&&(console.log("paymentData",o),x(o).then((e=>a.onPaySuccess(e))).catch((e=>a.onPayFail(e)))),t===S.WECHAT.value&&(console.log("paymentData",o),w({orderKey:a.orderId,...o}).then((e=>a.onPaySuccess(e))).catch((e=>a.onPayFail(e))))},onPaySuccess({res:e,option:{isRequireQuery:a,outTradeNo:t,method:o}}){if(a)return this.onTradeQuery(t,o),!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 o=this;var s;(s={outTradeNo:a,method:t,client:o.platform},e.get(U,s)).then((e=>e.data.isPay?o.onShowSuccess(e):o.onPayFail(e))).finally((()=>o.showConfirmModal=!1))},onSuccessNav(){uni.$emit("syncRefresh",!0);const e=a(),o=e.length<2?null:e[e.length-2],s=["pages/order/index","pages/order/detail"];setTimeout((()=>{o&&t(o.route,s)?uni.navigateBack():this.$navTo("pages/order/index",{},"redirectTo")}),1200)}}},[["render",function(e,a,t,S,g,T){const b=p,v=P("count-down"),x=d,w=C(_("u-modal"),I);return g.isLoading?l("",!0):(o(),s(x,{key:0,class:"container",style:r(e.appThemeStyle)},{default:n((()=>[i(x,{class:"order-info"},{default:n((()=>[g.order.showExpiration?(o(),s(x,{key:0,class:"order-countdown"},{default:n((()=>[i(b,{class:"m-r-6"},{default:n((()=>[c("剩余时间")])),_:1}),i(v,{date:g.order.expirationTime,separator:"zh",theme:"text"},null,8,["date"])])),_:1})):l("",!0),i(x,{class:"order-amount"},{default:n((()=>[i(b,{class:"unit"},{default:n((()=>[c("¥")])),_:1}),i(b,{class:"amount"},{default:n((()=>[c(m(g.order.pay_price),1)])),_:1})])),_:1})])),_:1}),i(x,{class:"payment-method"},{default:n((()=>[(o(!0),u(f,null,h(g.methods,((e,a)=>(o(),s(x,{key:a,class:"pay-item dis-flex flex-x-between",onClick:e=>T.handleSelectPayType(a)},{default:n((()=>[i(x,{class:"item-left dis-flex flex-y-center"},{default:n((()=>[i(x,{class:y(["item-left_icon",[e.method]])},{default:n((()=>[i(b,{class:y(["iconfont",[g.PayMethodIconEnum[e.method]]])},null,8,["class"])])),_:2},1032,["class"]),i(x,{class:"item-left_text"},{default:n((()=>[i(b,null,{default:n((()=>[c(m(g.PayMethodEnum[e.method].name),1)])),_:2},1024)])),_:2},1024),e.method===g.PayMethodEnum.BALANCE.value?(o(),s(x,{key:0,class:"user-balance"},{default:n((()=>[i(b,null,{default:n((()=>[c("(可用¥"+m(g.personal.balance)+"元)",1)])),_:1})])),_:1})):l("",!0)])),_:2},1024),g.curPaymentItem&&g.curPaymentItem.method==e.method?(o(),s(x,{key:0,class:"item-right col-m"},{default:n((()=>[i(b,{class:"iconfont icon-check"})])),_:1})):l("",!0)])),_:2},1032,["onClick"])))),128))])),_:1}),i(x,{class:"footer-fixed"},{default:n((()=>[i(x,{class:"btn-wrapper"},{default:n((()=>[i(x,{class:y(["btn-item btn-item-main",{disabled:g.disabled}]),onClick:a[0]||(a[0]=e=>T.handleSubmit())},{default:n((()=>[c("确认支付")])),_:1},8,["class"])])),_:1})])),_:1}),g.tempUnifyData?(o(),s(w,{key:0,modelValue:g.showConfirmModal,"onUpdate:modelValue":a[1]||(a[1]=e=>g.showConfirmModal=e),title:"支付确认","show-cancel-button":"","confirm-text":"已完成支付","confirm-color":e.appTheme.mainBg,"negative-top":"100",asyncClose:!0,onConfirm:a[2]||(a[2]=e=>T.onTradeQuery(g.tempUnifyData.outTradeNo,g.tempUnifyData.method))},{default:n((()=>[i(x,{class:"modal-content"},{default:n((()=>[i(b,null,{default:n((()=>[c("请在"+m(g.PayMethodClientNameEnum[g.tempUnifyData.method])+"内完成支付,如果您已经支付成功,请点击“已完成支付”按钮",1)])),_:1})])),_:1})])),_:1},8,["modelValue","confirm-color"])):l("",!0)])),_:1},8,["style"]))}],["__scopeId","data-v-8edcdc3e"]]);export{j as default};
|
|
|