Files
AIGC/demo/deploy_baota/frontend/static/Payments-05a5ce8f.js

2 lines
10 KiB
JavaScript
Raw Normal View History

import{E as p,a as _e,c as fe,u as ye}from"./element-plus-83a396df.js";import{g as ve,c as ge,t as Pe}from"./payments-540791d2.js";import{_ as Ae,u as be}from"./index-e070bca6.js";import{r as _,l as N,c as Ce,m as he,al as u,ar as Ie,z as f,A as C,B as i,R as t,J as a,u as j,O as o,K as we,I as D,P as n,M as h,Q as xe,a4 as ke}from"./vue-vendor-164775a6.js";import"./utils-edfcd65b.js";const Le={class:"payments"},De={class:"page-header"},Ee={class:"amount"},Se={class:"description"},Ve={class:"pagination-container"},Me={key:0},Ne={class:"amount"},ze={key:0,class:"payment-description"},Te={class:"subscription-info"},Ue={class:"price"},Ye={class:"description"},$e={class:"benefits"},Fe={class:"points-info"},Be={class:"payment-method"},Ge={key:0,class:"converted-price"},Re={class:"price-display"},Oe={__name:"Payments",setup(He){const J=be(),E=_(!1),z=_([]),y=N({status:"",search:""}),c=N({page:1,size:10,total:0}),S=_(!1),d=_(null),I=_(!1),V=_(!1),T=_(""),v=_("ALIPAY"),L=_(""),U=_(7.2),r=N({title:"",price:0,description:"",benefits:[],points:0}),K=Ce(()=>T.value==="standard"?"标准版订阅":"专业版订阅"),Y=l=>({ALIPAY:"primary",PAYPAL:"success",WECHAT:"success",UNIONPAY:"warning"})[l]||"",$=l=>({ALIPAY:"支付宝",PAYPAL:"PayPal",WECHAT:"微信支付",UNIONPAY:"银联支付"})[l]||l,F=l=>({PENDING:"warning",SUCCESS:"success",FAILED:"danger",CANCELLED:"info"})[l]||"",B=l=>({PENDING:"待支付",SUCCESS:"支付成功",FAILED:"支付失败",CANCELLED:"已取消"})[l]||l,w=l=>new Date(l).toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),g=async()=>{try{E.value=!0;const l=await ve({page:c.page-1,size:c.size,status:y.status,search:y.search});l.success?(z.value=l.data,c.total=l.total||l.data.length):p.error(l.message||"获取支付记录失败")}catch(l){console.error("Fetch payments error:",l),p.error("获取支付记录失败")}finally{E.value=!1}},Q=()=>{c.page=1,g()},q=()=>{c.page=1,g()},X=()=>{y.status="",y.search="",c.page=1,g()},Z=l=>{c.size=l,c.page=1,g()},ee=l=>{c.page=l,g()},te=l=>{d.value=l,S.value=!0},G=()=>{if(v.value==="ALIPAY"){const l=(r.price*U.value).toFixed(2);L.value=`¥${l}`}else v.value==="PAYPAL"&&(L.value=`$${r.price}`)},R=l=>{if(!J.isAuthenticated){p.warning("请先登录后再订阅");return}T.value=l,l==="standard"?(r.title="标准版订阅",r.price=59,r.description="适合个人用户的基础功能订阅",r.benefits=["基础AI功能使用","每月100次API调用","邮件技术支持","基础模板库访问"],r.points=200):l==="professional"&&(r.title="专业版订阅",r.price=259,r.description="适合企业用户的高级功能订阅",r.benefits=["高级AI功能使用","每月1000次API调用","优先技术支持","完整模板库访问","API接口集成","数据分析报告"],r.points=1e3),I.value=!0,G()},ae=async()=>{try{V.value=!0;let l;v.value==="ALIPAY"?l=(r.price*U.value).toFixed(2):l=r.price.toString();const e=await ge({amount:l,method:v.value});if(e.success){if(p.success(`${r.title}支付记录创建成功`),v.value==="ALIPAY")try{const m=await createAlipayPayment({paymentId:e.data.id});m.success?(window.open(m.data.paymentUrl,"_blank"),p.success("正在跳转到支付宝支付页面")):p.error(m.message||"创建支付宝支付失败")}catch(m){console.error("创建支付宝支付失败:",m),p.error("创建支付宝支付失败")}else if(v.value==="PAYPAL")try{const m=await createPayPalPayment({paymentId:e.data.id});m.success?(window.open(m.data.paymentUrl,"_blank"),p.success("正在跳转到PayPal支付页面")):p.error(m.message||"创建PayPal支付失败")}catch(m){console.error("创建PayPal支付失败:",m),p.error("创建PayPal支付失败")}I.value=!1,g()}else p.error(e.message||"创建订阅支付记录失败")}catch(l){console.error("Create subscription error:",l),p.error("创建订阅支付记录失败")}finally{V.value=!1}},se=async l=>{try{await _e.confirm(`确定要测试完成支付 ${l.orderId} 吗?这将自动创建订单。`,"确认测试",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"});const e=a