loadmore 7.23

This commit is contained in:
2020-07-23 20:58:56 +08:00
parent be9f2ec1c7
commit 59362ebc7c
12 changed files with 227 additions and 83 deletions

View File

@@ -3,10 +3,11 @@
<view>
<u-tabs-swiper ref="uTabs" :list="tabList" name="gc_name" :current="current" @change="tabsChange" :is-scroll="true" active-color="#FF780F" swiperWidth="750" height="88" :show-bar="false"></u-tabs-swiper>
</view>
<swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" >
<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">
<SpecialGoods v-for="(item, index) in pinTuanList" :key="index" :item="item" type='group'></SpecialGoods>
<!-- <loadmore ref="loadmore" @callback="getPinTuanList" bgColor="#FFF"></loadmore> -->
<u-empty text="暂无商品" mode="list" color="#000" v-if="!pinTuanList.length"></u-empty>
</scroll-view>
</swiper-item>
@@ -14,27 +15,32 @@
</view>
</template>
<script>
import SpecialGoods from "../../components/shop/special-shop/index"
import loadmore from "@/components/loadmore/index";
import SpecialGoods from "../../components/shop/special-shop/index";
export default {
data() {
return {
tabList: [],
current: Number,
current: -1,
swiperCurrent: 0,
page: 0,
pinTuanList: [],
swiperHeight: '',
timer: '', // 限制下拉刷新
}
},
components: {
SpecialGoods
loadmore,
SpecialGoods,
},
onLoad() {
this.getGoodsClass();
this.setViewHeight();
},
watch: {
current(index) {
// console.log(this.tabList);
this.getPinTuanList(this.tabList[index].gc_id);
this.getPinTuanList({id: this.tabList[index].gc_id });
}
},
methods: {
@@ -48,13 +54,13 @@ export default {
})
},
// 拼团列表
getPinTuanList(id) {
this.$u.api.getPinTuanList({
async getPinTuanList({ id, page }) {
const res = await this.$u.api.getPinTuanList({
page: this.page,
gc_id: id,
}).then(res => {
this.pinTuanList = res.data;
})
this.pinTuanList = res.data;
return res.data.length;
},
// tabs通知swiper切换
tabsChange(index) {
@@ -74,8 +80,26 @@ export default {
},
// 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';
},
}
};
</script>