From 253401ace3578ed3118b912b039304e40ee95399 Mon Sep 17 00:00:00 2001 From: owen Date: Wed, 22 Nov 2023 16:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=90=A5=E9=94=80=EF=BC=9A=E9=80=82=E9=85=8D?= =?UTF-8?q?=E5=95=86=E5=9F=8E=E8=A3=85=E4=BF=AE=E7=BB=84=E4=BB=B6=E3=80=90?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/promotion/coupon/couponTemplate.ts | 7 + .../mobile/CouponCard/component.tsx | 78 ++++++++++ .../components/mobile/CouponCard/config.ts | 47 ++++++ .../components/mobile/CouponCard/index.vue | 142 ++++++++++++++++++ .../components/mobile/CouponCard/property.vue | 104 +++++++++++++ .../components/mobile/ProductCard/config.ts | 2 +- .../components/mobile/ProductList/config.ts | 2 +- .../components/mobile/ProductList/index.vue | 37 ++--- src/components/DiyEditor/util.ts | 8 +- .../mall/product/comment/CommentForm.vue | 2 +- .../product/spu/components/SpuShowcase.vue | 30 ++-- .../product/spu/components/SpuTableSelect.vue | 18 +-- .../coupon/components/CouponSelect.vue | 10 +- .../coupon/template/CouponTemplateForm.vue | 5 +- 14 files changed, 436 insertions(+), 56 deletions(-) create mode 100644 src/components/DiyEditor/components/mobile/CouponCard/component.tsx create mode 100644 src/components/DiyEditor/components/mobile/CouponCard/config.ts create mode 100644 src/components/DiyEditor/components/mobile/CouponCard/index.vue create mode 100644 src/components/DiyEditor/components/mobile/CouponCard/property.vue diff --git a/src/api/mall/promotion/coupon/couponTemplate.ts b/src/api/mall/promotion/coupon/couponTemplate.ts index 243e22ee..50ae226c 100755 --- a/src/api/mall/promotion/coupon/couponTemplate.ts +++ b/src/api/mall/promotion/coupon/couponTemplate.ts @@ -73,6 +73,13 @@ export function getCouponTemplatePage(params: PageParam) { }) } +// 获得优惠劵模板分页 +export function getCouponTemplateList(ids: number[]) { + return request.get({ + url: `/promotion/coupon-template/list?ids=${ids}` + }) +} + // 导出优惠劵模板 Excel export function exportCouponTemplateExcel(params: PageParam) { return request.get({ diff --git a/src/components/DiyEditor/components/mobile/CouponCard/component.tsx b/src/components/DiyEditor/components/mobile/CouponCard/component.tsx new file mode 100644 index 00000000..1542cad6 --- /dev/null +++ b/src/components/DiyEditor/components/mobile/CouponCard/component.tsx @@ -0,0 +1,78 @@ +import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate' +import { CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum } from '@/utils/constants' +import { floatToFixed2 } from '@/utils' +import { formatDate } from '@/utils/formatTime' + +// 优惠值 +export const CouponDiscount = defineComponent({ + name: 'CouponDiscount', + props: { + coupon: { + type: CouponTemplateApi.CouponTemplateVO + } + }, + setup(props) { + const coupon = props.coupon as CouponTemplateApi.CouponTemplateVO + // 折扣 + let value = coupon.discountPercent + '' + 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: CouponTemplateApi.CouponTemplateVO + } + }, + setup(props) { + const coupon = props.coupon as CouponTemplateApi.CouponTemplateVO + // 使用条件 + const useCondition = coupon.usePrice > 0 ? `满${floatToFixed2(coupon.usePrice)}元,` : '' + // 优惠描述 + const discountDesc = + coupon.discountType === PromotionDiscountTypeEnum.PRICE.type + ? `减${floatToFixed2(coupon.discountPrice)}元` + : `打${coupon.discountPercent}折` + return () => ( +
+ {useCondition} + {discountDesc} +
+ ) + } +}) + +// 有效期 +export const CouponValidTerm = defineComponent({ + name: 'CouponValidTerm', + props: { + coupon: { + type: CouponTemplateApi.CouponTemplateVO + } + }, + setup(props) { + const coupon = props.coupon as CouponTemplateApi.CouponTemplateVO + 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/src/components/DiyEditor/components/mobile/CouponCard/config.ts b/src/components/DiyEditor/components/mobile/CouponCard/config.ts new file mode 100644 index 00000000..304533d1 --- /dev/null +++ b/src/components/DiyEditor/components/mobile/CouponCard/config.ts @@ -0,0 +1,47 @@ +import { ComponentStyle, DiyComponent } from '@/components/DiyEditor/util' + +/** 商品卡片属性 */ +export interface CouponCardProperty { + // 列数 + columns: number + // 背景图 + bgImg: string + // 文字颜色 + textColor: string + // 按钮样式 + button: { + // 颜色 + color: string + // 背景颜色 + bgColor: string + } + // 间距 + space: number + // 优惠券编号列表 + couponIds: number[] + // 组件样式 + style: ComponentStyle +} + +// 定义组件 +export const component = { + id: 'CouponCard', + name: '优惠券', + icon: 'ep:ticket', + property: { + columns: 1, + bgImg: '', + textColor: '#E9B461', + button: { + color: '#434343', + bgColor: '' + }, + space: 0, + couponIds: [], + style: { + bgType: 'color', + bgColor: '', + marginBottom: 8 + } as ComponentStyle + } +} as DiyComponent diff --git a/src/components/DiyEditor/components/mobile/CouponCard/index.vue b/src/components/DiyEditor/components/mobile/CouponCard/index.vue new file mode 100644 index 00000000..3e2302af --- /dev/null +++ b/src/components/DiyEditor/components/mobile/CouponCard/index.vue @@ -0,0 +1,142 @@ + + + diff --git a/src/components/DiyEditor/components/mobile/CouponCard/property.vue b/src/components/DiyEditor/components/mobile/CouponCard/property.vue new file mode 100644 index 00000000..4f32c21e --- /dev/null +++ b/src/components/DiyEditor/components/mobile/CouponCard/property.vue @@ -0,0 +1,104 @@ + + + + + diff --git a/src/components/DiyEditor/components/mobile/ProductCard/config.ts b/src/components/DiyEditor/components/mobile/ProductCard/config.ts index 49dd30d0..735b6ba0 100644 --- a/src/components/DiyEditor/components/mobile/ProductCard/config.ts +++ b/src/components/DiyEditor/components/mobile/ProductCard/config.ts @@ -62,7 +62,7 @@ export interface ProductCardFieldProperty { export const component = { id: 'ProductCard', name: '商品卡片', - icon: 'system-uicons:carousel', + icon: 'fluent:text-column-two-left-24-filled', property: { layoutType: 'oneColBigImg', fields: { diff --git a/src/components/DiyEditor/components/mobile/ProductList/config.ts b/src/components/DiyEditor/components/mobile/ProductList/config.ts index 019be74e..436de405 100644 --- a/src/components/DiyEditor/components/mobile/ProductList/config.ts +++ b/src/components/DiyEditor/components/mobile/ProductList/config.ts @@ -41,7 +41,7 @@ export interface ProductListFieldProperty { export const component = { id: 'ProductList', name: '商品栏', - icon: 'system-uicons:carousel', + icon: 'fluent:text-column-two-24-filled', property: { layoutType: 'twoCol', fields: { diff --git a/src/components/DiyEditor/components/mobile/ProductList/index.vue b/src/components/DiyEditor/components/mobile/ProductList/index.vue index cf644ea1..8a35628e 100644 --- a/src/components/DiyEditor/components/mobile/ProductList/index.vue +++ b/src/components/DiyEditor/components/mobile/ProductList/index.vue @@ -1,13 +1,13 @@ diff --git a/src/components/DiyEditor/util.ts b/src/components/DiyEditor/util.ts index 5dfcea9e..a8d0e095 100644 --- a/src/components/DiyEditor/util.ts +++ b/src/components/DiyEditor/util.ts @@ -111,7 +111,11 @@ export const PAGE_LIBS = [ { name: '会员组件', extended: true, - components: ['UserCard', 'OrderCard', 'WalletCard', 'CouponCard'] + components: ['UserCard', 'UserOrder', 'UserWallet', 'UserCoupon'] }, - { name: '营销组件', extended: true, components: ['Combination', 'Seckill', 'Point', 'Coupon'] } + { + name: '营销组件', + extended: true, + components: ['CombinationCard', 'SeckillCard', 'PointCard', 'CouponCard'] + } ] as DiyComponentLibrary[] diff --git a/src/views/mall/product/comment/CommentForm.vue b/src/views/mall/product/comment/CommentForm.vue index e9913ade..df6756a0 100644 --- a/src/views/mall/product/comment/CommentForm.vue +++ b/src/views/mall/product/comment/CommentForm.vue @@ -48,7 +48,7 @@ - +