Bladeren bron

[搜索门店][修改]:[搜索门店增加分页]

tags/富茂链客4.1.0
meo 6 jaren geleden
bovenliggende
commit
3b4d791fb6
2 gewijzigde bestanden met toevoegingen van 58 en 50 verwijderingen
  1. +53
    -42
      pages/index/searchbar/index.js
  2. +5
    -8
      pages/index/searchbar/index.wxss

+ 53
- 42
pages/index/searchbar/index.js Bestand weergeven

@@ -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) {


+ 5
- 8
pages/index/searchbar/index.wxss Bestand weergeven

@@ -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;


Laden…
Annuleren
Opslaan