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 new file mode 100644 index 00000000..436de405 --- /dev/null +++ b/src/components/DiyEditor/components/mobile/ProductList/config.ts @@ -0,0 +1,64 @@ +import { ComponentStyle, DiyComponent } from '@/components/DiyEditor/util' + +/** 商品卡片属性 */ +export interface ProductListProperty { + // 布局类型:双列 | 三列 | 水平滑动 + layoutType: 'twoCol' | 'threeCol' | 'horizSwiper' + // 商品字段 + fields: { + // 商品名称 + name: ProductListFieldProperty + // 商品价格 + price: ProductListFieldProperty + } + // 角标 + badge: { + // 是否显示 + show: boolean + // 角标图片 + imgUrl: string + } + // 上圆角 + borderRadiusTop: number + // 下圆角 + borderRadiusBottom: number + // 间距 + space: number + // 商品编号列表 + spuIds: number[] + // 组件样式 + style: ComponentStyle +} +// 商品字段 +export interface ProductListFieldProperty { + // 是否显示 + show: boolean + // 颜色 + color: string +} + +// 定义组件 +export const component = { + id: 'ProductList', + name: '商品栏', + icon: 'fluent:text-column-two-24-filled', + property: { + layoutType: 'twoCol', + fields: { + name: { show: true, color: '#000' }, + price: { show: true, color: '#ff3000' } + }, + badge: { show: false, imgUrl: '' }, + borderRadiusTop: 8, + borderRadiusBottom: 8, + space: 8, + spuIds: [], + style: { + bgType: 'color', + bgColor: '', + marginLeft: 8, + marginRight: 8, + marginBottom: 8 + } as ComponentStyle + } +} as DiyComponent diff --git a/src/components/DiyEditor/components/mobile/ProductList/index.vue b/src/components/DiyEditor/components/mobile/ProductList/index.vue new file mode 100644 index 00000000..8a35628e --- /dev/null +++ b/src/components/DiyEditor/components/mobile/ProductList/index.vue @@ -0,0 +1,131 @@ + + + + diff --git a/src/components/DiyEditor/components/mobile/ProductList/property.vue b/src/components/DiyEditor/components/mobile/ProductList/property.vue new file mode 100644 index 00000000..872affc3 --- /dev/null +++ b/src/components/DiyEditor/components/mobile/ProductList/property.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/src/components/DiyEditor/util.ts b/src/components/DiyEditor/util.ts index 8f8c2c0c..a8d0e095 100644 --- a/src/components/DiyEditor/util.ts +++ b/src/components/DiyEditor/util.ts @@ -107,11 +107,15 @@ export const PAGE_LIBS = [ extended: true, components: ['ImageBar', 'Carousel', 'TitleBar', 'VideoPlayer', 'Divider', 'MagicCube'] }, - { name: '商品组件', extended: true, components: ['ProductCard'] }, + { name: '商品组件', extended: true, components: ['ProductCard', 'ProductList'] }, { 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/components/ShortcutDateRangePicker/index.vue b/src/components/ShortcutDateRangePicker/index.vue index 9f268a3f..117c079a 100644 --- a/src/components/ShortcutDateRangePicker/index.vue +++ b/src/components/ShortcutDateRangePicker/index.vue @@ -74,11 +74,6 @@ const emits = defineEmits<{ }>() /** 触发时间范围选中事件 */ const emitDateRangePicker = async () => { - // 开始与截止在同一天的, 折线图出不来, 需要延长一天 - if (DateUtil.isSameDay(times.value[0], times.value[1])) { - // 前天 - times.value[0] = DateUtil.formatDate(dayjs(times.value[0]).subtract(1, 'd')) - } emits('change', times.value) } diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index e2ffcadd..466f1e1f 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -335,5 +335,8 @@ export function getDateRange( beginDate: dayjs.ConfigType, endDate: dayjs.ConfigType ): [string, string] { - return [dayjs(beginDate).startOf('d').toString(), dayjs(endDate).endOf('d').toString()] + return [ + dayjs(beginDate).startOf('d').format('YYYY-MM-DD HH:mm:ss'), + dayjs(endDate).endOf('d').format('YYYY-MM-DD HH:mm:ss') + ] } diff --git a/src/views/mall/product/comment/CommentForm.vue b/src/views/mall/product/comment/CommentForm.vue index 284e9a61..df6756a0 100644 --- a/src/views/mall/product/comment/CommentForm.vue +++ b/src/views/mall/product/comment/CommentForm.vue @@ -8,14 +8,7 @@ v-loading="formLoading" > -
-
- -
-
- -
-
+
@@ -51,12 +44,11 @@ 取 消 - - + diff --git a/src/views/mall/product/spu/components/SpuTableSelect.vue b/src/views/mall/product/spu/components/SpuTableSelect.vue index e748b76d..8028f749 100644 --- a/src/views/mall/product/spu/components/SpuTableSelect.vue +++ b/src/views/mall/product/spu/components/SpuTableSelect.vue @@ -1,8 +1,14 @@ - + diff --git a/src/views/mall/statistics/trade/index.vue b/src/views/mall/statistics/trade/index.vue index e89f0cc3..86deaa87 100644 --- a/src/views/mall/statistics/trade/index.vue +++ b/src/views/mall/statistics/trade/index.vue @@ -219,6 +219,8 @@ import { TradeSummaryRespVO, TradeTrendSummaryRespVO } from '@/api/mall/statisti import { calculateRelativeRate, fenToYuan } from '@/utils' import download from '@/utils/download' import { CardTitle } from '@/components/Card' +import * as DateUtil from '@/utils/formatTime' +import dayjs from 'dayjs' /** 交易统计 */ defineOptions({ name: 'TradeStatistics' }) @@ -289,6 +291,13 @@ const lineChartOptions = reactive({ /** 处理交易状况查询 */ const getTradeTrendData = async () => { trendLoading.value = true + // 1. 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天 + const times = shortcutDateRangePicker.value.times + if (DateUtil.isSameDay(times[0], times[1])) { + // 前天 + times[0] = DateUtil.formatDate(dayjs(times[0]).subtract(1, 'd')) + } + // 查询数据 await Promise.all([getTradeTrendSummary(), getTradeStatisticsList()]) trendLoading.value = false }