From 39ddf5a1ea9ba74d1672a7e570d058c720121671 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 2 Nov 2025 17:05:18 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90antd=E3=80=91=E3=80=90mal?= =?UTF-8?q?l=E3=80=91diy-editor=20=E7=9A=84=20promotion-point=20=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=20100%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mobile/promotion-point/config.ts | 75 ++-- .../mobile/promotion-point/index.vue | 67 ++-- .../mobile/promotion-point/property.vue | 47 +-- .../mall/promotion/point/components/index.ts | 1 + .../point/components/point-showcase.vue | 178 --------- .../point/components/point-table-select.vue | 354 ------------------ .../promotion/point/components/showcase.vue | 149 ++++++++ .../point/components/table-select.vue | 239 ++++++++++++ 8 files changed, 468 insertions(+), 642 deletions(-) create mode 100644 apps/web-ele/src/views/mall/promotion/point/components/index.ts delete mode 100644 apps/web-ele/src/views/mall/promotion/point/components/point-showcase.vue delete mode 100644 apps/web-ele/src/views/mall/promotion/point/components/point-table-select.vue create mode 100644 apps/web-ele/src/views/mall/promotion/point/components/showcase.vue create mode 100644 apps/web-ele/src/views/mall/promotion/point/components/table-select.vue diff --git a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/config.ts b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/config.ts index 738ca3b31..8393f8ca2 100644 --- a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/config.ts +++ b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/config.ts @@ -2,64 +2,41 @@ import type { ComponentStyle, DiyComponent } from '../../../util'; /** 积分商城属性 */ export interface PromotionPointProperty { - // 布局类型:单列 | 三列 - layoutType: 'oneColBigImg' | 'oneColSmallImg' | 'twoCol'; - // 商品字段 + layoutType: 'oneColBigImg' | 'oneColSmallImg' | 'twoCol'; // 布局类型:单列 | 三列 fields: { - // 商品简介 - introduction: PromotionPointFieldProperty; - // 市场价 - marketPrice: PromotionPointFieldProperty; - // 商品名称 - name: PromotionPointFieldProperty; - // 商品价格 - price: PromotionPointFieldProperty; - // 商品销量 - salesCount: PromotionPointFieldProperty; - // 商品库存 - stock: PromotionPointFieldProperty; - }; - // 角标 + introduction: PromotionPointFieldProperty; // 商品简介 + marketPrice: PromotionPointFieldProperty; // 市场价 + name: PromotionPointFieldProperty; // 商品名称 + price: PromotionPointFieldProperty; // 商品价格 + salesCount: PromotionPointFieldProperty; // 商品销量 + stock: PromotionPointFieldProperty; // 商品库存 + }; // 商品字段 badge: { - // 角标图片 - imgUrl: string; - // 是否显示 - show: boolean; - }; + imgUrl: string; // 角标图片 + show: boolean; // 是否显示 + }; // 角标 // 按钮 btnBuy: { - // 文字按钮:背景渐变起始颜色 - bgBeginColor: string; - // 文字按钮:背景渐变结束颜色 - bgEndColor: string; - // 图片按钮:图片地址 - imgUrl: string; - // 文字 - text: string; - // 类型:文字 | 图片 - type: 'img' | 'text'; - }; - // 上圆角 - borderRadiusTop: number; - // 下圆角 - borderRadiusBottom: number; - // 间距 - space: number; - // 秒杀活动编号 - activityIds: number[]; - // 组件样式 - style: ComponentStyle; + bgBeginColor: string; // 文字按钮:背景渐变起始颜色 + bgEndColor: string; // 文字按钮:背景渐变结束颜色 + imgUrl: string; // 图片按钮:图片地址 + text: string; // 文字 + type: 'img' | 'text'; // 类型:文字 | 图片 + }; // 按钮 + borderRadiusTop: number; // 上圆角 + borderRadiusBottom: number; // 下圆角 + space: number; // 间距 + activityIds: number[]; // 积分活动编号 + style: ComponentStyle; // 组件样式 } -// 商品字段 +/** 商品字段属性 */ export interface PromotionPointFieldProperty { - // 是否显示 - show: boolean; - // 颜色 - color: string; + show: boolean; // 是否显示 + color: string; // 颜色 } -// 定义组件 +/** 定义组件 */ export const component = { id: 'PromotionPoint', name: '积分商城', diff --git a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/index.vue b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/index.vue index 3ff8336dd..139fc63d6 100644 --- a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/index.vue +++ b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/index.vue @@ -14,10 +14,10 @@ import * as PointActivityApi from '#/api/mall/promotion/point'; /** 积分商城卡片 */ defineOptions({ name: 'PromotionPoint' }); -// 定义属性 + const props = defineProps<{ property: PromotionPointProperty }>(); -// 商品列表 -const spuList = ref([]); + +const spuList = ref([]); // 商品列表 const spuIdList = ref([]); const pointActivityList = ref([]); @@ -27,7 +27,7 @@ watch( try { // 新添加的积分商城组件,是没有活动ID的 const activityIds = props.property.activityIds; - // 检查活动ID的有效性 + // 检查活动 ID 的有效性 if (Array.isArray(activityIds) && activityIds.length > 0) { // 获取积分商城活动详情列表 pointActivityList.value = @@ -66,41 +66,33 @@ watch( }, ); -/** - * 计算商品的间距 - * @param index 商品索引 - */ -const calculateSpace = (index: number) => { - // 商品的列数 - const columns = props.property.layoutType === 'twoCol' ? 2 : 1; - // 第一列没有左边距 - const marginLeft = index % columns === 0 ? '0' : `${props.property.space}px`; - // 第一行没有上边距 - const marginTop = index < columns ? '0' : `${props.property.space}px`; - +/** 计算商品的间距 */ +function calculateSpace(index: number) { + const columns = props.property.layoutType === 'twoCol' ? 2 : 1; // 商品的列数 + const marginLeft = index % columns === 0 ? '0' : `${props.property.space}px`; // 第一列没有左边距 + const marginTop = index < columns ? '0' : `${props.property.space}px`; // 第一行没有上边距 return { marginLeft, marginTop }; -}; +} -// 容器 const containerRef = ref(); -// 计算商品的宽度 -const calculateWidth = () => { + +/** 计算商品的宽度 */ +function calculateWidth() { let width = '100%'; - // 双列时每列的宽度为:(总宽度 - 间距)/ 2 if (props.property.layoutType === 'twoCol') { + // 双列时每列的宽度为:(总宽度 - 间距)/ 2 width = `${(containerRef.value.offsetWidth - props.property.space) / 2}px`; } return { width }; -}; +} - - diff --git a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/property.vue b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/property.vue index 6ce0b5099..69465b223 100644 --- a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/property.vue +++ b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/property.vue @@ -16,10 +16,13 @@ import { ElTooltip, } from 'element-plus'; +import UploadImg from '#/components/upload/image-upload.vue'; import { ColorInput } from '#/views/mall/promotion/components'; -import PointShowcase from '#/views/mall/promotion/point/components/point-showcase.vue'; +import { PointShowcase } from '#/views/mall/promotion/point/components'; -// 秒杀属性面板 +import ComponentContainerProperty from '../../component-container-property.vue'; + +/** 积分属性面板 */ defineOptions({ name: 'PromotionPointProperty' }); const props = defineProps<{ modelValue: PromotionPointProperty }>(); @@ -29,11 +32,11 @@ const formData = useVModel(props, 'modelValue', emit); - + @@ -157,9 +160,9 @@ const formData = useVModel(props, 'modelValue', emit); v-model="formData.borderRadiusBottom" :max="100" :min="0" - :show-input-controls="false" - input-size="small" show-input + input-size="small" + :show-input-controls="false" /> @@ -167,14 +170,12 @@ const formData = useVModel(props, 'modelValue', emit); v-model="formData.space" :max="100" :min="0" - :show-input-controls="false" - input-size="small" show-input + input-size="small" + :show-input-controls="false" /> - - diff --git a/apps/web-ele/src/views/mall/promotion/point/components/index.ts b/apps/web-ele/src/views/mall/promotion/point/components/index.ts new file mode 100644 index 000000000..bb0194057 --- /dev/null +++ b/apps/web-ele/src/views/mall/promotion/point/components/index.ts @@ -0,0 +1 @@ +export { default as PointShowcase } from './showcase.vue'; diff --git a/apps/web-ele/src/views/mall/promotion/point/components/point-showcase.vue b/apps/web-ele/src/views/mall/promotion/point/components/point-showcase.vue deleted file mode 100644 index 6a39d3803..000000000 --- a/apps/web-ele/src/views/mall/promotion/point/components/point-showcase.vue +++ /dev/null @@ -1,178 +0,0 @@ - - - - diff --git a/apps/web-ele/src/views/mall/promotion/point/components/point-table-select.vue b/apps/web-ele/src/views/mall/promotion/point/components/point-table-select.vue deleted file mode 100644 index e850d8eb3..000000000 --- a/apps/web-ele/src/views/mall/promotion/point/components/point-table-select.vue +++ /dev/null @@ -1,354 +0,0 @@ - - - diff --git a/apps/web-ele/src/views/mall/promotion/point/components/showcase.vue b/apps/web-ele/src/views/mall/promotion/point/components/showcase.vue new file mode 100644 index 000000000..95aceb9ec --- /dev/null +++ b/apps/web-ele/src/views/mall/promotion/point/components/showcase.vue @@ -0,0 +1,149 @@ + + + + diff --git a/apps/web-ele/src/views/mall/promotion/point/components/table-select.vue b/apps/web-ele/src/views/mall/promotion/point/components/table-select.vue new file mode 100644 index 000000000..eff545cba --- /dev/null +++ b/apps/web-ele/src/views/mall/promotion/point/components/table-select.vue @@ -0,0 +1,239 @@ + + + +