weizong song 7 days ago
parent 40411e614c
commit 923bd94b7d

@ -96,6 +96,8 @@ export interface CompetitionTrackPayload {
}
export type SignupChannelStatus = 'enabled' | 'disabled'
export type SignupChannelCallbackType = 'none' | 'web' | 'mini_program'
export type SignupChannelMiniProgramMethod = 'navigateTo' | 'redirectTo' | 'reLaunch'
/** 赛事报名渠道配置channel_code 由后端创建时自动生成 */
export interface SignupChannelRow {
@ -113,6 +115,9 @@ export interface SignupChannelRow {
encryption_algorithm?: string | null
entry_encryption_enabled: boolean
success_callback_url: string
success_callback_type: SignupChannelCallbackType
mini_program_callback_path: string | null
mini_program_callback_method: SignupChannelMiniProgramMethod
remark: string | null
created_at?: string
updated_at?: string
@ -124,6 +129,9 @@ export interface SignupChannelPayload {
shared_secret: string
entry_encryption_enabled: boolean
success_callback_url: string
success_callback_type: SignupChannelCallbackType
mini_program_callback_path: string | null
mini_program_callback_method: SignupChannelMiniProgramMethod
remark: string | null
}

@ -110,6 +110,9 @@ const channelForm = ref<SignupChannelPayload>({
shared_secret: '',
entry_encryption_enabled: false,
success_callback_url: '',
success_callback_type: 'web',
mini_program_callback_path: null,
mini_program_callback_method: 'redirectTo',
remark: null,
})
@ -632,7 +635,10 @@ async function openChannelModal(row?: SignupChannelRow) {
status: detail.status,
shared_secret: detail.shared_secret ?? '',
entry_encryption_enabled: detail.entry_encryption_enabled ?? false,
success_callback_url: detail.success_callback_url,
success_callback_url: detail.success_callback_url ?? '',
success_callback_type: detail.success_callback_type ?? 'web',
mini_program_callback_path: detail.mini_program_callback_path ?? null,
mini_program_callback_method: detail.mini_program_callback_method ?? 'redirectTo',
remark: detail.remark,
}
: {
@ -641,6 +647,9 @@ async function openChannelModal(row?: SignupChannelRow) {
shared_secret: '',
entry_encryption_enabled: false,
success_callback_url: '',
success_callback_type: 'web',
mini_program_callback_path: null,
mini_program_callback_method: 'redirectTo',
remark: null,
}
channelDialogVisible.value = true
@ -670,6 +679,18 @@ function generateChannelSecret() {
.replace(/=+$/g, '')
}
function channelCallbackTypeLabel(type: SignupChannelRow['success_callback_type']): string {
if (type === 'mini_program') return '小程序'
if (type === 'none') return '不回调'
return 'URL'
}
function channelCallbackTarget(row: SignupChannelRow): string {
if (row.success_callback_type === 'mini_program') return row.mini_program_callback_path || '—'
if (row.success_callback_type === 'none') return '—'
return row.success_callback_url || '—'
}
async function saveChannel() {
const cid = competitionId.value
if (!cid) return
@ -679,12 +700,23 @@ async function saveChannel() {
shared_secret: channelForm.value.shared_secret.trim(),
entry_encryption_enabled: channelForm.value.entry_encryption_enabled,
success_callback_url: channelForm.value.success_callback_url.trim(),
success_callback_type: channelForm.value.success_callback_type,
mini_program_callback_path: channelForm.value.mini_program_callback_path?.trim() || null,
mini_program_callback_method: channelForm.value.mini_program_callback_method,
remark: channelForm.value.remark?.trim() || null,
}
if (!payload.channel_name || !payload.shared_secret) {
ElMessage.warning('请填写渠道名称与共享密钥')
return
}
if (payload.success_callback_type === 'web' && !payload.success_callback_url) {
ElMessage.warning('请填写 URL 回跳地址,或选择不回调')
return
}
if (payload.success_callback_type === 'mini_program' && !payload.mini_program_callback_path) {
ElMessage.warning('请填写小程序页面路径')
return
}
channelSaving.value = true
try {
if (channelEditingId.value) {
@ -1146,7 +1178,16 @@ onMounted(() => {
</el-tag>
</template>
</el-table-column>
<el-table-column prop="success_callback_url" label="成功回跳地址" min-width="240" show-overflow-tooltip />
<el-table-column label="回调类型" width="96">
<template #default="{ row }">
{{ channelCallbackTypeLabel(row.success_callback_type) }}
</template>
</el-table-column>
<el-table-column label="回调目标" min-width="240" show-overflow-tooltip>
<template #default="{ row }">
<span class="cell-muted">{{ channelCallbackTarget(row) }}</span>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" min-width="150" show-overflow-tooltip>
<template #default="{ row }">
<span class="cell-muted">{{ row.remark || '—' }}</span>
@ -1496,8 +1537,39 @@ onMounted(() => {
</el-button>
</el-form-item>
</template>
<el-form-item label="成功回跳地址">
<el-input v-model="channelForm.success_callback_url" autocomplete="off" placeholder="可留空;填写时请输入 https://example.com/..." />
<el-form-item label="报名成功回调">
<el-radio-group v-model="channelForm.success_callback_type">
<el-radio-button value="none">不回调</el-radio-button>
<el-radio-button value="web">URL</el-radio-button>
<el-radio-button value="mini_program">小程序</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item v-if="channelForm.success_callback_type === 'web'" label="成功回跳地址">
<el-input
v-model="channelForm.success_callback_url"
autocomplete="off"
placeholder="https://example.com/..."
/>
</el-form-item>
<template v-if="channelForm.success_callback_type === 'mini_program'">
<el-form-item label="小程序页面路径">
<el-input
v-model="channelForm.mini_program_callback_path"
autocomplete="off"
placeholder="/pages/signup/result"
/>
<p class="form-hint">可带查询参数系统会追加 stateapplication_idstatushash 等回调参数</p>
</el-form-item>
<el-form-item label="小程序路由方式">
<el-select v-model="channelForm.mini_program_callback_method" class="w-100">
<el-option label="redirectTo替换当前页面" value="redirectTo" />
<el-option label="navigateTo打开新页面" value="navigateTo" />
<el-option label="reLaunch重启到指定页" value="reLaunch" />
</el-select>
</el-form-item>
</template>
<el-form-item v-if="channelForm.success_callback_type === 'none'" label="回调说明">
<p class="form-hint mb-0">选择不回调时选手提交成功后只展示系统报名成功提示</p>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="channelForm.remark" type="textarea" :rows="3" />

Loading…
Cancel
Save