import{d as b,ag as v,ah as S,r as N,$ as q,c as r,F as I,bf as P,L as B,a5 as C,bh as A,f as u,br as y,bS as T,o as J,m as O,bs as R}from"./index.27735e87.js";import{O as W}from"./index.61a124fa.js";import{C as E}from"./index.5a2d3ded.js";import{C as _}from"./index.997909e4.js";const L="_paywxresult_1bih4_1",M="_container_1bih4_23";var s={paywxresult:L,"van-cell":"_van-cell_1bih4_5","van-cell__title":"_van-cell__title_1bih4_8","van-cell__value":"_van-cell__value_1bih4_9","van-button":"_van-button_1bih4_14","van-loading__spinner":"_van-loading__spinner_1bih4_19",container:M,"order-loading":"_order-loading_1bih4_27","error-text":"_error-text_1bih4_37","error-icon":"_error-icon_1bih4_44"},D=b({name:"pay-result",setup(){const g=v(),t=S(),o=N({errorText:"",browserStatus:!1,code:null,paymentType:t.query.paymentType,pay_channel:t.query.pay_channel,wxAppId:t.query.wxAppId,alipayAppId:t.query.alipayAppId,body:t.query.body,price:t.query.price,orderNo:t.query.orderNo,userId:t.query.userId,payInfo:{},isYeePay:!1,dialogStatus:!1,dialogMessage:""}),f=()=>{var a;const e=t.query;console.log(e);const n=((a=o.paymentType)==null?void 0:a.indexOf("yeepay"))!==-1;if(!e.orderNo||!e.pay_channel)A({message:"\u652F\u4ED8\u8BA2\u5355\u4FE1\u606F\u9519\u8BEF\u8BF7\u91CD\u65B0\u652F\u4ED8",showCancelButton:!1}).then(()=>{g.back()});else if(u().weixin)o.browserStatus=!0,x();else if(u().alipay)if(n){const i=y("auth_code")||t.query.auth_code;i?(o.code=i,o.browserStatus=!0,c()):T(o.alipayAppId)}else o.browserStatus=!0,c();else o.errorText="\u8BF7\u5728\u5FAE\u4FE1\u6216\u652F\u4ED8\u5B9D\u5BA2\u6237\u7AEF\u6253\u5F00",document.title="ERROR"},c=async()=>{var e;try{if(parseFloat(o.price)<=0){J("\u652F\u4ED8\u91D1\u989D\u5F02\u5E38");return}const n={merOrderNo:o.orderNo,paymentChannel:o.pay_channel,userId:o.userId};o.pay_channel=="wx_pub"&&(n.code=o.code);const a=await O.post("/api-student/open/userOrder/executePayment",{data:{...n}});a.code===999?(o.dialogStatus=!0,o.dialogMessage=a.message):(o.isYeePay=((e=a.data.paymentVender)==null?void 0:e.indexOf("yeepay"))!==-1,console.log(a.data,"payment",o.pay_channel),h(a.data.reqParams))}catch(n){console.log(n),window.location.replace(location.origin+"/orchestra-student/#/payment-result?orderNo="+o.orderNo)}},w=e=>{window.AlipayJSBridge?e&&e():document.addEventListener("AlipayJSBridgeReady",e,!1)},m=e=>{w(function(){window.AlipayJSBridge.call("tradePay",{tradeNO:e},function(n){n.resultCode=="9000",window.location.replace(location.origin+"/orchestra-student/#/payment-result?orderNo="+o.orderNo),window.AlipayJSBridge.call("closeWebview")})})},h=e=>{var n,a,i,d;if(o.pay_channel=="alipay_qr")if(o.isYeePay)m(e.tradeNO);else{const p=e.prod_mode==="false"?((n=e==null?void 0:e.expend)==null?void 0:n.qrcode_url)+"?payment_id="+e.id+"&pay_channel="+e.pay_channel:(a=e==null?void 0:e.expend)==null?void 0:a.qrcode_url;window.location.href=p}else if(o.pay_channel=="alipay_wap")window.location.href=(i=e==null?void 0:e.expend)==null?void 0:i.pay_info;else if(o.pay_channel=="wx_pub"){const p=o.isYeePay?JSON.parse(e.prePayTn):e!=null&&e.expend?JSON.parse((d=e==null?void 0:e.expend)==null?void 0:d.pay_info):e;o.payInfo=p,typeof window.WeixinJSBridge=="undefined"?document.addEventListener?document.addEventListener("WeixinJSBridgeReady",l,!1):document.attachEvent&&document.attachEvent("WeixinJSBridgeReady",l)(document).attachEvent("onWeixinJSBridgeReady",l):l()}},l=()=>{const e=o.payInfo;window.WeixinJSBridge.invoke("getBrandWCPayRequest",{appId:e.appId,timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package||e.packageValue,signType:e.signType,paySign:e.paySign},n=>{n.err_msg=="get_brand_wcpay_request:cancel"||n.err_msg=="get_brand_wcpay_request:fail",window.location.replace(location.origin+"/orchestra-student/#/payment-result?orderNo="+o.orderNo)})},x=()=>{const e=y();e?(o.code=e,c()):R(o.wxAppId)};return q(()=>{f()}),()=>r("div",{class:s.paywxresult},[o.browserStatus&&r(I,null,[r("div",{class:s.container},[r(E,{border:!1},{default:()=>[r(_,{title:"\u8BA2\u5355\u91D1\u989D",value:"\uFFE5 "+P(o.price)},null),r(_,{title:"\u8BA2\u5355\u4FE1\u606F",value:o.body},null)]})]),r("div",{class:s["order-loading"]},[r("p",null,[o.pay_channel=="wx_pub"?"\u5FAE\u4FE1\u652F\u4ED8":"\u652F\u4ED8\u5B9D\u652F\u4ED8"]),r(B,{type:"spinner",color:"#01C1B5"},null)])]),!o.browserStatus&&r("div",{class:s["error-text"]},[o.errorText&&r(C,{class:s["error-icon"],name:"warning-o"},null),o.errorText]),r(W,{title:"\u63D0\u793A",show:o.dialogStatus,"onUpdate:show":e=>o.dialogStatus=e,message:o.dialogMessage,confirmButtonText:"\u786E\u5B9A",onConfirm:()=>{window.location.replace(location.origin+"/orchestra-student/#/payment-result?orderNo="+o.orderNo)}},null)])}});export{D as default};
