
/**
 * 由 Fantastic-admin 提供技术支持
 * Powered by Fantastic-admin
 * https://fantastic-admin.github.io
 */

import{_ as B}from"./index.vue_vue_type_script_setup_true_lang-BTce45WY.js";import{d as D,m as O,r as _,a as j,p as o,g as M,c as g,b as e,w as a,h as b,F as L,s as $,e as s,G as x,j as E,_ as F,t as H,k as V}from"./index-nGFMSQGw.js";import{a as U}from"./config-CYXO1pNF.js";const J=s("div",{class:"flex items-center gap-4"},"码支付设置",-1),z=s("div",{class:"text-sm/6"},[s("div",null,"支付通知地址为： https://您的域名/api/pay/notify。")],-1),G=D({__name:"mpay",setup(K){const t=O({payMpayStatus:"",payMpayPid:"",payMpaySecret:"",payMpayNotifyUrl:"",payMpayReturnUrl:"",payMpayApiPayUrl:"",payMpayRedirect:"",payMpayChannel:[]}),C=_({payMpayStatus:[{required:!0,trigger:"change",message:"请选择当前支付开启状态"}],payMpaySecret:[{required:!0,trigger:"blur",message:"请填写支付秘钥"}],payMpayPid:[{required:!0,trigger:"blur",message:"请填写商户PID"}],payMpayNotifyUrl:[{required:!0,trigger:"blur",message:"请填写支付通知地址"}],payMpayApiPayUrl:[{required:!0,trigger:"blur",message:"请填写平台支付API请求地址"}]}),i=_(),P=[{label:"微信支付",value:"wxpay"},{label:"支付宝支付",value:"alipay"}];async function c(){const n=await U.queryConfig({keys:["payMpaySecret","payMpayNotifyUrl","payMpayReturnUrl","payMpayPid","payMpayStatus","payMpayApiPayUrl","payMpayRedirect","payMpayChannel"]}),l=n.data.payMpayChannel?JSON.parse(n.data.payMpayChannel):[];Object.assign(t,n.data,{payMpayChannel:l})}function S(){var n;(n=i.value)==null||n.validate(async l=>{if(l){try{await U.setConfig({settings:v(t)}),x.success("变更配置信息成功")}catch{}c()}else x.error("请填写完整信息")})}function h(n,l){if(["payMpayChannel"].includes(n)){if(!l)return[];if(l)return JSON.stringify(l)}else return l}function v(n){return Object.keys(n).map(l=>({configKey:l,configVal:h(l,n[l])}))}return j(()=>{c()}),(n,l)=>{const m=E,k=F,w=B,N=o("el-switch"),r=o("el-form-item"),u=o("el-col"),y=o("el-row"),d=o("el-input"),f=o("el-divider"),A=o("el-checkbox"),R=o("el-checkbox-group"),q=o("el-form"),I=o("el-card");return M(),g("div",null,[e(w,null,{title:a(()=>[J]),content:a(()=>[z]),default:a(()=>[e(k,{outline:"",onClick:S},{default:a(()=>[e(m,{name:"i-ri:file-text-line"}),b(" 保存设置 ")]),_:1})]),_:1}),e(I,{style:{margin:"20px"}},{default:a(()=>[e(q,{ref_key:"formRef",ref:i,rules:C.value,model:t,"label-width":"120px"},{default:a(()=>[e(y,null,{default:a(()=>[e(u,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(r,{label:"启用当前支付",prop:"payMpayPid"},{default:a(()=>[e(N,{modelValue:t.payMpayStatus,"onUpdate:modelValue":l[0]||(l[0]=p=>t.payMpayStatus=p),"active-value":"1","inactive-value":"0"},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(y,null,{default:a(()=>[e(u,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(r,{label:"商户PID",prop:"payMpayPid"},{default:a(()=>[e(d,{modelValue:t.payMpayPid,"onUpdate:modelValue":l[1]||(l[1]=p=>t.payMpayPid=p),placeholder:"请填写商户PID",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(y,null,{default:a(()=>[e(u,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(r,{label:"商户秘钥",prop:"payMpaySecret"},{default:a(()=>[e(d,{modelValue:t.payMpaySecret,"onUpdate:modelValue":l[2]||(l[2]=p=>t.payMpaySecret=p),placeholder:"请填写商户秘钥",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(y,null,{default:a(()=>[e(u,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(r,{label:"支付通知地址",prop:"payMpaySecret"},{default:a(()=>[e(d,{modelValue:t.payMpayNotifyUrl,"onUpdate:modelValue":l[3]||(l[3]=p=>t.payMpayNotifyUrl=p),placeholder:"请填写支付通知地址",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(y,null,{default:a(()=>[e(u,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(r,{label:"支付回调地址",prop:"payMpaySecret"},{default:a(()=>[e(d,{modelValue:t.payMpayReturnUrl,"onUpdate:modelValue":l[4]||(l[4]=p=>t.payMpayReturnUrl=p),placeholder:"请填写支付成功后的回跳地址",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(f),e(y,null,{default:a(()=>[e(u,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(r,{label:"支付请求地址",prop:"payMpayApiPayUrl"},{default:a(()=>[e(d,{modelValue:t.payMpayApiPayUrl,"onUpdate:modelValue":l[5]||(l[5]=p=>t.payMpayApiPayUrl=p),placeholder:"请填写平台支付请求地址",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(f),e(y,null,{default:a(()=>[e(u,{xs:24,md:24,lg:24,xl:24},{default:a(()=>[e(r,{label:"开启支付渠道",prop:"payMpayChannel"},{default:a(()=>[e(R,{modelValue:t.payMpayChannel,"onUpdate:modelValue":l[6]||(l[6]=p=>t.payMpayChannel=p),size:"small"},{default:a(()=>[(M(),g(L,null,$(P,p=>e(A,{key:p.value,border:"",label:p.value},{default:a(()=>[b(H(p.label),1)]),_:2},1032,["label"])),64))]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1},8,["rules","model"])]),_:1})])}}});typeof V=="function"&&V(G);export{G as default};
