import{d as f,a2 as h,u as x,$ as b,E as v,g as o,F as q,ap as S,at as I,I as N,aq as C,p as d,f as R,a as B,bm as T,bn as W}from"./index-bc617d61.js";import{C as E}from"./index-344192ea.js";import{C as _}from"./index-917ed250.js";const P="_paywxresult_1bih4_1",J="_container_1bih4_23",t={paywxresult:P,"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:J,"order-loading":"_order-loading_1bih4_27","error-text":"_error-text_1bih4_37","error-icon":"_error-icon_1bih4_44"},O=f({name:"pay-result",setup(){const y=h(),r=x(),n=b({errorText:"",browserStatus:!1,code:null,pay_channel:r.query.pay_channel,wxAppId:r.query.wxAppId,body:r.query.body,price:r.query.price,orderNo:r.query.orderNo,userId:r.query.userId,payInfo:{}});console.log(n.errorText);const g=()=>{const e=r.query;console.log(e),!e.orderNo||!e.pay_channel?C({message:"支付订单信息错误请重新支付",showCancelButton:!1}).then(()=>{y.back()}):d().weixin?(n.browserStatus=!0,w()):d().alipay?(n.browserStatus=!0,l()):(n.errorText="请在微信或支付宝客户端打开",document.title="ERROR")},l=async()=>{try{if(parseFloat(n.price)<=0){R("支付金额异常");return}const e={merOrderNo:n.orderNo,paymentChannel:n.pay_channel,userId:n.userId};n.pay_channel=="wx_pub"&&(e.code=n.code);const{data:a}=await B.post("/edu-app/open/userOrder/executePayment",{data:{...e}});m(a.reqParams)}catch(e){console.log(e),window.location.replace(location.origin+"/classroom-app/#/payment-result?orderNo="+n.orderNo)}},m=e=>{var a,c,p,u;if(n.pay_channel=="alipay_qr"){const i=e.prod_mode==="false"?((a=e==null?void 0:e.expend)==null?void 0:a.qrcode_url)+"?payment_id="+e.id+"&pay_channel="+e.pay_channel:(c=e==null?void 0:e.expend)==null?void 0:c.qrcode_url;window.location.href=i}else if(n.pay_channel=="alipay_wap")window.location.href=(p=e==null?void 0:e.expend)==null?void 0:p.pay_info;else if(n.pay_channel=="wx_pub"){const i=e!=null&&e.expend?JSON.parse((u=e==null?void 0:e.expend)==null?void 0:u.pay_info):e;n.payInfo=i,typeof window.WeixinJSBridge>"u"?document.addEventListener?document.addEventListener("WeixinJSBridgeReady",s,!1):document.attachEvent&&document.attachEvent("WeixinJSBridgeReady",s)(document).attachEvent("onWeixinJSBridgeReady",s):s()}},s=()=>{const e=n.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},a=>{a.err_msg=="get_brand_wcpay_request:cancel"||a.err_msg=="get_brand_wcpay_request:fail",window.location.replace(location.origin+"/orchestra-student/#/payment-result?orderNo="+n.orderNo)})},w=()=>{const e=T();e?(n.code=e,l()):W(n.wxAppId)};return v(()=>{g()}),()=>o("div",{class:t.paywxresult},[n.browserStatus&&o(q,null,[o("div",{class:t.container},[o(E,{border:!1},{default:()=>[o(_,{title:"订单金额",value:"￥ "+S(n.price)},null),o(_,{title:"订单信息",value:n.body},null)]})]),o("div",{class:t["order-loading"]},[o("p",null,[n.pay_channel=="wx_pub"?"微信支付":"支付宝支付"]),o(I,{type:"spinner",color:"#01C1B5"},null)])]),!n.browserStatus&&o("div",{class:t["error-text"]},[n.errorText&&o(N,{class:t["error-icon"],name:"warning-o"},null),n.errorText])])}});export{O as default};
