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