index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. list: [],
  5. filtrate: false,
  6. "content": {
  7. nocache: true,
  8. "pageNumber": 1,
  9. "pageSize": 20,
  10. "pageTotal": 1,
  11. "where": {
  12. "condition": ""
  13. }
  14. },
  15. unreadNum: 0,
  16. filtratelist: [{
  17. label: "板块",
  18. index: null,
  19. showName: "classname", //显示字段
  20. valueKey: "sat_notice_classid", //返回Key
  21. selectKey: "sat_notice_classid", //传参 代表选着字段 不传参返回整个选择对象
  22. value: "", //选中值
  23. list: null
  24. }]
  25. },
  26. onLoad(options) {
  27. this.getList(true);
  28. },
  29. getList(init = false) {
  30. if (init.detail != undefined) init = init.detail;
  31. let content = this.data.content;
  32. if (init) content.pageNumber = 1;
  33. if (content.pageNumber > content.pageTotal) return;
  34. _Http.basic({
  35. id: 20221111090904,
  36. content: content
  37. }).then(res => {
  38. console.log("通告列表", res)
  39. this.selectComponent('#ListBox').RefreshToComplete();
  40. if (res.msg != '成功') return wx.showToast({
  41. title: res.msg,
  42. icon: "none"
  43. })
  44. this.setData({
  45. total: res.total,
  46. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  47. 'content.pageNumber': res.pageNumber + 1,
  48. 'content.pageTotal': res.pageTotal,
  49. unreadNum: res.total - res.tips.readNum
  50. })
  51. })
  52. },
  53. /* 查看详情 */
  54. toDetails(e) {
  55. const {
  56. item
  57. } = e.currentTarget.dataset;
  58. wx.navigateTo({
  59. url: `./details?id=${item.sat_noticeid}`
  60. })
  61. },
  62. onReady() {
  63. this.selectComponent("#ListBox").setHeight(".top", this);
  64. },
  65. startSearch({
  66. detail
  67. }) {
  68. if (detail == this.data.content.where.condition) return;
  69. this.data.content.where.condition = detail;
  70. this.getList(true);
  71. },
  72. /* 取消搜索 */
  73. onClear() {
  74. this.data.content.where.condition = "";
  75. this.getList(true);
  76. },
  77. openFiltrate() {
  78. console.log(123123)
  79. if (this.data.filtratelist[0].list == null) {
  80. _Http.basic({
  81. id: 20221101094603,
  82. "content": {
  83. nocache: true,
  84. "pageNumber": 1,
  85. "pageSize": 999,
  86. "where": {
  87. "condition": ""
  88. }
  89. }
  90. }).then(res => {
  91. console.log("通告板块", res)
  92. this.setData({
  93. "filtratelist[0].list": res.data,
  94. filtrate: true
  95. })
  96. })
  97. } else {
  98. this.setData({
  99. filtrate: true
  100. })
  101. }
  102. },
  103. /* 处理筛选 */
  104. handleFilter(e) {
  105. this.data.content.where.sat_notice_classid = e.detail.sat_notice_classid || "";
  106. this.getList(true)
  107. },
  108. })