From 1bae42ea2ce1358817cbdd338515b2f374d8585e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Mon, 19 Aug 2024 18:19:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model-custom/model-custom-content.vue | 3 +++ src/components/model-shop-list/index.vue | 26 +++++++++---------- .../model-shop-list-content.vue | 22 ++++++++-------- src/store/index.ts | 1 + 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/components/model-custom/model-custom-content.vue b/src/components/model-custom/model-custom-content.vue index be341d15..0905ad95 100644 --- a/src/components/model-custom/model-custom-content.vue +++ b/src/components/model-custom/model-custom-content.vue @@ -39,6 +39,9 @@ import Dialog from './components/dialog.vue'; import DragIndex from './components/index.vue'; import { cloneDeep } from 'lodash'; +import { DataSourceStore } from '@/store'; +const data_source = DataSourceStore(); + const props = defineProps({ value: { type: Object, diff --git a/src/components/model-shop-list/index.vue b/src/components/model-shop-list/index.vue index f77eb42b..80f2044d 100644 --- a/src/components/model-shop-list/index.vue +++ b/src/components/model-shop-list/index.vue @@ -58,7 +58,7 @@
-
+
{{ item.show_price_symbol }}{{ item.min_price }}{{ item.show_price_unit }}
{{ item.show_original_price_symbol }}{{ item.min_original_price }}{{ item.show_original_price_unit }}
@@ -133,17 +133,6 @@ const default_list = { new_src: [] } const list = ref([]); -watchEffect(() => { - if (form.value.product_check == '0') { - if (!isEmpty(form.value.product_list)) { - list.value = form.value.product_list; - } else { - list.value = Array(4).fill(default_list); - } - } else { - get_products(); - } -}); const get_products = () => { const { goods_category_ids, goods_brand_ids, number, sort, sort_rules } = form.value; const params = { @@ -163,6 +152,17 @@ const get_products = () => { } }); }; +watchEffect(() => { + if (form.value.product_check == '0') { + if (!isEmpty(form.value.product_list)) { + list.value = form.value.product_list; + } else { + list.value = Array(4).fill(default_list); + } + } else { + get_products(); + } +}); // 圆角设置 const content_radius = computed(() => radius_computer(new_style.value.shop_radius)); @@ -376,7 +376,7 @@ const style_container = computed(() => { height: 11.4rem; } .flex-img4 { - width: 100%; + width: 7rem; height: 7rem; } .flex-img5 { diff --git a/src/components/model-shop-list/model-shop-list-content.vue b/src/components/model-shop-list/model-shop-list-content.vue index 800e7be0..1f28acef 100644 --- a/src/components/model-shop-list/model-shop-list-content.vue +++ b/src/components/model-shop-list/model-shop-list-content.vue @@ -91,7 +91,7 @@ const state = reactive({ // 如果需要解构,确保使用toRefs const { form } = toRefs(state); -const base_list = { +const base_list = reactive({ product_style_list: [ { name: '单列展示', value: '0' }, { name: '大图展示', value: '2' }, @@ -117,16 +117,6 @@ const base_list = { { name: '降序(desc)', value: '0' }, { name: '升序(asc)', value: '1' }, ] -}; - -onBeforeMount(() => { - if (!shop_store.is_shop_api) { - shop_store.set_is_shop_api(true); - init(); - } else { - base_list.product_category_list = shop_store.category_list; - base_list.product_brand_list = shop_store.brand_list; - } }); const init = () => { @@ -138,6 +128,16 @@ const init = () => { }); }; +onMounted(() => { + if (!shop_store.is_shop_api) { + shop_store.set_is_shop_api(true); + init(); + } else { + base_list.product_category_list = shop_store.category_list; + base_list.product_brand_list = shop_store.brand_list; + } +}); + const product_list_remove = (index: number) => { form.value.product_list.splice(index, 1); }; diff --git a/src/store/index.ts b/src/store/index.ts index f34bf617..9b0b1f55 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -11,4 +11,5 @@ export * from './modules/footer-nav-content'; export * from './modules/upload'; export * from './modules/shop'; export * from './modules/url-value'; +export * from './modules/custom'; export { store }; From b8bd964a2b5efbf60f3ad83e14d3028cdd48f831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Mon, 19 Aug 2024 18:20:44 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/custom.ts | 13 +++++++++++++ src/store/modules/custom.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/api/custom.ts create mode 100644 src/store/modules/custom.ts diff --git a/src/api/custom.ts b/src/api/custom.ts new file mode 100644 index 00000000..26af9682 --- /dev/null +++ b/src/api/custom.ts @@ -0,0 +1,13 @@ +import request from '@/utils/request'; + +class CustomAPI { + /** 分类品牌查询接口*/ + static getCustominit() { + return request({ + url: `diyapi/custominit`, + method: 'post', + }); + } +} + +export default CustomAPI; diff --git a/src/store/modules/custom.ts b/src/store/modules/custom.ts new file mode 100644 index 00000000..5b58d086 --- /dev/null +++ b/src/store/modules/custom.ts @@ -0,0 +1,29 @@ +import { ref } from 'vue'; +import { defineStore } from 'pinia'; + +export const DataSourceStore = defineStore('dataSource', () => { + interface product_list { + id: number; + name: string; + }; + // 上传是否需要调接口判断 + const is_data_source_api = ref(false); + // 数据源 + const data_source_list = ref([]); + // 存储上传分类列表 + const set_data_source = (category: product_list[], brand: product_list[]) => { + data_source_list.value = category; + is_data_source_api.value = true; + }; + // 如果为false 则转为true + const set_is_shop_api = (bool: boolean) => { + is_data_source_api.value = bool; + }; + + return { + data_source_list, + is_data_source_api, + set_data_source, + set_is_shop_api, + }; +}); From 3de196663ce7258e7e15672b9263c16dfbf15b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Tue, 20 Aug 2024 09:35:57 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8E=A5=E5=8F=A3=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model-image/model-image-style.vue | 2 +- .../model-text/model-text-style.vue | 5 +- .../model-custom/model-custom-content.vue | 51 +++++++++++++++---- .../model-shop-list-content.vue | 9 +++- src/store/modules/custom.ts | 20 +++++--- 5 files changed, 63 insertions(+), 24 deletions(-) diff --git a/src/components/common/custom-module/model-image/model-image-style.vue b/src/components/common/custom-module/model-image/model-image-style.vue index 19009184..d6dfbd33 100644 --- a/src/components/common/custom-module/model-image/model-image-style.vue +++ b/src/components/common/custom-module/model-image/model-image-style.vue @@ -8,7 +8,7 @@
- +