index.js 4.1 KB

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