样式wxml
<!-- // 滚动条 --> <view class='category_list'> <!-- // 左侧 --> <view class='r_first_category' style="width:160rpx"> <scroll-view scroll-y style='height:{{clientHeight * 2}}rpx;'> <view class="r_item {{itemIndex === index ? 'item_active':'' }}" wx:for="{{category_list}}" wx:key='index' data-id="{{item.category_id}}" data-index="{{index}}" bindtap='navChange'> {{item.short_name =='' ? item.category_name:item.short_name}} </view> <view class="no_more {{cart_goods_num > 0? 'margin_top':'' }}"> </view> </scroll-view> </view> <!-- // 收银台右侧 写到右侧样式 --> <view style='width:590rpx;position:absolute;top:0;right:0;flex:1;'> <scroll-view lower-threshold='8' bindscrolltolower="getnextgoods" scroll-y style='height:{{clientHeight * 2}}rpx;'> <view class='list' wx:for="{{goods_list}}" wx:key='index' wx:for-item="goodItem"> <view class='item'> <view class='img'> <image wx:if='{{goodItem.img_list[0]}}' src='{{goodItem.img_list[0]}}'></image> <image wx:else src='../../../imgs/nopic.jpg'></image> </view> <view class='info'> <view class='good_name'>{{goodItem.goods_name}}</view> <view class='stock_num' wx:if="{{buy_type == 'purchase'}}"> 平台库存:{{goodItem.total_stock}} </view> <view class='stock_num' wx:if="{{buy_type == 'localgoodssale'}}"> 库存:{{goodItem.total_stock}} </view> <view class='cell_price'> <view class='price' wx:if="{{buy_type == 'purchase'}}"> 平台采购价:¥ {{goodItem.min_price}} </view> <view class='price' wx:if="{{buy_type == 'localgoodssale'}}"> 零售价:¥ {{goodItem.price}} </view> <van-icon name="add" color='#1989fa' size='40rpx' data-gooditem='{{goodItem}}' bindtap='goodsSkuShowFun' /> </view> </view> </view> </view> <view class="no_more {{cart_goods_num > 0? 'margin_top':'' }}"> {{flagMoreNext?'上拉加载更多':'没有更多了'}} </view> </scroll-view> </view> </view>
js
getnextgoods() { ============》同等于onReachBottom: function () {},
const that = this; that.data.page_index = that.data.page_index + 1; console.log(that.data.page_index, that.data.page_count) if (that.data.page_index <= that.data.page_count) { // 如果当前页面小于或者等于总页数则才会加载下一页的数据,否则不请求接口
that.getChannelGradeGoods(); } if (that.data.page_index == that.data.page_count) { // 如果当前页等于接口返回的总页数显示'没有更多了'
that.setData({ flagMoreNext: false }) }
},
==============================================
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
const that = this;
that.data.page_index = that.data.page_index + 1;
console.log(that.data.page_index, that.data.page_count)
if (that.data.page_index <= that.data.page_count) { // 如果当前页面小于或者等于总页数则才会加载下一页的数据,否则不请求接口
that.getChannelGradeGoods();
}
if (that.data.page_index == that.data.page_count) { // 如果当前页等于接口返回的总页数显示'没有更多了'
that.setData({
flagMoreNext: false
})
}
},
view class="no_more {{cart_goods_num > 0? 'margin_top':'' }}"> {{flagMoreNext?'上拉加载更多':'没有更多了'}} </view>
// getBrandShopInfo /wapapi/brand/getBrandShopInfo post请求 参数 page_index第几页 page_size每页显示的条数 shop_id 品牌id
getBrandShopInfo: function (shop_id) {
console.log(shop_id, '形参shop_id')
wx.showLoading({
title: '加载中',
})
const that = this;
var postData = {
page_index: that.data.page_index,
page_size: that.data.page_size,
shop_id: shop_id
};
let header = getApp().header;
let datainfo = requestSign.requestSign(postData);
header.sign = datainfo;
wx.request({
url: api.get_getBrandShopInfo,
data: postData,
header: header,
method: 'POST',
dataType: 'json',
responseType: 'text',
success: ({
data
}) => {
console.log(data, '品牌金额记录')
if (data.code == 1) {
wx.hideLoading()
if (that.data.page_index == 1) {
that.setData({
logList: data.data.log
})
} else {
that.setData({
logList: that.data.logList.concat(data.data.log),
page_count: data.data.total_ye
})
}
if (data.data.total_ye <= 1) {
that.setData({
flagMoreNext: false
})
}
}
},
fail: (res) => {},
})
},