From 344f1eecd20eb76ff8f92ea7e0ddef3126189e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Thu, 3 Apr 2025 17:52:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=BE=E7=A4=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/model-salerecords/index.vue | 18 ++++--- src/components/model-seckill/index.vue | 52 +++++++++++--------- src/config/const/binding.ts | 56 ++++++++-------------- src/config/const/salerecords.ts | 2 + src/config/const/seckill.ts | 4 ++ src/views/layout/index.vue | 4 ++ 6 files changed, 71 insertions(+), 65 deletions(-) diff --git a/src/components/model-salerecords/index.vue b/src/components/model-salerecords/index.vue index 3ef65d18..8ad9ae97 100644 --- a/src/components/model-salerecords/index.vue +++ b/src/components/model-salerecords/index.vue @@ -120,7 +120,7 @@ type data_list = { const default_list = { user: { avatar: '', - user_name_view: '测试昵称测试昵称测试昵称测试昵称', + user_name_view: '测试昵称', }, title: '测试商品标题测试', images: '', @@ -133,11 +133,15 @@ const new_list = ref([]); const list = ref([]); // 初始化的时候执行 onMounted(() => { - if (!isEmpty(form.value.data_auto_list)) { - // 筛选商品并且筛选商品数组不为空 - list.value = form.value.data_auto_list; + if (form.value.is_left == '1') { + get_products(); } else { - list.value = Array(10).fill(default_list); + if (!isEmpty(form.value.data_auto_list)) { + // 筛选商品并且筛选商品数组不为空 + list.value = form.value.data_auto_list; + } else { + list.value = Array(10).fill(default_list); + } } }); @@ -145,7 +149,7 @@ const get_products = () => { const { number, keywords } = form.value; const params = { keywords: keywords, - number: number, + number: number || 1, }; // 获取商品列表 SalerecordsAPI.getAutoList(params).then((res: any) => { @@ -167,7 +171,7 @@ watch(() => watch_data.value, (val, oldVal) => { if ((JSON.stringify(val) !== JSON.stringify(oldVal)) || props.isCommonStyle) { get_products(); } -}, { immediate: true, deep: true }); +}, { deep: true }); //#endregion //#region 轮播设置 // 轮播图key值 diff --git a/src/components/model-seckill/index.vue b/src/components/model-seckill/index.vue index 5b0cf2d8..0b67736a 100644 --- a/src/components/model-seckill/index.vue +++ b/src/components/model-seckill/index.vue @@ -365,31 +365,39 @@ const updateCountdown = () => { const list = ref([]); // 更新倒计时函数 onBeforeMount(() => { - SeckillAPI.getSeckillList({}).then((res: any) => { - const data = res.data; - if (!isEmpty(data.current)) { - if (!isEmpty(data.current.goods)) { - list.value = data.current.goods; - } else { - list.value = Array(4).fill(default_list); - } - const { status, time_first_text } = data.current.time; - seckill_time.value = { - endTime: data.current.time_end, - startTime: data.current.time_start, - status: status, - time_first_text: time_first_text, - }; - // 先执行一次倒计时,后续的等待倒计时执行 - setTimeout(() => { - updateCountdown(); - }, 0); - intervalId.value = setInterval(updateCountdown, 1000); + if (form.value.is_left == '1') { + SeckillAPI.getSeckillList({}).then((res: any) => { + const data = res.data; + init(data); + }); + } else { + init(form.value.data); + } +}); + +const init = (data: any) => { + if (!isEmpty(data.current)) { + if (!isEmpty(data.current.goods)) { + list.value = data.current.goods; } else { list.value = Array(4).fill(default_list); } - }); -}); + const { status, time_first_text } = data.current.time; + seckill_time.value = { + endTime: data.current.time_end, + startTime: data.current.time_start, + status: status, + time_first_text: time_first_text, + }; + // 先执行一次倒计时,后续的等待倒计时执行 + setTimeout(() => { + updateCountdown(); + }, 0); + intervalId.value = setInterval(updateCountdown, 1000); + } else { + list.value = Array(4).fill(default_list); + } +} // 组件销毁时,清除定时器 onUnmounted(() => { clearInterval(intervalId.value); diff --git a/src/config/const/binding.ts b/src/config/const/binding.ts index 2360b59f..eeccbd2b 100644 --- a/src/config/const/binding.ts +++ b/src/config/const/binding.ts @@ -132,11 +132,6 @@ interface defaultRealstore { goods_margin: marginStyle; goods_padding: paddingStyle; goods_radius: radiusStyle; - goods_title_img_width: number, - goods_title_img_height: number, - goods_title_img_radius: radiusStyle, - goods_title_img_inner_spacing: number, - goods_title_img_outer_spacing: number, goods_title_color: string; goods_title_typeface: string; goods_title_size: number; @@ -220,11 +215,11 @@ const defaultRealstore: defaultRealstore = { data_background_img: [], // 图片圆角 data_img_radius: { - radius: 0, - radius_top_left: 0, - radius_top_right: 0, - radius_bottom_left: 0, - radius_bottom_right: 0, + radius: 8, + radius_top_left: 8, + radius_top_right: 8, + radius_bottom_left: 8, + radius_bottom_right: 8, }, data_margin: { margin: 0, @@ -300,11 +295,11 @@ const defaultRealstore: defaultRealstore = { goods_background_img: [], // 图片圆角 goods_img_radius: { - radius: 0, - radius_top_left: 0, - radius_top_right: 0, - radius_bottom_left: 0, - radius_bottom_right: 0, + radius: 4, + radius_top_left: 4, + radius_top_right: 4, + radius_bottom_left: 4, + radius_bottom_right: 4, }, goods_margin: { margin: 0, @@ -321,23 +316,12 @@ const defaultRealstore: defaultRealstore = { padding_right: 10, }, goods_radius: { - radius: 0, - radius_top_left: 0, - radius_top_right: 0, - radius_bottom_left: 0, - radius_bottom_right: 0, + radius: 4, + radius_top_left: 4, + radius_top_right: 4, + radius_bottom_left: 4, + radius_bottom_right: 4, }, - goods_title_img_width: 12, - goods_title_img_height: 12, - goods_title_img_radius: { - radius: 0, - radius_top_left: 0, - radius_top_right: 0, - radius_bottom_left: 0, - radius_bottom_right: 0, - }, - goods_title_img_inner_spacing: 5, - goods_title_img_outer_spacing: 5, goods_title_color: '#333', goods_title_typeface: '400', goods_title_size: 12, @@ -411,11 +395,11 @@ const defaultRealstore: defaultRealstore = { direction: '180deg', background_img_style: '2', background_img: [], - radius: 0, - radius_top_left: 0, - radius_top_right: 0, - radius_bottom_left: 0, - radius_bottom_right: 0, + radius: 8, + radius_top_left: 8, + radius_top_right: 8, + radius_bottom_left: 8, + radius_bottom_right: 8, padding: 10, padding_top: 10, padding_bottom: 10, diff --git a/src/config/const/salerecords.ts b/src/config/const/salerecords.ts index d70ec859..e911fae1 100644 --- a/src/config/const/salerecords.ts +++ b/src/config/const/salerecords.ts @@ -5,6 +5,7 @@ import { cloneDeep } from "lodash"; interface defaultSalerecords { content: { content_top: object; + is_left: string, is_roll: string; rotation_direction: string; interval_time: number; @@ -69,6 +70,7 @@ const defaultSalerecords: defaultSalerecords = { ...commonTop, }, is_roll: '1', + is_left: '1', rotation_direction: 'vertical', interval_time: 3, show_number: 2, diff --git a/src/config/const/seckill.ts b/src/config/const/seckill.ts index 935ff256..6cced29d 100644 --- a/src/config/const/seckill.ts +++ b/src/config/const/seckill.ts @@ -7,6 +7,8 @@ interface DefaultSeckill { content: { content_top: object; head_state: string; + is_left: string; + data: string[], theme: string; title_type: string; title_src: uploadList[]; @@ -111,6 +113,8 @@ const defaultSeckill: DefaultSeckill = { }, // 头部状态 head_state: '1', + is_left: '1', + data: [], // 主题风格配置 theme: '1', title_type: 'image', diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue index edfa4298..9c3f869c 100644 --- a/src/views/layout/index.vue +++ b/src/views/layout/index.vue @@ -384,6 +384,10 @@ const save_formmat_form_data = (data: diy_data_item, close: boolean = false, is_ }); } else if (['salerecords'].includes(item.key)) { item.com_data.content.data_auto_list = []; + item.com_data.content.is_left = '0'; + } else if (['seckill'].includes(item.key)) { + item.com_data.content.data = []; + item.com_data.content.is_left = '0'; } return { ...item,