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.
2 lines
6.2 KiB
2 lines
6.2 KiB
11 months ago
|
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:"te
|