• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

【小程序开发】上拉加载更多demo

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

wxml:

<scroll-view class='swiper-scroll' scroll-y="{{true}}" bindscrolltolower="lower" style='height:800rpx;'>
<block wx:for="{{requestRes}}" wx:key="item" wx:for-index="idx">
<view>
<image style='width:100rpx;height:100rpx;' src="{{requestRes[idx].avatar}}" alt=""></image>
</view>
<view>{{requestRes[idx].description}}</view>
<view><text>¥<text>{{item.price}}</text></text><text>¥{{item.oldprice}}</text></view>
</block>
<view class="tips1">
<view wx:if="{{hasMore}}">
<text>玩命的加载中...</text>
</view>
<view wx:else>
<text>没有更多内容了</text>
</view>
</view>
</scroll-view>
 
js:
 
//index.js
//获取应用实例
var app = getApp()
var http = app.globalData.http

Page({
data: {
requestRes: {},
pagel: 1, // 发出的 页数
hasMore: false
},
// 触底加载数据
lower: function (e) {
console.log('kaihsi')
this.setData({
hasMore: true
})
this.loaddatal();
},

onLoad: function (option) {
var that = this
// 请求数据
wx.request({
url: 'http://cloud.topmdrt.com/api/v1/activity/goods_praise/page',
method: 'get',
data: {
currentPage: this.data.pagel,
sourceId: 2,
id: 83
},
success: function (res) {
console.log(res)
that.setData({
requestRes: res.data.response.dataList
})
}
})
},

// 发出的数据 加载
loaddatal: function () {
console.log('chufa')
var listData = this.data.requestRes;
var that = this;
var pag = this.data.pagel + 1;
wx.request({
url: 'http://cloud.topmdrt.com/api/v1/activity/goods_praise/page',
method: 'get',
data: {
currentPage: pag,
sourceId: 2,
id: 83
},
success: function (res) {
var pagel = that.data.pagel + 1;
if (res.data.response.dataList.length == 0) {
this.setData({
requestRes: res.data.response.dataList,
pagel: -1
})
return false;
}
that.setData({
pagel: pagel,
requestRes: listData.concat(res.data.response.dataList),
hasMore: false
})
// that.update()

}

})
}

})
 
wxss:

/**上拉加载更多**/

.tips1{
height: 60rpx;
line-height: 60rpx;
color: #999;
font-size: 21rpx;
text-align: center;
}
/* */
.minearea image {
text-align: center;
display: block;
}

.minearea {
text-align: center;
line-height: 3.2rem;
}

.page-section {
width: 76%;
margin: auto;
margin-top: 36rpx;
}

.weui-input {
border: solid 1px #e6e6e6;
height: 90rpx;
border-radius: 2rpx;
padding-left: 20rpx;
padding-right: 20rpx;
">#f5f5f5;
color: #333;
}

.page-body {
margin-top: 120rpx;
}

.page-section-title {
color: #333;
font-size: 32rpx;
padding-left: 0rpx;
}

.placeholder {
color: #cbcbcb;
}

.btn-area {
margin-top: 90rpx;
}
 
 
 
 
 
 
 
 
 
 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
微信小程序---页面刷新的几种方法发布时间:2022-07-18
下一篇:
微信小程序获得高度发布时间:2022-07-18
热门推荐
    热门话题
    阅读排行榜

    扫描微信二维码

    查看手机版网站

    随时了解更新最新资讯

    139-2527-9053

    在线客服(服务时间 9:00~18:00)

    在线QQ客服
    地址:深圳市南山区西丽大学城创智工业园
    电邮:jeky_zhao#qq.com
    移动电话:139-2527-9053

    Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap