interpretation.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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: '158048'
  15. },
  16. {
  17. title: '图文解读',
  18. channelId: '158049'
  19. },
  20. {
  21. title: '视频解读',
  22. channelId: '239780'
  23. },
  24. {
  25. title: '媒体解读',
  26. channelId: '298206'
  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=20&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 || this.data.currentTab == 2) {
  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. // console.log(url);
  80. let logo = temp[i].LOGOURL.substring(temp[i].LOGOURL.lastIndexOf("FileName=") + "fileName=".length)
  81. // console.log(logo);
  82. if (logo == '' || logo == null) {
  83. temp[i].logoImg = '../../images/zw.jpg'
  84. } else {
  85. temp[i].logoImg = url + logo
  86. }
  87. }
  88. }
  89. temp = this.data.interpretationListInfo.concat(temp);
  90. this.setData({
  91. interpretationListInfo: temp
  92. })
  93. wx.hideToast();
  94. } else {
  95. wx.showToast({
  96. title: '已加载全部数据',
  97. icon: 'success',
  98. duration: 1000
  99. })
  100. }
  101. }
  102. })
  103. },
  104. gotoDetail(e) {
  105. wx.navigateTo({
  106. url: '/pages/publics/governmentArticlesDetail/governmentArticlesDetail?channelId=' + e.currentTarget.dataset.channelid + '&isFile=false'
  107. })
  108. },
  109. gotoWeb(e) {
  110. // console.log(e);
  111. wx.navigateTo({
  112. url: '/pages/web/web?url=' + e.currentTarget.dataset.url
  113. })
  114. },
  115. gotoDetailByDocId(e) {
  116. let url = e.currentTarget.dataset.url
  117. url = url.substring(0, url.lastIndexOf("/") + 1)
  118. wx.navigateTo({
  119. url: '/pages/publics/governmentArticlesDetail/governmentArticlesDetail?channelId=' + e.currentTarget.dataset.channelid + '&docId=' + e.currentTarget.dataset.docid + '&url=' + url + '&isFile=false&isPic=true'
  120. })
  121. },
  122. // 触底
  123. scrollBottom(e) {
  124. this.setData({
  125. page: this.data.page + 1
  126. })
  127. this.getInterpretationById()
  128. },
  129. /**
  130. * 生命周期函数--监听页面加载
  131. */
  132. onLoad(options) {
  133. this.getInterpretationById();
  134. },
  135. /**
  136. * 生命周期函数--监听页面初次渲染完成
  137. */
  138. onReady() {
  139. },
  140. /**
  141. * 生命周期函数--监听页面显示
  142. */
  143. onShow() {
  144. },
  145. /**
  146. * 生命周期函数--监听页面隐藏
  147. */
  148. onHide() {
  149. },
  150. /**
  151. * 生命周期函数--监听页面卸载
  152. */
  153. onUnload() {
  154. },
  155. /**
  156. * 页面相关事件处理函数--监听用户下拉动作
  157. */
  158. onPullDownRefresh() {
  159. },
  160. /**
  161. * 页面上拉触底事件的处理函数
  162. */
  163. onReachBottom() {
  164. },
  165. /**
  166. * 用户点击右上角分享
  167. */
  168. onShareAppMessage() {
  169. return {
  170. title: '政策解读'
  171. }
  172. }
  173. })