import{f as e,p as n,t as r}from"./index-9ce39810.js";import{e as i}from"./apiManager.70733ad9.js";function t(e,n){let r=function(){WeixinJSBridge.invoke("getBrandWCPayRequest",JSON.parse(e.payInfo),(function(r){c(e.payOrderId,r),"get_brand_wcpay_request:ok"==r.err_msg&&(n.returnUrl?location.href=n.returnUrl:(alert("支付成功！"),window.WeixinJSBridge.call("closeWindow"))),"get_brand_wcpay_request:cancel"==r.err_msg&&(alert("支付取消"),window.WeixinJSBridge.call("closeWindow")),"get_brand_wcpay_request:fail"==r.err_msg&&(alert("支付失败:"+JSON.stringify(r)),window.WeixinJSBridge.call("closeWindow")),"total_fee"==r.err_msg&&(alert("缺少参数"),window.WeixinJSBridge.call("closeWindow"))}))};"undefined"==typeof WeixinJSBridge?document.addEventListener?document.addEventListener("WeixinJSBridgeReady",r,!1):document.attachEvent&&(document.attachEvent("WeixinJSBridgeReady",r),document.attachEvent("onWeixinJSBridgeReady",r)):r()}function a(e){let n=function(){AlipayJSBridge.call("tradePay",{tradeNO:e.alipayTradeNo},(function(n){c(e.payOrderId,n),"9000"==n.resultCode?e.returnUrl?location.href=e.returnUrl:(alert("支付成功！"),window.AlipayJSBridge.call("closeWebview")):"8000"==n.resultCode||"6004"==n.resultCode?(alert(JSON.stringify(n)),window.AlipayJSBridge.call("closeWebview")):(alert("用户已取消！"),window.AlipayJSBridge.call("closeWebview"))}))};window.AlipayJSBridge?n():document.addEventListener("AlipayJSBridgeReady",n,!1)}function o(e,i){const t=JSON.parse(e.payInfo);wx.requestPayment({timeStamp:t.timeStamp,nonceStr:t.nonceStr,package:t.package,signType:t.signType,paySign:t.paySign,success:function(e){if(i.fun)return i.fun();n({url:"/pages/paySuccess/paySuccess?amount="+i.amount})},fail:function(e){"requestPayment:fail cancel"==e.errMsg?r("取消支付"):r(e.errMsg)},complete:n=>{c(e.payOrderId,n)}})}function d(e,i){my.tradePay({tradeNO:e.alipayTradeNo,success:e=>{if(9e3==e.resultCode){if(i.fun)return i.fun();n({url:"/pages/paySuccess/paySuccess?amount="+i.amount})}else 6001==e.resultCode?r("取消支付"):4e3==e.resultCode?r("订单处理失败"):4==e.resultCode?r("无权限调用"):r(JSON.stringify(e))},fail:e=>{r(JSON.stringify(e))},complete:n=>{c(e.payOrderId,n)}})}function l(e){window.location.href=e.redirectUrl}function c(e,n){i(e,n)}const s=()=>{let n={};return n[e.PAGE_TYPE_ENUM.WECHAT_H5]=t,n[e.PAGE_TYPE_ENUM.ALIPAY_H5]=a,n[e.PAGE_TYPE_ENUM.WECHAT_LITE]=o,n[e.PAGE_TYPE_ENUM.ALIPAY_LITE]=d,n[e.PAGE_TYPE_ENUM.YSFPAY_H5]=l,n};export{s as p};
