xz_dingjie/pages/broadcast/broadcast.js

105 lines
2.0 KiB
JavaScript

// pages/broadcast/broadcast.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
live: {
liveUrl: app.liveUrl,
liveList: []
},
currentPage: 1,
rows: 10
},
doGetLiveList: function(page) {
var self = this;
app.dialog.loading('正在加载');
app.restAjax.get(app.restAjax.path('{liveUrl}/app/liveplan/listpageliveplanrelease', [self.data.live.liveUrl]), {
page: page,
rows: self.data.rows
}, null, function(code, data) {
if(data.rows.length == 0) {
app.dialog.msg('暂无数据');
return;
}
var liveArray;
if(page <= 1) {
liveArray = data.rows;
} else {
liveArray = self.data.live.liveList;
liveArray = liveArray.concat(data.rows);
}
self.setData({
currentPage: page,
'live.liveList': liveArray
})
}, function(code, data) {
app.dialog.msg(data.msg);
}, function() {
wx.stopPullDownRefresh();
wx.hideLoading();
});
},
goDetail: function (event) {
wx.navigateTo({
url: '../broadcastDetail/broadcastDetail?livePlanId='+ event.currentTarget.dataset.livePlanId,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var self = this;
self.doGetLiveList(1);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.doGetLiveList(1);
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.doGetLiveList(this.data.currentPage + 1);
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})