Merge pull request '秒杀查看更多' (#397) from zhy into master

Reviewed-on: http://git.luyuan.tk/luyuan/deming/pulls/397
This commit is contained in:
hansu 2020-11-24 12:09:13 +08:00
commit 3a880711ad

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="spike"> <scroll-view class="spike" scroll-y @scrolltolower="onreachBottom">
<view class="title"> <view class="title">
<view class="name">全部秒杀</view> <view class="name">全部秒杀</view>
<view class="time"> <view class="time">
<text class="num">{{ seckillTime.littleHour || '00' }}</text> <text class="num">{{ seckillTime.littleHour || '00' }}</text>
<text class="mah">:</text> <text class="mah">:</text>
@ -19,8 +19,9 @@
<view class="spike-list"> <view class="spike-list">
<SpecialGoods v-for="(item, index) in spikeList" :key="index" :item="item" type='spike'></SpecialGoods> <SpecialGoods v-for="(item, index) in spikeList" :key="index" :item="item" type='spike'></SpecialGoods>
<u-empty mode="list" v-if="!spikeList.length" :margin-top="240"></u-empty> <u-empty mode="list" v-if="!spikeList.length" :margin-top="240"></u-empty>
<u-loadmore :status="loadStatus" bgColor="#FFF" margin-top="20" margin-bottom="20" @loadmore="onreachBottom"></u-loadmore>
</view> </view>
</view> </scroll-view>
</template> </template>
<script> <script>
import SpecialGoods from "@/components/shop/special-shop/index" import SpecialGoods from "@/components/shop/special-shop/index"
@ -29,27 +30,50 @@ export default {
return { return {
spikeList: [], spikeList: [],
page: 0, page: 0,
seckillTime: {} seckillTime: {},
timer: true, //
loadStatus: 'loadmore',
} }
}, },
components: { components: {
SpecialGoods SpecialGoods
}, },
onShow() { onShow() {
this.getSpikeList(); this.getSpikeList({ load: "reload" });
}, },
methods: { methods: {
// //
getSpikeList() { async getSpikeList({ load }) {
this.$u.api.getSpikeList({ page: this.page }).then(res => { const res = await this.$u.api.getSpikeList({
console.log(res) page: this.page,
if(res.errCode == 0) { })
this.spikeList = res.data.list; this.timer = true;
this.seckillTime = { if (res.errCode == 0) {
bigHour: res.data.bigHour, this.seckillTime = {
littleHour: res.data.littleHour, bigHour: res.data.bigHour,
} littleHour: res.data.littleHour,
} }
if(load == 'reload') this.spikeList = res.data.list;
else if(load == 'loadmore') this.spikeList.push(...res.data.list);
}
this.$forceUpdate();
return res.data.list.length;
},
onreachBottom() {
if(!this.timer) return false;
this.loadStatus = "loading";
this.page++;
this.getSpikeList({ load: "loadmore" }).then(length => {
// console.log(length);
if(length == 0) {
this.page--;
this.loadStatus = 'nomore';
} else {
this.loadStatus = 'loadmore';
}
}).catch(() => {
this.loadStatus = "nomore";
this.page--;
}) })
}, },
} }
@ -57,9 +81,10 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.spike{ .spike{
min-height: calc(100vh - var(--window-top)); height: calc(100vh - var(--window-top));
padding: 30rpx; padding: 30rpx;
border-top: 1rpx solid rgba(236,236,236,1); border-top: 1rpx solid rgba(236,236,236,1);
box-sizing: border-box;
.title{ .title{
margin-bottom: 30rpx; margin-bottom: 30rpx;
display: flex; display: flex;