// pages/learning/learning.js const app = getApp() var host = app.globalData.host; Page({ /** * 页面的初始数据 */ data: { act:0, arct:[], hot_arct:[], over_arct:[], conference:[], over:[], pre:[], keyword:'', array: ['时间正序', '时间倒序'], val: ['-ctime', 'ctime'], index: 0, show_tj:0, page_0:1, page_1:1, page_2:1, total_0:0, total_1: 0, total_2: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { this.setData({ conference: [], over: [], pre: [], page_0: 1, page_1: 1, page_2: 1, total_0: 0, total_1: 0, total_2: 0, show: 0 }) this.getData(); }, getData:function(){ var that=this; var order_by = this.data.val[this.data.index] wx.showNavigationBarLoading() wx.request({ url: host+'/api/recommend', success:function(res){ wx.hideNavigationBarLoading() that.setData({ arct: res.data.data.article, hot_arct: res.data.data.hot_act, pre_arct: res.data.data.pre_act, over_arct: res.data.data.over_act }) } }) //学术会议 this.getcon() //活动预告 this.getpre() //活动回顾 this.getover() }, //学术会议 next_0: function () { if (this.data.conference.length < this.data.total_0) { const page = this.data.page_0 + 1 this.setData({ page_0: page }) this.getcon() } }, getcon: function () { const conference = this.data.conference; const order_by = this.data.val[this.data.index] wx.request({ url: host + '/api/conference/list', method: 'GET', data: { order_by: order_by, keyword: this.data.keyword, page: this.data.page_0 }, success: res => { wx.hideNavigationBarLoading() if (res.data.code == 0) { const list = res.data.data.list; for (let i = 0; i < list.length; i++) { conference.push(list[i]) } this.setData({ conference: conference, total_0: res.data.data.total }) } } }) }, //活动预告 next_1: function () { if (this.data.pre.length < this.data.total_1) { const page = this.data.page_1 + 1 this.setData({ page_1: page }) this.getpre() } }, getpre: function () { const pre = this.data.pre; const order_by = this.data.val[this.data.index] wx.request({ url: host + '/api/activity/list', method: 'GET', data: { type: 'pre', order_by: order_by, keyword: this.data.keyword, page: this.data.page_1 }, success: res => { wx.hideNavigationBarLoading() if (res.data.code == 0) { const list = res.data.data.list; for (let i = 0; i < list.length; i++) { pre.push(list[i]) } this.setData({ pre: pre, total_1: res.data.data.total }) } } }) }, //活动预告 next_2: function () { if (this.data.over.length < this.data.total_2) { const page = this.data.page_2 + 1 this.setData({ page_2: page }) this.getover() } }, getover: function () { const over = this.data.over; const order_by = this.data.val[this.data.index] wx.request({ url: host + '/api/activity/list', method: 'GET', data: { type: 'over', order_by: order_by, keyword: this.data.keyword, page: this.data.page_2 }, success: res => { wx.hideNavigationBarLoading() if (res.data.code == 0) { const list = res.data.data.list; for (let i = 0; i < list.length; i++) { over.push(list[i]) } this.setData({ over: over, total_2: res.data.data.total }) } } }) }, // 查看更多 more:function(e){ var type=e.target.dataset.id; //精品推荐 if(type == 1){ this.setData({show_tj:1}) }else{ this.setData({ act: type-1 }) } }, search: function (e) { wx.navigateTo({ url: '../searchList/searchList', }) }, showmenu: function () { this.setData({ show: !this.data.show }) }, check: function (e) { this.setData({ show: 0, conference: [], over: [], pre: [], page_0: 1, page_1: 1, page_2: 1, total_0: 0, total_1: 0, total_2: 0, index: e.target.dataset.id }) this.getData(); }, tab: function (e) { this.setData({ act: e.target.dataset.id, show_tj: 0 }) }, swchange: function (e) { this.setData({ act: e.detail.current, show_tj: 0 }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })