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; }); + 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个 -

菜单设置

- + - - @@ -70,7 +72,7 @@ const formData = useVModel(props, 'modelValue', emit);