import{d as f,q as h,U as x,x as b,y as v,a as n,F as q,P as S,L as I,I as N,Q as C,R as _,E as R,D as B,bo as P,bp as T}from"./index-971588a5.js";import{C as W}from"./index-d00f4365.js";import{C as d}from"./index-a1fa647c.js";const E="_paywxresult_1bih4_1",J="_container_1bih4_23",t={paywxresult:E,"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"},L=f({name:"pay-result",setup(){const y=h(),r=x(),o=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(o.errorText);const m=()=>{const e=r.query;console.log(e),!e.orderNo||!e.pay_channel?C({message:"支付订单信息错误请重新支付",showCancelButton:!1}).then(()=>{y.back()}):_().weixin?(o.browserStatus=!0,g()):_().alipay?(o.browserStatus=!0,l()):(o.errorText="请在微信或支付宝客户端打开",document.title="ERROR")},l=async()=>{try{if(parseFloat(o.price)<=0){R("支付金额异常");return}const e={merOrderNo:o.orderNo,paymentChannel:o.pay_channel,userId:o.userId};o.pay_channel=="wx_pub"&&(e.code=o.code);const{data:a}=await B.post("/edu-app/open/userOrder/executePayment",{data:{...e}});w(a.reqParams)}catch(e){console.log(e),window.location.replace(location.origin+"/classroom-app/#/payment-result?orderNo="+o.orderNo)}},w=e=>{var a,c,p,u;if(o.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(o.pay_channel=="alipay_wap")window.location.href=(p=e==null?void 0:e.expend)==null?void 0:p.pay_info;else if(o.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;o.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=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},a=>{a.err_msg=="get_brand_wcpay_request:cancel"||a.err_msg=="get_brand_wcpay_request:fail",window.location.replace(location.origin+"/classroom-app/#/payment-result?orderNo="+o.orderNo)})},g=()=>{const e=P();e?(o.code=e,l()):T(o.wxAppId)};return v(()=>{m()}),()=>n("div",{class:t.paywxresult},[o.browserStatus&&n(q,null,[n("div",{class:t.container},[n(W,{border:!1},{default:()=>[n(d,{title:"订单金额",value:"￥ "+S(o.price)},null),n(d,{title:"订单信息",value:o.body},null)]})]),n("div",{class:t["order-loading"]},[n("p",null,[o.pay_channel=="wx_pub"?"微信支付":"支付宝支付"]),n(I,{type:"spinner",color:"#01C1B5"},null)])]),!o.browserStatus&&n("div",{class:t["error-text"]},[o.errorText&&n(N,{class:t["error-icon"],name:"warning-o"},null),o.errorText])])}});export{L as default};
