index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. let _Http = getApp().globalData.http,
  2. DataCarousel = null;
  3. Page({
  4. data: {
  5. bannerList: [], //banner列表
  6. gridList: [],
  7. notice: "",
  8. msgCount: 1,
  9. msgList: [], //消息列表
  10. },
  11. onLoad(options) {
  12. this.setData({ //获取胶囊位置信息
  13. capsule: wx.getMenuButtonBoundingClientRect()
  14. })
  15. this.refreshData() //更新权限等信息
  16. },
  17. /* 更新站点信息 */
  18. refreshData() {
  19. this.setData({
  20. user: wx.getStorageSync('userMsg')
  21. })
  22. /* 首页宫格授权查询 */
  23. if (wx.getStorageSync('userauth').length != 0) {
  24. let auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], []),
  25. gridList = [],
  26. authList = {};
  27. wx.setStorageSync('auth', authList)
  28. gridList.push({
  29. name: "商城",
  30. path: "/packageA/market/index",
  31. color: "#F29C37",
  32. bColor: "#FCF6EF",
  33. icon: "icon-shangcheng"
  34. })
  35. gridList.push({
  36. name: "销售订单",
  37. path: "/packageA/orderForm/index",
  38. color: "#5AB73F",
  39. bColor: "#F4FAEF",
  40. icon: "icon-dingdan"
  41. })
  42. gridList.push({
  43. name: "收货",
  44. path: "/packageA/shipment/index",
  45. color: "#3874F6",
  46. bColor: "#F0F3FF",
  47. icon: "icon-shouhuo"
  48. })
  49. gridList.push({
  50. name: "业绩目标",
  51. path: "/packageA/target/index",
  52. color: "#5AB73F",
  53. bColor: "#F4FAEF",
  54. icon: "icon-yejimubiao"
  55. })
  56. gridList.push({
  57. name: "账户",
  58. path: "/packageA/account/index",
  59. color: "#EB4B5C",
  60. bColor: "#FDF1ED",
  61. icon: "icon-zhanghu"
  62. })
  63. gridList.push({
  64. name: "促销活动",
  65. path: "/packageA/activity/index",
  66. color: "#3874F6",
  67. bColor: "#F0F3FF",
  68. icon: "icon-cuxiaohuodong"
  69. })
  70. gridList.push({
  71. name: "工具查询",
  72. path: "/packageA/tool/index",
  73. color: "#EB4B5C",
  74. bColor: "#FDF1ED",
  75. icon: "icon-kaipiao"
  76. })
  77. gridList.push({
  78. name: "购物车",
  79. path: "/packageA/shopping/index",
  80. color: "#EB4B5C",
  81. bColor: "#FDF1ED",
  82. icon: "icon-kaipiao"
  83. })
  84. gridList.push({
  85. name: "开票",
  86. path: "/packageA/invoice/index",
  87. color: "#EB4B5C",
  88. bColor: "#FDF1ED",
  89. icon: "icon-kaipiao"
  90. })
  91. /* ------------------------------- */
  92. gridList.push({
  93. name: "数据查询",
  94. path: "#",
  95. color: "#F29C37",
  96. bColor: "#FCF6EF",
  97. icon: "icon-shujuchaxun"
  98. })
  99. /* ------------------------------- */
  100. gridList.push({
  101. name: "打款凭证",
  102. path: "/packageA/remitVoucher/index",
  103. color: "#F29C37",
  104. bColor: "#FCF6EF",
  105. icon: "icon-shujuchaxun"
  106. })
  107. /* ------------------------------- */
  108. gridList.push({
  109. name: "工具归还",
  110. path: "/packageA/toolBill/index",
  111. color: "#F29C37",
  112. bColor: "#FCF6EF",
  113. icon: "icon-shujuchaxun"
  114. })
  115. /* ------------------------------- */
  116. gridList.push({
  117. name: "居间费结算",
  118. path: "/packageA/betweenFee/index",
  119. color: "#F29C37",
  120. bColor: "#FCF6EF",
  121. icon: "icon-shujuchaxun"
  122. })
  123. this.setData({
  124. gridList
  125. })
  126. } else {
  127. setTimeout(this.refreshData, 10);
  128. return;
  129. }
  130. /* 获取首页banner */
  131. let banner = wx.getStorageSync('banner_list').find(v => v.location == "index_top");
  132. if (banner) this.setData({
  133. bannerList: banner.ads
  134. })
  135. },
  136. /* 获取最新信息 */
  137. queryMessage(i = 0) {
  138. _Http.basic({
  139. "classname": "system.message.Message",
  140. "method": "queryMessage",
  141. content: {
  142. nocache: true,
  143. pageNumber: 1,
  144. pageSize: 5,
  145. pageTotal: 1,
  146. type: "",
  147. where: {}
  148. },
  149. }, false).then(res => {
  150. if (res.msg != '成功') return (i <= 5) ? this.queryMessage(i + 1) : wx.showToast({
  151. title: res.msg,
  152. icon: "none"
  153. })
  154. this.setData({
  155. msgList: res.data,
  156. notice: res.data[0]
  157. })
  158. if (this.data.msgList.length > 2) this.startDataCarousel();
  159. })
  160. },
  161. /* 开启消息轮播 */
  162. startDataCarousel() {
  163. clearInterval(DataCarousel);
  164. DataCarousel = setInterval(() => {
  165. let count = this.data.msgCount < this.data.msgList.length ? this.data.msgCount : 0;
  166. this.setData({
  167. msgCount: count + 1,
  168. notice: this.data.msgList[count]
  169. })
  170. }, 5000)
  171. },
  172. /* 去消息详情 */
  173. toMsg(e) {
  174. const {
  175. item
  176. } = e.currentTarget.dataset;
  177. wx.navigateTo({
  178. url: '/pages/tabbar/message/details?id=' + item.messageid,
  179. })
  180. },
  181. /* banner */
  182. bannerClick(e) {
  183. const {
  184. item
  185. } = e.currentTarget.dataset,
  186. hyperlink = item.hyperlink.split(":");
  187. if (hyperlink[0] == 'path') wx.navigateTo({
  188. url: hyperlink[1]
  189. })
  190. },
  191. onShow() {
  192. this.getTabBar().init();
  193. if (this.data.msgList.length > 2) this.startDataCarousel();
  194. this.queryMessage(0); //更新最新消息
  195. },
  196. onHide() {
  197. clearInterval(DataCarousel);
  198. },
  199. onReady() {
  200. this.setListHeight();
  201. },
  202. /* 设置页面高度 */
  203. setListHeight() {
  204. this.selectComponent("#ListBox").setHeight(".grld-title", this);
  205. },
  206. onShareAppMessage() {}
  207. })