import{aG as a,b3 as e,u as i,ai as n}from"./index-90c12cc1.js";import{u as t}from"./useInterface.bd4f041a.js";import{w as r}from"./order.190c4706.js";import{C as o}from"./config.6730da78.js";const{loading:p,hideLoading:s}=t(),{push:c}=i(),y="h5",m="weixin_applet",d="weixin_app",f="weixin_h5",u="weixin",w="weixin_applet",g="weixin_app",I="yue",S={0:"wechat",1:"yue",2:"alipay"},l="app",P="miniProgram",h="h5InWechat",x="h5OutWechat";async function j(i){try{return p({title:"支付中..."}),await async function(i){const{type:t,payInfo:r,isGroup:p}=i;let s;if(t===S[0])switch(function(){let a;return a=n()?h:x,a}()){case l:s=await function(i){return new Promise((async(n,t)=>{const r={from:d,payType:g,orderId:i.payInfo.orderId},p=await _(r);a(o.PAY_INFO,JSON.stringify({payData:r,options:i}));const s={appid:p.appId,prepayid:p.merchant_id,timestamp:p.timeStamp,sign:p.paySign,partnerid:p.out_trade_no,noncestr:p.nonceStr,package:"Sign=WXPay"};uni.requestPayment({provider:"wxpay",orderInfo:s,success:a=>n(e("用户支付成功",a)),fail:a=>t(e("用户支付失败",a))})}))}(i);break;case P:s=await async function(i){return await new Promise((async(n,t)=>{const r={from:m,payType:w,orderId:i.payInfo.orderId},p=await _(r);a(o.PAY_INFO,JSON.stringify({payData:r,options:i})),uni.requestPayment({timeStamp:p.timeStamp,nonceStr:p.nonceStr,signType:p.signType,paySign:p.paySign,package:p.package,provider:"wxpay",success:a=>n(e("用户支付成功",a)),fail:a=>t(e("用户支付失败",a))})}))}(i);break;case h:s=await async function(i){return new Promise((async(n,t)=>{const r={from:y,payType:u,orderId:i.payInfo.orderId},p=await _(r);jweixin.config({debug:!1,appId:p.appId,timestamp:p.timeStamp,nonceStr:p.nonceStr,signature:p.paySign,jsApiList:["chooseWXPay"]}),jweixin.ready((()=>{jweixin.checkJsApi({jsApiList:["chooseWXPay"],success:()=>{a(o.PAY_INFO,JSON.stringify({payData:r,options:i})),jweixin.chooseWXPay({timestamp:p.timeStamp,nonceStr:p.nonceStr,package:p.package,signType:p.signType,paySign:p.paySign,success:a=>n(e("用户支付成功",a)),cancel:a=>t(e("用户取消支付",{})),fail:a=>t(e("跳转微信支付失败",a))})},fail:a=>t(e("微信版本过低，请升级微信版本",a))})})),jweixin.error((a=>t(e("JS-SDK加载错误",a))))}))}(i);break;case x:s=await async function(i){const n={from:y,payType:f,orderId:i.payInfo.orderId},t=await _(n);return t&&t.mwebUrl?(a(o.PAY_INFO,JSON.stringify({payData:n,options:i})),location.replace(t.mwebUrl),Promise.resolve(e("拉起支付成功",{type:"h5"}))):Promise.reject(e("服务端拉起支付失败",{type:"h5",error:t}))}(i)}t===S[1]&&(s=await async function(e){let i;i=y;const n={from:i,payType:I,orderId:e.payInfo.orderId},t=await _(n);return a(o.PAY_INFO,JSON.stringify({payData:n,options:e})),c({url:"/pages/payStatus/index"},{type:"redirectTo"}),t}(i));t===S[2]&&(s=await Promise.reject("暂不支持支付宝支付"));return s}(i)}finally{s()}}async function _(a){return await r(a)}export{S as P,j as d};
