1 |
- import{d as f,br as T,D as p,e as i,s as h,p as _,T as o,b1 as g,i as e,N as l,A as r,B as C}from"./index.7994470a.js";import{C as u}from"./index.777f4790.js";import{C as b}from"./index.9cdb5783.js";import{R as O,a as y}from"./index.9dc8689d.js";import"./index.c9af17c2.js";import{u as c}from"./hooks.04c1f931.js";const k="_payment_1us1e_1",B="_title_1us1e_13",N="_payAmount_1us1e_21",P="_amount_1us1e_31",v="_blank_1us1e_39",I="_payBtn_1us1e_42";var t={payment:k,title:B,payAmount:N,amount:P,blank:v,payBtn:I};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 A=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:"ali_app",pay_channel:""}},unmounted(){T("paymentOperation",this.paymentOperation)},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(),c("\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}});_({api:"paymentOrder",content:{orderNo:this.orderInfo.orderNo,payChannel:this.payType,payInfo:s.data.pay_info}}),o.loading({message:"\u652F\u4ED8\u4E2D...",forbidClick:!0,duration:3e3,loadingType:"spinner"}),o.clear(),this.$emit("update:modelValue",!1),g("paymentOperation",n=>{console.log(n,"init paymentOperation"),this.paymentOperation(n==null?void 0:n.content)})}catch(a){console.log(a)}c("\u8D2D\u4E70\u652F\u4ED8")},paymentOperation(a){if(console.log(a,"paymentOperation",this.paymentType,this.orderInfo),a.status==="success"||a.status==="error"){if(o.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")o.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(()=>{o.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,"van-hairline--bottom"]},[r("\u9009\u62E9\u652F\u4ED8\u65B9\u5F0F")]),e("div",{class:t.payAmount},[e("p",null,[r("\u5E94\u4ED8\u91D1\u989D")]),e("div",{class:t.amount},[this.$filters.moneyFormat(this.orderInfo.actualPrice),e("span",null,[r("\u5143")])])]),e(O,{modelValue:this.payType,"onUpdate:modelValue":a=>this.payType=a},{default:()=>[e(b,{border:!1},{default:()=>[e(u,{title:"\u652F\u4ED8\u5B9D\u652F\u4ED8",border:!1,center:!0,onClick:()=>{this.payType="ali_app"}},{icon:()=>e(l,{name:"alipay",color:"#009fe9",size:22},null),"right-icon":()=>e(y,{name:"ali_app"},null)}),e(u,{title:"\u5FAE\u4FE1\u652F\u4ED8",border:!1,center:!0,onClick:()=>{this.payType="wx_app"}},{icon:()=>e(l,{name:"wechat-pay",color:"#15c434",size:22},null),"right-icon":()=>e(y,{name:"wx_app"},null)})]})]}),e("div",{class:t.blank},null),e(C,{type:"primary",class:t.payBtn,block:!0,round:!0,onClick:this.onSubmit},{default:()=>[r("\u786E\u8BA4\u652F\u4ED8")]})])}});export{A as P};
|