缓存结构更改
This commit is contained in:
parent
53c2a9bcd9
commit
1737d73573
21
src/App.vue
21
src/App.vue
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<router-view v-slot="{ Component }">
|
||||
<keep-alive :include="cacheList">
|
||||
<component :is="Component" :key="$route.name" @updateShare="updateShare" />
|
||||
<keep-alive include="Index,Category">
|
||||
<component :is="Component" />
|
||||
</keep-alive>
|
||||
</router-view>
|
||||
</template>
|
||||
@ -10,10 +10,7 @@
|
||||
export default {
|
||||
name: 'App',
|
||||
computed: {
|
||||
cacheList() {
|
||||
const routes = this.$router.getRoutes()
|
||||
return routes.filter(r => r.meta.cache).map(r => r.name)
|
||||
}
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -51,6 +48,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
updateTitle(title) {
|
||||
@ -67,6 +65,11 @@ export default {
|
||||
document.body.appendChild(iframe)
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.$get('/v1/client/HWxinfoClient/share').then(res => {
|
||||
this.wechatShareInfo = res.data || {}
|
||||
})
|
||||
},
|
||||
updateShare(title, desc, imgUrl) {
|
||||
if (wx && this.$isWechat()) {
|
||||
const url = location.href;
|
||||
@ -84,9 +87,9 @@ export default {
|
||||
const data = res.data || {};
|
||||
// alert(JSON.stringify(data))
|
||||
let shareinfo = {
|
||||
title: title || data.title || '泰古润',
|
||||
desc: data.contents || '汇聚平凡梦想,共创美好未来',
|
||||
imgUrl: imgUrl || data.img,
|
||||
title: title || this.wechatShareInfo.title || '泰古润',
|
||||
desc: desc || this.wechatShareInfo.contents || '汇聚平凡梦想,共创美好未来',
|
||||
imgUrl: imgUrl || this.wechatShareInfo.img || data.img,
|
||||
link: this.$getShareLink(),
|
||||
};
|
||||
// alert(JSON.stringify(shareinfo))
|
||||
|
||||
@ -8,30 +8,35 @@ const routes = [
|
||||
{
|
||||
path: '/Home',
|
||||
name: 'Home',
|
||||
parentName: 'Index',
|
||||
component: () => import('./views/Tabbars/Home.vue'),
|
||||
meta: { title: '主页', cache: true }
|
||||
},
|
||||
{
|
||||
path: '/Gift',
|
||||
name: 'Gift',
|
||||
parentName: 'Index',
|
||||
component: () => import('./views/Tabbars/Gift.vue'),
|
||||
meta: { title: '礼包区', cache: true }
|
||||
},
|
||||
{
|
||||
path: '/Mall',
|
||||
name: 'Mall',
|
||||
parentName: 'Index',
|
||||
component: () => import('./views/Tabbars/Mall.vue'),
|
||||
meta: { title: '商城', cache: true }
|
||||
},
|
||||
{
|
||||
path: '/PointMall',
|
||||
name: 'PointMall',
|
||||
parentName: 'Index',
|
||||
component: () => import('./views/Tabbars/PointMall.vue'),
|
||||
meta: { title: '积分区', cache: true }
|
||||
},
|
||||
{
|
||||
path: '/My',
|
||||
name: 'My',
|
||||
parentName: 'Index',
|
||||
component: () => import('./views/User/My.vue'),
|
||||
meta: { title: '我的' }
|
||||
},
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
<template>
|
||||
<router-view />
|
||||
<router-view v-slot="{ Component }">
|
||||
<keep-alive :include="cacheRoutes">
|
||||
<component :is="Component" />
|
||||
</keep-alive>
|
||||
</router-view>
|
||||
<van-tabbar v-model="DefaultActive" placeholder @change="changeActive" active-color="#841e36" inactive-color="#1b1b1b"
|
||||
fixed>
|
||||
<van-tabbar-item v-for="item in Tabbars" :key="item.Name" :name="item.Name" :badge="getBadge(item)" :dot="item.Dot"
|
||||
@ -19,6 +23,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
DefaultActive: 'Home',
|
||||
cacheRoutes: ['Home', 'Gift', 'Mall', 'PointMall'],
|
||||
Tabbars: [
|
||||
{
|
||||
Name: 'Home',
|
||||
@ -75,14 +80,15 @@ export default {
|
||||
this.DefaultActive = tabbar.Name
|
||||
}
|
||||
},
|
||||
changeActive(name) {
|
||||
// if (name === 'PointMall') {
|
||||
// this.$showToast('暂未开放');
|
||||
// this.DefaultActive = this.$route.name; // 恢复之前的选项
|
||||
// return
|
||||
// }
|
||||
this.$router.push({ name })
|
||||
changeActive(e) {
|
||||
if (this.$route.name === e) {
|
||||
this.DefaultActive = e;
|
||||
location.replace(`#/${e}`);
|
||||
location.reload();
|
||||
window.scrollTo(0, 0)
|
||||
|
||||
}
|
||||
this.DefaultActive = e;
|
||||
},
|
||||
getBadge(item) {
|
||||
return item.Badge || ''
|
||||
|
||||
@ -207,46 +207,18 @@ export default {
|
||||
hotData: [],
|
||||
typeData: [],
|
||||
bgcolor: '',
|
||||
_pauseScroll: false,
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
console.log('[Mall] mounted')
|
||||
window.addEventListener('scroll', this.saveScroll)
|
||||
this.init().then(() => {
|
||||
console.log('[Mall] init completed')
|
||||
const scroll = sessionStorage.getItem('Mall_scroll')
|
||||
window.scrollTo(0, Number(scroll))
|
||||
})
|
||||
},
|
||||
|
||||
unmounted() {
|
||||
window.removeEventListener('scroll', this.saveScroll)
|
||||
},
|
||||
|
||||
beforeRouteLeave(to, from) {
|
||||
if (to.name === 'GoodsDetail') {
|
||||
sessionStorage.setItem('Mall_fromDetail', '1')
|
||||
}
|
||||
this.init()
|
||||
},
|
||||
|
||||
activated() {
|
||||
if (sessionStorage.getItem('Mall_fromDetail') === '1') {
|
||||
sessionStorage.removeItem('Mall_fromDetail')
|
||||
const scroll = sessionStorage.getItem('Mall_scroll')
|
||||
setTimeout(() => {
|
||||
window.scrollTo(0, Number(scroll))
|
||||
}, 100)
|
||||
} else {
|
||||
window.scrollTo(0, 0)
|
||||
}
|
||||
this.init()
|
||||
},
|
||||
|
||||
methods: {
|
||||
saveScroll() {
|
||||
sessionStorage.setItem('Mall_scroll', window.scrollY || 0)
|
||||
},
|
||||
init() {
|
||||
return Promise.all([
|
||||
this.$get('/v1/client/EProcatesClient').then(res => {
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<div class="prodetail">
|
||||
<b>{{ product.name }}</b>
|
||||
<div>
|
||||
<p>{{ product.typename }}订单</p>
|
||||
<p>{{ product.mallstatename }}</p>
|
||||
|
||||
<b class="r" v-if="product.mallstate !== 5"><span>¥</span>{{ product.saleprice?.toFixed(2)
|
||||
}}</b>
|
||||
@ -218,6 +218,7 @@ export default {
|
||||
deductjifen: data.deductjifen || 0,
|
||||
deducthuiyuanka: data.deducthuiyuanka || 0,
|
||||
mallstate: data.mallstate || 0,
|
||||
mallstatename: data.mallstatename || '',
|
||||
};
|
||||
this.$emit('updateShare', this.product.name, this.product.typename + '订单', this.product.img);
|
||||
});
|
||||
|
||||
@ -120,6 +120,10 @@ export default {
|
||||
{
|
||||
"value": 4,
|
||||
"label": "已完成"
|
||||
},
|
||||
{
|
||||
"value": 6,
|
||||
"label": "已退款"
|
||||
}
|
||||
],
|
||||
mallList: [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user