import{d as h,P as S,S as v,V as P,j as r,A as c,bC as y,B as b,N as I,T,y as q,g as l,f as u,bS as f,bT as B,bU as N}from"./ResizeObserver.es.b7226882.js";import{C as p}from"./index.40f703b6.js";import{C as A}from"./index.9269bf1e.js";const C="_paydefine_gyhp9_1",J="_amount_gyhp9_16";var t={paydefine:C,amount:J,"error-text":"_error-text_gyhp9_27","error-icon":"_error-icon_gyhp9_34"},k=h({name:"pay-define",setup(){const n=S(),e=v({browserStatus:!1,errorText:"",code:null,pay_channel:n.query.pay_channel,wxAppId:n.query.wxAppId,paymentType:n.query.paymentType,alipayAppId:n.query.alipayAppId,body:n.query.body,price:n.query.price,orderNo:n.query.orderNo,userId:n.query.userId,payInfo:{},isYeePay:!1}),m=async()=>{try{if(parseFloat(e.price)<=0){T("\u652F\u4ED8\u91D1\u989D\u5F02\u5E38");return}const a={merOrderNo:e.orderNo,paymentChannel:e.pay_channel,userId:e.userId,code:e.code},{data:o}=await q.post("/api-student/open/userOrder/executePayment/v2",{hideLoading:!1,data:{...a}});console.log(o,"paymentVender"),_(o.reqParams)}catch(a){console.log(a)}},_=a=>{if(e.pay_channel=="alipay_qr")if(e.isYeePay)w(a.prePayTn);else{const o=a.prod_mode==="false"?a.expend.qrcode_url+"?payment_id="+a.id+"&pay_channel="+a.pay_channel:a.expend.qrcode_url;window.location.href=o}else if(e.pay_channel=="wx_pub"){console.log(e.isYeePay,a==null?void 0:a.expend,"payInfo");const o=e.isYeePay?JSON.parse(a.prePayTn):JSON.parse(a.expend.pay_info);e.payInfo=o,typeof window.WeixinJSBridge=="undefined"?document.addEventListener?document.addEventListener("WeixinJSBridgeReady",s,!1):document.attachEvent&&document.attachEvent("WeixinJSBridgeReady",s)(document).attachEvent("onWeixinJSBridgeReady",s):s()}},g=a=>{window.AlipayJSBridge?a&&a():document.addEventListener("AlipayJSBridgeReady",a,!1)},w=a=>{g(function(){window.AlipayJSBridge.call("tradePay",{tradeNO:a},function(o){o.resultCode=="9000"?window.location.replace(location.origin+ +l.payBackPath+"#/tradeDetail?orderNo="+e.orderNo):window.location.replace(location.origin+ +l.payBackPath+"#/tradeDetail?orderNo="+e.orderNo),window.AlipayJSBridge.call("closeWebview")})})},s=()=>{const a=e.payInfo;window.WeixinJSBridge.invoke("getBrandWCPayRequest",{appId:a.appId,timeStamp:a.timeStamp,nonceStr:a.nonceStr,package:a.package,signType:a.signType,paySign:a.paySign},o=>{o.err_msg=="get_brand_wcpay_request:cancel"||o.err_msg=="get_brand_wcpay_request:fail"?window.location.replace(location.origin+l.payBackPath+"#/tradeDetail?orderNo="+e.orderNo):window.location.replace(location.origin+l.payBackPath+"#/tradeDetail?orderNo="+e.orderNo)})},x=()=>{var d;const a=e.pay_channel,o=e.paymentType?((d=e.paymentType)==null?void 0:d.indexOf("yeepay"))!==-1:!1;if(e.isYeePay=o,u().weixin)if(a==="wx_pub"){const i=f();i?e.code=i:B(e.wxAppId),e.browserStatus=!0,document.title="\u5FAE\u4FE1\u652F\u4ED8"}else a=="alipay_qr"&&(e.errorText="\u8BF7\u4F7F\u7528\u652F\u4ED8\u5B9D\u626B\u7801");else if(u().alipay){if(a==="wx_pub")e.errorText="\u8BF7\u4F7F\u7528\u5FAE\u4FE1\u626B\u7801";else if(a=="alipay_qr"){if(o){const i=f("auth_code");i?e.code=i:N(e.alipayAppId)}e.browserStatus=!0,document.title="\u652F\u4ED8\u5B9D\u652F\u4ED8"}}else e.errorText="\u8BF7\u5728\u5FAE\u4FE1\u6216\u652F\u4ED8\u5B9D\u5BA2\u6237\u7AEF\u6253\u5F00";e.errorText&&(document.title="ERROR")};return P(()=>{console.log(e),x()}),()=>r("div",{class:t.paydefine},[e.browserStatus&&r("div",{class:t.container},[r("div",{class:t.amount},[r("span",null,[c("\uFFE5 ")]),y(e.price)]),r(A,{inset:!0},{default:()=>[r(p,{title:"\u8BA2\u5355\u4FE1\u606F",value:e.body,valueClass:t.values},null),r(p,{title:"\u652F\u4ED8\u65B9\u5F0F",value:e.pay_channel==="wx_pub"?"\u5FAE\u4FE1":"\u652F\u4ED8\u5B9D"},null),r(p,{title:"\u5B9E\u4ED8\u91D1\u989D",value:`\uFFE5 ${y(e.price)}\u5143`},null)]}),r(b,{type:"primary",block:!0,size:"large",onClick:m,round:!0},{default:()=>[c("\u7ACB\u5373\u652F\u4ED8")]})]),!e.browserStatus&&r("div",{class:t.container},[r("div",{class:t["error-text"]},[e.errorText&&r(I,{class:t["error-icon"],name:"warning-o"},null),e.errorText])])])}});export{k as default};