learning.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // pages/learning/learning.js
  2. const app = getApp()
  3. var host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. act:0,
  10. arct:[],
  11. hot_arct:[],
  12. over_arct:[],
  13. conference:[],
  14. over:[],
  15. pre:[],
  16. keyword:'',
  17. array: ['时间正序', '时间倒序'],
  18. val: ['ctime', '-ctime'],
  19. index: 0,
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. this.getData();
  26. },
  27. getData:function(){
  28. var that=this;
  29. var order_by = this.data.val[this.data.index]
  30. wx.showNavigationBarLoading()
  31. wx.request({
  32. url: host+'/api/recommend',
  33. success:function(res){
  34. wx.hideNavigationBarLoading()
  35. that.setData({
  36. arct: res.data.data.article,
  37. hot_arct: res.data.data.hot_act,
  38. pre_arct: res.data.data.pre_act,
  39. over_arct: res.data.data.over_act
  40. })
  41. }
  42. })
  43. //学术会议
  44. wx.request({
  45. url: host + '/api/conference/list',
  46. data:{
  47. order_by: order_by,
  48. keyword: this.data.keyword
  49. },
  50. success: function (res) {
  51. that.setData({
  52. conference: res.data.data.list
  53. })
  54. }
  55. })
  56. //活动预告
  57. wx.request({
  58. url: host + '/api/activity/list',
  59. data:{
  60. type:'pre',
  61. order_by: order_by,
  62. keyword: this.data.keyword
  63. },
  64. success: function (res) {
  65. if(!res.data){
  66. return
  67. }
  68. that.setData({
  69. pre: res.data.data.list
  70. })
  71. }
  72. })
  73. //活动回顾
  74. wx.request({
  75. url: host + '/api/activity/list',
  76. data: {
  77. type: 'over',
  78. order_by: order_by,
  79. keyword: this.data.keyword
  80. },
  81. success: function (res) {
  82. if (!res.data) {
  83. return
  84. }
  85. that.setData({
  86. over: res.data.data.list
  87. })
  88. }
  89. })
  90. },
  91. showmenu: function () {
  92. this.setData({
  93. show: !this.data.show
  94. })
  95. },
  96. check: function (e) {
  97. this.setData({
  98. show: 0,
  99. index: e.target.dataset.id
  100. })
  101. this.getData();
  102. },
  103. tab: function (e) {
  104. this.setData({
  105. act: e.target.dataset.id
  106. })
  107. },
  108. swchange: function (e) {
  109. this.setData({
  110. act: e.detail.current
  111. })
  112. },
  113. /**
  114. * 生命周期函数--监听页面初次渲染完成
  115. */
  116. onReady: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面显示
  120. */
  121. onShow: function () {
  122. },
  123. /**
  124. * 生命周期函数--监听页面隐藏
  125. */
  126. onHide: function () {
  127. },
  128. /**
  129. * 生命周期函数--监听页面卸载
  130. */
  131. onUnload: function () {
  132. },
  133. /**
  134. * 页面相关事件处理函数--监听用户下拉动作
  135. */
  136. onPullDownRefresh: function () {
  137. },
  138. /**
  139. * 页面上拉触底事件的处理函数
  140. */
  141. onReachBottom: function () {
  142. },
  143. /**
  144. * 用户点击右上角分享
  145. */
  146. onShareAppMessage: function () {
  147. }
  148. })