index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. console.log(options.auth)
  26. let auth = JSON.parse(options.auth)[0].meta.auth;
  27. let authList = [];
  28. auth.forEach(v => authList.push(v.optionname));
  29. console.log(authList)
  30. this.setData({
  31. authList
  32. })
  33. this.getList();
  34. },
  35. getList(init = false) {
  36. if (init.detail != undefined) init = init.detail;
  37. if (init) this.setData({
  38. ['content.pageNumber']: 1
  39. })
  40. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  41. _Http.basic({
  42. "classname": "saletool.notice.notice",
  43. "method": "queryNoticeList",
  44. content: this.data.content
  45. }).then(res => {
  46. console.log("通告列表", res)
  47. this.selectComponent('#ListBox').RefreshToComplete();
  48. if (res.msg != '成功') return wx.showToast({
  49. title: res.data,
  50. icon: "none"
  51. })
  52. this.setData({
  53. total: res.total,
  54. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  55. ['content.pageNumber']: res.pageNumber + 1,
  56. ['content.pageTotal']: res.pageTotal,
  57. unreadNum: res.total - res.tips.readNum
  58. })
  59. })
  60. },
  61. /* 查看详情 */
  62. toDetails(e) {
  63. const {
  64. item
  65. } = e.currentTarget.dataset;
  66. let authList = this.data.authList;
  67. wx.navigateTo({
  68. url: `./details?id=${item.sat_noticeid}&feedback=${authList.includes('反馈')}&auth=${authList}`
  69. })
  70. },
  71. /**
  72. * 生命周期函数--监听页面初次渲染完成
  73. */
  74. onReady() {
  75. getHeight.getHeight('.top', this).then(res => {
  76. this.setData({
  77. scrollHeight: res
  78. })
  79. })
  80. },
  81. })