拓恒河湖长制全民护河平台WEB端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
5.0KB

  1. // pages/FirstPage/index.js
  2. import {getOnlive} from '../../api/home.js'
  3. import {getOpenidData} from '../../utils/getUserInfo.js'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. announcementList: [], // 公告列表
  10. // 快捷入口
  11. entersList: [
  12. // {
  13. // title:'上报问题',
  14. // iconPath: '../../assets/first/upload.png',
  15. // path: '/pages/all/index',
  16. // type: 'tabbar'
  17. // },
  18. {
  19. title:'护河行动',
  20. iconPath: '../../assets/first/new.png',
  21. path: '/package_first/pages/announceList/index',
  22. type: 'page'
  23. },
  24. {
  25. title:'热点资讯',
  26. iconPath: '../../assets/first/ask.png',
  27. path: '/package_first/pages/askAdmin/index',
  28. type: 'page'
  29. },
  30. {
  31. title:'大好河山',
  32. iconPath: '../../assets/first/rivers.png',
  33. path: '/package_first/pages/beautyList/index',
  34. type: 'page'
  35. },
  36. {
  37. title:'积分商城',
  38. iconPath: '../../assets/first/stores.png',
  39. path: '/package_A/pages/stores/index',
  40. type: 'page'
  41. },
  42. {
  43. title:'护河活动',
  44. iconPath: '../../assets/first/activity.png',
  45. path: '/package_first/pages/ProtectionActivity/index',
  46. type: 'page'
  47. },
  48. {
  49. title:'护河建议',
  50. iconPath: '../../assets/first/suggestion.png',
  51. path: '/package_first/pages/ProtectionSuggestion/index',
  52. type: 'page'
  53. }
  54. ],
  55. infoList: ['name', 'location', 'note'],
  56. liveNum: 0, // 在线人数
  57. list: [], // 河道展示
  58. current: '',
  59. params: {
  60. page: 1,
  61. limit: 3
  62. }
  63. },
  64. /**
  65. * 生命周期函数--监听页面加载
  66. */
  67. onLoad(options) {
  68. this.getTabBar().setData({
  69. selected: 0
  70. })
  71. let tenant = wx.getStorageSync('tenant')
  72. if(!Object.keys(tenant).length) {
  73. const path = '/pages/FirstPage/index'
  74. const fromType = 'tabbar'
  75. wx.redirectTo({
  76. url: `/pages/login/login?path=${path}&fromType=${fromType}`,
  77. })
  78. } else {
  79. this.setData({current: '/stream/index',})
  80. }
  81. },
  82. onShow() {
  83. this.getOnliveNum()
  84. },
  85. /* 更新数据 */
  86. updateList(e) {
  87. let list = this.data.list.concat(e.detail || [])
  88. this.setData({ list })
  89. },
  90. /* 重置数据 */
  91. resetList() {
  92. this.setData({ list: [] })
  93. },
  94. // 获取在线人数
  95. getOnliveNum() {
  96. getOnlive().then(res=> {
  97. if(res.code === 0) {
  98. this.setData({liveNum: res.data})
  99. }
  100. })
  101. },
  102. // 公告详情
  103. showAnnouncementDetail() {
  104. wx.navigateTo({
  105. url:"/package_first/pages/announceList/index"
  106. })
  107. },
  108. // 获取点击详情
  109. getCurrentData(dataKey, e) {
  110. let index = e.currentTarget.dataset.current;
  111. return this.data[dataKey][index]
  112. },
  113. // 进入对应页面
  114. goPage(e) {
  115. let title = e.currentTarget.dataset.title
  116. if(title !== '敬请期待') {
  117. // 判断是否有权限
  118. let tenant = wx.getStorageSync('tenant')
  119. let path = e.currentTarget.dataset.path
  120. let type = e.currentTarget.dataset.type
  121. if(Object.keys(tenant).length) {
  122. if(type === 'tabbar') {
  123. wx.switchTab({
  124. url: path,
  125. })
  126. } else {
  127. wx.navigateTo({
  128. url: path,
  129. })
  130. }
  131. } else {
  132. wx.redirectTo({
  133. url: `/pages/login/login?path=${path}&fromType=${type}`,
  134. })
  135. }
  136. }
  137. },
  138. // 上报问题
  139. uploadProblem(e) {
  140. let detail = e.currentTarget.dataset.detail
  141. let openid = wx.getStorageSync('openid')
  142. if(openid) {
  143. wx.navigateTo({
  144. url: '/package_A/pages/report/index?data=' + JSON.stringify(detail),
  145. })
  146. } else {
  147. getOpenidData().then(res=> {
  148. wx.navigateTo({
  149. url: '/package_A/pages/report/index?data=' + JSON.stringify(detail),
  150. })
  151. })
  152. }
  153. },
  154. /* 跳转至筛选页 */
  155. goSelectLocation(e) {
  156. const path = '/pages/FirstPage/index'
  157. wx.redirectTo({
  158. url: `/pages/login/login?path=${path}`,
  159. })
  160. },
  161. /* 跳转至详情页 */
  162. showDetail(e) {
  163. let data = e.currentTarget.dataset.item
  164. wx.navigateTo({
  165. url: '/package_A/pages/riverDetail/index?data='+ JSON.stringify(data),
  166. })
  167. }
  168. })