mi-assessment/server/MiAssessment/src/MiAssessment.Admin/wwwroot/assets/payment-BRdHZQ45.js
2026-02-23 22:27:47 +08:00

2 lines
8.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{d as $,a as G,o as L,g as p,B as R,c as f,k as m,e,C as T,w as l,b as i,z as E,G as b,F as k,y as q,t as u,x as w,l as I,I as F,D as S,E as y,Z as W,_ as Z}from"./index-CcDqJDLV.js";import{a as j,b as H}from"./config-DFcXqecy.js";const J={class:"payment-config-container"},O={class:"card-header"},Q={class:"item-header"},X={class:"item-title"},ee={class:"item-actions"},le={key:1,class:"form-actions"},ae=$({__name:"payment",setup(te){const n=G({loading:!1,saving:!1,formData:{merchants:[]}});async function U(){n.loading=!0;try{const d=await j();d.code===0&&d.data&&(n.formData=d.data,n.formData.merchants||(n.formData.merchants=[]))}catch(d){console.error("加载支付配置失败:",d),y.error("加载配置失败")}finally{n.loading=!1}}function P(){n.formData.merchants.push({name:"",mch_id:"",order_prefix:"",pay_version:"V3",api_v3_key:"",cert_serial_no:"",private_key_path:"",private_key_content:"",wechat_public_key_id:"",wechat_public_key_path:"",wechat_public_key_content:"",api_key:"",cert_path:"",is_enabled:"1"})}async function x(d){const a=n.formData.merchants[d];await W.confirm(`确定删除商户「${a.name||"未命名"}」吗?`,"提示",{type:"warning"}),n.formData.merchants.splice(d,1)}function h(d){d.is_enabled=d.is_enabled==="1"?"0":"1"}async function B(){var d;for(const a of n.formData.merchants)if(!((d=a.mch_id)!=null&&d.trim())){y.warning("请填写所有商户的商户号");return}n.saving=!0;try{const a=await H(n.formData);a.code===0?y.success("保存成功"):y.error(a.message||"保存失败")}catch(a){console.error("保存支付配置失败:",a),y.error("保存失败")}finally{n.saving=!1}}function N(){U()}return L(()=>{U()}),(d,a)=>{const D=p("el-card"),c=p("el-button"),A=p("el-empty"),M=p("el-tag"),r=p("el-input"),s=p("el-form-item"),_=p("el-col"),V=p("el-row"),C=p("el-radio"),z=p("el-radio-group"),g=p("el-divider"),K=p("el-form"),Y=R("loading");return m(),f("div",J,[e(D,{class:"page-header"},{default:l(()=>[...a[0]||(a[0]=[i("div",{class:"header-content"},[i("h2",{class:"page-title"},"微信支付配置"),i("span",{class:"page-description"},"配置微信支付商户信息支持V2和V3版本")],-1)])]),_:1}),T((m(),E(D,{class:"config-form-card"},{header:l(()=>[i("div",O,[a[2]||(a[2]=i("span",null,"商户列表",-1)),e(c,{type:"primary",icon:I(S),onClick:P},{default:l(()=>[...a[1]||(a[1]=[u("添加商户",-1)])]),_:1},8,["icon"])])]),default:l(()=>[n.formData.merchants.length===0?(m(),E(A,{key:0,description:"暂无支付商户配置,请点击上方按钮添加"})):b("",!0),(m(!0),f(k,null,q(n.formData.merchants,(t,v)=>(m(),f("div",{key:v,class:"merchant-item"},[i("div",Q,[i("span",X,[e(M,{type:t.is_enabled==="1"?"success":"info",size:"small"},{default:l(()=>[u(w(t.is_enabled==="1"?"启用":"禁用"),1)]),_:2},1032,["type"]),u(" "+w(t.name||`商户 ${v+1}`),1)]),i("div",ee,[e(c,{type:t.is_enabled==="1"?"warning":"success",link:"",size:"small",onClick:o=>h(t)},{default:l(()=>[u(w(t.is_enabled==="1"?"禁用":"启用"),1)]),_:2},1032,["type","onClick"]),e(c,{type:"danger",link:"",size:"small",icon:I(F),onClick:o=>x(v)},{default:l(()=>[...a[3]||(a[3]=[u("删除",-1)])]),_:1},8,["icon","onClick"])])]),e(K,{"label-width":"160px","label-position":"right"},{default:l(()=>[e(V,{gutter:20},{default:l(()=>[e(_,{span:12},{default:l(()=>[e(s,{label:"商户名称",required:""},{default:l(()=>[e(r,{modelValue:t.name,"onUpdate:modelValue":o=>t.name=o,placeholder:"请输入商户名称",clearable:""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024),e(_,{span:12},{default:l(()=>[e(s,{label:"商户号",required:""},{default:l(()=>[e(r,{modelValue:t.mch_id,"onUpdate:modelValue":o=>t.mch_id=o,placeholder:"请输入微信支付商户号",clearable:""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024)]),_:2},1024),e(V,{gutter:20},{default:l(()=>[e(_,{span:12},{default:l(()=>[e(s,{label:"订单前缀"},{default:l(()=>[e(r,{modelValue:t.order_prefix,"onUpdate:modelValue":o=>t.order_prefix=o,placeholder:"3位字符",maxlength:"3",clearable:""},null,8,["modelValue","onUpdate:modelValue"]),a[4]||(a[4]=i("div",{class:"form-item-tip"},"用于区分不同商户的订单必须3位",-1))]),_:2},1024)]),_:2},1024),e(_,{span:12},{default:l(()=>[e(s,{label:"支付版本"},{default:l(()=>[e(z,{modelValue:t.pay_version,"onUpdate:modelValue":o=>t.pay_version=o},{default:l(()=>[e(C,{value:"V3"},{default:l(()=>[...a[5]||(a[5]=[u("V3推荐",-1)])]),_:1}),e(C,{value:"V2"},{default:l(()=>[...a[6]||(a[6]=[u("V2",-1)])]),_:1})]),_:1},8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024)]),_:2},1024),t.pay_version==="V3"?(m(),f(k,{key:0},[e(g,{"content-position":"left"},{default:l(()=>[...a[7]||(a[7]=[u("V3 支付配置",-1)])]),_:1}),e(V,{gutter:20},{default:l(()=>[e(_,{span:12},{default:l(()=>[e(s,{label:"APIv3密钥"},{default:l(()=>[e(r,{modelValue:t.api_v3_key,"onUpdate:modelValue":o=>t.api_v3_key=o,placeholder:"32位APIv3密钥",type:"password","show-password":"",clearable:""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024),e(_,{span:12},{default:l(()=>[e(s,{label:"证书序列号"},{default:l(()=>[e(r,{modelValue:t.cert_serial_no,"onUpdate:modelValue":o=>t.cert_serial_no=o,placeholder:"商户API证书序列号",clearable:""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024)]),_:2},1024),e(V,{gutter:20},{default:l(()=>[e(_,{span:12},{default:l(()=>[e(s,{label:"微信支付公钥ID"},{default:l(()=>[e(r,{modelValue:t.wechat_public_key_id,"onUpdate:modelValue":o=>t.wechat_public_key_id=o,placeholder:"微信支付公钥ID",clearable:""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024)]),_:2},1024),e(g,{"content-position":"left"},{default:l(()=>[...a[8]||(a[8]=[u("证书配置(二选一:粘贴内容 或 填写服务器路径)",-1)])]),_:1}),e(s,{label:"商户私钥内容"},{default:l(()=>[e(r,{modelValue:t.private_key_content,"onUpdate:modelValue":o=>t.private_key_content=o,type:"textarea",rows:4,placeholder:"粘贴 apiclient_key.pem 文件内容(-----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----"},null,8,["modelValue","onUpdate:modelValue"]),a[9]||(a[9]=i("div",{class:"form-item-tip"},"推荐方式直接粘贴PEM文件内容迁移服务器无需重新上传证书文件",-1))]),_:2},1024),e(s,{label:"商户私钥路径"},{default:l(()=>[e(r,{modelValue:t.private_key_path,"onUpdate:modelValue":o=>t.private_key_path=o,placeholder:"备选apiclient_key.pem 服务器文件路径",clearable:""},null,8,["modelValue","onUpdate:modelValue"]),a[10]||(a[10]=i("div",{class:"form-item-tip"},"仅当未填写私钥内容时使用",-1))]),_:2},1024),e(s,{label:"微信支付公钥内容"},{default:l(()=>[e(r,{modelValue:t.wechat_public_key_content,"onUpdate:modelValue":o=>t.wechat_public_key_content=o,type:"textarea",rows:4,placeholder:"粘贴 pub_key.pem 文件内容(-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----"},null,8,["modelValue","onUpdate:modelValue"]),a[11]||(a[11]=i("div",{class:"form-item-tip"},"推荐方式直接粘贴PEM文件内容",-1))]),_:2},1024),e(s,{label:"微信支付公钥路径"},{default:l(()=>[e(r,{modelValue:t.wechat_public_key_path,"onUpdate:modelValue":o=>t.wechat_public_key_path=o,placeholder:"备选pub_key.pem 服务器文件路径",clearable:""},null,8,["modelValue","onUpdate:modelValue"]),a[12]||(a[12]=i("div",{class:"form-item-tip"},"仅当未填写公钥内容时使用",-1))]),_:2},1024)],64)):b("",!0),t.pay_version==="V2"?(m(),f(k,{key:1},[e(g,{"content-position":"left"},{default:l(()=>[...a[13]||(a[13]=[u("V2 支付配置",-1)])]),_:1}),e(V,{gutter:20},{default:l(()=>[e(_,{span:12},{default:l(()=>[e(s,{label:"API密钥"},{default:l(()=>[e(r,{modelValue:t.api_key,"onUpdate:modelValue":o=>t.api_key=o,placeholder:"微信支付API密钥",type:"password","show-password":"",clearable:""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024),e(_,{span:12},{default:l(()=>[e(s,{label:"证书路径"},{default:l(()=>[e(r,{modelValue:t.cert_path,"onUpdate:modelValue":o=>t.cert_path=o,placeholder:"apiclient_cert.p12 文件路径",clearable:""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024)]),_:2},1024)],64)):b("",!0)]),_:2},1024)]))),128)),n.formData.merchants.length>0?(m(),f("div",le,[e(c,{type:"primary",loading:n.saving,onClick:B},{default:l(()=>[...a[14]||(a[14]=[u("保存配置",-1)])]),_:1},8,["loading"]),e(c,{onClick:N},{default:l(()=>[...a[15]||(a[15]=[u("重置",-1)])]),_:1})])):b("",!0)]),_:1})),[[Y,n.loading]])])}}}),de=Z(ae,[["__scopeId","data-v-6513f827"]]);export{de as default};