|
|
|
@ -31,12 +31,6 @@
|
|
|
|
|
:key="item.id"
|
|
|
|
|
></UiGoodsItem>
|
|
|
|
|
</div>
|
|
|
|
|
<UiPagination
|
|
|
|
|
:current-page="currentPage"
|
|
|
|
|
:page-size="query.length"
|
|
|
|
|
:total="total"
|
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -45,8 +39,8 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import _ from "lodash";
|
|
|
|
|
import UiGoodsItem from "@/components/UiGoodsItem.vue";
|
|
|
|
|
import UiPagination from "@/components/UiPagination.vue";
|
|
|
|
|
import {
|
|
|
|
|
ApiGetHomeSeckill,
|
|
|
|
|
ApiGetCurrentTime,
|
|
|
|
@ -62,9 +56,10 @@ import Pick from "./module/Pick.vue";
|
|
|
|
|
import TabbarFixed from "./module/TabbarFixed.vue";
|
|
|
|
|
const SECKILL_COUNT = 20; // 秒杀商品数
|
|
|
|
|
const NEW_COUNT = 5; // 新品上架商品数
|
|
|
|
|
const FOOTER_BAR_HEIGHT = 200; // 公共底部高度
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: { Banner, Seckil, Pick, UiGoodsItem, UiPagination, TabbarFixed },
|
|
|
|
|
components: { Banner, Seckil, Pick, UiGoodsItem, TabbarFixed },
|
|
|
|
|
async asyncData({ store }) {
|
|
|
|
|
// 获取秒杀数据
|
|
|
|
|
let seckillData = { activityTimeVO: null };
|
|
|
|
@ -120,6 +115,7 @@ export default {
|
|
|
|
|
loading: false,
|
|
|
|
|
currentPage: 0,
|
|
|
|
|
scrollTop: 0,
|
|
|
|
|
ticking: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
@ -133,9 +129,21 @@ export default {
|
|
|
|
|
window.removeEventListener("scroll", this.scrollEventMethod);
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
scrollEventMethod() {
|
|
|
|
|
scrollEventMethod: _.debounce(function () {
|
|
|
|
|
this.scrollTop = window.scrollY;
|
|
|
|
|
},
|
|
|
|
|
const contentHeight = document.body.scrollHeight; // 内容高度
|
|
|
|
|
const clientHeight = document.body.clientHeight; // 屏幕高度
|
|
|
|
|
if (
|
|
|
|
|
window.scrollY + clientHeight >= contentHeight - FOOTER_BAR_HEIGHT &&
|
|
|
|
|
this.total &&
|
|
|
|
|
this.selectProducts.length < this.total
|
|
|
|
|
) {
|
|
|
|
|
this.query.pageIndex += 1;
|
|
|
|
|
|
|
|
|
|
// “为你精选”上拉加载
|
|
|
|
|
this.getSelectProducts();
|
|
|
|
|
}
|
|
|
|
|
}, 200),
|
|
|
|
|
|
|
|
|
|
// 刷新秒杀活动状态
|
|
|
|
|
async handleSeckillRefresh() {
|
|
|
|
@ -153,13 +161,9 @@ export default {
|
|
|
|
|
if (result) {
|
|
|
|
|
const { total, records } = result;
|
|
|
|
|
this.total = total;
|
|
|
|
|
this.selectProducts = records;
|
|
|
|
|
this.selectProducts = this.selectProducts.concat(records);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleCurrentChange(page) {
|
|
|
|
|
this.query.pageIndex = page;
|
|
|
|
|
this.getSelectProducts();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|