diff --git a/src/api/goods-magic.ts b/src/api/goods-magic.ts new file mode 100644 index 00000000..d54208cb --- /dev/null +++ b/src/api/goods-magic.ts @@ -0,0 +1,13 @@ +import request from '@/utils/request'; + +class CustomAPI { + /** 分类品牌查询接口*/ + static getGoodsmagicinit() { + return request({ + url: `diyapi/goodsmagicinit`, + method: 'post', + }); + } +} + +export default CustomAPI; diff --git a/src/components/common/data-tabs-common/data-custom-content.vue b/src/components/common/data-tabs-common/data-custom-content.vue index 659348cd..02dfa45d 100644 --- a/src/components/common/data-tabs-common/data-custom-content.vue +++ b/src/components/common/data-tabs-common/data-custom-content.vue @@ -247,15 +247,18 @@ const getCustominit = () => { const { data_source } = res.data; options.value = data_source; data_source_store.set_data_source(data_source); + data_source_store.set_is_data_source_api(true); // 数据处理 processing_data(form.value.data_source); data_processing(); + }).catch((err) => { + data_source_store.set_is_data_source_api(false); }); }; onBeforeMount(() => { + // 如果没有数据源,那么就请求一次数据源 if (!data_source_store.is_data_source_api) { - data_source_store.set_is_data_source_api(true); getCustominit(); } else { options.value = data_source_store.data_source_list; diff --git a/src/components/common/div-content/index.vue b/src/components/common/div-content/index.vue index 935906e1..135155a4 100644 --- a/src/components/common/div-content/index.vue +++ b/src/components/common/div-content/index.vue @@ -98,6 +98,10 @@ + + + + diff --git a/src/components/model-custom/model-custom-content.vue b/src/components/model-custom/model-custom-content.vue index 0bf2a458..5f6d4b3d 100644 --- a/src/components/model-custom/model-custom-content.vue +++ b/src/components/model-custom/model-custom-content.vue @@ -49,7 +49,8 @@ 数据设置 - + + {{ +item === 0 ? '指定数据' : '筛选数据' }} @@ -227,6 +228,7 @@ interface custom_config { show_type: string[], show_number: number[], data_type: string[], + is_type_show: boolean, filter_config: object, appoint_config: object, } @@ -249,15 +251,20 @@ const getCustominit = () => { const { data_source } = res.data; options.value = data_source; data_source_store.set_data_source(data_source); + // 接口成功之后设置true + data_source_store.set_is_data_source_api(true); // 数据处理 processing_data(form.value.data_source); data_processing(); + }).catch((err) => { + // 接口成功之后设置为false,下次仍旧获取数据 + data_source_store.set_is_data_source_api(false); }); }; onBeforeMount(() => { + // 如果没有数据源,那么就请求一次接口, 获取数据源 if (!data_source_store.is_data_source_api) { - data_source_store.set_is_data_source_api(true); getCustominit(); } else { options.value = data_source_store.data_source_list; @@ -280,6 +287,7 @@ const data_processing = () => { show_type: custom_config?.show_type || ['vertical', 'vertical-scroll', 'horizontal'], show_number: custom_config?.show_number || [1, 2, 3, 4], data_type: custom_config?.data_type || [0, 1], + is_type_show: custom_config?.is_type_show || true, }; filter_data_handling('old'); default_data(); @@ -337,7 +345,7 @@ const filter_data_handling = (type: string = 'old') => { data_type: type == 'old'? (form.value.data_source_content?.data_type ?? data_type) : data_type, }; let new_data_field = {}; - // 根据不同的数据初始化不同的内容 + // 根据不同的数据初始化不同的内容, 两个处理看似一样,实际上是后边的覆盖前面的内容,避免老数据没有更新 if (staging_data.data_type === 0) { // 如果是手动模式,就取手动模式的数据为默认数据,避免两者重复导致数据冲突 new_data_field = { @@ -378,6 +386,7 @@ const url_value_dialog_visible = ref(false); const default_type_data = ref({}) const url_value_multiple_bool = ref(true); const emits = defineEmits(['data_source_change']); +// 动态数据切换时触发的逻辑 const changeDataSource = (key: string) => { form.value.is_custom_data = '0'; const type_data = options.value.filter((item) => item.type == key); @@ -409,6 +418,7 @@ const changeDataSource = (key: string) => { show_type: custom_config?.show_type || ['vertical', 'vertical-scroll', 'horizontal'], show_number: custom_config?.show_number || [1, 2, 3, 4], data_type: custom_config?.data_type || [0, 1], + is_type_show: custom_config?.is_type_show || true, }; // 默认数据处理 default_data(); @@ -478,6 +488,7 @@ const url_value_dialog_call_back = (item: any[]) => { } data_list_index_update(); }; +// 更新索引, 避免添加多条时,索引不连续 const data_list_index_update = () => { if (form.value.data_source_content.data_list.length > 0) { form.value.data_source_content.data_list.forEach((item: any, index: number) => { diff --git a/src/components/model-goods-magic/index.vue b/src/components/model-goods-magic/index.vue new file mode 100644 index 00000000..f429d39f --- /dev/null +++ b/src/components/model-goods-magic/index.vue @@ -0,0 +1,554 @@ + + + + + + + + + + {{ item.title }} + + {{ item.show_price_symbol }}{{ item.min_price }} + {{ item.show_price_unit }} + + + + + + + + + + + + + + + + + + + + {{ item.title }} + {{ item.simple_desc }} + + + {{ icon_data.name }} + + + + + + {{ 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 }} + + + + + + + + 已售{{ item.sales_count }}件 + + + + + + + {{ form.shop_button_text }} + + + + + + + + + + + {{ 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 }} + + + + + + + {{ form.shop_button_text }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ item.title }} + {{ item.simple_desc }} + + + {{ icon_data.name }} + + + + + + {{ 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 }} + + + + + + + {{ form.shop_button_text }} + + + + + + + + + + + + + + + + + + diff --git a/src/components/model-goods-magic/model-goods-magic-content.vue b/src/components/model-goods-magic/model-goods-magic-content.vue new file mode 100644 index 00000000..a22528c9 --- /dev/null +++ b/src/components/model-goods-magic/model-goods-magic-content.vue @@ -0,0 +1,417 @@ + + + + + + + 列表设置 + + + + + + + + {{ item.name }} + + + + + 单列展示 + 两列展示 + 三列展示 + 四列展示 + + + + + + + + 商品设置 + + + + + {{ +item === 0 ? '指定数据' : '筛选数据' }} + + + + + + + +添加 + + + + + + + + + + + + + + + 角标设置 + + + + + + + + + + diff --git a/src/components/model-goods-magic/model-goods-magic-setting.vue b/src/components/model-goods-magic/model-goods-magic-setting.vue new file mode 100644 index 00000000..80938f9b --- /dev/null +++ b/src/components/model-goods-magic/model-goods-magic-setting.vue @@ -0,0 +1,47 @@ + + + + + + + + + + + + diff --git a/src/components/model-goods-magic/model-goods-magic-styles.vue b/src/components/model-goods-magic/model-goods-magic-styles.vue new file mode 100644 index 00000000..b0f265cc --- /dev/null +++ b/src/components/model-goods-magic/model-goods-magic-styles.vue @@ -0,0 +1,210 @@ + + + + + 商品样式 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 轮播设置 + + + + + + + + + + + 平移 + 切屏 + + + + + + + + + + + + + 购物车按钮 + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/config/const/goods-magic.ts b/src/config/const/goods-magic.ts new file mode 100644 index 00000000..26067d15 --- /dev/null +++ b/src/config/const/goods-magic.ts @@ -0,0 +1,243 @@ +import defaultCommon from './index'; +import defaultSetting from '../setting/index'; +import subscriptStyle from './subscript-style'; +import commonTop from './common-top'; +import { online_url } from '@/utils'; +const new_url = await online_url('/static/app/common/').then((res) => res); +interface content { + data_ids: Array; + data_list: Array; + data_auto_list: Array; +} +interface DefaultProductMagic { + content: { + content_top: object; + theme: string; + carousel_col: number; + is_custom_data: string; + data_source_content: content; + is_price_solo: string; + is_show: string[]; + simple_desc_row: string; + static_img: uploadList[]; + is_shop_show: string; + shop_type: string; + shop_button_text: string; + shop_button_icon_class: string; + shop_button_effect: string; + seckill_subscript_show: string; + subscript_type: string; + subscript_img_src: uploadList[]; + subscript_icon_class: string; + subscript_text: string; + }; + style: { + shop_direction: string; + shop_color_list: color_list[]; + shop_background_img_style: string; + shop_background_img: uploadList[]; + shop_padding: paddingStyle; + shop_margin: marginStyle; + border_is_show: string; + border_color: string; + border_style: string; + border_size: paddingStyle; + // 阴影 + box_shadow_color: string; + box_shadow_x: number; + box_shadow_y: number; + box_shadow_blur: number; + box_shadow_spread: number; + shop_img_radius: radiusStyle; + shop_radius: radiusStyle; + content_outer_spacing: number; + content_outer_height: number; + content_img_width: number | undefined; + content_img_height: number | undefined; + is_roll: string; + interval_time: number; + rolling_fashion: string; + content_spacing: number; + shop_title_typeface: string; + shop_title_size: number; + shop_title_color: string; + shop_simple_desc_typeface: string; + shop_simple_desc_size: number; + shop_simple_desc_color: string; + title_simple_desc_spacing: number; + shop_price_typeface: string; + shop_price_size: number; + shop_price_color: string; + shop_price_symbol_color: string; + shop_price_symbol_size: number; + shop_price_unit_color: string; + shop_price_unit_size: number; + shop_original_price_color: string; + shop_original_price_size: number; + shop_sold_number_typeface: string; + shop_sold_number_size: number; + shop_sold_number_color: string; + shop_score_typeface: string; + shop_score_size: number; + shop_score_color: string; + shop_button_typeface:string; + shop_button_size: number; + shop_button_color: color_list[]; + shop_button_text_color: string; + shop_icon_size: number; + shop_icon_color: string; + subscript_style: object; + common_style: object; + }; +} +const DefaultProductMagic: DefaultProductMagic = { + content: { + content_top: { + ...commonTop, + }, + carousel_col: 3, + // 商品风格 + theme: '0', + is_custom_data: '1',// 是否自定义数据源 + // 数据源内容 + data_source_content: { + // 存放手动输入的id + data_ids: [], + // 手动输入 + data_list: [], + // 自动 + data_auto_list: [], + }, + // 价格是否独行 + is_price_solo: '1', + // 显示内容 + is_show: ['title', 'plugins_view_icon', 'price', 'sales_count', 'original_price'], + simple_desc_row: '1', + // 价格图标地址 + static_img: [{ id: 2, url: new_url + 'price.png', original: '角标', title: '角标', ext: '.png', type: 'img' }], + // 是否显示购买按钮 + is_shop_show: '1', + // 购买按钮类型 + shop_type: 'text', + shop_button_text: '购买', + shop_button_icon_class: 'cart', + // 点击购买按钮的操作处理 + shop_button_effect: '0', + // 角标配置 + seckill_subscript_show: '0', + subscript_type: 'text', + subscript_img_src: [], + subscript_icon_class: '', + subscript_text: '', + }, + style: { + shop_direction: '90deg', + shop_color_list: [{ color: '#fff', color_percentage: undefined }], + shop_background_img_style: '0', + shop_background_img: [], + // 边框样式 + border_is_show: '0', + border_color: '#FF3F3F', + border_style: 'solid', + border_size: { + padding: 1, + padding_top: 1, + padding_right: 1, + padding_bottom: 1, + padding_left: 1, + }, + // 阴影 + box_shadow_color: '', + box_shadow_x: 0, + box_shadow_y: 0, + box_shadow_blur: 0, + box_shadow_spread: 0, + // 商品内边距 + shop_padding: { + padding: 10, + padding_top: 10, + padding_bottom: 10, + padding_left: 10, + padding_right: 10, + }, + shop_margin: { + margin: 0, + margin_top: 0, + margin_bottom: 0, + margin_left: 0, + margin_right: 0, + }, + // 图标圆角 + shop_img_radius: { + radius: 4, + radius_top_left: 4, + radius_top_right: 4, + radius_bottom_left: 4, + radius_bottom_right: 4, + }, + // 商品圆角 + shop_radius: { + radius: 8, + radius_top_left: 8, + radius_top_right: 8, + radius_bottom_left: 8, + radius_bottom_right: 8, + }, + content_outer_spacing: 10, // 商品外间距 + // 商品内间距 + content_spacing: 10, + // 商品高度 + content_outer_height: 232, + content_img_width: 110, + content_img_height: 120, + // 是否滚动 + is_roll: '1', + interval_time: 3, + rolling_fashion: 'translation', // 滚动方式 translation 平移 cut-screen 切屏 + // 商品内容大小和颜色设置 + shop_title_typeface: 'bold', + shop_title_size: 14, + shop_title_color: "#333333", + shop_simple_desc_typeface: '400', + shop_simple_desc_size: 12, + shop_simple_desc_color: "#999", + title_simple_desc_spacing: 4, + shop_price_typeface: 'bold', + shop_price_size: 18, + shop_price_color: "#EA3323;", + shop_price_symbol_color: '#EA3323', + shop_price_symbol_size: 9, + shop_price_unit_color: '#EA3323', + shop_price_unit_size: 9, + shop_original_price_color: '#999', + shop_original_price_size: 12, + shop_sold_number_typeface: '400', + shop_sold_number_size: 10, + shop_sold_number_color: "#999999", + shop_score_typeface: '400', + shop_score_size: 10, + shop_score_color: "#999999", + shop_button_typeface:'400', + shop_button_size: 12, + // 购买按钮渐变颜色 + shop_button_color: [ + { + color: '#FF3D53', + color_percentage: undefined + }, + { + color: '#D73A3A', + color_percentage: undefined + } + ], + // 购买按钮文字颜色 + shop_button_text_color: '#fff', + // 购买按钮图标颜色和大小 + shop_icon_size: 10, + shop_icon_color: "#fff", + subscript_style: subscriptStyle, + common_style: { ...defaultCommon, padding: 10, padding_top: 10, padding_bottom: 10, padding_left: 10, padding_right: 10 }, + }, +}; + +export default DefaultProductMagic; diff --git a/src/store/modules/custom.ts b/src/store/modules/custom.ts index f835be17..71aa4120 100644 --- a/src/store/modules/custom.ts +++ b/src/store/modules/custom.ts @@ -14,22 +14,35 @@ export const DataSourceStore = defineStore('dataSource', () => { type: string; }; const is_children_custom = ref(false); - // 上传是否需要调接口判断 + // 自定义是否需要调接口判断 const is_data_source_api = ref(false); // 数据源 const data_source_list = ref([]); + // 自定义是否需要调接口判断 + const is_goods_source_api = ref(false); + // 数据源 + const goods_source_list = ref([]); // 自定义历史记录 const custom_records_index = ref(-1); const custom_records = ref([]); // 自定义组历史记录 const custom_group_records_index = ref(-1); const custom_group_records = ref([]); - // 存储上传分类列表 + // 存储自定义分类列表 const set_data_source = (data_source_content: data_source_content[]) => { data_source_list.value = data_source_content; is_data_source_api.value = true; }; // 如果为false 则转为true + const set_is_goods_source_api = (bool: boolean) => { + is_goods_source_api.value = bool; + }; + // 存储自定义分类列表 + const set_goods_source = (data_source_content: data_source_content[]) => { + goods_source_list.value = data_source_content; + is_goods_source_api.value = true; + }; + // 如果为false 则转为true const set_is_data_source_api = (bool: boolean) => { is_data_source_api.value = bool; }; @@ -59,8 +72,12 @@ export const DataSourceStore = defineStore('dataSource', () => { is_children_custom, data_source_list, is_data_source_api, + goods_source_list, + is_goods_source_api, set_data_source, set_is_data_source_api, + set_goods_source, + set_is_goods_source_api, set_is_children_custom, set_custom_records, set_custom_records_index, diff --git a/src/views/layout/components/main/index.ts b/src/views/layout/components/main/index.ts index 77303d3e..a36e1453 100644 --- a/src/views/layout/components/main/index.ts +++ b/src/views/layout/components/main/index.ts @@ -33,6 +33,7 @@ import defaultSalerecords from '@/config/const/salerecords'; import defaultAsk from '@/config/const/ask'; import defaultAskTabs from '@/config/const/ask-tabs'; import defaultActivity from '@/config/const/activity'; +import defaultGoodsMagic from '@/config/const/goods-magic'; // 系统设置 interface DefaultSettings { @@ -71,6 +72,7 @@ interface DefaultSettings { ask: object; ask_tabs: object; activity: object; + goods_magic: object; } const defaultSettings: DefaultSettings = { @@ -109,6 +111,7 @@ const defaultSettings: DefaultSettings = { ask: defaultAsk, ask_tabs: defaultAskTabs, activity: defaultActivity, + goods_magic: defaultGoodsMagic, }; export default defaultSettings; diff --git a/src/views/layout/components/settings/index.vue b/src/views/layout/components/settings/index.vue index 5158e255..9a6c3e74 100644 --- a/src/views/layout/components/settings/index.vue +++ b/src/views/layout/components/settings/index.vue @@ -82,6 +82,10 @@ + + + + diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue index 9c3f869c..7c91e95b 100644 --- a/src/views/layout/index.vue +++ b/src/views/layout/index.vue @@ -259,7 +259,7 @@ const save_formmat_form_data = (data: diy_data_item, close: boolean = false, is_ // 层级更深 const new_array_4 = ['data-magic']; // 自定义数据 - const new_array_5 = ['custom']; + const new_array_5 = ['custom', 'goods-magic']; // 导航组 const new_array_6 = ['nav-group']; clone_form.diy_data = clone_form.diy_data.map((item: any) => {