Skip to content

Commit

Permalink
首页增加数据载入 toast
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca_Han committed Nov 21, 2016
1 parent 36ce0eb commit e8b7b4b
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Page({
console.log('onLoad')
var that = this
//调用应用实例的方法获取全局数据
this.refresh();
this.getData();
},
upper: function () {
wx.showNavigationBarLoading()
Expand Down Expand Up @@ -53,25 +53,59 @@ Page({
},

//使用本地 fake 数据实现刷新效果
getData: function(){
var feed = util.getData2();
console.log("loaddata");
var feed_data = feed.data;
this.setData({
feed:feed_data,
feed_length: feed_data.length
});
},
refresh: function(){
wx.showToast({
title: '刷新中',
icon: 'loading',
duration: 3000
});
var feed = util.getData2();
console.log("loaddata");
var feed_data = feed.data;
this.setData({
feed:feed_data,
feed_length: feed_data.length
});
setTimeout(function(){
wx.showToast({
title: '刷新成功',
icon: 'success',
duration: 2000
})
},3000)

},

//使用本地 fake 数据实现继续加载效果
nextLoad: function(){
wx.showToast({
title: '加载中',
icon: 'loading',
duration: 4000
})
var next = util.getNext();
console.log("continueload");
var next_data = next.data;
this.setData({
feed: this.data.feed.concat(next_data),
feed_length: this.data.feed_length + next_data.length
});
setTimeout(function(){
wx.showToast({
title: '加载成功',
icon: 'success',
duration: 2000
})
},3000)
}


Expand Down

0 comments on commit e8b7b4b

Please sign in to comment.