index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const getHeight = require("../../utils/getRheRemainingHeight");
  2. const _Http = getApp().globalData.http;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. scrollHeight: 0,
  9. list: [],
  10. "content": {
  11. nocache: true,
  12. "pageNumber": 1,
  13. "pageSize": 20,
  14. "pageTotal": 1,
  15. "where": {
  16. "condition": ""
  17. }
  18. },
  19. unreadNum: 0
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad(options) {
  25. const auth = options.auth ? JSON.parse(options.auth) : getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['通告'])[0].apps;
  26. let authList = [];
  27. auth[0].meta.auth.forEach(v => authList.push(v.optionname));
  28. this.setData({
  29. authList
  30. })
  31. this.getList();
  32. },
  33. getList(init = false) {
  34. if (init.detail != undefined) init = init.detail;
  35. if (init) this.setData({
  36. ['content.pageNumber']: 1
  37. })
  38. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  39. _Http.basic({
  40. "classname": "saletool.notice.notice",
  41. "method": "queryNoticeList",
  42. content: this.data.content
  43. }).then(res => {
  44. console.log("通告列表", res)
  45. this.selectComponent('#ListBox').RefreshToComplete();
  46. if (res.msg != '成功') return wx.showToast({
  47. title: res.msg,
  48. icon: "none"
  49. })
  50. this.setData({
  51. total: res.total,
  52. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  53. ['content.pageNumber']: res.pageNumber + 1,
  54. ['content.pageTotal']: res.pageTotal,
  55. unreadNum: res.total - res.tips.readNum
  56. })
  57. })
  58. },
  59. /* 查看详情 */
  60. toDetails(e) {
  61. const {
  62. item
  63. } = e.currentTarget.dataset, authList = this.data.authList;
  64. wx.navigateTo({
  65. url: `./details?id=${item.sat_noticeid}&auth=${authList}`
  66. })
  67. },
  68. /**
  69. * 生命周期函数--监听页面初次渲染完成
  70. */
  71. onReady() {
  72. getHeight.getHeight('.top', this).then(res => {
  73. this.setData({
  74. scrollHeight: res
  75. })
  76. })
  77. },
  78. onShareAppMessage(res) { }
  79. })