From 3b4d791fb6c3740eea96cf393dca889f8e00c3e8 Mon Sep 17 00:00:00 2001 From: meo <18801474720@163.com> Date: Wed, 6 Mar 2019 16:15:33 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=90=9C=E7=B4=A2=E9=97=A8=E5=BA=97][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]:[=E6=90=9C=E7=B4=A2=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E9=A1=B5]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/searchbar/index.js | 95 ++++++++++++++++++-------------- pages/index/searchbar/index.wxss | 13 ++--- 2 files changed, 58 insertions(+), 50 deletions(-) diff --git a/pages/index/searchbar/index.js b/pages/index/searchbar/index.js index 12c861e..1adbe47 100644 --- a/pages/index/searchbar/index.js +++ b/pages/index/searchbar/index.js @@ -9,16 +9,27 @@ Page({ */ data: { lists: [], + merchantVoList:[], indexId: 0, + businessId:0, + page:1, + isFirstPage:false, + isLastPage:false, teljpgUrl: imgurl.teljpg.url, }, // 左侧点击事件 jumpIndex(e) { - let index = e.currentTarget.dataset.menuindex - let that = this + let that = this; + let index = e.currentTarget.dataset.menuindex; + console.log(index) that.setData({ - indexId: index + indexId: index, + businessId: index }); + that.setData({ + page:1 + }) + that.getList(1, that.data.businessId); }, /** * 生命周期函数--监听页面加载 @@ -33,21 +44,13 @@ Page({ } }); }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - /** * 生命周期函数--监听页面显示 */ onShow: function () { let that = this; that.getBussiness(); - that.getList(1); + that.getList(1,0); }, getBussiness:function(){ let that = this; @@ -64,7 +67,7 @@ Page({ that.setData({ lists: res.data.list.concat(businessObj).sort(compare("id")) }); - console.log(that.data.lists) + console.log(that.data.lists); }) .catch(err => { wx.showToast({ @@ -75,18 +78,37 @@ Page({ }); }) }, - getList: function (pageNum) { + getList: function (page, businessId) { let that = this; - Http.get({ - url: config.api.merchantList, - data: { - pageNum: pageNum, + let data; + if(businessId == 0){ + data = { + pageNum: page, pageSize: 15 } + }else{ + data = { + pageNum: page, + pageSize: 15, + businessId: businessId + } + } + Http.get({ + url: config.api.merchantList, + data: data }).then(res => { - console.log(res) + if (page == 1) { + that.setData({ + merchantVoList: [], + }) + } + var tmpArr = that.data.merchantVoList; + tmpArr.push.apply(tmpArr, res.data.list); + console.log(tmpArr) that.setData({ - merchantVoList: res.data.list + merchantVoList: tmpArr, + isFirstPage: res.data.isFirstPage, + isLastPage: res.data.isLastPage }) console.log(that.data.merchantVoList) }) @@ -107,32 +129,21 @@ Page({ }) } }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { - + let that = this; + that.data.page++; + that.setData({ + page: that.data.page + }); + console.log(that.data.page); + // 如果是最后一页 + //就不发送请求 + if (!that.data.isLastPage || that.data.isFirstPage && that.data.isLastPage){ + that.getList(that.data.page, that.data.businessId); + } } }) function compare(pro) { diff --git a/pages/index/searchbar/index.wxss b/pages/index/searchbar/index.wxss index fd6ea9a..d845f4d 100644 --- a/pages/index/searchbar/index.wxss +++ b/pages/index/searchbar/index.wxss @@ -2,11 +2,11 @@ width: 100%; } .scrollY { - width: 139rpx; + width: 138rpx; position: fixed; left: 0; top: 0; - border-right: 1rpx solid #efefef; + border-right: 2rpx solid #efefef; } .left { @@ -46,10 +46,9 @@ .posi>view:nth-child(2) { width: 100%; - height: 87rpx; display: flex; justify-content: space-between; - line-height: 87rpx; + box-sizing: border-box; } .posi>view:nth-child(2) text:nth-child(1) { @@ -67,15 +66,15 @@ display: flex; padding: 20rpx 0; background: #fff; - height: 100rpx; padding-left:5%; padding-right:5%; margin-bottom: 20rpx; + overflow: hidden; } .posi_logo view:nth-child(1) { width: 100rpx; - height: 100rpx; + /* height: 100rpx; */ border-radius: 16rpx; } @@ -95,7 +94,6 @@ } .posi_logo view:nth-child(2) text:nth-child(1) { - width: 400rpx; overflow: hidden; font-size: 32rpx; color: #333; @@ -105,7 +103,6 @@ } .posi_logo view:nth-child(2) text:nth-child(2) { - width: 400rpx; font-size: 24rpx; color: #b8b8b8; padding-top: 3rpx;