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