This commit is contained in:
2020-07-30 20:33:16 +08:00
parent 04adc72d92
commit 6d00107944
17 changed files with 241 additions and 124 deletions

View File

@@ -5,9 +5,9 @@
</view>
<swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" :style="{height: swiperHeight}">
<swiper-item class="swiper-item" v-for="(_, index) in tabList" :key="index">
<scroll-view scroll-y style="height: 800rpx;width: 100%;" @scrolltolower="onreachBottom">
<scroll-view scroll-y style="width: 100%;" @scrolltolower="onreachBottom">
<SpecialGoods v-for="(item, index) in pinTuanList" :key="index" :item="item" type='group'></SpecialGoods>
<loadmore ref="loadmore" @callback="getPinTuanList" bgColor="#FFF"></loadmore>
<u-loadmore :status="loadStatus" bgColor="#FFF" margin-top="20" margin-bottom="20" v-if="pinTuanList.length>=pageSize" @loadmore="onreachBottom"></u-loadmore>
<u-empty text="暂无商品" mode="list" color="#000" v-if="!pinTuanList.length"></u-empty>
</scroll-view>
</swiper-item>
@@ -15,22 +15,22 @@
</view>
</template>
<script>
import loadmore from "@/components/loadmore/index";
import SpecialGoods from "../../components/shop/special-shop/index";
export default {
data() {
return {
pageSize: 12,
tabList: [],
current: -1,
swiperCurrent: 0,
page: 0,
pinTuanList: [],
swiperHeight: '',
timer: '', // 限制下拉刷新
timer: true, // 限制下拉刷新
loadStatus: 'loadmore',
}
},
components: {
loadmore,
SpecialGoods,
},
onLoad() {
@@ -39,7 +39,7 @@ export default {
},
watch: {
current(index) {
this.getPinTuanList({ id: this.tabList[index].gc_id });
this.getPinTuanList({ id: this.tabList[index].gc_id, load: 'reload' });
}
},
methods: {
@@ -53,14 +53,39 @@ export default {
})
},
// 拼团列表
async getPinTuanList({ id, page }) {
async getPinTuanList({ id, page, load }) {
const res = await this.$u.api.getPinTuanList({
page: this.page,
gc_id: id,
})
this.pinTuanList = res.data;
this.timer = true;
if (res.errCode == 0) {
if(load == 'reload') this.pinTuanList = res.data;
else if(load == 'loadmore') this.pinTuanList.push(...res.data);
}
return res.data.length;
},
// scroll-view到底部加载更多
onreachBottom() {
if(!this.timer) return false;
this.loadStatus = "loading";
this.page++;
this.getPinTuanList({
id: this.tabList[this.current].gc_id,
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--;
})
},
// tabs通知swiper切换
tabsChange(index) {
this.swiperCurrent = index;
@@ -77,24 +102,6 @@ export default {
this.swiperCurrent = current;
this.current = current;
},
// scroll-view到底部加载更多
onreachBottom() {
this.$$refs.loadmore.reachBottom();
if(!this.timer) return false;
this.loadStatus = "loading";
this.page++;
this.getPinTuanList().then(length => {
if(length == 0) {
this.page--;
this.status = 'nomore';
} else {
this.status = 'loading';
}
}).catch(() => {
this.loadStatus = "nomore";
this.page--;
})
},
setViewHeight() {
const res = uni.getSystemInfoSync();
this.swiperHeight = res.windowHeight - (88 / 2) + 'px';