index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. user: {},
  8. annunciateList: [], //通告列表
  9. gridList: [],
  10. showAnnunciate: false, //显示最新通告
  11. unreadNum: 0, //通告未读
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad(options) {
  17. if (wx.getStorageSync('userauth').length != 0) {
  18. let auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['通告', '推广素材', '商学院', '提报']);
  19. let gridList = [];
  20. auth.forEach(v => {
  21. switch (v.systemmodulename) {
  22. case "通告":
  23. gridList.push({
  24. name: "通告",
  25. path: "/pages/annunciate/index",
  26. icon: "icon-a-shouyejingangqutonggao",
  27. apps: v.apps
  28. });
  29. let annunciateAuthList = v.apps[0].meta.auth.map(v => v.optionname);
  30. this.setData({
  31. showAnnunciate: true,
  32. annunciateAuthList
  33. });
  34. break;
  35. case "推广素材":
  36. gridList.push({
  37. name: "推广素材",
  38. path: "/pages/promotional/index",
  39. icon: "icon-a-shouyejingangqutuiguangsucai",
  40. apps: v.apps
  41. })
  42. break;
  43. case "商学院":
  44. gridList.push({
  45. name: "商学院",
  46. path: "/pages/college/index",
  47. icon: "icon-a-shangxueyuanxuexi",
  48. apps: v.apps
  49. })
  50. break;
  51. case "提报":
  52. gridList.push({
  53. name: "提报",
  54. path: "/pages/submission/index",
  55. icon: "icon-a-tibaoguanlitibao",
  56. apps: v.apps
  57. })
  58. break;
  59. };
  60. });
  61. this.setData({
  62. gridList
  63. })
  64. }
  65. this.refreshData(wx.getStorageSync('userMsg'))
  66. this.setData({ //获取胶囊位置信息
  67. capsule: wx.getMenuButtonBoundingClientRect()
  68. })
  69. },
  70. /* 查看通告详情 */
  71. toAnnunciateDetails(e) {
  72. const {
  73. item
  74. } = e.currentTarget.dataset;
  75. let authList = this.data.annunciateAuthList;
  76. wx.navigateTo({
  77. url: `/pages/annunciate/details?id=${item.sat_noticeid}&feedback=${authList.includes('反馈')}&auth=${authList}`,
  78. })
  79. },
  80. /* 获取通告列表 */
  81. queryNoticeList(i) {
  82. if (i == 5) return;
  83. _Http.basic({
  84. "classname": "saletool.notice.notice",
  85. "method": "queryNoticeList",
  86. "content": {
  87. "pageNumber": 1,
  88. "pageSize": 3
  89. }
  90. }).then(res => {
  91. console.log("通告列表", res)
  92. if (res.msg != '成功') return this.queryNoticeList(i + 1);
  93. this.setData({
  94. annunciateList: res.data,
  95. unreadNum: res.total - res.tips.readNum
  96. })
  97. })
  98. },
  99. /* 更新站点信息 */
  100. refreshData(item) {
  101. this.setData({
  102. user: item
  103. })
  104. this.queryNoticeList(0); //获取通告列表
  105. },
  106. /* 宫格区域应用程序 */
  107. applications(e) {
  108. const {
  109. item
  110. } = e.currentTarget.dataset;
  111. wx.navigateTo({
  112. url: `${item.path}?auth=${JSON.stringify(item.apps)}`,
  113. });
  114. },
  115. /* 去通告 */
  116. toAnnunciate() {
  117. this.applications({
  118. currentTarget: {
  119. dataset: {
  120. item: this.data.gridList.find(v => v.name == '通告')
  121. }
  122. }
  123. })
  124. },
  125. /**
  126. * 生命周期函数--监听页面初次渲染完成
  127. */
  128. onReady() {
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow() {
  134. this.getTabBar().init();
  135. },
  136. /**
  137. * 生命周期函数--监听页面隐藏
  138. */
  139. onHide() {
  140. },
  141. /**
  142. * 生命周期函数--监听页面卸载
  143. */
  144. onUnload() {
  145. },
  146. /**
  147. * 页面相关事件处理函数--监听用户下拉动作
  148. */
  149. onPullDownRefresh() {
  150. },
  151. /**
  152. * 页面上拉触底事件的处理函数
  153. */
  154. onReachBottom() {
  155. },
  156. /**
  157. * 用户点击右上角分享
  158. */
  159. onShareAppMessage() {
  160. }
  161. })