diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/component.tsx b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/component.tsx
index d4dbfee44..b09a30966 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/component.tsx
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/component.tsx
@@ -1,4 +1,87 @@
-// 导出所有优惠券相关组件
-export { CouponDiscount } from './coupon-discount';
-export { CouponDiscountDesc } from './coupon-discount-desc';
-export { CouponValidTerm } from './coupon-validTerm';
+import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
+
+import { defineComponent } from 'vue';
+
+import {
+ CouponTemplateValidityTypeEnum,
+ PromotionDiscountTypeEnum,
+} from '@vben/constants';
+import { floatToFixed2, formatDate } from '@vben/utils';
+
+/** 有效期 */
+export const CouponValidTerm = defineComponent({
+ name: 'CouponValidTerm',
+ props: {
+ coupon: {
+ type: Object as () => MallCouponTemplateApi.CouponTemplate,
+ required: true,
+ },
+ },
+ setup(props) {
+ const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
+ const text =
+ coupon.validityType === CouponTemplateValidityTypeEnum.DATE.type
+ ? `有效期:${formatDate(coupon.validStartTime, 'YYYY-MM-DD')} 至 ${formatDate(
+ coupon.validEndTime,
+ 'YYYY-MM-DD',
+ )}`
+ : `领取后第 ${coupon.fixedStartTerm} - ${coupon.fixedEndTerm} 天内可用`;
+ return () =>
{text}
;
+ },
+});
+
+/** 优惠值 */
+export const CouponDiscount = defineComponent({
+ name: 'CouponDiscount',
+ props: {
+ coupon: {
+ type: Object as () => MallCouponTemplateApi.CouponTemplate,
+ required: true,
+ },
+ },
+ setup(props) {
+ const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
+ // 折扣
+ let value = `${(coupon.discountPercent ?? 0) / 10}`;
+ let suffix = ' 折';
+ // 满减
+ if (coupon.discountType === PromotionDiscountTypeEnum.PRICE.type) {
+ value = floatToFixed2(coupon.discountPrice);
+ suffix = ' 元';
+ }
+ return () => (
+
+ {value}
+ {suffix}
+
+ );
+ },
+});
+
+/** 优惠描述 */
+export const CouponDiscountDesc = defineComponent({
+ name: 'CouponDiscountDesc',
+ props: {
+ coupon: {
+ type: Object as () => MallCouponTemplateApi.CouponTemplate,
+ required: true,
+ },
+ },
+ setup(props) {
+ const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
+ // 使用条件
+ const useCondition =
+ coupon.usePrice > 0 ? `满${floatToFixed2(coupon.usePrice)}元,` : '';
+ // 优惠描述
+ const discountDesc =
+ coupon.discountType === PromotionDiscountTypeEnum.PRICE.type
+ ? `减${floatToFixed2(coupon.discountPrice)}元`
+ : `打${(coupon.discountPercent ?? 0) / 10}折`;
+ return () => (
+
+ {useCondition}
+ {discountDesc}
+
+ );
+ },
+});
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/coupon-discount-desc.tsx b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/coupon-discount-desc.tsx
deleted file mode 100644
index 89f360564..000000000
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/coupon-discount-desc.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
-
-import { defineComponent } from 'vue';
-
-import { PromotionDiscountTypeEnum } from '@vben/constants';
-import { floatToFixed2 } from '@vben/utils';
-
-// 优惠描述
-export const CouponDiscountDesc = defineComponent({
- name: 'CouponDiscountDesc',
- props: {
- coupon: {
- type: Object as () => MallCouponTemplateApi.CouponTemplate,
- required: true,
- },
- },
- setup(props) {
- const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
- // 使用条件
- const useCondition =
- coupon.usePrice > 0 ? `满${floatToFixed2(coupon.usePrice)}元,` : '';
- // 优惠描述
- const discountDesc =
- coupon.discountType === PromotionDiscountTypeEnum.PRICE.type
- ? `减${floatToFixed2(coupon.discountPrice)}元`
- : `打${(coupon.discountPercent ?? 0) / 10}折`;
- return () => (
-
- {useCondition}
- {discountDesc}
-
- );
- },
-});
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/coupon-discount.tsx b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/coupon-discount.tsx
deleted file mode 100644
index 15a95887c..000000000
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/coupon-discount.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
-
-import { defineComponent } from 'vue';
-
-import { PromotionDiscountTypeEnum } from '@vben/constants';
-import { floatToFixed2 } from '@vben/utils';
-
-// 优惠值
-export const CouponDiscount = defineComponent({
- name: 'CouponDiscount',
- props: {
- coupon: {
- type: Object as () => MallCouponTemplateApi.CouponTemplate,
- required: true,
- },
- },
- setup(props) {
- const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
- // 折扣
- let value = `${(coupon.discountPercent ?? 0) / 10}`;
- let suffix = ' 折';
- // 满减
- if (coupon.discountType === PromotionDiscountTypeEnum.PRICE.type) {
- value = floatToFixed2(coupon.discountPrice);
- suffix = ' 元';
- }
- return () => (
-
- {value}
- {suffix}
-
- );
- },
-});
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/coupon-validTerm.tsx b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/coupon-validTerm.tsx
deleted file mode 100644
index 7b2e373b2..000000000
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/coupon-validTerm.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
-
-import { defineComponent } from 'vue';
-
-import { CouponTemplateValidityTypeEnum } from '@vben/constants';
-import { formatDate } from '@vben/utils';
-
-// 有效期
-export const CouponValidTerm = defineComponent({
- name: 'CouponValidTerm',
- props: {
- coupon: {
- type: Object as () => MallCouponTemplateApi.CouponTemplate,
- required: true,
- },
- },
- setup(props) {
- const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
- const text =
- coupon.validityType === CouponTemplateValidityTypeEnum.DATE.type
- ? `有效期:${formatDate(coupon.validStartTime, 'YYYY-MM-DD')} 至 ${formatDate(
- coupon.validEndTime,
- 'YYYY-MM-DD',
- )}`
- : `领取后第 ${coupon.fixedStartTerm} - ${coupon.fixedEndTerm} 天内可用`;
- return () => {text}
;
- },
-});
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue
index 25b37ec8c..0a57272d7 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue
@@ -13,12 +13,19 @@ import {
CouponValidTerm,
} from './component';
-/** 商品卡片 */
+/** 优惠劵卡片 */
defineOptions({ name: 'CouponCard' });
-// 定义属性
+
+/** 定义属性 */
const props = defineProps<{ property: CouponCardProperty }>();
-// 商品列表
-const couponList = ref([]);
+
+const couponList = ref([]); // 优惠劵列表
+const phoneWidth = ref(375); // 手机宽度
+const containerRef = ref(); // 容器引用
+const scrollbarWidth = ref('100%'); // 滚动条宽度
+const couponWidth = ref(375); // 优惠券宽度
+
+/** 监听优惠券 ID 变化,加载优惠券列表 */
watch(
() => props.property.couponIds,
async () => {
@@ -32,15 +39,7 @@ watch(
},
);
-// 手机宽度
-const phoneWidth = ref(384);
-// 容器
-const containerRef = ref();
-// 滚动条宽度
-const scrollbarWidth = ref('100%');
-// 优惠券的宽度
-const couponWidth = ref(384);
-// 计算布局参数
+/** 计算布局参数 */
watch(
() => [props.property, phoneWidth, couponList.value.length],
() => {
@@ -56,9 +55,10 @@ watch(
},
{ immediate: true, deep: true },
);
+
+/** 初始化 */
onMounted(() => {
- // 提取手机宽度
- phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 384;
+ phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 375;
});
@@ -82,17 +82,14 @@ onMounted(() => {
v-for="(coupon, index) in couponList"
:key="index"
>
-
+
-
-
-
@@ -107,17 +104,14 @@ onMounted(() => {
-
+
-
-
-
仅剩:{{ coupon.totalCount - coupon.takeCount }}张
@@ -135,11 +129,9 @@ onMounted(() => {
-
+
-
-
();
-// 是否展开
-const expanded = ref(false);
-// 处理展开/折叠
-const handleToggleFab = () => {
- expanded.value = !expanded.value;
-};
+const expanded = ref(false); // 是否展开
-const handleActive = (index: number) => {
- message.success(`点击了${index}`);
-};
+/** 处理展开/折叠 */
+function handleToggleFab() {
+ expanded.value = !expanded.value;
+}
{
v-for="(item, index) in property.list"
:key="index"
class="flex flex-col items-center"
- @click="handleActive(index)"
>
-
+
{
-
+
-
-
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/hot-zone/components/hot-zone-edit-dialog/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/hot-zone/components/hot-zone-edit-dialog/index.vue
index 27d20bada..dbb17e6ea 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/hot-zone/components/hot-zone-edit-dialog/index.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/hot-zone/components/hot-zone-edit-dialog/index.vue
@@ -11,7 +11,7 @@ import { IconifyIcon } from '@vben/icons';
import { Button, Image } from 'ant-design-vue';
-import AppLinkSelectDialog from '#/views/mall/promotion/components/app-link-input/app-link-select-dialog.vue';
+import { AppLinkSelectDialog } from '#/views/mall/promotion/components';
import {
CONTROL_DOT_LIST,
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/magic-cube/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/magic-cube/index.vue
index c5d9ead5b..1d7ecf89a 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/magic-cube/index.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/magic-cube/index.vue
@@ -9,9 +9,11 @@ import { Image } from 'ant-design-vue';
/** 广告魔方 */
defineOptions({ name: 'MagicCube' });
+
const props = defineProps<{ property: MagicCubeProperty }>();
-// 一个方块的大小
-const CUBE_SIZE = 93.75;
+
+const CUBE_SIZE = 93.75; // 一个方块的大小
+
/**
* 计算方块的行数
* 行数用于计算魔方的总体高度,存在以下情况:
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/magic-cube/property.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/magic-cube/property.vue
index 2fc781939..62573bcc0 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/magic-cube/property.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/magic-cube/property.vue
@@ -57,6 +57,7 @@ const handleHotAreaSelected = (_: any, index: number) => {
+
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-grid/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-grid/index.vue
index a572b74ae..38336f5a9 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-grid/index.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-grid/index.vue
@@ -5,6 +5,7 @@ import { Image } from 'ant-design-vue';
/** 宫格导航 */
defineOptions({ name: 'MenuGrid' });
+
defineProps<{ property: MenuGridProperty }>();
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-grid/property.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-grid/property.vue
index de92c23c8..917a0ce43 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-grid/property.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-grid/property.vue
@@ -9,6 +9,7 @@ import {
AppLinkInput,
ColorInput,
Draggable,
+ InputWithColor,
} from '#/views/mall/promotion/components';
import ComponentContainerProperty from '../../component-container-property.vue';
@@ -18,7 +19,9 @@ import { EMPTY_MENU_GRID_ITEM_PROPERTY } from './config';
defineOptions({ name: 'MenuGridProperty' });
const props = defineProps<{ modelValue: MenuGridProperty }>();
+
const emit = defineEmits(['update:modelValue']);
+
const formData = useVModel(props, 'modelValue', emit);
@@ -32,7 +35,6 @@ const formData = useVModel(props, 'modelValue', emit);
4个
-
菜单设置
- 建议尺寸:44 * 44
+ 建议尺寸:44 * 44
-
-
@@ -70,7 +72,7 @@ const formData = useVModel(props, 'modelValue', emit);
-
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-list/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-list/index.vue
index e7f67ee25..88606b4eb 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-list/index.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/menu-list/index.vue
@@ -7,6 +7,7 @@ import { Image } from 'ant-design-vue';
/** 列表导航 */
defineOptions({ name: 'MenuList' });
+
defineProps<{ property: MenuListProperty }>();
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/components/cell-property.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/components/cell-property.vue
index 410d555c4..f85293f7d 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/components/cell-property.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/components/cell-property.vue
@@ -23,7 +23,7 @@ import {
MagicCubeEditor,
} from '#/views/mall/promotion/components';
-// 导航栏属性面板
+/** 导航栏单元格属性面板 */
defineOptions({ name: 'NavigationBarCellProperty' });
const props = defineProps({
@@ -36,26 +36,21 @@ const props = defineProps({
default: () => [],
},
});
+
const emit = defineEmits(['update:modelValue']);
+
const cellList = useVModel(props, 'modelValue', emit);
-// 单元格数量:小程序6个(右侧胶囊按钮占了2个),其它平台8个
+/**
+ * 计算单元格数量
+ * 1. 小程序:6 个(因为右侧有胶囊按钮占据 2 个格子的空间)
+ * 2. 其它平台:8 个(全部空间可用)
+ */
const cellCount = computed(() => (props.isMp ? 6 : 8));
-// 转换为Rect格式的数据
-const rectList = computed(() => {
- return cellList.value.map((cell) => ({
- left: cell.left,
- top: cell.top,
- width: cell.width,
- height: cell.height,
- right: cell.left + cell.width,
- bottom: cell.top + cell.height,
- }));
-});
+const selectedHotAreaIndex = ref(0); // 选中的热区
-// 选中的热区
-const selectedHotAreaIndex = ref(0);
+/** 处理热区被选中事件 */
const handleHotAreaSelected = (
cellValue: NavigationBarCellProperty,
index: number,
@@ -71,7 +66,7 @@ const handleHotAreaSelected = (
();
-// 背景
+/** 计算背景样式 */
const bgStyle = computed(() => {
const background =
props.property.bgType === 'img' && props.property.bgImg
@@ -26,19 +26,22 @@ const bgStyle = computed(() => {
: props.property.bgColor;
return { background };
});
-// 单元格列表
+
+/** 获取当前预览的单元格列表 */
const cellList = computed(() =>
props.property._local?.previewMp
? props.property.mpCells
: props.property.otherCells,
);
-// 单元格宽度
+
+/** 计算单元格宽度 */
const cellWidth = computed(() => {
return props.property._local?.previewMp
- ? (384 - 80 - 86) / 6
- : (384 - 90) / 8;
+ ? (375 - 80 - 86) / 6
+ : (375 - 90) / 8;
});
-// 获得单元格样式
+
+/** 获取单元格样式 */
const getCellStyle = (cell: NavigationBarCellProperty) => {
return {
width: `${cell.width * cellWidth.value + (cell.width - 1) * 10}px`,
@@ -46,7 +49,8 @@ const getCellStyle = (cell: NavigationBarCellProperty) => {
position: 'absolute',
} as StyleValue;
};
-// 获得搜索框属性
+
+/** 获取搜索框属性配置 */
const getSearchProp = computed(() => (cell: NavigationBarCellProperty) => {
return {
height: 30,
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/property.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/property.vue
index 860ba178b..3603c46a0 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/property.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/property.vue
@@ -17,16 +17,16 @@ import { ColorInput } from '#/views/mall/promotion/components';
import NavigationBarCellProperty from './components/cell-property.vue';
-// 导航栏属性面板
+/** 导航栏属性面板 */
defineOptions({ name: 'NavigationBarProperty' });
+
const props = defineProps<{ modelValue: NavigationBarProperty }>();
const emit = defineEmits(['update:modelValue']);
-// 表单校验
const rules: Record = {
name: [{ required: true, message: '请输入页面名称', trigger: 'blur' }],
-};
+}; // 表单校验
const formData = useVModel(props, 'modelValue', emit);
if (!formData.value._local) {
diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/popover/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/popover/index.vue
index 709b62a6c..64f76a98d 100644
--- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/popover/index.vue
+++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/popover/index.vue
@@ -9,18 +9,19 @@ import { Image } from 'ant-design-vue';
/** 弹窗广告 */
defineOptions({ name: 'Popover' });
-// 定义属性
-defineProps<{ property: PopoverProperty }>();
-// 处理选中
-const activeIndex = ref(0);
-const handleActive = (index: number) => {
+const props = defineProps<{ property: PopoverProperty }>();
+
+const activeIndex = ref(0); // 选中 index
+
+/** 处理选中 */
+function handleActive(index: number) {
activeIndex.value = index;
-};
+}
{{ index + 1 }}
-
-
diff --git a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue
index 5f6bcbb32..a34392443 100644
--- a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue
+++ b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue
@@ -7,7 +7,7 @@ import { onMounted, ref, watch } from 'vue';
import { ElScrollbar } from 'element-plus';
-import * as CouponTemplateApi from '#/api/mall/promotion/coupon/couponTemplate';
+import { getCouponTemplateList } from '#/api/mall/promotion/coupon/couponTemplate';
import {
CouponDiscount,
@@ -32,9 +32,7 @@ watch(
() => props.property.couponIds,
async () => {
if (props.property.couponIds?.length > 0) {
- couponList.value = await CouponTemplateApi.getCouponTemplateList(
- props.property.couponIds,
- );
+ couponList.value = await getCouponTemplateList(props.property.couponIds);
}
},
{
diff --git a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/floating-action-button/index.vue b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/floating-action-button/index.vue
index 7a5986658..3d114b29c 100644
--- a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/floating-action-button/index.vue
+++ b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/floating-action-button/index.vue
@@ -39,7 +39,7 @@ function handleToggleFab() {
-
+
@@ -55,7 +55,7 @@ function handleToggleFab() {
diff --git a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/popover/index.vue b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/popover/index.vue
index 694f77ed2..a55c0e37c 100644
--- a/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/popover/index.vue
+++ b/apps/web-ele/src/views/mall/promotion/components/diy-editor/components/mobile/popover/index.vue
@@ -19,7 +19,6 @@ function handleActive(index: number) {
activeIndex.value = index;
}
-