diff --git a/components/diy/article-list.vue b/components/diy/article-list.vue index 49b99ae1..cebc04b4 100644 --- a/components/diy/article-list.vue +++ b/components/diy/article-list.vue @@ -58,7 +58,7 @@ diff --git a/components/diy/modules/tabs-view.vue b/components/diy/modules/tabs-view.vue index 3a63ce45..4943d09d 100644 --- a/components/diy/modules/tabs-view.vue +++ b/components/diy/modules/tabs-view.vue @@ -23,7 +23,7 @@ - + {{ item.title }} diff --git a/components/diy/tabs.vue b/components/diy/tabs.vue index 85c896b1..a828a831 100644 --- a/components/diy/tabs.vue +++ b/components/diy/tabs.vue @@ -31,6 +31,10 @@ type: Object, default: () => ({}), }, + propId: { + type: String, + default: '', + }, }, components: { componentDiyModulesTabsView, @@ -62,6 +66,36 @@ // 调接口 // 回调到上一级 // 更新上一级的数据,渲染更新页面 + // 请求远程数据 + let new_data = {}; + let params = { + id: this.propId, + }; + if (index == 0) { + // 获取缓存数据 + 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: () => {}, + }); }, }, }; diff --git a/pages/index/index.vue b/pages/index/index.vue index 225b9e79..4c9385db 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,28 +3,30 @@ - + + + - + - + - + - {{user_location.text || ''}} + {{ user_location.text || '' }} @@ -57,11 +59,11 @@ - + @onicon="search_icon_event" propIcon="icon-scan" :propIsIconOnEvent="true" - > + > @@ -78,7 +80,7 @@ - + @@ -92,7 +94,10 @@ - {{$t('index.index.t8bll8')}}{{$t('index.index.t8bll9')}} + + {{ $t('index.index.t8bll8') }}{{ $t('index.index.t8bll9') }} + @@ -124,7 +129,7 @@ - {{$t('common.more')}} + {{ $t('common.more') }} @@ -138,27 +143,27 @@ {{ plugins_realstore_data.base.home_data_list_title }} - {{$t('common.more')}} + {{ $t('common.more') }} - + {{ plugins_shop_data.base.home_data_list_title }} - {{$t('common.more')}} + {{ $t('common.more') }} - + {{ plugins_binding_data.base.home_data_list_title }} - {{$t('common.more')}} + {{ $t('common.more') }} - + @@ -168,7 +173,7 @@ - + @@ -188,7 +193,7 @@ {{ floor.name }} {{ floor.describe }} - {{$t('common.more')}} + {{ $t('common.more') }} @@ -363,7 +368,7 @@ top_content_style: 'padding-top:' + (bar_height + 14) + 'px;', // #endif // #ifdef APP - top_content_style: 'padding-top:' + (bar_height) + 'px;', + top_content_style: 'padding-top:' + bar_height + 'px;', // #endif // 是否单页预览 is_single_page: app.globalData.is_current_single_page() || 0, @@ -424,7 +429,7 @@ componentBindingList, componentMagicList, componentAppAdmin, - componentDiy + componentDiy, }, props: {}, @@ -438,23 +443,23 @@ app.globalData.page_event_onshow_handle(); // 加载数据 - if(this.is_home_location_choice == 1) { + if (this.is_home_location_choice == 1) { // 用户位置初始化 this.user_location_init(); // 先解绑自定义事件 uni.$off('refresh'); // 监听自定义事件并进行页面刷新操作 -     uni.$on('refresh', (data) => { + uni.$on('refresh', (data) => { // 初始位置数据 -         if((data.location_success || false) == true) { + if ((data.location_success || false) == true) { // 用户位置初始化 this.user_location_init(); // 重新请求数据 // #ifdef APP this.init(); // #endif -         } -     }); + } + }); } // 数据加载 @@ -476,7 +481,7 @@ // 下拉刷新 onPullDownRefresh() { - if(this.data_list_loding_status === 1) { + if (this.data_list_loding_status === 1) { uni.stopPullDownRefresh(); } else { this.init(); @@ -505,11 +510,10 @@ init(params = {}) { // 还没有数据则读取缓存 var cache_key = app.globalData.data.cache_index_data_key; - if(this.load_status == 0) - { + if (this.load_status == 0) { // 本地缓存数据 var upd_data = uni.getStorageSync(cache_key) || null; - if(upd_data != null) { + if (upd_data != null) { // 先使用缓存数据展示 this.setData(upd_data); @@ -522,13 +526,13 @@ } // 网络检查 - if((params || null) == null || (params.loading || 0) == 0) { + if ((params || null) == null || (params.loading || 0) == 0) { app.globalData.network_type_handle(this, 'init', params); return false; } // 没有缓存数据则开启加载层 - if(upd_data == null) { + if (upd_data == null) { this.setData({ data_list_loding_status: 1, }); @@ -556,7 +560,7 @@ cart_total: data.cart_total.buy_number || 0, message_total: parseInt(data.message_total || 0), right_icon_list: data.right_icon_list || [], - data_list_loding_status: (data_list == null || data_list.length == 0) ? 0 : 3, + data_list_loding_status: data_list == null || data_list.length == 0 ? 0 : 3, plugins_sort_list: data.plugins_sort_list || [], plugins_seckill_data: data.plugins_seckill_data || null, plugins_salerecords_data: (data.plugins_salerecords_data || null) == null || data.plugins_salerecords_data.length <= 0 ? null : data.plugins_salerecords_data, @@ -572,7 +576,7 @@ plugins_magic_data: data.plugins_magic_data || null, }; // 如果开启了哀悼灰色则不固定导航 - if(upd_data.plugins_mourning_data_is_app == 1) { + if (upd_data.plugins_mourning_data_is_app == 1) { upd_data['common_app_is_header_nav_fixed'] = 0; } this.setData(upd_data); @@ -584,8 +588,8 @@ this.plugins_popupscreen_handle(); // 是否需要重新加载数据 - if(parseInt(data.is_result_data_cache || 0) == 1) { - this.init({is_cache: 0}); + if (parseInt(data.is_result_data_cache || 0) == 1) { + this.init({ is_cache: 0 }); } else { // 导航购物车处理、缓存数据则不更新导航角标 if (this.cart_total <= 0) { @@ -632,7 +636,7 @@ // 轮播数据处理 if (this.load_status == 0 || (this.top_content_search_bg_color || null) == null) { - var color = (this.banner_list && this.banner_list.length > 0 && (this.banner_list[0]['bg_color'] || null) != null) ? this.banner_list[0]['bg_color'] : theme_color; + var color = this.banner_list && this.banner_list.length > 0 && (this.banner_list[0]['bg_color'] || null) != null ? this.banner_list[0]['bg_color'] : theme_color; this.change_banner(color); } @@ -661,7 +665,7 @@ // 用户地理位置初始化 user_location_init() { this.setData({ - user_location: app.globalData.choice_user_location_init() + user_location: app.globalData.choice_user_location_init(), }); }, @@ -732,4 +736,4 @@ \ No newline at end of file +