增加vip

This commit is contained in:
zhx 2026-05-16 02:26:12 +08:00
parent 10eba5fa86
commit 5102e086aa
2 changed files with 45 additions and 7 deletions

View File

@ -24,6 +24,7 @@ import {
} from '#/api/legacy/props'; } from '#/api/legacy/props';
import { import {
BADGE_DISPLAY_TYPE_OPTIONS,
BADGE_TYPE_OPTIONS, BADGE_TYPE_OPTIONS,
NOBLE_VIP_OPTIONS, NOBLE_VIP_OPTIONS,
PROPS_RESOURCE_CONFIG_TYPES, PROPS_RESOURCE_CONFIG_TYPES,
@ -54,6 +55,7 @@ const notSelectInputRef = ref<HTMLInputElement>();
const form = reactive<Record<string, any>>({ const form = reactive<Record<string, any>>({
adminFree: false, adminFree: false,
amount: '', amount: '',
badgeDisplayType: 'SHORT',
badgeKey: '', badgeKey: '',
badgeLevel: '', badgeLevel: '',
badgeType: 'ACTIVITY', badgeType: 'ACTIVITY',
@ -107,6 +109,10 @@ const badgeTypeOptions = BADGE_TYPE_OPTIONS.filter((item) =>
label: item.name, label: item.name,
value: item.value as any, value: item.value as any,
})); }));
const badgeDisplayTypeOptions = BADGE_DISPLAY_TYPE_OPTIONS.map((item) => ({
label: item.name,
value: item.value as any,
}));
function parseBadgeExpand(value: unknown) { function parseBadgeExpand(value: unknown) {
if (!value || typeof value !== 'string') { if (!value || typeof value !== 'string') {
@ -124,12 +130,17 @@ function applyBadgeExpand(value: unknown) {
form.badgeKey = expand.badgeKey ?? ''; form.badgeKey = expand.badgeKey ?? '';
form.badgeLevel = expand.badgeLevel ?? ''; form.badgeLevel = expand.badgeLevel ?? '';
form.badgeType = expand.badgeType || 'ACTIVITY'; form.badgeType = expand.badgeType || 'ACTIVITY';
form.badgeDisplayType = normalizeBadgeDisplayType(
expand.badgeDisplayType || expand.displayType,
form.badgeType,
);
form.milestone = expand.milestone ?? ''; form.milestone = expand.milestone ?? '';
form.notSelectUrl = expand.notSelectUrl ?? ''; form.notSelectUrl = expand.notSelectUrl ?? '';
} }
function buildBadgeExpand() { function buildBadgeExpand() {
const expand: Record<string, any> = { const expand: Record<string, any> = {
badgeDisplayType: normalizeBadgeDisplayType(form.badgeDisplayType, form.badgeType),
badgeType: form.badgeType || 'ACTIVITY', badgeType: form.badgeType || 'ACTIVITY',
}; };
if (String(form.badgeKey || '').trim()) { if (String(form.badgeKey || '').trim()) {
@ -147,9 +158,18 @@ function buildBadgeExpand() {
return JSON.stringify(expand); return JSON.stringify(expand);
} }
function normalizeBadgeDisplayType(value: unknown, badgeType?: unknown) {
const displayType = String(value || '').trim().toUpperCase();
if (displayType === 'LONG' || displayType === 'SHORT') {
return displayType;
}
return String(badgeType || '').trim().toUpperCase() === 'VIP' ? 'LONG' : 'SHORT';
}
function resetForm() { function resetForm() {
form.adminFree = false; form.adminFree = false;
form.amount = ''; form.amount = '';
form.badgeDisplayType = 'SHORT';
form.badgeKey = ''; form.badgeKey = '';
form.badgeLevel = ''; form.badgeLevel = '';
form.badgeType = 'ACTIVITY'; form.badgeType = 'ACTIVITY';
@ -212,6 +232,9 @@ watch(
if (value === 'BADGE' && !form.badgeType) { if (value === 'BADGE' && !form.badgeType) {
form.badgeType = 'ACTIVITY'; form.badgeType = 'ACTIVITY';
} }
if (value === 'BADGE' && !form.badgeDisplayType) {
form.badgeDisplayType = 'SHORT';
}
if (!['BADGE', 'CHAT_BUBBLE'].includes(value)) { if (!['BADGE', 'CHAT_BUBBLE'].includes(value)) {
form.expand = ''; form.expand = '';
} }
@ -288,6 +311,10 @@ function validateForm() {
message.warning('请选择徽章类型'); message.warning('请选择徽章类型');
return false; return false;
} }
if (form.type === 'BADGE' && !form.badgeDisplayType) {
message.warning('请选择徽章展示形态');
return false;
}
if ( if (
form.type === 'BADGE' && form.type === 'BADGE' &&
String(form.badgeLevel || '').trim() && String(form.badgeLevel || '').trim() &&
@ -384,6 +411,13 @@ async function handleSubmit() {
/> />
</FormItem> </FormItem>
<template v-if="form.type === 'BADGE'"> <template v-if="form.type === 'BADGE'">
<FormItem label="展示形态">
<Select
v-model:value="form.badgeDisplayType"
:options="badgeDisplayTypeOptions"
option-label-prop="label"
/>
</FormItem>
<FormItem label="徽章类型"> <FormItem label="徽章类型">
<Select <Select
v-model:value="form.badgeType" v-model:value="form.badgeType"

View File

@ -32,8 +32,8 @@ import {
defineOptions({ name: 'ResidentVipConfigPage' }); defineOptions({ name: 'ResidentVipConfigPage' });
const resourceFields = [ const resourceFields = [
{ key: 'longBadge', title: '长徽章素材', type: 'BADGE', badgeTypes: ['VIP'] }, { key: 'longBadge', title: '长徽章素材', type: 'BADGE', badgeDisplayTypes: ['LONG'] },
{ key: 'shortBadge', title: '短徽章素材', type: 'BADGE', badgeTypes: ['ACTIVITY', 'ACHIEVEMENT'] }, { key: 'shortBadge', title: '短徽章素材', type: 'BADGE', badgeDisplayTypes: ['SHORT'] },
{ key: 'avatarFrame', title: '头像框', type: 'AVATAR_FRAME' }, { key: 'avatarFrame', title: '头像框', type: 'AVATAR_FRAME' },
{ key: 'entryEffect', title: '进场特效', type: 'RIDE' }, { key: 'entryEffect', title: '进场特效', type: 'RIDE' },
{ key: 'chatBubble', title: '聊天气泡', type: 'CHAT_BUBBLE' }, { key: 'chatBubble', title: '聊天气泡', type: 'CHAT_BUBBLE' },
@ -298,16 +298,20 @@ async function loadResourceOptions(field: ResourceField) {
} }
function filterResourceRowsByField(rows: Array<Record<string, any>>, field: ResourceField) { function filterResourceRowsByField(rows: Array<Record<string, any>>, field: ResourceField) {
if (!('badgeTypes' in field) || !field.badgeTypes?.length) { if (!('badgeDisplayTypes' in field) || !field.badgeDisplayTypes?.length) {
return rows; return rows;
} }
const allowed = new Set(field.badgeTypes.map((item) => String(item).toUpperCase())); const allowed = new Set(field.badgeDisplayTypes.map((item) => String(item).toUpperCase()));
return rows.filter((item) => allowed.has(resourceBadgeType(item))); return rows.filter((item) => allowed.has(resourceBadgeDisplayType(item)));
} }
function resourceBadgeType(value: Record<string, any>) { function resourceBadgeDisplayType(value: Record<string, any>) {
const expand = parseJsonObject(value.expand); const expand = parseJsonObject(value.expand);
return String(expand.badgeType || 'ACTIVITY').toUpperCase(); const displayType = String(expand.badgeDisplayType || expand.displayType || '').toUpperCase();
if (displayType === 'LONG' || displayType === 'SHORT') {
return displayType;
}
return String(expand.badgeType || 'ACTIVITY').toUpperCase() === 'VIP' ? 'LONG' : 'SHORT';
} }
function parseJsonObject(value: unknown) { function parseJsonObject(value: unknown) {