diff --git a/src/components/model-data-magic/model-data-magic-content.vue b/src/components/model-data-magic/model-data-magic-content.vue index f30b1021..4938861a 100644 --- a/src/components/model-data-magic/model-data-magic-content.vue +++ b/src/components/model-data-magic/model-data-magic-content.vue @@ -97,6 +97,7 @@ const data_content = { heading_title: '主标题', subtitle: '副标题', goods_list:[], + goods_ids: '', is_show: ['title', 'price'], images_list:[ { diff --git a/src/views/layout/components/main/default/coupon.ts b/src/views/layout/components/main/default/coupon.ts index f958ba81..57b78322 100644 --- a/src/views/layout/components/main/default/coupon.ts +++ b/src/views/layout/components/main/default/coupon.ts @@ -8,6 +8,7 @@ interface DefaultCoupon { title: string; desc: string; data_list: object[]; + data_ids: string; }; style: { price_color: string; @@ -41,6 +42,7 @@ const defaultCoupoin: DefaultCoupon = { // 只有主题4用到 desc: '领券下单·享购物优惠', data_list: [], + data_ids: '', }, style: { price_color: '#FF3830', diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue index d0c78e33..e248e288 100644 --- a/src/views/layout/index.vue +++ b/src/views/layout/index.vue @@ -116,6 +116,7 @@ const init = () => { DiyAPI.getInit({ id: get_id() }).then((res: any) => { if (res.data) { form.value = form_data_transfor_diy_data(res.data); + console.log(form.value); } else { is_empty.value = true; } @@ -131,13 +132,6 @@ const init = () => { // 初始化公共数据 const common_init = () => { CommonAPI.getInit().then((res: any) => { - // article_category ---- 文章分类 - // attachment_category ---- 附件分类 - // brand_category; ---- 品牌分类 - // brand_list ---- 品牌列表 - // goods_category ---- 商品分类 - // module_list ---- 模块列表 - //page_link_list ---- 页面链接 common_store.set_common(res.data); api_count.value += 1; loading_event(api_count.value); @@ -159,16 +153,26 @@ const preview = () => { console.log('预览'); }; const save = () => { - formmat_form_data(form.value); + save_formmat_form_data(form.value); }; const save_close = () => { - formmat_form_data(form.value, true); + save_formmat_form_data(form.value, true); }; -const formmat_form_data = (data: diy_data_item, close: boolean = false) => { +const save_formmat_form_data = (data: diy_data_item, close: boolean = false) => { const clone_form = cloneDeep(data); clone_form.header.show_tabs = '1'; clone_form.footer.show_tabs = '0'; + const new_array = ['goods-list', 'goods-tabs', 'article-list', 'article-tabs', 'coupon']; clone_form.diy_data = clone_form.diy_data.map((item: any) => { + if (new_array.includes(item.key)) { + item.com_data.content.data_ids = item.com_data.content.data_list.map((item: any) => item.data.id).join(',') || ''; + item.com_data.content.data_list = []; + } else if (item.key == 'data-magic') { + item.com_data.content.data_magic_list.map((item1: any) => { + item1.goods_ids = item.goods_list.map((item2: any) => item2.data.id).join(',') || ''; + item1.goods_list = []; + }); + } return { ...item, show_tabs: '0',