Преглед на файлове

所有列表页代码优化

DELL преди 3 години
родител
ревизия
f0e571136e

+ 36 - 32
src/packageGoods/coupon/index.vue

@@ -1,16 +1,18 @@
 <template>
 	<view>
 		<!-- #ifdef MP-ALIPAY -->
-		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="选择优惠券" leftIconSize="0"></u-navbar>
+		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="选择优惠券" leftIconSize="0">
+		</u-navbar>
 		<!-- #endif -->
 		<!-- #ifndef MP-ALIPAY -->
 		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="选择优惠券"></u-navbar>
 		<!-- #endif -->
-		
+
 		<view class="coupon-title">可用优惠券:{{ total }}</view>
 		<view class="coupon-list">
 			<u-radio-group v-model="radiovalue1" placement="column" @change="changeChechk()">
-				<view class="flex coupon-list-item" v-for="(item,index) in list" :key="index" :style="{backgroundImage:`url(${ index == isActive ? backOn : backOff })`}">
+				<view class="flex coupon-list-item" v-for="(item,index) in list" :key="index"
+					:style="{backgroundImage:`url(${ index == isActive ? backOn : backOff })`}">
 					<view class="flex coupon-list-item-info">
 						<view class="money">
 							<!-- <view class="">¥<text>{{ item.discount / 100 }}</text></view> -->
@@ -28,17 +30,21 @@
 						</view>
 					</view>
 					<view class="uradio">
-						<u-radio :customStyle="{ marginBottom: '8px' }" :name="item.id" activeColor="#E96737" size="24" @change="exclusive(index)">
-					</u-radio>
+						<u-radio :customStyle="{ marginBottom: '8px' }" :name="item.id" activeColor="#E96737" size="24"
+							@change="exclusive(index)">
+						</u-radio>
 					</view>
-					
 				</view>
+				<u-loadmore :line="true" v-if="list.length>5" :status="status" :loading-text="'努力加载中'"
+					:nomore-text="'已经到底了'" />
 			</u-radio-group>
 		</view>
 
 		<view class="flex empty" v-if="!list.length">
 			<view class="center">
-				<image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_1.png" mode="scaleToFill"></image>
+				<image class="center-img"
+					src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_1.png" mode="scaleToFill">
+				</image>
 				<view class="center-font">暂无优惠券</view>
 			</view>
 			<!-- <u-empty text="数据为空" mode="order" /> -->
@@ -69,7 +75,8 @@
 				couponId: '', //选中项的id
 				boxId: '',
 				ticketId: '',
-				
+				status: 'nomore', //上拉刷新状态
+
 				isActive: undefined,
 				backOn: "https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/coupon_bkg2.png",
 				backOff: "https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/coupon_bkg1.png",
