マイクロ信ウィジェットによる下部ロード

6857 ワード

    scroll-view
<scroll-view scroll-y="true" bindscrolltolower="load" class="scroll-loading" style="height:{{windowHeight}}px;">

    view>
scroll-view>
loading:function () {
    var that = this;
    wx.request({
        method: 'GET',
        url: '',
        data: {
            offset: that.data.pageSize * (that.data.page - 1),
            limit: that.data.pageSize
        },
        header: {
            'content-type': 'application/json', //    
        },
        success: function(res) {
            console.log(res.data);
            if (res.statusCode == 200) {
                if (that.data.page === 1) {
                    that.setData({
                        projectList:res.data
                    });
                } else {
                    var words = that.data.projectList.concat(res.data);
                    that.setData({
                        projectList: words
                    })
                }

            } else {

            }
        }
    });
},
onLoad:function () {
    var that = this;
    that.loading();
    //      
    wx.getSystemInfo({
        success: function (res) {
            that.setData({
                windowHeight: res.windowHeight
            });
            console.log("    : " + res.windowHeight)
        }
    })
},
 
  
load:function () {
  var that = this;
  that.setData({
      page :that.data.page + 1
  });
  that.loading();
},