diff --git a/components/products/products.vue b/components/products/products.vue index 372e49f..7f60bef 100644 --- a/components/products/products.vue +++ b/components/products/products.vue @@ -65,11 +65,8 @@ this.tagsArray = tag.split(',') item.tags = this.tagsArray[0] } + this.$emit("getChild", tags.length); - // if (res.data.data.length == 0) { - // requestTask.abort() - // } - console.log(res); // 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接 this.productList = [...this.productList, ...res.data.data] diff --git a/pages/index/index.vue b/pages/index/index.vue index cf9b3f6..e6ce84b 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -38,7 +38,7 @@ - + @@ -59,15 +59,14 @@ ], imgUrl: '', swiperList: [], + reachBottomLength: '' } }, onReachBottom() { - // console.log('pageNum===', this.$refs.getProducts); this.$refs.getProducts.pageNum += 1 - this.$refs.getProducts.getProducts() - - //关闭下拉刷新 - // uni.stopPullDownRefresh() + if (this.reachBottomLength !== 0) { + this.$refs.getProducts.getProducts() + } }, onLoad() { this.getCategories() @@ -77,6 +76,10 @@ }, methods: { + //获取子组件的getProducts方法返回数据的length,用于当length为0时取消发送请求 + getChild(e) { + this.reachBottomLength = e + }, //获取一级分类 getCategories() { this.$apiServe.getCategories().then(res => {