@@ -99,12 +106,8 @@
 
 			getList() {
 				let _this = this
-				uni.showLoading({
-					title: '加载中'
-				});
 				$http.post(`/api/v1/mp/user/ticket/order/coupon/listPage?pageNum=${_this.pageNum}&pageSize=20`, {}).then(
 					res => {
-						uni.hideLoading();
 						if (res.code == 0) {
 							this.listNum = res.rows.length
 							res.rows.forEach(item => {
@@ -114,17 +117,16 @@
 							_this.list = [..._this.list, ...res.rows]
 							_this.total = res.total
 							for (var i = 0; i < _this.list.length; i++) {
-								if(_this.list[i].id == _this.couponId){
+								if (_this.list[i].id == _this.couponId) {
 									_this.isActive = i
 								}
 							}
 						}
 
 					}).catch(() => {
-					uni.hideLoading();
 				})
 			},
-			
+
 			exclusive(index) {
 				this.isActive = index
 			},
@@ -176,21 +178,19 @@
 		},
 		onReachBottom() {
 			// 判断是否有数据
-			if (this.total > this.pageNum * 20) {
-				setTimeout(() => {
-					++this.pageNum
-					this.getList()
-				}, 500)
-			} else {
-				uni.$u.toast('已经到底了')
-			}
+			if (this.total < this.pageNum * 20) return;
+			this.status = 'loading';
+			++this.pageNum
+			if (this.total < this.pageNum * 20) this.status = 'nomore';
+			else this.status = 'loading';
+			this.getList()
 		},
 	}
 </script>
 
 <style lang="scss" scoped>
 	.coupon {
-		
+
 		&-title {
 			position: fixed;
 			z-index: 10;
@@ -201,7 +201,7 @@
 
 		&-list {
 			margin-top: 100rpx;
-			padding: 0 20rpx 100rpx;
+			padding: 0 20rpx 200rpx;
 
 			&-item {
 				justify-content: space-between;
@@ -227,6 +227,7 @@
 						flex-direction: column;
 						align-items: flex-start;
 						justify-content: space-between;
+
 						.txt {
 							font-size: 24rpx;
 							line-height: 24rpx;
@@ -244,18 +245,19 @@
 					.money {
 						width: 220rpx;
 						height: 100%;
-						margin:0 10rpx 0;
+						margin: 0 10rpx 0;
+
 						.price {
 							position: absolute;
 							color: #fff;
 							z-index: 0;
-							
+
 							text:first-child {
 								line-height: 150rpx;
 								font-size: 70rpx;
 								padding-right: 20rpx;
 							}
-							
+
 							text:last-child {
 								font-size: 40rpx;
 							}
@@ -264,8 +266,10 @@
 				}
 
 				.uradio {
-					position: absolute;right: 40rpx;
+					position: absolute;
+					right: 40rpx;
 				}
+
 				.circle {
 					width: 40rpx;
 					height: 40rpx;
@@ -285,15 +289,15 @@
 
 	.empty {
 		height: 60vh;
-		
+
 		.center {
 			text-align: center;
-		
+
 			&-img {
 				width: 228rpx;
 				height: 320rpx;
 			}
-		
+
 			&-font {
 				font-size: 30rpx;
 				font-weight: 400;

+ 0 - 7
src/packageGoods/goods/list.vue

@@ -112,9 +112,6 @@
 			
 			// 商品列表
 			getList() {
-				uni.showLoading({
-					title: '加载中'
-				});
 				let data = {
 					goodsName: this.title,
 					priceSort: this.priceSort,
@@ -125,7 +122,6 @@
 				}
 				$http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`,data).then(
 					res => {
-						uni.hideLoading();
 						if (res.code == 0) {
 							res.rows.forEach(item => {
 								item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/340'
@@ -134,7 +130,6 @@
 							this.list = this.list.concat(res.rows)
 						}
 					}).catch(() => {
-					uni.hideLoading();
 				})
 			},
 			
@@ -166,12 +161,10 @@
 		onReachBottom() {
 			if(this.total < this.pageNum * 20) return ;
 			this.status = 'loading';
-			// setTimeout(() => {
 			++this.pageNum
 			if(this.total < this.pageNum * 20) this.status = 'nomore';
 				else this.status = 'loading';
 			this.getList()
-			// }, 2000)
 		},
 	}
 </script>

+ 0 - 7
src/packageGoods/order/index.vue

@@ -104,14 +104,10 @@
 		},
 		methods: {
 			getList() {
-				uni.showLoading({
-					title: '加载中'
-				});
 				this.loading = true
 				$http.post(`/api/v1/mp/user/deliver/order/list?pageNum=${ this.pageNum }&pageSize=20`, {
 					status: this.status
 				}).then(res => {
-					uni.hideLoading();
 					this.loading = false
 					if (res.code == 0) {
 						res.rows.forEach(item => {
@@ -126,7 +122,6 @@
 						this.list = this.list.concat(res.rows)
 					}
 				}).catch(() => {
-					uni.hideLoading();
 					this.loading = false
 				})
 			},
@@ -269,12 +264,10 @@
 		onReachBottom() {
 			if(this.total < this.pageNum * 20) return ;
 			this.statusNomore = 'loading';
-			// setTimeout(() => {
 			++this.pageNum
 			if(this.total < this.pageNum * 20) this.statusNomore = 'nomore';
 				else this.statusNomore = 'loading';
 			this.getList()
-			// }, 2000)
 		},
 	}
 </script>

+ 0 - 7
src/packageGoods/ticket/index.vue

@@ -64,9 +64,6 @@
 		},
 		methods: {
 			getList() {
-				uni.showLoading({
-					title: '加载中'
-				});
 				let data = {
 					categoryId: '',
 					tagId: '',
@@ -76,7 +73,6 @@
 				}
 				$http.post(`/api/v1/mp/user/mall/ticket/goods/list?pageNum=${this.pageNum}&pageSize=20`, data).then(
 					res => {
-						uni.hideLoading();
 						if (res.code == 0) {
 							res.rows.forEach(item => {
 								let picUrlArr = item.picUrl.split(',')
@@ -86,7 +82,6 @@
 							this.list = this.list.concat(res.rows)
 						}
 					}).catch(() => {
-					uni.hideLoading();
 				})
 			},
 		},
@@ -94,12 +89,10 @@
 		onReachBottom() {
 			if (this.total < this.pageNum * 20) return;
 			this.status = 'loading';
-			// setTimeout(() => {
 			++this.pageNum
 			if (this.total < this.pageNum * 20) this.status = 'nomore';
 			else this.status = 'loading';
 			this.getList()
-			// }, 2000)
 		},
 	}
 </script>

+ 0 - 7
src/packagePrize/bean/index.vue

@@ -57,16 +57,11 @@
 		},
 		methods: {
 			getBean() {
-				uni.showLoading({
-					title: '加载中'
-				});
 				$http.post('/api/v1/mp/user/mine/init', {}).then(res => {
-					uni.hideLoading();
 					if (res.code == 0) {
 						this.initData = res.data
 					}
 				}).catch(() => {
-					uni.hideLoading();
 				})
 			},
 
@@ -105,12 +100,10 @@
 		onReachBottom() {
 			if(this.total < this.pageNum * 50) return ;
 			this.status = 'loading';
-			// setTimeout(() => {
 			++this.pageNum
 			if(this.total < this.pageNum * 50) this.status = 'nomore';
 				else this.status = 'loading';
 			this.getList()
-			// }, 2000)
 		},
 	}
 </script>

+ 0 - 7
src/packagePrize/coupon/use.vue

@@ -80,14 +80,10 @@
 			getList() {
 				let _this = this
 				let url = '/api/v1/mp/user/mine/coupon/list'
-				uni.showLoading({
-					title: '加载中'
-				});
 				this.loading = true
 				$http.post(`${ url }?pageNum=${_this.pageNum}&pageSize=20`, {
 					status: this.state
 				}).then(res => {
-					uni.hideLoading();
 					this.loading = false
 					if (res.code == 0) {
 						res.rows.forEach(item => {
@@ -99,7 +95,6 @@
 						_this.list = _this.list.concat(res.rows)
 					}
 				}).catch(() => {
-					uni.hideLoading();
 					this.loading = false
 				})
 			},
@@ -127,12 +122,10 @@
 		onReachBottom() {
 			if(this.total < this.pageNum * 20) return ;
 			this.status = 'loading';
-			// setTimeout(() => {
 			++this.pageNum
 			if(this.total < this.pageNum * 20) this.status = 'nomore';
 				else this.status = 'loading';
 			this.getList()
-			// }, 2000)
 		},
 	}
 </script>

+ 0 - 7
src/packagePrize/prize/index.vue

@@ -242,13 +242,9 @@
 				let data = _this.state == 0 ? { } : {
 					status: 1
 				}
-				uni.showLoading({
-					title: '加载中'
-				});
 				this.loading = true
 				this.checkedAll = false
 				$http.post(`${ url }?pageNum=${_this.pageNum}&pageSize=20`, data).then(res => {
-					uni.hideLoading();
 					this.loading = false
 					if (res.code == 0) {
 						res.rows.forEach(item => {
@@ -265,7 +261,6 @@
 						_this.list = _this.list.concat(res.rows)
 					}
 				}).catch(() => {
-					uni.hideLoading();
 					this.loading = false
 				})
 			},
@@ -571,12 +566,10 @@
 		onReachBottom() {
 			if(this.total < this.pageNum * 20) return ;
 			this.status = 'loading';
-			// setTimeout(() => {
 			++this.pageNum
 			if(this.total < this.pageNum * 20) this.status = 'nomore';
 				else this.status = 'loading';
 			this.statusIndex == 3 && this.state == 0 ? this.getListTwo():this.getList()
-			// }, 2000)
 		},
 	}
 </script>

+ 0 - 7
src/packagePrize/ticket/index.vue

@@ -86,13 +86,9 @@
 		},
 		methods: {
 			getList() {
-				uni.showLoading({
-					title: '加载中'
-				});
 				$http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
 					status: this.state
 				}).then(res => {
-					uni.hideLoading();
 					if (res.code == 0) {
 						res.rows.forEach(item => {
 							item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/170'
@@ -101,7 +97,6 @@
 						this.list = this.list.concat(res.rows)
 					}
 				}).catch(() => {
-					uni.hideLoading();
 				})
 			},
 
@@ -167,12 +162,10 @@
 		onReachBottom() {
 			if(this.total < this.pageNum * 20) return ;
 			this.status = 'loading';
-			// setTimeout(() => {
 			++this.pageNum
 			if(this.total < this.pageNum * 20) this.status = 'nomore';
 				else this.status = 'loading';
 			this.getList()
-			// }, 2000)
 		},
 	}
 </script>

+ 0 - 7
src/pages/activity/index.vue

@@ -144,14 +144,10 @@
 				this.getList()
 			},
 			getList() {
-				uni.showLoading({
-					title: '加载中'
-				});
 				this.loading = true
 				$http.post(`/api/v1/mp/user/marketing/list?pageNum=${this.pageNum}&pageSize=5`, {
 					triggerStatus: this.triggerStatus,
 				}).then(res => {
-					uni.hideLoading();
 					this.loading = false
 					if (res.code == 0) {
 						res.rows.forEach(item => {
@@ -163,7 +159,6 @@
 						this.list = this.list.concat(res.rows)
 					}
 				}).catch(() => {
-					uni.hideLoading();
 					this.loading = false
 				})
 			},
@@ -188,8 +183,6 @@
 		onShareTimeline() {
 			return {
 				title: '盲票,玩的就是有趣',
-				// query: { userId: this.userInfo.userId,
-				// 		type: 1, }
 				query: `userId=${ this.userInfo.userId?this.userInfo.userId:null }&type=1`
 			}
 		},

+ 0 - 6
src/pages/core/index.vue

@@ -349,7 +349,6 @@
 				})
 				let goodsList = []
 				for (let item of resData.data) {
-
 					let resDatas = await $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=1&pageSize=10`, {
 						noToken: true,
 						tagIds: item.tagId
@@ -371,9 +370,6 @@
 
 			// 商品列表
 			getList() {
-				uni.showLoading({
-					title: '加载中'
-				});
 				let data = {
 					categoryId: this.categoryId,
 					priceSort: this.priceSort,
@@ -382,7 +378,6 @@
 				}
 				$http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`, data).then(
 					res => {
-						uni.hideLoading();
 						if (res.code == 0) {
 							res.rows.forEach(item => {
 								let picUrlArr = item.picUrl.split(',')
@@ -393,7 +388,6 @@
 							this.list = this.list.concat(res.rows)
 						}
 					}).catch(() => {
-					uni.hideLoading();
 				})
 			},
 

+ 0 - 9
src/pages/ticketBox/detail.vue

@@ -250,14 +250,10 @@
 			},
 			
 			getDetail() {
-				uni.showLoading({
-					title: '加载中'
-				});
 				$http.post('/api/v1/mp/user/mall/ticket/detail/new', {
 					boxId: this.boxId,
 					noToken: true
 				}).then(res => {
-					uni.hideLoading();
 					if (res.code == 0) {
 						this.info = {
 							...res.data,
@@ -272,7 +268,6 @@
 						this.getPrizeList()
 					}
 				}).catch(() => {
-					uni.hideLoading();
 				})
 			},
 			getPrizeList() {
@@ -409,8 +404,6 @@
 		onShareTimeline() {
 			return {
 				title: '一起来刮盲票吧',
-				// query: { userId: this.userInfo.userId,
-				// 		type: 1, },
 				query: `boxId=${ this.info.boxId }&userId=${ this.userInfo.userId?this.userInfo.userId:null }&type=1`
 						
 			}
@@ -418,12 +411,10 @@
 		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>