136 lines
3.0 KiB
JavaScript
136 lines
3.0 KiB
JavaScript
// pages/resource/resource.js
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
newsUrl: app.newsUrl,
|
|
directoriesParentId: '98c74389-2088-499b-a046-8611bdc57ea4',
|
|
typeList: [],
|
|
currentPage: 1,
|
|
rows: 10,
|
|
currentNewsDictionariesId: ''
|
|
},
|
|
getType: function () {
|
|
var self = this
|
|
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newsdirectories/listnewsdirectoriesrelease', [app.newsUrl]), {
|
|
directoriesParentId: self.data.directoriesParentId
|
|
}, null, function (code, data) {
|
|
self.setData({
|
|
typeList: data
|
|
})
|
|
self.getList(1)
|
|
})
|
|
},
|
|
changeType: function (e) {
|
|
this.setData({
|
|
currentNewsDictionariesId: e.currentTarget.dataset.newsDirectoriesId
|
|
})
|
|
this.getList(1)
|
|
},
|
|
getList: function (page) {
|
|
var self = this
|
|
app.dialog.loading('正在加载');
|
|
var info = {
|
|
newsDirectoriesParentId: self.data.directoriesParentId,
|
|
newsDirectoriesId: self.data.currentNewsDictionariesId ? self.data.currentNewsDictionariesId : '',
|
|
page: page,
|
|
rows: self.data.rows
|
|
}
|
|
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.news.newsList;
|
|
newsArray = newsArray.concat(data.rows);
|
|
}
|
|
self.setData({
|
|
currentPage: page,
|
|
trainList: 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=' + link,
|
|
})
|
|
} else {
|
|
wx.navigateTo({
|
|
url: '../template/template?url=' + url,
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getType()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
this.getList(1);
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.getList(this.data.currentPage + 1);
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |