learning.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. show_tj:0
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. this.getData();
  27. },
  28. getData:function(){
  29. var that=this;
  30. var order_by = this.data.val[this.data.index]
  31. wx.showNavigationBarLoading()
  32. wx.request({
  33. url: host+'/api/recommend',
  34. success:function(res){
  35. wx.hideNavigationBarLoading()
  36. that.setData({
  37. arct: res.data.data.article,
  38. hot_arct: res.data.data.hot_act,
  39. pre_arct: res.data.data.pre_act,
  40. over_arct: res.data.data.over_act
  41. })
  42. }
  43. })
  44. //学术会议
  45. wx.request({
  46. url: host + '/api/conference/list',
  47. data:{
  48. order_by: order_by,
  49. keyword: this.data.keyword
  50. },
  51. success: function (res) {
  52. that.setData({
  53. conference: res.data.data.list
  54. })
  55. }
  56. })
  57. //活动预告
  58. wx.request({
  59. url: host + '/api/activity/list',
  60. data:{
  61. type:'pre',
  62. order_by: order_by,
  63. keyword: this.data.keyword
  64. },
  65. success: function (res) {
  66. if(!res.data){
  67. return
  68. }
  69. that.setData({
  70. pre: res.data.data.list
  71. })
  72. }
  73. })
  74. //活动回顾
  75. wx.request({
  76. url: host + '/api/activity/list',
  77. data: {
  78. type: 'over',
  79. order_by: order_by,
  80. keyword: this.data.keyword
  81. },
  82. success: function (res) {
  83. if (!res.data) {
  84. return
  85. }
  86. that.setData({
  87. over: res.data.data.list
  88. })
  89. }
  90. })
  91. },
  92. // 查看更多
  93. more:function(e){
  94. var type=e.target.dataset.id;
  95. //精品推荐
  96. if(type == 1){
  97. this.setData({show_tj:1})
  98. }else{
  99. this.setData({ act: type-1 })
  100. }
  101. },
  102. search: function (e) {
  103. wx.navigateTo({
  104. url: '../search/search',
  105. })
  106. },
  107. showmenu: function () {
  108. this.setData({
  109. show: !this.data.show
  110. })
  111. },
  112. check: function (e) {
  113. this.setData({
  114. show: 0,
  115. index: e.target.dataset.id
  116. })
  117. this.getData();
  118. },
  119. tab: function (e) {
  120. this.setData({
  121. act: e.target.dataset.id,
  122. show_tj: 0
  123. })
  124. },
  125. swchange: function (e) {
  126. this.setData({
  127. act: e.detail.current,
  128. show_tj: 0
  129. })
  130. },
  131. /**
  132. * 生命周期函数--监听页面初次渲染完成
  133. */
  134. onReady: function () {
  135. },
  136. /**
  137. * 生命周期函数--监听页面显示
  138. */
  139. onShow: function () {
  140. this.setData({
  141. show:0
  142. })
  143. },
  144. /**
  145. * 生命周期函数--监听页面隐藏
  146. */
  147. onHide: function () {
  148. },
  149. /**
  150. * 生命周期函数--监听页面卸载
  151. */
  152. onUnload: function () {
  153. },
  154. /**
  155. * 页面相关事件处理函数--监听用户下拉动作
  156. */
  157. onPullDownRefresh: function () {
  158. },
  159. /**
  160. * 页面上拉触底事件的处理函数
  161. */
  162. onReachBottom: function () {
  163. },
  164. /**
  165. * 用户点击右上角分享
  166. */
  167. onShareAppMessage: function () {
  168. }
  169. })