learning.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. page_0:1,
  22. page_1:1,
  23. page_2:1,
  24. total_0:0,
  25. total_1: 0,
  26. total_2: 0,
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function () {
  32. this.setData({
  33. conference: [],
  34. over: [],
  35. pre: [],
  36. page_0: 1,
  37. page_1: 1,
  38. page_2: 1,
  39. total_0: 0,
  40. total_1: 0,
  41. total_2: 0,
  42. show: 0
  43. })
  44. this.getData();
  45. },
  46. getData:function(){
  47. var that=this;
  48. var order_by = this.data.val[this.data.index]
  49. wx.showNavigationBarLoading()
  50. wx.request({
  51. url: host+'/api/recommend',
  52. success:function(res){
  53. wx.hideNavigationBarLoading()
  54. that.setData({
  55. arct: res.data.data.article,
  56. hot_arct: res.data.data.hot_act,
  57. pre_arct: res.data.data.pre_act,
  58. over_arct: res.data.data.over_act
  59. })
  60. }
  61. })
  62. //学术会议
  63. this.getcon()
  64. //活动预告
  65. this.getpre()
  66. //活动回顾
  67. this.getover()
  68. },
  69. //学术会议
  70. next_0: function () {
  71. if (this.data.conference.length < this.data.total_0) {
  72. const page = this.data.page_0 + 1
  73. this.setData({
  74. page_0: page
  75. })
  76. this.getcon()
  77. }
  78. },
  79. getcon: function () {
  80. const conference = this.data.conference;
  81. const order_by = this.data.val[this.data.index]
  82. wx.request({
  83. url: host + '/api/conference/list',
  84. method: 'GET',
  85. data: {
  86. order_by: order_by,
  87. keyword: this.data.keyword,
  88. page: this.data.page_0
  89. },
  90. success: res => {
  91. wx.hideNavigationBarLoading()
  92. if (res.data.code == 0) {
  93. const list = res.data.data.list;
  94. for (let i = 0; i < list.length; i++) {
  95. conference.push(list[i])
  96. }
  97. this.setData({
  98. conference: conference,
  99. total_0: res.data.data.total
  100. })
  101. }
  102. }
  103. })
  104. },
  105. //活动预告
  106. next_1: function () {
  107. if (this.data.pre.length < this.data.total_1) {
  108. const page = this.data.page_1 + 1
  109. this.setData({
  110. page_1: page
  111. })
  112. this.getpre()
  113. }
  114. },
  115. getpre: function () {
  116. const pre = this.data.pre;
  117. const order_by = this.data.val[this.data.index]
  118. wx.request({
  119. url: host + '/api/activity/list',
  120. method: 'GET',
  121. data: {
  122. type: 'pre',
  123. order_by: order_by,
  124. keyword: this.data.keyword,
  125. page: this.data.page_1
  126. },
  127. success: res => {
  128. wx.hideNavigationBarLoading()
  129. if (res.data.code == 0) {
  130. const list = res.data.data.list;
  131. for (let i = 0; i < list.length; i++) {
  132. pre.push(list[i])
  133. }
  134. this.setData({
  135. pre: pre,
  136. total_1: res.data.data.total
  137. })
  138. }
  139. }
  140. })
  141. },
  142. //活动预告
  143. next_2: function () {
  144. if (this.data.over.length < this.data.total_2) {
  145. const page = this.data.page_2 + 1
  146. this.setData({
  147. page_2: page
  148. })
  149. this.getover()
  150. }
  151. },
  152. getover: function () {
  153. const over = this.data.over;
  154. const order_by = this.data.val[this.data.index]
  155. wx.request({
  156. url: host + '/api/activity/list',
  157. method: 'GET',
  158. data: {
  159. type: 'over',
  160. order_by: order_by,
  161. keyword: this.data.keyword,
  162. page: this.data.page_2
  163. },
  164. success: res => {
  165. wx.hideNavigationBarLoading()
  166. if (res.data.code == 0) {
  167. const list = res.data.data.list;
  168. for (let i = 0; i < list.length; i++) {
  169. over.push(list[i])
  170. }
  171. this.setData({
  172. over: over,
  173. total_2: res.data.data.total
  174. })
  175. }
  176. }
  177. })
  178. },
  179. // 查看更多
  180. more:function(e){
  181. var type=e.target.dataset.id;
  182. //精品推荐
  183. if(type == 1){
  184. this.setData({show_tj:1})
  185. }else{
  186. this.setData({ act: type-1 })
  187. }
  188. },
  189. search: function (e) {
  190. wx.navigateTo({
  191. url: '../searchList/searchList',
  192. })
  193. },
  194. showmenu: function () {
  195. this.setData({
  196. show: !this.data.show
  197. })
  198. },
  199. check: function (e) {
  200. this.setData({
  201. show: 0,
  202. conference: [],
  203. over: [],
  204. pre: [],
  205. page_0: 1,
  206. page_1: 1,
  207. page_2: 1,
  208. total_0: 0,
  209. total_1: 0,
  210. total_2: 0,
  211. index: e.target.dataset.id
  212. })
  213. this.getData();
  214. },
  215. tab: function (e) {
  216. this.setData({
  217. act: e.target.dataset.id,
  218. show_tj: 0
  219. })
  220. },
  221. swchange: function (e) {
  222. this.setData({
  223. act: e.detail.current,
  224. show_tj: 0
  225. })
  226. },
  227. /**
  228. * 生命周期函数--监听页面初次渲染完成
  229. */
  230. onReady: function () {
  231. },
  232. /**
  233. * 生命周期函数--监听页面显示
  234. */
  235. /**
  236. * 生命周期函数--监听页面隐藏
  237. */
  238. onHide: function () {
  239. },
  240. /**
  241. * 生命周期函数--监听页面卸载
  242. */
  243. onUnload: function () {
  244. },
  245. /**
  246. * 页面相关事件处理函数--监听用户下拉动作
  247. */
  248. onPullDownRefresh: function () {
  249. },
  250. /**
  251. * 页面上拉触底事件的处理函数
  252. */
  253. onReachBottom: function () {
  254. },
  255. /**
  256. * 用户点击右上角分享
  257. */
  258. onShareAppMessage: function () {
  259. }
  260. })