yijianjun 3 hari lalu
induk
melakukan
4678a52d36

+ 3 - 0
mer_uniapp/pages/merchant_search/index.vue

@@ -214,6 +214,9 @@
 					console.log(err)
 				});
 			},
+			item2Click(item) {
+				item.checked = !item.checked;
+			},
 			onOptionClick(item) {
 				if (this.optionIndex === item.id) return
 				this.page = 1;

+ 55 - 13
mer_uniapp/pages/takeout/index.vue

@@ -68,7 +68,7 @@
 				<text class="no-data-tip">{{noDataTip}}</text>
 			</view>
 
-			<scroll-view scroll-y scroll-with-animation style="flex: 1;overflow: hidden;">
+			<scroll-view scroll-y scroll-with-animation style="flex: 1;overflow: hidden;" @scrolltolower="onScrollBottom">
 				<view class="content-goods2" v-for="item in merchantList" :key="item.id" @click="merchantTab(item)">
 					<view>
 						<image :src="item.avatar" style="width: 230rpx;height: 230rpx;"></image>
@@ -104,6 +104,10 @@
 
 					</view>
 				</view>
+				<view class='loadingicon flex-center' :hidden='!loading'>
+					<text class='loading iconfont icon-jiazai' style="width: auto;"></text>加载更多
+				</view>
+				<view class="flex-center no-data-tip" v-if="loadTitle">{{loadTitle}}</view>
 			</scroll-view>
 		</view>
 	</view>
@@ -122,7 +126,8 @@
 	import navBar from '@/components/navBar';
 	import {
 		getMerchantList,
-		getHomeInfo
+		getHomeInfo,
+		getMerchantSearchList
 	} from '@/api/home.js';
 	import {
 		getTakeoutList,
@@ -163,6 +168,9 @@
 					checked: false
 				}],
 				merchantList: [],
+				loadTitle:'',
+				loading: false,
+				page: 1,
 			}
 		},
 		onLoad(options) {
@@ -183,6 +191,7 @@
 				data[0].icon = '/static/img/quanbu.png';
 				that.optionIndex = data[0].id;
 				that.optionData = data || []
+				that.page = 1;
 				that.getMatchedData()
 				console.log(that.optionData, '12312321321312321321312312')
 			})  
@@ -197,6 +206,39 @@
 			})
 		},
 		methods: {
+			onScrollBottom() {
+				if (!this.loadTitle) {
+					this.getMatchedData()
+				}
+			},
+			getMatchedData() {
+				if (this.loading) return;
+				this.loading = true
+				getMerchantSearchList({
+					latitude: uni.getStorageSync('user_latitude'),
+					longitude: uni.getStorageSync('user_longitude'),
+					productType: this.takeoutId,
+					// typeIds: this.optionIndex==0?"":this.optionIndex,
+					page: this.page,
+					limit: 10
+				}).then(res => {
+					let list = res.data.list || [];
+					this.merchantList = this.$util.SplitArray(list, this.merchantList);
+					if (this.merchantList.length == 0) {
+						this.loadTitle = ''
+						this.noDataTip = ' 暂无外卖商家 ';
+					} else {
+						this.noDataTip = ''
+						this.loadTitle = list.length < 10 ? "我也是有底线的~" : '';
+					}
+					this.loading = false
+					console.log('商品信息:', this.merchantList);
+					this.page += 1;
+				}).catch(err => {
+					this.loading = false
+					console.log(err)
+				});
+			},
 			handBack() {
 				uni.navigateBack({
 					delta: 1
@@ -208,17 +250,17 @@
 			item2Click(item) {
 				item.checked = !item.checked;
 			},
-			getMatchedData() {
-				getMerchantList({
-					latitude: uni.getStorageSync('user_latitude'),
-					longitude: uni.getStorageSync('user_longitude'),
-					cateId: this.takeoutId
-				}).then(res => {
-					this.merchantList = res.data.list;
-					this.noDataTip = this.merchantList.length ? '' : ' 暂无外卖商家 ';
-					console.log('商品信息:', this.merchantList);
-				});
-			},
+			// getMatchedData() {
+			// 	getMerchantList({
+			// 		latitude: uni.getStorageSync('user_latitude'),
+			// 		longitude: uni.getStorageSync('user_longitude'),
+			// 		cateId: this.takeoutId
+			// 	}).then(res => {
+			// 		this.merchantList = res.data.list;
+			// 		this.noDataTip = this.merchantList.length ? '' : ' 暂无外卖商家 ';
+			// 		console.log('商品信息:', this.merchantList);
+			// 	});
+			// },
 			onOptionClick(item) {
 				if (this.optionIndex === item.id) return
 				this.optionIndex = item.id;