1 |
- import{d as b,q as v,P as S,x as N,y as q,a as r,F as I,W as P,L as A,I as B,a4 as C,S as y,bi as u,bY as J,N as R,D as T,bk as W}from"./index-869d77fb.js";import{C as O}from"./index-cff93552.js";import{C as _}from"./index-1c6c2ec0.js";const E="_paywxresult_1bih4_1",Y="_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:Y,"order-loading":"_order-loading_1bih4_27","error-text":"_error-text_1bih4_37","error-icon":"_error-icon_1bih4_44"},V=b({name:"pay-result",setup(){const w=v(),a=S(),o=N({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=()=>{const e=a.query,n=o.paymentType.indexOf("yeepay")!==-1;if(!e.orderNo||!e.pay_channel)C({message:"支付订单信息错误请重新支付",showCancelButton:!1}).then(()=>{w.back()});else if(y().weixin)o.browserStatus=!0,x();else if(y().alipay)if(n){let i=u("auth_code");i?(o.code=i,o.browserStatus=!0,l()):J(o.alipayAppId)}else o.browserStatus=!0,l();else o.errorText="请在微信或支付宝客户端打开",document.title="ERROR"},l=async()=>{var e;try{if(parseFloat(o.price)<=0){R("支付金额异常");return}const n={merOrderNo:o.orderNo,paymentChannel:o.pay_channel,userId:o.userId,code:o.code},{data:i}=await T.post("/edu-app/open/userOrder/executePayment",{data:{...n}});o.isYeePay=((e=i.paymentVender)==null?void 0:e.indexOf("yeepay"))!==-1,console.log(i,"data"),h(i.reqParams)}catch(n){console.log(n),window.location.replace(location.origin+"/classroom-app/#/payment-result?orderNo="+o.orderNo)}},f=e=>{window.AlipayJSBridge?e&&e():document.addEventListener("AlipayJSBridgeReady",e,!1)},g=e=>{f(function(){window.AlipayJSBridge.call("tradePay",{tradeNO:e},function(n){n.resultCode=="9000",window.location.replace(location.origin+"/classroom-app/#/payment-result?orderNo="+o.orderNo),window.AlipayJSBridge.call("closeWebview")})})},h=e=>{var n,i,c,d;if(o.pay_channel=="alipay_qr")if(o.isYeePay)g(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:(i=e==null?void 0:e.expend)==null?void 0:i.qrcode_url;window.location.href=p}else if(o.pay_channel=="alipay_wap")window.location.href=(c=e==null?void 0:e.expend)==null?void 0:c.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>"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},n=>{n.err_msg=="get_brand_wcpay_request:cancel"||n.err_msg=="get_brand_wcpay_request:fail",window.location.replace(location.origin+"/classroom-app/#/payment-result?orderNo="+o.orderNo)})},x=()=>{const e=u();e?(o.code=e,l()):W(o.wxAppId)};return q(()=>{m()}),()=>r("div",{class:t.paywxresult},[o.browserStatus&&r(I,null,[r("div",{class:t.container},[r(O,{border:!1},{default:()=>[r(_,{title:"订单金额",value:"¥ "+P(o.price)},null),r(_,{title:"订单信息",value:o.body},null)]})]),r("div",{class:t["order-loading"]},[r("p",null,[o.pay_channel=="wx_pub"?"微信支付":"支付宝支付"]),r(A,{type:"spinner",color:"#01C1B5"},null)])]),!o.browserStatus&&r("div",{class:t["error-text"]},[o.errorText&&r(B,{class:t["error-icon"],name:"warning-o"},null),o.errorText])])}});export{V as default};
|