From 68f19bbb0b0f58e07b620209273a8432f35381db Mon Sep 17 00:00:00 2001 From: sws <1141121512@qq.com> Date: Fri, 20 Sep 2024 16:53:30 +0800 Subject: [PATCH] =?UTF-8?q?1.diy---=E9=80=89=E9=A1=B9=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/diy/diy.vue | 5 ++-- components/diy/tabs.vue | 51 ++++++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/components/diy/diy.vue b/components/diy/diy.vue index a6ac962f..0f143395 100644 --- a/components/diy/diy.vue +++ b/components/diy/diy.vue @@ -132,7 +132,7 @@ return `padding-top:${this.header_top}rpx;padding-bottom:${this.padding_footer_computer}rpx`; }, }, - mounted() { + created() { this.init(); }, methods: { @@ -152,9 +152,10 @@ this.padding_footer_computer = number * 2; }, // 选项卡回调更新数据 - tabs_click_event(data) { + tabs_click_event(data, bool) { this.setData({ diy_data: data, + is_tabs_type: bool, }); }, }, diff --git a/components/diy/tabs.vue b/components/diy/tabs.vue index a828a831..69fcc52f 100644 --- a/components/diy/tabs.vue +++ b/components/diy/tabs.vue @@ -4,13 +4,13 @@ - + - + @@ -43,6 +43,7 @@ return { style_container: '', content: '', + tabs_data: {}, // 是否滑动置顶 top_up: 0, @@ -56,13 +57,18 @@ init() { const new_content = this.value.content || {}; const new_style = this.value.style || {}; + let new_tabs_data = this.value; + const new_tabs_list = new_content.tabs_list.unshift(new_content.home_data); + new_tabs_data.tabs_list = new_tabs_list; this.setData({ + tabs_data: new_tabs_data, style_container: common_styles_computer(new_style.common_style), top_up: new_content.tabs_top_up, }); }, // 回调 tabs_click_event(index, item) { + console.log(item); // 调接口 // 回调到上一级 // 更新上一级的数据,渲染更新页面 @@ -75,27 +81,30 @@ // 获取缓存数据 new_data = uni.getStorageSync('diy-data-' + this.propId) || {}; } else { - params.id = item.id; new_data = uni.getStorageSync('diy-data-' + item.id) || {}; } - this.$emit('tabs-click', new_data); - uni.request({ - url: app.globalData.get_request_url('diy', 'index'), - method: 'POST', - data: params, - dataType: 'json', - success: (res) => { - // 数据处理 - var data = res.data.data; - if (res.data.code == 0) { - uni.setStorageSync('diy-data-' + item.id, data.config.diy_data); - this.$emit('tabs-click', data.config.diy_data); - } else { - app.globalData.showToast(res.data.msg); - } - }, - fail: () => {}, - }); + this.$emit('tabs-click', new_data, true); + if (item.data_type == '0') { + if (index !== 0) params.id = item.classify.id; + uni.request({ + url: app.globalData.get_request_url('index', 'diy'), + method: 'POST', + data: params, + dataType: 'json', + success: (res) => { + // 数据处理 + var data = res.data.data; + if (res.data.code == 0) { + uni.setStorageSync('diy-data-' + item.id, data.config.diy_data); + this.$emit('tabs-click', data.config.diy_data, true); + } else { + app.globalData.showToast(res.data.msg); + } + }, + }); + } else { + console.log('123123123123123'); + } }, }, };