index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. },
  5. options: {
  6. addGlobalClass: true
  7. },
  8. data: {
  9. height: 0,
  10. list: [],
  11. content: {
  12. nocache: true,
  13. pageNumber: 1,
  14. pageSize: 20,
  15. pageTotal: 1,
  16. type: "应用",
  17. where: {}
  18. },
  19. total: 0,
  20. tabshow: false
  21. },
  22. methods: {
  23. init() {
  24. this.setData({
  25. tabshow: true
  26. })
  27. this.getlist(true);
  28. return true;
  29. },
  30. getlist(init = false) {
  31. if (init.detail != undefined) init = init.detail;
  32. if (init) this.setData({
  33. ['content.pageNumber']: 1
  34. })
  35. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  36. _Http.basic({
  37. "classname": "system.message.Message",
  38. "method": "queryMessage",
  39. content: this.data.content
  40. }).then(res => {
  41. console.log("xiaox", res)
  42. this.selectComponent("#ListBox").setHeight("#tabs", this);
  43. this.selectComponent('#ListBox').RefreshToComplete();
  44. if (res.msg != '成功') return wx.showToast({
  45. title: res.msg,
  46. icon: "none"
  47. })
  48. this.setData({
  49. total: res.total,
  50. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  51. ['content.pageNumber']: res.pageNumber + 1,
  52. ['content.pageTotal']: res.pageTotal
  53. })
  54. })
  55. },
  56. //切换tab选项
  57. tabChange({
  58. detail
  59. }) {
  60. this.setData({
  61. "content.type": detail.name
  62. })
  63. this.getlist(true);
  64. },
  65. onAllRead() {
  66. wx.showModal({
  67. title: '提示',
  68. content: '是否确定阅读所有消息',
  69. complete: (res) => {
  70. if (res.confirm) {
  71. console.log("s")
  72. _Http.basic({
  73. "classname": "system.message.Message",
  74. "method": "readAllMessage",
  75. content: {}
  76. }).then(res => {
  77. console.log("一键阅读", res)
  78. wx.showToast({
  79. title: res.msg != '成功' ? res.msg : "操作成功",
  80. icon: "none"
  81. });
  82. getApp().globalData.socketCallback()
  83. this.setData({
  84. list: this.data.list.map(v => {
  85. v.isread = 1;
  86. return v
  87. })
  88. })
  89. })
  90. }
  91. }
  92. })
  93. },
  94. callback({
  95. detail
  96. }) {
  97. let i = this.data.list.findIndex(v => v.messageid == detail);
  98. this.setData({
  99. [`list[${i}].isread`]: 1
  100. })
  101. }
  102. }
  103. })