Przeglądaj źródła

盲票详情页奖品列表分页

DELL 3 lat temu
rodzic
commit
ba3cbb0986
1 zmienionych plików z 33 dodań i 8 usunięć
  1. 33 8
      src/pages/ticketBox/detail.vue

+ 33 - 8
src/pages/ticketBox/detail.vue

@@ -83,7 +83,7 @@
 		
 		<!-- 盲票奖品数量、概率 -->
 		<view class="prize-total">
-			<view class="prize-total-num">共{{ prizeList.length }}款</view>
+			<view class="prize-total-num">共{{ total }}款</view>
 			<!-- 中奖概率 -->
 			<view class="prize-total-chance flex">
 				<view class="prize-total-chance-content flex" v-for="(item, index) in info.ticketAwardsLabelList">
@@ -108,6 +108,7 @@
 					<image :src="item.awardsLabelPicUrl" />
 				</view>
 			</view>
+			<u-loadmore :line="true" v-if="prizeList.length>10" :status="status" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
 		</view>
 		
 		<view class="footer-fixed" v-if="btnFixed">
@@ -137,6 +138,9 @@
 				boxId: '',
 				picUrlArr: [],
 				info: {},
+				status: 'nomore',//上拉刷新状态
+				pageNum: 1,
+				total: 0,
 				prizeList: [],
 
 				payShow: false,
@@ -219,7 +223,7 @@
 				uni.showLoading({
 					title: '加载中'
 				});
-				$http.post('/api/v1/mp/user/mall/ticket/detail', {
+				$http.post('/api/v1/mp/user/mall/ticket/detail/new', {
 					boxId: this.boxId,
 					noToken: true
 				}).then(res => {
@@ -232,16 +236,27 @@
 								return { ...item, picUrl: env.filePublic + item.picUrl }
 							})
 						}
-						let prizeList = res.data.prizeList
+						this.pageNum = 1
+						this.total = 0
+						this.prizeList = []
+						this.getPrizeList()
+					}
+				}).catch(() => {
+					uni.hideLoading();
+				})
+			},
+			getPrizeList() {
+				$http.post(`/api/v1/mp/user/ticket/prize/list/${this.boxId}?pageNum=${this.pageNum}&pageSize=10`,{}).then(res => {
+					if (res.code == 0) {
+						let prizeList = res.rows
 						prizeList.forEach(item => {
 							item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/375'
 							item.awardsLabelPicUrl = env.filePublic + item.awardsLabelPicUrl
 						})
-						this.prizeList = prizeList
+						this.total = res.total
+						this.prizeList = this.prizeList.concat(prizeList)
 						this.prizeInfo = this.prizeList[this.prizeIndex]
 					}
-				}).catch(() => {
-					uni.hideLoading();
 				})
 			},
 
@@ -368,7 +383,17 @@
 				query: `boxId=${ this.info.boxId }&userId=${ this.userInfo.userId?this.userInfo.userId:null }&type=1`
 						
 			}
-		}
+		},
+		onReachBottom() {
+			if(this.total < this.pageNum * 10) return ;
+			this.status = 'loading';
+			// setTimeout(() => {
+			++this.pageNum
+			if(this.total < this.pageNum * 10) this.status = 'nomore';
+				else this.status = 'loading';
+			this.getPrizeList()
+			// }, 2000)
+		},
 	}
 </script>
 
@@ -630,7 +655,7 @@
 	
 	// 盲票奖品列表
 	.prize-list {
-		padding: 0 34rpx;
+		padding: 0 34rpx 70rpx;
 		
 		&-item {
 			position: relative;