xz_bailang/pages/travel/travel.js
2020-10-13 16:40:53 +08:00

118 lines
2.4 KiB
JavaScript

// pages/travel/travel.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
newsUrl: app.newsUrl,
newsDirectoriesId: '51ae7beb-f277-47a4-937a-088e6d47656d',
currentPage: 1,
rows: 10,
travelList: []
},
getTravel: function (page) {
var self = this
app.dialog.loading('正在加载');
var info = {
page: page,
rows: self.data.rows,
newsDirectoriesId: self.data.newsDirectoriesId
}
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [app.newsUrl]), info, null, function (code, data) {
var newsArray;
for (var i = 0; i < data.rows.length; i++) {
data.rows[i].newsContentCoverList = data.rows[i].newsContentCoverList[0].contentCoverId
}
if(page <= 1) {
newsArray = data.rows;
} else {
newsArray = self.data.travelList;
newsArray = newsArray.concat(data.rows);
}
console.log(newsArray)
self.setData({
currentPage: page,
travelList: newsArray
})
if(data.rows.length == 0) {
app.dialog.msg('暂无数据');
return;
}
}, function(code, data) {
app.dialog.msg(data.msg);
}, function() {
wx.stopPullDownRefresh();
wx.hideLoading();
})
},
goNewsDetail: function (e) {
var url = e.currentTarget.dataset.templateRecordUrl
var link = e.currentTarget.dataset.contentLink
if (link) {
wx.navigateTo({
url: '../template/template?link=' + encodeURIComponent(link),
})
} else {
wx.navigateTo({
url: '../template/template?url=' + encodeURIComponent(url),
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getTravel(1)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})