var C=Object.defineProperty;var i=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var p=(e,o,t)=>o in e?C(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,d=(e,o)=>{for(var t in o||(o={}))g.call(o,t)&&p(e,t,o[t]);if(i)for(var t of i(o))b.call(o,t)&&p(e,t,o[t]);return e};import{n as O,r as c,p as u,s as y,l as k}from"./index.3d95a92c.js";import{d as N,D as m,T as r,a,u as l,j as s,ac as x,C as I,q as h,ad as f,B as P}from"./vendor.a0144ce9.js";/* empty css               *//* empty css              *//* empty css               *//* empty css                */import{o as j}from"./orderStatus.243cb96a.js";const v="_payment_12480_1",V="_title_12480_13",B="_payAmount_12480_21",U="_amount_12480_31",$="_blank_12480_39";var n={payment:v,title:V,payAmount:B,amount:U,blank:$};const T=y.platformType==="TEACHER"?"/api-teacher":"/api-student",_={goodsPay:{cancelUrl:"/api-mall-portal/order/cancelUserOrder",payUrl:"/api-mall-portal/payment/orderPay"},orderPay:{cancelUrl:T+"/userOrder/orderCancel",payUrl:T+"/userOrder/orderPay"}};var z=N({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(){O("paymentOperation",this.paymentOperation)},methods:{onClose(){m.confirm({message:"\u662F\u5426\u653E\u5F03\u672C\u6B21\u4ED8\u6B3E",confirmButtonText:"\u7EE7\u7EED\u4ED8\u6B3E",cancelButtonText:"\u653E\u5F03"}).then(()=>{}).catch(async()=>{this.onCancel()})},async onCancel(e){try{await c.post(_[this.paymentType].cancelUrl,{data:{orderNo:this.orderInfo.orderNo}})}catch{}if(this.$emit("update:modelValue",!1),!e&&j.orderObject.orderType=="MUSIC"){u({api:"back",content:{}});return}!e&&this.$router.go(-1),this.onBackOut&&this.onBackOut()},async onSubmit(){try{let e={orderNo:this.orderInfo.orderNo,payChannel:this.payType,paymentClient:null};this.paymentType==="goodsPay"&&(e.paymentClient=y.platformType);let o=await c.post(_[this.paymentType].payUrl,{data:d({},e)});u({api:"paymentOrder",content:{orderNo:this.orderInfo.orderNo,payChannel:this.payType,payInfo:o.data.pay_info}}),r.loading({message:"\u652F\u4ED8\u4E2D...",forbidClick:!0,duration:3e3,loadingType:"spinner"}),r.clear(),this.$emit("update:modelValue",!1),k("paymentOperation",t=>{console.log(t,"init paymentOperation"),this.paymentOperation(t==null?void 0:t.content)})}catch(e){console.log(e)}},paymentOperation(e){if(console.log(e,"paymentOperation",this.paymentType,this.orderInfo),e.status==="success"||e.status==="error"){if(r.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(e.status==="cancel")r.clear(),this.$emit("update:modelValue",!1);else if(e.status==="fail"){const o=this.payType==="ali_app"?"\u60A8\u5C1A\u672A\u5B89\u88C5\u652F\u4ED8\u5B9D":"\u60A8\u5C1A\u672A\u5B89\u88C5\u5FAE\u4FE1";m.alert({title:"\u63D0\u793A",message:o}).then(()=>{r.clear(),this.$emit("update:modelValue",!1)})}}},render(){return a("div",{class:n.payment},[a(l,{onClick:this.onClose,name:"cross",size:20},null),a("div",{class:[n.title,"van-hairline--bottom"]},[s("\u9009\u62E9\u652F\u4ED8\u65B9\u5F0F")]),a("div",{class:n.payAmount},[a("p",null,[s("\u5E94\u4ED8\u91D1\u989D")]),a("div",{class:n.amount},[this.$filters.moneyFormat(this.orderInfo.actualPrice),a("span",null,[s("\u5143")])])]),a(x,{modelValue:this.payType,"onUpdate:modelValue":e=>this.payType=e},{default:()=>[a(I,{border:!1},{default:()=>[a(h,{title:"\u652F\u4ED8\u5B9D\u652F\u4ED8",border:!1,center:!0,onClick:()=>{this.payType="ali_app"}},{icon:()=>a(l,{name:"alipay",color:"#009fe9",size:22},null),"right-icon":()=>a(f,{name:"ali_app"},null)}),a(h,{title:"\u5FAE\u4FE1\u652F\u4ED8",border:!1,center:!0,onClick:()=>{this.payType="wx_app"}},{icon:()=>a(l,{name:"wechat-pay",color:"#15c434",size:22},null),"right-icon":()=>a(f,{name:"wx_app"},null)})]})]}),a("div",{class:n.blank},null),a(P,{type:"primary",block:!0,onClick:this.onSubmit},{default:()=>[s("\u786E\u8BA4\u652F\u4ED8")]})])}});export{z as P};
