import{d as S,S as P,Q as N,U as I,W as q,j as o,F as B,be as A,aU as C,O as T,D as J,f as _,bU as f,bW as O,T as R,y as W,A as s,g as l,bV as k}from"./ResizeObserver.es.62ab429c.js";import{C as w}from"./index.d7a13e47.js";import{C as D}from"./index.e24f8570.js";const E="_paywxresult_1bih4_1",Y="_container_1bih4_23";var p={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:Y,"order-loading":"_order-loading_1bih4_27","error-text":"_error-text_1bih4_37","error-icon":"_error-icon_1bih4_44"},V=S({name:"pay-result",setup(){const g=P(),a=N(),r=I({errorText:"",browserStatus:!1,code:null,pay_channel:a.query.pay_channel,wxAppId:a.query.wxAppId,paymentType:a.query.paymentType,alipayAppId:a.query.alipayAppId,body:a.query.body,price:a.query.price,orderNo:a.query.orderNo,userId:a.query.userId,payInfo:{},isYeePay:!1}),m=()=>{var t;const e=a.query,n=((t=r.paymentType)==null?void 0:t.indexOf("yeepay"))!==-1;if(!e.orderNo||!e.pay_channel)J.confirm({message:"\u652F\u4ED8\u8BA2\u5355\u4FE1\u606F\u9519\u8BEF\u8BF7\u91CD\u65B0\u652F\u4ED8",showCancelButton:!1}).then(()=>{g.back()});else if(_().weixin)r.browserStatus=!0,v();else if(_().alipay)if(n){const i=f("auth_code");i?(r.code=i,r.browserStatus=!0,d()):O(r.alipayAppId)}else r.browserStatus=!0,d();else r.errorText="\u8BF7\u5728\u5FAE\u4FE1\u6216\u652F\u4ED8\u5B9D\u5BA2\u6237\u7AEF\u6253\u5F00",document.title="ERROR"},d=async()=>{var e;try{if(parseFloat(r.price)<=0){R("\u652F\u4ED8\u91D1\u989D\u5F02\u5E38");return}const n={merOrderNo:r.orderNo,paymentChannel:r.pay_channel,userId:r.userId,code:r.code},{data:t}=await W.post("/api-student/open/userOrder/executePayment/v2",{data:{...n}});r.isYeePay=((e=t.paymentVender)==null?void 0:e.indexOf("yeepay"))!==-1,console.log(t,"data"),b(t.reqParams)}catch(n){console.log(n),window.location.replace(s()+l.payBackPath+"#/tradeDetail?orderNo="+r.orderNo)}},h=e=>{window.AlipayJSBridge?e&&e():document.addEventListener("AlipayJSBridgeReady",e,!1)},x=e=>{h(function(){window.AlipayJSBridge.call("tradePay",{tradeNO:e},function(n){n.resultCode=="9000"?window.location.replace(s()+l.payBackPath+"#/tradeDetail?orderNo="+r.orderNo):window.location.replace(s()+l.payBackPath+"#/tradeDetail?orderNo="+r.orderNo),window.AlipayJSBridge.call("closeWebview")})})},b=e=>{var n,t,i,u;if(r.pay_channel=="alipay_qr")if(r.isYeePay)x(e.tradeNO);else{const y=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:(t=e==null?void 0:e.expend)==null?void 0:t.qrcode_url;window.location.href=y}else if(r.pay_channel=="alipay_wap")window.location.href=(i=e==null?void 0:e.expend)==null?void 0:i.pay_info;else if(r.pay_channel=="wx_pub"){console.log(r.isYeePay,e==null?void 0:e.expend,"payInfo");const y=r.isYeePay?JSON.parse(e.prePayTn):e!=null&&e.expend?JSON.parse((u=e==null?void 0:e.expend)==null?void 0:u.pay_info):e;r.payInfo=y,typeof window.WeixinJSBridge=="undefined"?document.addEventListener?document.addEventListener("WeixinJSBridgeReady",c,!1):document.attachEvent&&document.attachEvent("WeixinJSBridgeReady",c)(document).attachEvent("onWeixinJSBridgeReady",c):c()}},c=()=>{const e=r.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(s()+l.payBackPath+"#/tradeDetail?orderNo="+r.orderNo):window.location.replace(s()+l.payBackPath+"#/tradeDetail?orderNo="+r.orderNo)})},v=()=>{const e=f();e?(r.code=e,d()):k(r.wxAppId)};return q(()=>{m()}),()=>o("div",{class:p.paywxresult},[r.browserStatus&&o(B,null,[o("div",{class:p.container},[o(D,{border:!1},{default:()=>[o(w,{title:"\u8BA2\u5355\u91D1\u989D",value:"\uFFE5 "+A(r.price)},null),o(w,{title:"\u8BA2\u5355\u4FE1\u606F",value:r.body},null)]})]),o("div",{class:p["order-loading"]},[o("p",null,[r.pay_channel=="wx_pub"?"\u5FAE\u4FE1\u652F\u4ED8":"\u652F\u4ED8\u5B9D\u652F\u4ED8"]),o(C,{type:"spinner",color:"#01C1B5"},null)])]),!r.browserStatus&&o("div",{class:p["error-text"]},[r.errorText&&o(T,{class:p["error-icon"],name:"warning-o"},null),r.errorText])])}});export{V as default};
