1 |
- import{g as h,d as f,bq as _,D as p,w as i,n as T,T as n,b0 as g,j as e,M as l,z as o,B as C}from"./index.e6d6174e.js";import{C as u}from"./index.af99cf22.js";import{C as O}from"./index.4aea64de.js";import{R as b,a as c}from"./index.cbc70232.js";import"./index.d92a5aca.js";import{u as y}from"./hooks.00b5b341.js";const k="_payment_1ot0l_1",B="_title_1ot0l_13",E="_payAmount_1ot0l_21",N="_amount_1ot0l_31",F="_blank_1ot0l_38",I="_payTypeRe_1ot0l_41",P="_recommend_1ot0l_45",v="_payBtn_1ot0l_54";var t={payment:k,title:B,payAmount:E,amount:N,blank:F,payTypeRe:I,recommend:P,payBtn:v};const d=h.platformType==="TEACHER"?"/api-teacher":"/api-student",m={goodsPay:{cancelUrl:"/api-mall-portal/order/cancelUserOrder",payUrl:"/api-mall-portal/payment/orderPay"},orderPay:{cancelUrl:d+"/userOrder/orderCancel",payUrl:d+"/userOrder/orderPay"}};var U=f({name:"payment",props:{modelValue:{type:Boolean,default:!1},orderInfo:{type:Object,default:{orderNo:"",actualPrice:0}},onBackOut:{type:Function,default:()=>{}},paymentType:{type:String,default:"orderPay"}},data(){return{payType:"wx_app",pay_channel:""}},unmounted(){_("paymentOperation",this.paymentOperation)},mounted(){console.log(this.orderInfo,"this.orderInfo")},methods:{onClose(){p.confirm({message:"\u662F\u5426\u653E\u5F03\u672C\u6B21\u4ED8\u6B3E",confirmButtonText:"\u7EE7\u7EED\u4ED8\u6B3E",cancelButtonText:"\u653E\u5F03"}).then(()=>{}).catch(async()=>{this.onCancel(),y("\u53D6\u6D88\u652F\u4ED8")})},async onCancel(a){try{await i.post(m[this.paymentType].cancelUrl,{data:{orderNo:this.orderInfo.orderNo}})}catch{}this.$emit("update:modelValue",!1),!a&&this.$router.go(-1),this.onBackOut&&this.onBackOut()},async onSubmit(){try{const a={orderNo:this.orderInfo.orderNo,payChannel:this.payType,paymentClient:null};this.paymentType==="goodsPay"&&(a.paymentClient=h.platformType);const s=await i.post(m[this.paymentType].payUrl,{data:{...a}});T({api:"paymentOrder",content:{orderNo:this.orderInfo.orderNo,payChannel:this.payType,payInfo:s.data.pay_info}}),n.loading({message:"\u652F\u4ED8\u4E2D...",forbidClick:!0,duration:3e3,loadingType:"spinner"}),n.clear(),this.$emit("update:modelValue",!1),g("paymentOperation",r=>{console.log(r,"init paymentOperation"),this.paymentOperation(r==null?void 0:r.content)})}catch(a){console.log(a)}y("\u8D2D\u4E70\u652F\u4ED8")},paymentOperation(a){if(console.log(a,"paymentOperation",this.paymentType,this.orderInfo),a.status==="success"||a.status==="error"){if(n.clear(),this.$emit("update:modelValue",!1),this.paymentType==="goodsPay"){this.$router.replace({path:"/shopTrade",query:{orderNo:this.orderInfo.orderNo}});return}this.$router.replace({path:"/tradeDetail",query:{orderNo:this.orderInfo.orderNo}})}else if(a.status==="cancel")n.clear(),this.$emit("update:modelValue",!1);else if(a.status==="fail"){const s=this.payType==="ali_app"?"\u60A8\u5C1A\u672A\u5B89\u88C5\u652F\u4ED8\u5B9D":"\u60A8\u5C1A\u672A\u5B89\u88C5\u5FAE\u4FE1";p.alert({title:"\u63D0\u793A",message:s}).then(()=>{n.clear(),this.$emit("update:modelValue",!1)})}}},render(){return e("div",{class:t.payment},[e(l,{onClick:this.onClose,name:"cross",size:20},null),e("div",{class:[t.title]},[o("\u9009\u62E9\u652F\u4ED8\u65B9\u5F0F")]),e("div",{class:t.payAmount},[e("p",null,[o("\u5E94\u4ED8\u91D1\u989D")]),e("div",{class:t.amount},[e("span",null,[o("\uFFE5 ")]),this.$filters.moneyFormat(this.orderInfo.actualPrice)])]),e(b,{modelValue:this.payType,"onUpdate:modelValue":a=>this.payType=a},{default:()=>[e(O,{border:!1},{default:()=>[e(u,{border:!0,center:!0,onClick:()=>{this.payType="wx_app"}},{icon:()=>e(l,{name:"wechat-pay",color:"#15c434",size:22},null),"right-icon":()=>e(c,{name:"wx_app"},null),title:()=>e("div",{class:t.payTypeRe},[o("\u5FAE\u4FE1\u652F\u4ED8 "),e("span",{class:t.recommend},[o("\u63A8\u8350")])])}),e(u,{title:"\u652F\u4ED8\u5B9D\u652F\u4ED8",border:!0,center:!0,onClick:()=>{this.payType="ali_app"}},{icon:()=>e(l,{name:"alipay",color:"#009fe9",size:22},null),"right-icon":()=>e(c,{name:"ali_app"},null)})]})]}),e("div",{class:t.blank},null),e(C,{type:"primary",class:t.payBtn,block:!0,round:!0,onClick:this.onSubmit},{default:()=>[o("\u786E\u8BA4\u652F\u4ED8")]})])}});export{U as P};
|