index.js 4.3 KB

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