feat(sms): 新增节点短信提醒(审核未通过/被租用需辅助/上架未成交)

This commit is contained in:
yml2213
2026-10-14 14:57:52 +08:00
parent efa0aa4ffd
commit 93e102b7c0
38 changed files with 3228 additions and 70 deletions
@@ -33,6 +33,7 @@ import {
} from '@/features/admin/api/adminDistribution'
import { formatDateTime } from '@/shared/utils/time'
import { readError } from '@/shared/utils/error'
import { smsNodeMetas } from '@/features/admin/api/smsNodeTemplates'
import {
distributionAdminBaseUrl,
distributionAdminLoginUrl,
@@ -143,6 +144,7 @@ const smsForm = reactive({
masked_secret: '',
has_secret: false,
endpoint: '',
business_templates: {} as Record<string, string>,
})
function handleOpenSettlement(row: DistributionSite) {
@@ -208,6 +210,10 @@ async function handleOpenSMS(row: DistributionSite) {
smsForm.masked_secret = cfg.masked_secret || ''
smsForm.has_secret = cfg.has_secret
smsForm.endpoint = cfg.endpoint || ''
// 逐节点初始化,未配置的节点留空表示回退主站模板。
smsForm.business_templates = Object.fromEntries(
smsNodeMetas.map(meta => [meta.code, cfg.business_templates?.[meta.code] || ''])
)
} catch (err) {
ElMessage.error(readError(err, '读取分站短信配置失败'))
} finally {
@@ -215,6 +221,15 @@ async function handleOpenSMS(row: DistributionSite) {
}
}
function trimmedBusinessTemplates() {
const out: Record<string, string> = {}
for (const meta of smsNodeMetas) {
const code = (smsForm.business_templates[meta.code] || '').trim()
if (code) out[meta.code] = code
}
return out
}
async function handleSMSSubmit() {
if (smsForm.enabled) {
if (!smsForm.sign_name.trim()) {
@@ -244,6 +259,7 @@ async function handleSMSSubmit() {
access_key_id: string
access_key_secret?: string
endpoint?: string
business_templates: Record<string, string>
} = {
enabled: smsForm.enabled,
provider: smsForm.provider || 'aliyun',
@@ -251,6 +267,7 @@ async function handleSMSSubmit() {
login_template_code: smsForm.login_template_code.trim(),
access_key_id: smsForm.access_key_id.trim(),
endpoint: smsForm.endpoint.trim(),
business_templates: trimmedBusinessTemplates(),
}
if (smsSecretInput.value.trim()) {
payload.access_key_secret = smsSecretInput.value.trim()
@@ -1082,6 +1099,14 @@ onMounted(() => {
<el-form-item label="API Endpoint">
<el-input v-model="smsForm.endpoint" placeholder="默认 dysmsapi.aliyuncs.com" />
</el-form-item>
<el-divider content-position="left">节点短信模板(可选)</el-divider>
<el-form-item v-for="meta in smsNodeMetas" :key="meta.code" :label="meta.name">
<el-input
v-model="smsForm.business_templates[meta.code]"
:placeholder="`留空则用主站模板,例如:${meta.templateCode}`"
/>
<div class="sms-node-hint">{{ meta.description }}</div>
</el-form-item>
<el-form-item label="连通性测试">
<div style="display: flex; gap: 8px; width: 100%">
<el-input v-model="smsTestPhone" placeholder="输入接收测试短信的手机号" />
@@ -1344,4 +1369,12 @@ onMounted(() => {
color: #6b7280;
font-size: 13px;
}
.sms-node-hint {
width: 100%;
margin-top: 4px;
color: #9ca3af;
font-size: 12px;
line-height: 1.5;
}
</style>