interpretation.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // pages/publics/interpretation/interpretation.js
  2. import {
  3. imgUrl
  4. } from "../../api/request"
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. // 图片前缀
  11. imgUrl: imgUrl,
  12. interpretationList: [{
  13. title: '文字解读',
  14. channelId: '222894'
  15. },
  16. {
  17. title: '图文解读',
  18. channelId: '158049'
  19. },
  20. {
  21. title: '视频解读',
  22. channelId: '158049'
  23. },
  24. {
  25. title: '媒体解读',
  26. channelId: '222894'
  27. }
  28. ],
  29. currentTab: 0,
  30. interpretationListInfo: [],
  31. page: 1
  32. },
  33. // 切换
  34. tabNav(e) {
  35. let currentTab = e.currentTarget.dataset.index
  36. this.setData({
  37. currentTab
  38. })
  39. },
  40. // 切换
  41. handleSwiper(e) {
  42. let {
  43. current,
  44. source
  45. } = e.detail
  46. if (source === 'autoplay' || source === 'touch') {
  47. const currentTab = current
  48. this.setData({
  49. currentTab
  50. })
  51. }
  52. this.setData({
  53. interpretationListInfo: [],
  54. page: 1
  55. })
  56. if (current == 2 || current ==3) {
  57. return;
  58. }
  59. this.getInterpretationById();
  60. },
  61. // 获取政策解读列表
  62. getInterpretationById() {
  63. wx.showToast({
  64. title: '加载中',
  65. icon: 'loading',
  66. duration: 1500
  67. })
  68. wx.request({
  69. url: 'https://data.cqna.gov.cn/mini/hlw/send?page=' + this.data.page + '&limit=10&channelId=' + this.data.interpretationList[this.data.currentTab].channelId,
  70. method: 'GET',
  71. success: res => {
  72. if (res.data.data.DATA.length > 0) {
  73. let temp = res.data.data.DATA;
  74. if (this.data.currentTab == 1) {
  75. // 图文解读
  76. for (let i=0;i<temp.length;i++) {
  77. // 截取logo图片
  78. let url = temp[i].DOCPUBURL.substring(0, temp[i].DOCPUBURL.lastIndexOf("/") + 1)
  79. let logo = temp[i].LOGOURL.substring(temp[i].LOGOURL.lastIndexOf("FileName=") + "fileName=".length)
  80. temp[i].logoImg = url + logo
  81. }
  82. }
  83. temp = this.data.interpretationListInfo.concat(temp);
  84. this.setData({
  85. interpretationListInfo: temp
  86. })
  87. wx.hideToast();
  88. } else {
  89. wx.showToast({
  90. title: '已加载全部数据',
  91. icon: 'success',
  92. duration: 1000
  93. })
  94. }
  95. }
  96. })
  97. },
  98. gotoDetail(e) {
  99. wx.navigateTo({
  100. url: '/pages/publics/governmentArticlesDetail/governmentArticlesDetail?channelId=' + e.currentTarget.dataset.channelid + '&isFile=false'
  101. })
  102. },
  103. gotoDetailByDocId(e) {
  104. let url = e.currentTarget.dataset.url
  105. url = url.substring(0, url.lastIndexOf("/") + 1)
  106. wx.navigateTo({
  107. url: '/pages/publics/governmentArticlesDetail/governmentArticlesDetail?channelId=' + e.currentTarget.dataset.channelid + '&docId=' + e.currentTarget.dataset.docid + '&url=' + url + '&isFile=false&isPic=true'
  108. })
  109. },
  110. // 触底
  111. scrollBottom(e) {
  112. this.setData({
  113. page: this.data.page + 1
  114. })
  115. this.getInterpretationById()
  116. },
  117. /**
  118. * 生命周期函数--监听页面加载
  119. */
  120. onLoad(options) {
  121. this.getInterpretationById();
  122. },
  123. /**
  124. * 生命周期函数--监听页面初次渲染完成
  125. */
  126. onReady() {
  127. },
  128. /**
  129. * 生命周期函数--监听页面显示
  130. */
  131. onShow() {
  132. },
  133. /**
  134. * 生命周期函数--监听页面隐藏
  135. */
  136. onHide() {
  137. },
  138. /**
  139. * 生命周期函数--监听页面卸载
  140. */
  141. onUnload() {
  142. },
  143. /**
  144. * 页面相关事件处理函数--监听用户下拉动作
  145. */
  146. onPullDownRefresh() {
  147. },
  148. /**
  149. * 页面上拉触底事件的处理函数
  150. */
  151. onReachBottom() {
  152. },
  153. /**
  154. * 用户点击右上角分享
  155. */
  156. onShareAppMessage() {
  157. return {
  158. title: '政策解读'
  159. }
  160. }
  161. })