fuwei 6 лет назад
Родитель
Сommit
712dfb7d3a
2 измененных файлов с 68 добавлено и 17 удалено
  1. 3 0
      mall/src/mixins/list.js
  2. 65 17
      mall/src/pages/home/category.vue

+ 3 - 0
mall/src/mixins/list.js

@@ -45,6 +45,9 @@ export default {
 			this.list.data = this.list.page === 1 ? listArr : this.list.data.concat(listArr)
 			this.list.total = res.data.totalPage * this.list.pageSize
 			this.list.totalPage = res.data.totalPage || res.totalPage
+			// if(res.data.moreData) {
+			// 	this.list.moreData = res.data.moreData
+			// }
 			if (!res.data.moreData) {
 				this.list.finished = true
 			} else {

+ 65 - 17
mall/src/pages/home/category.vue

@@ -6,10 +6,21 @@
 			</div>
 		</scroll-view>
 		<block v-for="(item,index) in tabbar" :key="index">
-			<scroll-view scroll-y class="right-box" :style="{height:height+'px'}" v-if="currentTab==index">
+			<scroll-view 
+				scroll-y 
+				class="right-box" 
+				:style="{height:height+'px'}"
+				@scrolltolower="onReachBottoms"
+				v-if="currentTab==index">
 				<!--内容部分 start -->
-				<div class="page-view" v-if="!$util.isEmpty(list.data)">
-					<div class="goods-list" v-for="(items, subIndex) in list.data" :key="items.id" @click="pageTo(`/pages/goods/detail?id=${items.id}`)">
+				<div 
+					class="page-view" 
+					v-if="!$util.isEmpty(list.data)">
+					<div 
+						class="goods-list" 
+						v-for="(items, subIndex) in list.data" 
+						:key="items.id" 
+						@click="pageTo(`/pages/goods/detail?id=${items.id}`)">
 						<div class="img-blo">
 							<app-img :src="items.smallImgList[0]" alt="商品图" mode="aspectFit" :height="200" />
 						</div>
@@ -54,21 +65,54 @@ export default {
 			}
 		}
 	},
-	onLoad: function() {
-		if (this.$util.isLogin()) {
-			setTimeout(() => {
-				uni.getSystemInfo({
-					success: res => {
-						this.height = res.windowHeight
-						this.sInit()
-					}
-				})
-			}, 50)
-		}
-	},
+	ceshi(){
+			console.log(1232)
+		},
+// 	onPullDownRefresh() {
+//     this.resetList();
+//     this._list().then(res => {
+//       uni.stopPullDownRefresh();
+//     });
+//   },
+//   // 加载更多
+//   onReachBottom() {
+// 	  console.log(1212)
+//     if (this.list.moreData == 1) {
+//       this._list().then(res => {
+//         uni.stopPullDownRefresh();
+//       });
+//     } else {
+//       uni.stopPullDownRefresh();
+//     }
+//   },
+		onLoad: function() {
+			if (this.$util.isLogin()) {
+				setTimeout(() => {
+					uni.getSystemInfo({
+						success: res => {
+							this.height = res.windowHeight
+							this.sInit()
+						}
+					})
+				}, 50)
+			}
+		},
+	
 	methods: {
+		onReachBottoms(){
+			console.log(789)
+			console.log(this.list)
+		if (!this.list.finished) {
+			this._list().then(res => {
+				uni.stopPullDownRefresh();
+			});
+		} else {
+		uni.stopPullDownRefresh();
+		}
+		},
 		async sInit() {
-			this._getClass().then(res => {
+			this._getClass()
+				.then(res => {
 				this._list()
 			})
 		},
@@ -82,7 +126,11 @@ export default {
 		},
 		// 列表
 		_list() {
-			return getList(this.form).then(res => {
+			return getList({
+				...this.form,
+				page:this.list.page
+			})
+				.then(res => {
 				this.completes(res)
 			})
 		},