index.js 2.3 KB

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