美文网首页
微信小程序—onReachBottom(触底加载数据)

微信小程序—onReachBottom(触底加载数据)

作者: name_howe | 来源:发表于2019-10-22 14:25 被阅读0次
        onReachBottom: function () {
            let that = this
    
            that.setData({//页面触底后 显示隐藏的加载图片
                touch:true
            })
    
            //动画加载实例
            let option = {
                duration: 3000,
                timingFunction: 'linear'
            }
            let lanimation = wx.createAnimation(option)
            lanimation.rotate(180*10).step()
            that.setData({
                rotate: lanimation.export()
            });
            setTimeout(function(){
                if(that.data.shopCase.length%6 !== 0){//判断当前加载的数据是否小于6
                    that.setData({
                        rotate: lanimation.export(),
                        touch2:true,
                        touch:false
                    })
                }else{
                    let dataSide = that.data.dataSide
                    dataSide.offset+=1
                    request.request('api','POST',dataSide).then(res => {//封装的request
                        that.hideShop()
                        let oshopCase = that.data.shopCase
                        let oshopCase2 = oshopCase.concat(res.data)
                        that.setData({
                            shopCase: oshopCase2,
                            rotate: lanimation.export(),
                            touch:false
                        })
                    })
                }
            },500)
        },
    

    相关文章

      网友评论

          本文标题:微信小程序—onReachBottom(触底加载数据)

          本文链接:https://www.haomeiwen.com/subject/elguectx.html