From abab4c1e35cf47c77ddd26e6a2edb5cb585eb0ad Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Wed, 25 Sep 2024 10:58:02 +0800 Subject: [PATCH] diy --- App.vue | 9 ++- components/diy/diy.vue | 14 ++-- pages/design/design.vue | 3 +- pages/diy/diy.vue | 144 +++++++++++++++++++++++++++++++++++++--- 4 files changed, 149 insertions(+), 21 deletions(-) diff --git a/App.vue b/App.vue index b22c7698..35bf8757 100644 --- a/App.vue +++ b/App.vue @@ -182,8 +182,13 @@ // 商品数据缓存key cache_goods_data_key: 'cache_goods_data_key', - // 页面设计数据缓存key - cache_design_data_key: 'cache_design_data_key', + // 页面设计页面数据缓存key + cache_design_page_data_key: 'cache_design_page_data_key', + + // diy模块数据缓存key + cache_diy_data_key: 'cache_diy_data_key', + // diy页面数据缓存key + cache_diy_page_data_key: 'cache_diy_page_data_key', // 默认用户头像 default_user_head_src: '/static/images/common/user.png', diff --git a/components/diy/diy.vue b/components/diy/diy.vue index 763eb93c..a648a415 100644 --- a/components/diy/diy.vue +++ b/components/diy/diy.vue @@ -102,7 +102,7 @@ type: Object, default: () => ({}), }, - propHomeId: { + propDataId: { type: [String, Number], default: '', }, @@ -155,7 +155,6 @@ // 选项卡数据 tabs_data: {}, diy_data: [], - tabs_home_id: this.propHomeId, // 商品列表 goods_list: [], goods_total: 0, @@ -173,6 +172,8 @@ // 判断数据是否在加载中 data_is_loading: 0, key: '', + // 缓存key + cache_key: app.globalData.data.cache_diy_data_key }; }, computed: { @@ -186,7 +187,6 @@ methods: { init() { // tabs选项卡数据过滤 - // const filter_tabs_list = this.value.tabs_data || []; this.setData({ key: get_math(), header_data: this.value.header, @@ -194,7 +194,7 @@ diy_data: this.value.diy_data, tabs_data: this.value.tabs_data, }); - uni.setStorageSync('diy-data-' + this.propId, this.value.diy_data); + uni.setStorageSync(this.cache_key + this.propDataId, this.value.diy_data); }, footer_height_computer(number) { this.padding_footer_computer = number * 2; @@ -210,7 +210,7 @@ id: tabs_id, }; if (tabs_id) { - new_data = uni.getStorageSync('diy-data-' + tabs_id) || []; + new_data = uni.getStorageSync(this.cache_key + tabs_id) || []; if (new_data.length > 0) { // 先使用缓存数据展示 this.setData({ @@ -231,7 +231,7 @@ const data = res.data.data.data; if (res.data.code == 0) { new_data = data?.config.diy_data || []; - uni.setStorageSync('diy-data-' + tabs_id, new_data); + uni.setStorageSync(this.cache_key + tabs_id, new_data); this.setData({ diy_data: new_data, }); @@ -248,7 +248,7 @@ this.get_goods_list(1); } } else { - new_data = uni.getStorageSync('diy-data-' + this.tabs_home_id) || []; + new_data = uni.getStorageSync(this.cache_key + this.propDataId) || []; // 先使用缓存数据展示 this.setData({ diy_data: new_data, diff --git a/pages/design/design.vue b/pages/design/design.vue index 48d62e67..b2de9b5e 100644 --- a/pages/design/design.vue +++ b/pages/design/design.vue @@ -80,7 +80,7 @@ // 获取数据 get_data(params = {}) { // 还没有数据则读取缓存 - var cache_key = app.globalData.data.cache_design_data_key; + var cache_key = app.globalData.data.cache_design_page_data_key+(this.params.id || 0); if (this.load_status == 0) { // 本地缓存数据 var upd_data = uni.getStorageSync(cache_key) || null; @@ -159,7 +159,6 @@ load_status: 1, data_list_loding_msg: this.$t('common.internet_error_tips') }); - app.globalData.showToast(this.$t('common.internet_error_tips')); } }); } diff --git a/pages/diy/diy.vue b/pages/diy/diy.vue index 774b688a..01e638b0 100644 --- a/pages/diy/diy.vue +++ b/pages/diy/diy.vue @@ -1,26 +1,150 @@ - - - + \ No newline at end of file