lsw hace 1 año
padre
commit
127ffd6ce6
Se han modificado 1 ficheros con 25 adiciones y 4 borrados
  1. 25 4
      app/pages/company/search.vue

+ 25 - 4
app/pages/company/search.vue

@@ -1,11 +1,13 @@
 <template>
 	<view>
-		<view class="search"><u-search placeholder="公司名称" v-model="companyName" :showAction="false" @search="getData()" @clear="clear()"></u-search></view>
+		<view class="search"><u-search placeholder="企业名称" v-model="companyName" :showAction="false" @search="getData()" @clear="clear()"></u-search></view>
 		<view class="list">
 			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
 				<text>{{ item.companyName }}</text>
 				<text class="icon">&#xe62b;</text>
 			</view>
+			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
+			<u-empty v-if="!loadMore && list.length == 0"></u-empty>
 		</view>
 	</view>
 </template>
@@ -15,13 +17,15 @@ export default {
 	data() {
 		return {
 			list: [],
-			companyName: ''
+			companyName: '',
+			param: { pageNum: 1, pageSize: 10 },
+			loadMore: false
 		};
 	},
 	watch: {
 		companyName(val) {
 			if (val.length > 3) {
-				this.getData();
+				this.refresh();
 			}
 		}
 	},
@@ -31,7 +35,10 @@ export default {
 				url: '/app/company/list',
 				data: { companyName: this.companyName },
 				success: (res) => {
-					this.list = res.data.data;
+					this.loadMore = res.data.pages > this.param.pageNum ? true : false;
+					res.data.rows.forEach((item) => {
+						this.list.push(item);
+					});
 				}
 			});
 		},
@@ -63,6 +70,20 @@ export default {
 		},
 		clear() {
 			this.list = [];
+		},
+		//刷新数据
+		refresh() {
+			this.loadMore = true;
+			this.param.pageNum = 1;
+			this.list = [];
+			this.getData();
+		}
+	},
+	//上拉加载
+	onReachBottom() {
+		if (this.loadMore) {
+			this.param.pageNum++;
+			this.getData();
 		}
 	}
 };