| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import request from '@/utils/request'
- const BASE = '/setting/operationPopup/v1'
- export type OperationPopupDisplayMode =
- | 'IMAGE_H'
- | 'IMAGE_V'
- | 'CARD'
- | 'COUPON_PACK'
- | 'ACTIVITY'
- const DISPLAY_MODE_VALUES: OperationPopupDisplayMode[] = [
- 'IMAGE_H',
- 'IMAGE_V',
- 'CARD',
- 'COUPON_PACK',
- 'ACTIVITY'
- ]
- /** 详情/列表 VO 归一化展示方式(兼容 display_mode、大小写) */
- export function resolveOperationPopupDisplayMode(raw: unknown): OperationPopupDisplayMode {
- if (raw == null || raw === '') return 'IMAGE_H'
- const normalized = String(raw).trim().toUpperCase()
- if (DISPLAY_MODE_VALUES.includes(normalized as OperationPopupDisplayMode)) {
- return normalized as OperationPopupDisplayMode
- }
- return 'IMAGE_H'
- }
- /** 解析 info 接口响应体(兼容 AjaxResult 与字段平铺) */
- export function unwrapOperationPopupVo(res: unknown): Record<string, any> {
- if (!res || typeof res !== 'object') return {}
- const root = res as Record<string, any>
- const data = root.data
- if (data && typeof data === 'object' && !Array.isArray(data)) {
- if (data.id != null || data.displayMode != null || data.display_mode != null || data.title != null) {
- return data
- }
- if (data.data && typeof data.data === 'object') {
- return data.data
- }
- }
- if (root.id != null || root.displayMode != null || root.display_mode != null) {
- return root
- }
- return {}
- }
- export const OPERATION_POPUP_DISPLAY_MODE_LABEL: Record<OperationPopupDisplayMode, string> = {
- IMAGE_H: '横版海报',
- IMAGE_V: '竖版纯图',
- CARD: '图文卡片',
- COUPON_PACK: '券包到账',
- ACTIVITY: '营销活动'
- }
- export function operationPopupDisplayModeLabel(raw: unknown): string {
- const mode = resolveOperationPopupDisplayMode(raw)
- return OPERATION_POPUP_DISPLAY_MODE_LABEL[mode]
- }
- export interface OperationPopupExtConfig {
- couponSource?: string
- templateIds?: string[]
- maxShow?: number
- moreText?: string
- moreLinkPath?: string
- ctaText?: string
- activityId?: string
- showCountdown?: boolean
- hideShellText?: boolean
- frequency?: string
- }
- export interface OperationPopupQueryVO {
- pageNo?: number
- pageSize?: number
- platform?: string
- status?: number
- title?: string
- }
- export interface OperationPopupSaveDTO {
- id?: string
- platform: string
- title?: string
- subtitle?: string
- displayMode?: OperationPopupDisplayMode
- extConfig?: string
- imageUrl?: string
- linkPath?: string
- closable: number
- displayBegin?: string
- displayEnd?: string
- sortOrder?: number
- status?: number
- }
- export function getOperationPopupInfo(id: string) {
- return request.get(`${BASE}/info`, { params: { id } })
- }
- export function getOperationPopupList(data: OperationPopupQueryVO) {
- return request.post(`${BASE}/list`, data)
- }
- export function saveOperationPopup(data: OperationPopupSaveDTO) {
- return request.post(`${BASE}/save`, data)
- }
- export function deleteOperationPopup(ids: string) {
- return request.get(`${BASE}/delete`, { params: { ids } })
- }
|