增加vip
This commit is contained in:
parent
10eba5fa86
commit
5102e086aa
@ -24,6 +24,7 @@ import {
|
||||
} from '#/api/legacy/props';
|
||||
|
||||
import {
|
||||
BADGE_DISPLAY_TYPE_OPTIONS,
|
||||
BADGE_TYPE_OPTIONS,
|
||||
NOBLE_VIP_OPTIONS,
|
||||
PROPS_RESOURCE_CONFIG_TYPES,
|
||||
@ -54,6 +55,7 @@ const notSelectInputRef = ref<HTMLInputElement>();
|
||||
const form = reactive<Record<string, any>>({
|
||||
adminFree: false,
|
||||
amount: '',
|
||||
badgeDisplayType: 'SHORT',
|
||||
badgeKey: '',
|
||||
badgeLevel: '',
|
||||
badgeType: 'ACTIVITY',
|
||||
@ -107,6 +109,10 @@ const badgeTypeOptions = BADGE_TYPE_OPTIONS.filter((item) =>
|
||||
label: item.name,
|
||||
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) {
|
||||
if (!value || typeof value !== 'string') {
|
||||
@ -124,12 +130,17 @@ function applyBadgeExpand(value: unknown) {
|
||||
form.badgeKey = expand.badgeKey ?? '';
|
||||
form.badgeLevel = expand.badgeLevel ?? '';
|
||||
form.badgeType = expand.badgeType || 'ACTIVITY';
|
||||
form.badgeDisplayType = normalizeBadgeDisplayType(
|
||||
expand.badgeDisplayType || expand.displayType,
|
||||
form.badgeType,
|
||||
);
|
||||
form.milestone = expand.milestone ?? '';
|
||||
form.notSelectUrl = expand.notSelectUrl ?? '';
|
||||
}
|
||||
|
||||
function buildBadgeExpand() {
|
||||
const expand: Record<string, any> = {
|
||||
badgeDisplayType: normalizeBadgeDisplayType(form.badgeDisplayType, form.badgeType),
|
||||
badgeType: form.badgeType || 'ACTIVITY',
|
||||
};
|
||||
if (String(form.badgeKey || '').trim()) {
|
||||
@ -147,9 +158,18 @@ function buildBadgeExpand() {
|
||||
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() {
|
||||
form.adminFree = false;
|
||||
form.amount = '';
|
||||
form.badgeDisplayType = 'SHORT';
|
||||
form.badgeKey = '';
|
||||
form.badgeLevel = '';
|
||||
form.badgeType = 'ACTIVITY';
|
||||
@ -212,6 +232,9 @@ watch(
|
||||
if (value === 'BADGE' && !form.badgeType) {
|
||||
form.badgeType = 'ACTIVITY';
|
||||
}
|
||||
if (value === 'BADGE' && !form.badgeDisplayType) {
|
||||
form.badgeDisplayType = 'SHORT';
|
||||
}
|
||||
if (!['BADGE', 'CHAT_BUBBLE'].includes(value)) {
|
||||
form.expand = '';
|
||||
}
|
||||
@ -288,6 +311,10 @@ function validateForm() {
|
||||
message.warning('请选择徽章类型');
|
||||
return false;
|
||||
}
|
||||
if (form.type === 'BADGE' && !form.badgeDisplayType) {
|
||||
message.warning('请选择徽章展示形态');
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
form.type === 'BADGE' &&
|
||||
String(form.badgeLevel || '').trim() &&
|
||||
@ -384,6 +411,13 @@ async function handleSubmit() {
|
||||
/>
|
||||
</FormItem>
|
||||
<template v-if="form.type === 'BADGE'">
|
||||
<FormItem label="展示形态">
|
||||
<Select
|
||||
v-model:value="form.badgeDisplayType"
|
||||
:options="badgeDisplayTypeOptions"
|
||||
option-label-prop="label"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="徽章类型">
|
||||
<Select
|
||||
v-model:value="form.badgeType"
|
||||
|
||||
@ -32,8 +32,8 @@ import {
|
||||
defineOptions({ name: 'ResidentVipConfigPage' });
|
||||
|
||||
const resourceFields = [
|
||||
{ key: 'longBadge', title: '长徽章素材', type: 'BADGE', badgeTypes: ['VIP'] },
|
||||
{ key: 'shortBadge', title: '短徽章素材', type: 'BADGE', badgeTypes: ['ACTIVITY', 'ACHIEVEMENT'] },
|
||||
{ key: 'longBadge', title: '长徽章素材', type: 'BADGE', badgeDisplayTypes: ['LONG'] },
|
||||
{ key: 'shortBadge', title: '短徽章素材', type: 'BADGE', badgeDisplayTypes: ['SHORT'] },
|
||||
{ key: 'avatarFrame', title: '头像框', type: 'AVATAR_FRAME' },
|
||||
{ key: 'entryEffect', title: '进场特效', type: 'RIDE' },
|
||||
{ key: 'chatBubble', title: '聊天气泡', type: 'CHAT_BUBBLE' },
|
||||
@ -298,16 +298,20 @@ async function loadResourceOptions(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;
|
||||
}
|
||||
const allowed = new Set(field.badgeTypes.map((item) => String(item).toUpperCase()));
|
||||
return rows.filter((item) => allowed.has(resourceBadgeType(item)));
|
||||
const allowed = new Set(field.badgeDisplayTypes.map((item) => String(item).toUpperCase()));
|
||||
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);
|
||||
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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user