index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. try {
  29. let privacyFieldC = wx.getStorageSync('auth').worderform.forms.detail.formcols.map(v => v.title);
  30. this.setData({
  31. privacyFieldC
  32. })
  33. console.log("privacyFieldC", privacyFieldC)
  34. } catch (error) {
  35. console.error(error)
  36. }
  37. return true;
  38. },
  39. getlist(init = false) {
  40. if (init.detail != undefined) init = init.detail;
  41. if (init) this.setData({
  42. ['content.pageNumber']: 1
  43. })
  44. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  45. _Http.basic({
  46. "classname": "system.message.Message",
  47. "method": "queryMessage",
  48. content: this.data.content
  49. }).then(res => {
  50. console.log("xiaox", res)
  51. this.selectComponent("#ListBox").setHeight("#tabs", this);
  52. this.selectComponent('#ListBox').RefreshToComplete();
  53. if (res.msg != '成功') return wx.showToast({
  54. title: res.msg,
  55. icon: "none"
  56. })
  57. if (!this.data.privacyFieldC.find(v => v == '详情金额')) res.data = res.data.map(v => {
  58. if (v.message.includes('】元')) v.message = v.message.replace(/【(.*?)】/g, '【****】')
  59. return v
  60. })
  61. this.setData({
  62. total: res.total,
  63. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  64. ['content.pageNumber']: res.pageNumber + 1,
  65. ['content.pageTotal']: res.pageTotal
  66. })
  67. })
  68. },
  69. //切换tab选项
  70. tabChange({
  71. detail
  72. }) {
  73. this.setData({
  74. "content.type": detail.name
  75. })
  76. this.getlist(true);
  77. },
  78. onAllRead() {
  79. wx.showModal({
  80. title: '提示',
  81. content: '是否确定阅读所有消息',
  82. complete: (res) => {
  83. if (res.confirm) {
  84. console.log("s")
  85. _Http.basic({
  86. "classname": "system.message.Message",
  87. "method": "readAllMessage",
  88. content: {}
  89. }).then(res => {
  90. console.log("一键阅读", res)
  91. wx.showToast({
  92. title: res.msg != '成功' ? res.msg : "操作成功",
  93. icon: "none"
  94. });
  95. getApp().globalData.socketCallback()
  96. this.setData({
  97. list: this.data.list.map(v => {
  98. v.isread = 1;
  99. return v
  100. })
  101. })
  102. })
  103. }
  104. }
  105. })
  106. },
  107. callback({
  108. detail
  109. }) {
  110. let i = this.data.list.findIndex(v => v.messageid == detail);
  111. this.setData({
  112. [`list[${i}].isread`]: 1
  113. })
  114. }
  115. }
  116. })