1 |
- import{d as h,ah as x,r as S,$ as v,c as o,q as p,b6 as c,B as q,a5 as b,o as I,m as N,f as y,bd as u,bg as P,bQ as T}from"./index.332c7f08.js";import{C as A}from"./index.324108a5.js";import{C as l}from"./index.91135ff9.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"},O=h({name:"pay-define",setup(){const n=x(),e=S({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}),f=async()=>{var a;try{if(parseFloat(e.price)<=0){I("\u652F\u4ED8\u91D1\u989D\u5F02\u5E38");return}const r={merOrderNo:e.orderNo,paymentChannel:e.pay_channel,userId:e.userId,code:e.code};console.log(r,"payMap");const{data:i}=await N.post("/api-student/open/userOrder/executePayment",{hideLoading:!1,data:{...r}});e.isYeePay=((a=i.paymentVender)==null?void 0:a.indexOf("yeepay"))!==-1,console.log(i,"payment"),m(i.reqParams)}catch(r){console.log(r)}},m=a=>{if(e.pay_channel=="alipay_qr")if(e.isYeePay)g(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"){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",d,!1):document.attachEvent&&document.attachEvent("WeixinJSBridgeReady",d)(document).attachEvent("onWeixinJSBridgeReady",d):d()}},_=a=>{window.AlipayJSBridge?a&&a():document.addEventListener("AlipayJSBridgeReady",a,!1)},g=a=>{_(function(){window.AlipayJSBridge.call("tradePay",{tradeNO:a},function(r){r.resultCode=="9000",window.location.replace(location.origin+"/orchestra-student/#/payment-result?orderNo="+e.orderNo),window.AlipayJSBridge.call("closeWebview")})})},d=()=>{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(location.origin+"/orchestra-student/#/payment-result?orderNo="+e.orderNo)})},w=()=>{var i;const a=((i=e.paymentType)==null?void 0:i.indexOf("yeepay"))!==-1;console.log(a,"isYeePay");const r=e.pay_channel;if(y().weixin)if(r==="wx_pub"){const s=u();s?e.code=s:P(e.wxAppId),e.browserStatus=!0,document.title="\u5FAE\u4FE1\u652F\u4ED8"}else r=="alipay_qr"&&(e.errorText="\u8BF7\u4F7F\u7528\u652F\u4ED8\u5B9D\u626B\u7801");else if(y().alipay){if(r==="wx_pub")e.errorText="\u8BF7\u4F7F\u7528\u5FAE\u4FE1\u626B\u7801";else if(r=="alipay_qr"){if(a){const s=u("auth_code")||n.query.auth_code;s?e.code=s:T(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 v(()=>{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(q,{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{O as default};
|