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