From 9e7a1b3ee37c8b699539cb1df1795f4782ff46fb Mon Sep 17 00:00:00 2001 From: Yer <17633066053@163.com> Date: Wed, 9 Aug 2023 14:56:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E7=AB=AF=E6=96=B0=E5=A2=9E=E6=A5=BC=E5=B1=82=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=88=B0=E6=9C=AC=E5=9C=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/page-decoration/wap/navbar.vue | 1 - seller/src/views/shop/renovation.vue | 43 +++++++++++++++++++ seller/src/views/shop/wap/index.vue | 15 +++++++ seller/src/views/shop/wap/navbar.vue | 19 +++++++- 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/manager/src/views/page-decoration/wap/navbar.vue b/manager/src/views/page-decoration/wap/navbar.vue index fa848aef..ae6c1f77 100644 --- a/manager/src/views/page-decoration/wap/navbar.vue +++ b/manager/src/views/page-decoration/wap/navbar.vue @@ -110,7 +110,6 @@ export default { }, }, mounted() { - console.log( this.getStore('managerMobilePageCache') ) this.hasCache = this.getStore('managerMobilePageCache') ? true : false; }, methods: { diff --git a/seller/src/views/shop/renovation.vue b/seller/src/views/shop/renovation.vue index a4649c0d..004ef1c7 100644 --- a/seller/src/views/shop/renovation.vue +++ b/seller/src/views/shop/renovation.vue @@ -28,6 +28,8 @@ >保存模板 + + @@ -42,16 +44,57 @@ export default { ModelForm, }, mounted() { + // 先读缓存,如果缓存有值则读缓存。 + const cache = this.getStore('managerPCPageCache') + this.hasCache = !!cache; + if(cache){ + this.$Modal.confirm({ + title: '提示', + content: '获取到本地有缓存数据,是否使用缓存数据?', + okText: '使用', + cancelText: '取消', + onOk: () => { + let pageData = cache; + if (pageData) { + pageData = JSON.parse(pageData); + if (pageData.list[0].type === "topAdvert") { + // topAdvert 为顶部广告 navList为导航栏 + this.$refs.modelForm.topAdvert = pageData.list[0]; + this.$refs.modelForm.navList = pageData.list[1]; + pageData.list.splice(0, 2); + this.modelForm = pageData; + } else { + this.modelForm = { list: [] }; + } + } else { + this.modelForm = { list: [] }; + } + } + }); + } this.getTemplateItem(this.$route.query.id); }, data() { return { + hasCache:false, modelData, // 可选模块数据 modelForm: { list: [] }, // 模板数据 submitLoading: false, // 提交加载状态 }; }, methods: { + clearCache(){ + this.setStore('managerPCPageCache', '') + this.$Message.success('清除成功') + }, + // 将楼层装修的内容写入到本地缓存中 + witeLocalStore(){ + const data ={...this.modelForm} + data.list.unshift(this.$refs.modelForm.navList); + data.list.unshift(this.$refs.modelForm.topAdvert); + this.setStore('managerPCPageCache', data) + this.$Message.success('写入成功') + }, saveTemplate() { // 保存模板 this.submitTemplate(this.$route.query.pageShow ? "OPEN" : "CLOSE"); diff --git a/seller/src/views/shop/wap/index.vue b/seller/src/views/shop/wap/index.vue index 0574f1e4..d850b51b 100644 --- a/seller/src/views/shop/wap/index.vue +++ b/seller/src/views/shop/wap/index.vue @@ -116,6 +116,21 @@ export default { // 初始化数据 init() { + // 先读缓存,如果缓存有值则读缓存。 + const cache = this.getStore('sellerMobilePageCache') + if(cache){ + this.$Modal.confirm({ + title: '提示', + content: '获取到本地有缓存数据,是否使用缓存数据?', + okText: '使用', + cancelText: '取消', + onOk: () => { + const data = JSON.parse(cache); + this.contentData = data; + } + }); + + } if (!this.$route.query.id) return false; API_Other.getHomeData(this.$route.query.id).then(res=>{ this.contentData = JSON.parse(res.result.pageData) diff --git a/seller/src/views/shop/wap/navbar.vue b/seller/src/views/shop/wap/navbar.vue index 45b7c9a4..5b8771a9 100644 --- a/seller/src/views/shop/wap/navbar.vue +++ b/seller/src/views/shop/wap/navbar.vue @@ -22,6 +22,7 @@
--> + 关 +
+ 将当前装修内容写入到本地缓存中,下次进入页面时可继续使用 + +
@@ -56,6 +61,7 @@ import * as API_Other from "@/api/other.js"; export default { data() { return { + hasCache:false, // 是否有缓存 progress: true, // 展示进度 num: 20, // 提交进度 saveDialog: false, // 加载状态 @@ -87,8 +93,19 @@ export default { }; }, watch: {}, - mounted() {}, + mounted() { + this.hasCache = this.getStore('sellerMobilePageCache') ? true : false; + }, methods: { + clearCache(){ + this.setStore('sellerMobilePageCache',''); + this.$Message.success('清空成功') + }, + // 将楼层装修的内容写入到本地缓存中 + witeLocalStore(){ + this.setStore('sellerMobilePageCache', this.$store.state.styleStore) + this.$Message.success('写入成功') + }, clickBtn(val) { this.way.forEach((item, index) => { item.selected = false;