index.335b4a65.js 4.4 KB

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