Administrator hace 4 años
padre
commit
05708573be
Se han modificado 2 ficheros con 21 adiciones y 18 borrados
  1. 19 9
      pages/search/search-second.vue
  2. 2 9
      second/pages/product/product-list.vue

+ 19 - 9
pages/search/search-second.vue

@@ -8,7 +8,7 @@
 			</view>
 		</view>
 		<view  class="commodity-list-wrapper"  :style="{'overflow':'auto','height':(listData.length>4? windowHeight + 'px' : 'auto')}">
-			<scroll-view :style="{'height':(listData.length>4? scrollHeight+'px' : 'auto')}" @scrolltolower="scrolltolower" scroll-y v-if="!showEmpty">
+			<scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y v-if="listData.length > 0">
 				<view class="Listitem" v-for="(item, index) in listData" :key="index" :class="item.sold==1?'activeImg':''"
 				 :productid="item.productID" @click.stop="navToDetailPage(item.productID)">
 				    <view class="itemImg onhref" >
@@ -95,10 +95,11 @@
 				secondHandType:1,
 				instrumentType:0,
 				name:'',
-				total:0
+				total:0,
+				hasNextPage:false
 			}
 		},
-		onLoad(option) {
+		created() {
 			this.getListFromServer()
 		},
 		computed: {
@@ -112,11 +113,6 @@
 					this.getListFromServer()
 				}
 			},
-			scrolltolower() {
-				if(this.total>this.listData.length && this.pullFlag) {
-					this.getListFromServer(true);
-				}
-			},
 			getListFromServer(loadMore) {
 				this.showLoading = true;
 				this.loadingNow = true;
@@ -138,6 +134,7 @@
 					const resList = resData.results;
 					if(resList && resList.length > 0){
 						this.total = resData.totalRecord;
+						this.hasNextPage = resData.hasNextPage;
 						this.showEmpty = false;
 						if(loadMore) {
 							this.listData = [...this.listData,...resList];
@@ -148,7 +145,7 @@
 						this.pullFlag = false;
 						setTimeout(()=>{ this.pullFlag = true; },500)
 						// 底部提示文案
-						if(this.totalPage>this.listData.length) {
+						if(hasNextPage) {
 							this.loadingText = '上拉加载更多';
 						} else {
 							this.showLoading = true;
@@ -163,6 +160,11 @@
 					this.$util.msg(error.msg,2000);
 				})
 			},
+			scrolltolower() {
+				if(this.hasNextPage && this.pullFlag) {
+					this.getListFromServer(true);
+				}
+			},
 			onShowClose () {//输入框失去焦点时触发
 				if(this.name != ''){
 					this.isShowClose = true;
@@ -173,6 +175,14 @@
 			onFocus () { //输入框获取焦点时触发
 				this.inputEmpty(this.searchInputVal)
 			},
+			inputEmpty(val){
+				this.isShowWrapper = false
+				if(val != ''){
+					this.isShowClose = true
+				}else{					
+					this.isShowClose = false
+				}
+			},
 			delInputText () { //清除输入框内容
 				this.name = ''
 				this.isShowClose = false

+ 2 - 9
second/pages/product/product-list.vue

@@ -3,14 +3,7 @@
 		<view class="good-search-top">
 			<view class="search-from name" @click="this.$api.navigateTo(clickPath)">
 				<text class="iconfont icon-iconfonticonfontsousuo1"></text>
-					<input class="input"  
-						   type="text" 
-						   :focus="isFocus"
-						   v-model="name" 
-						   placeholder="请输入商品关键词" 
-						   @input="onShowClose" 
-						   @confirm="searchOpertor"
-						   maxlength="20"/>
+				<view class="input">请输入商品关键词</view>
 				<text class="iconfont icon-shanchu1" v-if="isShowClose" @click="delInputText"></text>
 			</view>
 		</view>
@@ -320,7 +313,7 @@
 		height: 66rpx;
 		float: left;
 		line-height: 66rpx;
-		color: $text-color;
+		color: #b2b2b2;
 		font-size: 28rpx;
 	}
 	.icon-iconfonticonfontsousuo1{