<swiper class='swiper' style='height:{{swiper_height}}px;' bindchange="swiperChange" current='{{current_id}}'>
<swiper-item>
<view class='movement-height' animation="{{opaIn}}">
<scroll-view style="height:{{swiperHeight}}px;" scroll-y="true" bindscrolltolower="loadMoreData">
<view wx:for="{{list}}" wx:for-item="listItem" wx:for-index="listIndex" wx:key="listIndex">
<view wx:for="{{listItem}}" wx:for-index="myIndex" wx:for-item="myItem" wx:key="id">
<block wx:if="{{myItem.type=='2'}}">
<view class="content">
<view class="left-content">
<view class="image">
<image src="{{serverUrl}}{{myItem.user.image}}" data-old='{{myItem.open_id}}' bindtap="userNavFun"></image>
</view>
<view class="center-title">
<view class="cnt-title">
<text class='name'>{{myItem.user_nick}}</text>
<text class='attention'>关注了你</text>
<text class="time">{{myItem.time}}</text>
</view>
</view>
</view>
</view>
</block>
</view>
</view>
</scroll-view>
</view>
</swiper-item>
</swiper>
onLoad: function (options) {
const that = this;
wx.getSystemInfo({
success: function (res) {
let scrollH = res.windowHeight;
that.setData({
swiperHeight: scrollH
});
}
});
this.getUserLikePost();
},
getUserLikePost:function(){
const that = this;
wx.request({
url: app.globalData.basePath + 'user_like_content',
data: {
pageIndex: that.data.activityPage,
openId: '***********************'
},
header: {},
method: 'GET',
dataType: 'json',
responseType: 'text',
success: function (res) {
if(res.data.list ==null ||res.data.list.length<=0){
wx.showToast({
title: '已经到底啦...',
duration: 1000
})
}else{
var nowPost = res.data.list;
var pageNum = that.data.activityPage-1;
that.setData({
['list['+pageNum+']']: nowPost,//如果数据不能填充的高度小于scroll-view的高度,便不能触发bindscrolltolower事件
activityPage: that.data.activityPage+1
})
}
console.log(that.data.list);
},
fail: function (res) { },
complete: function (res) { },
})
},
loadMoreData:function(e){
this.getUserLikePost();
}
1 直接修改this.data,而不调用this.setData(),是无法改变当前页面的状态的,会导致数据不一致
2 仅支持可以JSON化的数据
3 单次设置的数据不能超过1024KB,尽量避免一次设置过多的数据
4 不要把data中的任何一项的value设为undefined,否则这一项将不能被设置,可能会有潜在的问题