feat: 商家端新增楼层数据保存到本地功能

master
Yer 2023-08-09 14:56:57 +08:00
parent c5e06ad1f2
commit 9e7a1b3ee3
4 changed files with 76 additions and 2 deletions

View File

@ -110,7 +110,6 @@ export default {
}, },
}, },
mounted() { mounted() {
console.log( this.getStore('managerMobilePageCache') )
this.hasCache = this.getStore('managerMobilePageCache') ? true : false; this.hasCache = this.getStore('managerMobilePageCache') ? true : false;
}, },
methods: { methods: {

View File

@ -28,6 +28,8 @@
>保存模板</Button >保存模板</Button
> >
<Button class="ml_10" @click="resetTemplate"></Button> <Button class="ml_10" @click="resetTemplate"></Button>
<Button class="ml_10" @click="witeLocalStore"></Button>
<Button class="ml_10" v-if="hasCache" @click="clearCache"></Button>
</div> </div>
</div> </div>
</template> </template>
@ -42,16 +44,57 @@ export default {
ModelForm, ModelForm,
}, },
mounted() { 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); this.getTemplateItem(this.$route.query.id);
}, },
data() { data() {
return { return {
hasCache:false,
modelData, // modelData, //
modelForm: { list: [] }, // modelForm: { list: [] }, //
submitLoading: false, // submitLoading: false, //
}; };
}, },
methods: { 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() { saveTemplate() {
// //
this.submitTemplate(this.$route.query.pageShow ? "OPEN" : "CLOSE"); this.submitTemplate(this.$route.query.pageShow ? "OPEN" : "CLOSE");

View File

@ -116,6 +116,21 @@ export default {
// //
init() { 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; if (!this.$route.query.id) return false;
API_Other.getHomeData(this.$route.query.id).then(res=>{ API_Other.getHomeData(this.$route.query.id).then(res=>{
this.contentData = JSON.parse(res.result.pageData) this.contentData = JSON.parse(res.result.pageData)

View File

@ -22,6 +22,7 @@
<div ref="qrCodeUrl"></div> <div ref="qrCodeUrl"></div>
</div> </div>
</Poptip> --> </Poptip> -->
<Button size="default" type="default" v-if="hasCache" @click="clearCache"></Button>
<Button size="default" type="primary" @click="handleSpinShow"></Button> <Button size="default" type="primary" @click="handleSpinShow"></Button>
<Modal <Modal
@ -42,6 +43,10 @@
<span slot="close"></span> <span slot="close"></span>
</i-switch> </i-switch>
</div> </div>
<div class="model-item">
将当前装修内容写入到本地缓存中下次进入页面时可继续使用
<Button type="small" @click="witeLocalStore"></Button>
</div>
<Button type="primary" @click="save()"></Button> <Button type="primary" @click="save()"></Button>
</div> </div>
@ -56,6 +61,7 @@ import * as API_Other from "@/api/other.js";
export default { export default {
data() { data() {
return { return {
hasCache:false, //
progress: true, // progress: true, //
num: 20, // num: 20, //
saveDialog: false, // saveDialog: false, //
@ -87,8 +93,19 @@ export default {
}; };
}, },
watch: {}, watch: {},
mounted() {}, mounted() {
this.hasCache = this.getStore('sellerMobilePageCache') ? true : false;
},
methods: { methods: {
clearCache(){
this.setStore('sellerMobilePageCache','');
this.$Message.success('清空成功')
},
//
witeLocalStore(){
this.setStore('sellerMobilePageCache', this.$store.state.styleStore)
this.$Message.success('写入成功')
},
clickBtn(val) { clickBtn(val) {
this.way.forEach((item, index) => { this.way.forEach((item, index) => {
item.selected = false; item.selected = false;