Karsa 4 gadi atpakaļ
vecāks
revīzija
60014472b5
3 mainītis faili ar 44 papildinājumiem un 19 dzēšanām
  1. 1 1
      config/api.js
  2. 2 2
      pages/index/index.vue
  3. 41 16
      pages/search/search.vue

+ 1 - 1
config/api.js

@@ -126,6 +126,6 @@ export const Search = {
 	},
 	/* 搜索  KeyWord */
 	getResult: params => {
-		return getHttp('/search/list',params)
+		return getHttp('/search/list',params,0)
 	}	
 }

+ 2 - 2
pages/index/index.vue

@@ -39,7 +39,7 @@
 							<image src="@/static/img/report_ico.png" class="report_ico"></image>
 							{{report.ExpertBackground}}
 						</view>
-						<text class="item-createtime">{{report.CreateDate}}</text>
+						<text class="item-createtime">{{report.PublishDate}}</text>
 					</view>
 				</view>
 				<view class="report-ul">
@@ -52,7 +52,7 @@
 							<image src="@/static/img/report_ico.png" class="report_ico"></image>
 							{{report.ExpertBackground}}
 						</view>
-						<text class="item-createtime">{{report.CreateDate}}</text>
+						<text class="item-createtime">{{report.PublishDate}}</text>
 					</view>
 				</view>
 			</view>

+ 41 - 16
pages/search/search.vue

@@ -37,8 +37,8 @@
 				</view>
 			</template>
 			<template v-else>
-				<view class="result-data">
-					<template v-if="haveResult">
+				<block v-if="haveResult">
+					<view class="result-data">
 						<view class="report-ul">
 							<view class="report-item" v-for="(report,index) in resultList" :key="index" v-if="index%2 === 0" @click="goDetail(report)">
 								<!-- <view class="item-content">{{report.content}}</view> -->
@@ -65,11 +65,12 @@
 								<text class="item-createtime">{{report.PublishDate}}</text>
 							</view>
 						</view>
-					</template>
-					<view class="nodata" v-else>
-						<image src="@/static/img/nodata.png" mode="" class="nodata_ico"></image>
-						<text>未找到您想搜索的内容</text>
 					</view>
+					<u-loadmore :status="status" icon-type="flower" :load-text="loadText" v-if="totalPage>1" bg-color="#F7F7F7" padding-bottom="20rpx"/>
+				</block>
+				<view class="nodata" v-else>
+					<image src="@/static/img/nodata.png" mode="" class="nodata_ico"></image>
+					<text>未找到您想搜索的内容</text>
 				</view>
 			</template>
 		</view>
@@ -78,7 +79,7 @@
 
 <script>
 	import { Search } from '@/config/api.js';
-	import { Debounce } from '@/config/util.js'
+	import { Debounce,Throttle } from '@/config/util.js'
 	export default {
 		data() {
 			return {
@@ -91,7 +92,16 @@
 				keywordList:[],
 				targetList:[],//所有指标列表
 				// 搜索结果列表
-				resultList:[]
+				resultList:[],
+				page_no: 1,
+				pageSize: 10,
+				totalPage: 0,
+				loadText:{
+					loadmore: '上拉加载更多',
+					loading: '加载中',
+					nomore: '已经到底了'
+				},
+				status:'loadmore',
 			};
 		},
 		watch:{
@@ -114,6 +124,8 @@
 			chooseTarget(item) {
 				this.searchTxt = item;
 				this.SecName = item;
+				this.resultList = [];
+				this.page_no = 1;
 				this.getDataList();	
 			},
 			// 键盘输入过程中
@@ -143,6 +155,8 @@
 						this.historySearchList.unshift(this.searchTxt);
 						this.$db.set('historySearchList',JSON.stringify(this.historySearchList))
 					}
+					this.resultList = [];
+					this.page_no = 1;
 					this.getDataList();
 				}else {
 					this.$util.toast('请输入关键字')
@@ -151,17 +165,21 @@
 			// 查找数据
 			getDataList() {
 				this.isResult = true;
-				this.resultList = [];
 				Search.getResult({
-					KeyWord: this.searchTxt
+					KeyWord: this.searchTxt,
+					PageSize: this.pageSize,
+					CurrentIndex: this.page_no,
 				}).then(res => {
 					if(res.Ret === 200) {
-						let resArr = res.Data || [];
-						this.resultList = resArr;
-						this.haveResult = this.resultList.length ? true : false;
-						// // resArr.forEach(item => {
-						// // 	item.ModifyTime = item.ModifyTime.substr(0,10);
-						// // })
+	
+						this.status = this.page_no < res.Data.Paging.Pages ? 'loadmore' : 'nomore';
+						this.totalPage = res.Data.Paging.Pages;//总页数
+						if(this.page_no === 1) {
+							this.resultList = res.Data.List || [];
+							this.haveResult = this.resultList.length ? true : false
+						}else {
+							this.resultList = this.resultList.concat(res.Data.List)
+						}
 					}
 				})
 			},
@@ -189,6 +207,13 @@
 				
 			},
 		},
+		/* 触底 */
+		onReachBottom: Throttle(function() {
+			if(this.status === 'nomore') return ;
+			this.status = 'loading';
+			this.page_no++;
+			this.getDataList();
+		}),
 		onLoad() {
 			// 获取历史搜索记录
 			if(this.$db.get('historySearchList')) {