1
This commit is contained in:
parent
0c1a561545
commit
53c2a9bcd9
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<router-view v-slot="{ Component, route }">
|
||||
<router-view v-slot="{ Component }">
|
||||
<keep-alive :include="cacheList">
|
||||
<component :is="Component" :key="route.name" @updateShare="updateShare" />
|
||||
<component :is="Component" :key="$route.name" @updateShare="updateShare" />
|
||||
</keep-alive>
|
||||
</router-view>
|
||||
</template>
|
||||
|
||||
@ -32,11 +32,9 @@ const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes,
|
||||
scrollBehavior(to, from, savedPosition) {
|
||||
if (to.meta.cache && savedPosition)
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(savedPosition);
|
||||
});
|
||||
else
|
||||
if (to.meta.cache && savedPosition) {
|
||||
return savedPosition;
|
||||
}
|
||||
return { top: 0 };
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import { useUserStore } from './stores/user'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
@ -24,7 +21,7 @@ const routes = [
|
||||
path: '/Mall',
|
||||
name: 'Mall',
|
||||
component: () => import('./views/Tabbars/Mall.vue'),
|
||||
meta: { title: '商城' }
|
||||
meta: { title: '商城', cache: true }
|
||||
},
|
||||
{
|
||||
path: '/PointMall',
|
||||
@ -39,7 +36,7 @@ const routes = [
|
||||
meta: { title: '我的' }
|
||||
},
|
||||
],
|
||||
meta: { noLogin: true }
|
||||
meta: { noLogin: true, cache: true }
|
||||
},
|
||||
{
|
||||
path: '/WxCallback',
|
||||
@ -226,7 +223,7 @@ const routes = [
|
||||
path: '/Category',
|
||||
name: 'Category',
|
||||
component: () => import('./views/Goods/Category.vue'),
|
||||
meta: { title: '全部分类', noLogin: true, }
|
||||
meta: { title: '全部分类', noLogin: true, cache: true }
|
||||
},
|
||||
{
|
||||
path: '/Operations',
|
||||
@ -306,20 +303,20 @@ const routes = [
|
||||
component: () => import('./views/User/Checkout/CheckoutTrade.vue'),
|
||||
meta: { title: '订单详情' }
|
||||
},
|
||||
{
|
||||
path: '/Refresh',
|
||||
name: 'Refresh',
|
||||
component: { render: () => null },
|
||||
meta: { noLogin: true },
|
||||
beforeRouteEnter(to, from, next) {
|
||||
next(vm => {
|
||||
setTimeout(() => {
|
||||
const redirect = to.query.redirect || '/Home'
|
||||
vm.$router.replace(decodeURIComponent(redirect))
|
||||
}, 50)
|
||||
})
|
||||
}
|
||||
},
|
||||
// {
|
||||
// path: '/Refresh',
|
||||
// name: 'Refresh',
|
||||
// component: { render: () => null },
|
||||
// meta: { noLogin: true },
|
||||
// beforeRouteEnter(to, from, next) {
|
||||
// next(vm => {
|
||||
// setTimeout(() => {
|
||||
// const redirect = to.query.redirect || '/Home'
|
||||
// vm.$router.replace(decodeURIComponent(redirect))
|
||||
// }, 50)
|
||||
// })
|
||||
// }
|
||||
// },
|
||||
{
|
||||
path: '/SyncAuth',
|
||||
name: 'SyncAuth',
|
||||
|
||||
@ -59,7 +59,7 @@
|
||||
销量 <img :src="getImageSource(2)" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="content product_content">
|
||||
<BaseList class="pro-list" ref="productList" :url="`/v1/client/EProsClient`"
|
||||
:params="queryParams" @load="onLoad">
|
||||
<template #default="{ item }">
|
||||
@ -130,32 +130,80 @@ export default {
|
||||
"/img/pro-list-px-1.png",
|
||||
"/img/pro-list-px-2.png",
|
||||
],
|
||||
_scrollRestored: false,
|
||||
_pauseScroll: false,
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
this._scrollRestored = false
|
||||
this._pauseScroll = false
|
||||
this.$nextTick(() => {
|
||||
const container = document.querySelector('.product_content')
|
||||
if (container) {
|
||||
container.addEventListener('scroll', this.saveScroll)
|
||||
this.restoreScroll(container)
|
||||
}
|
||||
})
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
sessionStorage.setItem('category_scroll', window.scrollY)
|
||||
this._pauseScroll = true
|
||||
const container = document.querySelector('.product_content')
|
||||
if (container) {
|
||||
sessionStorage.setItem('Category_scroll', container.scrollTop || 0)
|
||||
}
|
||||
next()
|
||||
},
|
||||
deactivated() {
|
||||
sessionStorage.setItem('category_scroll', window.scrollY)
|
||||
this._pauseScroll = true
|
||||
const container = document.querySelector('.product_content')
|
||||
if (container) {
|
||||
sessionStorage.setItem('Category_scroll', container.scrollTop || 0)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
const container = document.querySelector('.product_content')
|
||||
if (container) {
|
||||
container.addEventListener('scroll', this.saveScroll)
|
||||
}
|
||||
this.init()
|
||||
},
|
||||
activated() {
|
||||
beforeUnmount() {
|
||||
const container = document.querySelector('.product_content')
|
||||
if (container) {
|
||||
container.removeEventListener('scroll', this.saveScroll)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
saveScroll() {
|
||||
if (this._pauseScroll) return
|
||||
const container = document.querySelector('.product_content')
|
||||
if (container) {
|
||||
sessionStorage.setItem('Category_scroll', container.scrollTop || 0)
|
||||
}
|
||||
},
|
||||
restoreScroll(container) {
|
||||
const scrollTop = sessionStorage.getItem('Category_scroll')
|
||||
if (scrollTop && scrollTop !== '0' && !this._scrollRestored) {
|
||||
this._scrollRestored = true
|
||||
container.removeEventListener('scroll', this.saveScroll)
|
||||
this.$nextTick(() => {
|
||||
container.scrollTo(0, Number(scrollTop))
|
||||
})
|
||||
setTimeout(() => {
|
||||
container.addEventListener('scroll', this.saveScroll)
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
async init() {
|
||||
await this.loadCategories();
|
||||
if (this.$route.query.id) {
|
||||
this.changeMainById(Number(this.$route.query.id));
|
||||
}
|
||||
// 如果URL带有SortType=2(从热销入口进入),默认以销量排序
|
||||
if (this.$route.query.SortType == 2) {
|
||||
this.searchParams.SortType = 2;
|
||||
this.searchParams.IsDesc = true;
|
||||
}
|
||||
// 如果URL带有name参数,初始化搜索
|
||||
if (this.$route.query.name) {
|
||||
this.searchKey = this.$route.query.name;
|
||||
this.queryParams.name = this.searchKey;
|
||||
@ -254,9 +302,6 @@ export default {
|
||||
this.queryParams.name = this.searchKey;
|
||||
this.refreshProductList();
|
||||
},
|
||||
onLoad() {
|
||||
// loaded
|
||||
},
|
||||
refreshProductList() {
|
||||
this.$refs.productList?.refresh();
|
||||
},
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<BasePage :title="data.name || '产品详情'">
|
||||
<BasePage :title="data.name || '产品详情'" :back="back">
|
||||
<div class="goodsdetails">
|
||||
<div class="t">
|
||||
<img :src="$file(data.img)" alt="">
|
||||
|
||||
@ -207,17 +207,48 @@ export default {
|
||||
hotData: [],
|
||||
typeData: [],
|
||||
bgcolor: '',
|
||||
_fromDetail: false,
|
||||
_pauseScroll: false,
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.init();
|
||||
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')
|
||||
}
|
||||
},
|
||||
|
||||
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)
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
saveScroll() {
|
||||
sessionStorage.setItem('Mall_scroll', window.scrollY || 0)
|
||||
},
|
||||
init() {
|
||||
Promise.all([
|
||||
return Promise.all([
|
||||
this.$get('/v1/client/EProcatesClient').then(res => {
|
||||
this.data.SpuType = res.data.filter(i => i.homeshowed)
|
||||
}),
|
||||
|
||||
@ -33,7 +33,9 @@
|
||||
</div>
|
||||
<div class="price">
|
||||
<b>
|
||||
<span>¥</span>{{ data.proskusaleprice?.toFixed(2) }}
|
||||
<span v-if="data.mallstate !== 5">¥</span>
|
||||
{{ data.proskusaleprice?.toFixed(2) }}
|
||||
<span v-if="data.mallstate === 5"> 积分</span>
|
||||
</b>
|
||||
<p>x{{ data.buynums }}</p>
|
||||
</div>
|
||||
@ -47,7 +49,52 @@
|
||||
</span>
|
||||
</div>
|
||||
<div class="_detail">
|
||||
<div class="p">
|
||||
<div class="p" v-if="data.mallstate === 5">
|
||||
<p>
|
||||
积分数量
|
||||
<b style="color: #f00;"> <span>{{ data.payjifen?.toFixed(2) }}</span></b>
|
||||
</p>
|
||||
<p v-if="data.paychannelname">
|
||||
支付方式
|
||||
<span>{{ data.paychannelname }}</span>
|
||||
</p>
|
||||
<p v-if="data.zongsongjifen">
|
||||
赠送积分
|
||||
<span>{{ data.zongsongjifen?.toFixed(2) }}</span>
|
||||
</p>
|
||||
<hr style="margin:1.67vw 0;height: 1px;border: none;background: #f5f5f580;">
|
||||
<p>
|
||||
订单号:
|
||||
<span>{{ data.ordernum }} <img @click="$copyText(data.ordernum); $showSuccessToast('复制成功')"
|
||||
src="/img/copy.png"></span>
|
||||
</p>
|
||||
<!-- <p>
|
||||
商品总数
|
||||
<span>{{ data.buynums }}</span>
|
||||
</p> -->
|
||||
|
||||
<p>
|
||||
下单时间
|
||||
<span>{{ $formatGMT(data.addtime, 'yyyy-MM-dd HH:mm:ss') }}</span>
|
||||
</p>
|
||||
<p v-if="data.paytime">
|
||||
付款时间
|
||||
<span>{{ $formatGMT(data.paytime, 'yyyy-MM-dd HH:mm:ss') }}</span>
|
||||
</p>
|
||||
<p v-if="data.exporttime">
|
||||
发货时间
|
||||
<span>{{ $formatGMT(data.exporttime, 'yyyy-MM-dd HH:mm:ss') }}</span>
|
||||
</p>
|
||||
<p v-if="data.receipttime">
|
||||
完成时间
|
||||
<span>{{ $formatGMT(data.receipttime, 'yyyy-MM-dd HH:mm:ss') }}</span>
|
||||
</p>
|
||||
<p v-if="data.evaltime">
|
||||
评价时间
|
||||
<span>{{ $formatGMT(data.evaltime, 'yyyy-MM-dd HH:mm:ss') }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="p" v-else>
|
||||
<p>
|
||||
商品总价
|
||||
<span>¥{{ data.ordermoney?.toFixed(2) }}</span>
|
||||
|
||||
@ -38,14 +38,18 @@
|
||||
<p>x{{ item.buynums }}</p>
|
||||
</div>
|
||||
<div class="concession">
|
||||
<span>¥{{ item.proskusaleprice?.toFixed(2) }}</span>
|
||||
<p v-if="item.discountratio">惠利{{ item.discountratio }}%</p>
|
||||
<span v-if="item.mallstate !== 5">¥{{ item.proskusaleprice?.toFixed(2) }}</span>
|
||||
<span v-else>{{ item.proskusaleprice?.toFixed(2) }}积分</span>
|
||||
<p v-if="item.discountratio && item.mallstate !== 5">惠利{{ item.discountratio }}%</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="price">
|
||||
<div class="price" v-if="item.mallstate !== 5">
|
||||
实付:<span>¥<b>{{ item.realmoney?.toFixed(2) }}</b></span>
|
||||
</div>
|
||||
<div class="price" v-else>
|
||||
实付:<span><b>{{ item.ordermoney?.toFixed(2) }}</b></span>
|
||||
</div>
|
||||
<div class="state_box">
|
||||
<b :class="'b' + item.state">{{ item.statename }}</b>
|
||||
<div class="btn_box">
|
||||
|
||||
@ -78,6 +78,11 @@ export default {
|
||||
this.init()
|
||||
this.stopPolling()
|
||||
this.pollingTimer = setInterval(() => {
|
||||
// 如果全部已核销,停止轮询
|
||||
if (this.items.length > 0 && this.items.every(i => i.state === 1)) {
|
||||
this.stopPolling()
|
||||
return
|
||||
}
|
||||
this.init()
|
||||
}, 3000)
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user