items.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. comments: {
  8. type: Array,
  9. value: []
  10. },
  11. ownertable: {
  12. type: String,
  13. value: 'sys_datafollowup'
  14. },
  15. ownerid: {
  16. type: String
  17. },
  18. replyid: {
  19. type: [Number, String]
  20. },
  21. userid: {
  22. type: [Number, String]
  23. }
  24. },
  25. lifetimes: {
  26. attached: function () {
  27. getApp().globalData.Language.getLanguagePackage(this)
  28. }
  29. },
  30. data: {
  31. loading: false,
  32. comment: '',
  33. },
  34. methods: {
  35. onInput(e) {
  36. this.setData({
  37. comment: e.detail.value
  38. })
  39. },
  40. onSend() {
  41. this.setData({
  42. loading: true
  43. })
  44. _Http.basic({
  45. "id": 20240429161601,
  46. "content": {
  47. "ownertable": this.data.ownertable, //数据表
  48. "ownerid": this.data.ownerid,
  49. "content": this.data.comment,
  50. replyid: this.data.replyid
  51. }
  52. }).then(res => {
  53. console.log("发送评论", res)
  54. this.setData({
  55. loading: false
  56. })
  57. wx.showToast({
  58. title: getApp().globalData.Language.getMapText(res.code == '1' ? '回复成功' : res.msg),
  59. icon: "none"
  60. })
  61. if (res.code == '1') {
  62. this.setData({
  63. comment: ""
  64. })
  65. _Http[this.data.ownerid].updateCommentList();
  66. _Http[this.data.ownerid].changeReply()
  67. }
  68. })
  69. },
  70. reply(e) {
  71. let {
  72. item
  73. } = e.currentTarget.dataset;
  74. _Http[this.data.ownerid].changeReply(item.sys_datacommentid)
  75. this.setData({
  76. comment: '',
  77. replyUser: item
  78. })
  79. },
  80. deleteItem(e) {
  81. const {
  82. item
  83. } = e.currentTarget.dataset;
  84. wx.showModal({
  85. title: getApp().globalData.Language.getMapText('提示'),
  86. content: getApp().globalData.Language.getMapText('是否确定删除该评论'),
  87. complete: ({
  88. confirm
  89. }) => {
  90. if (confirm) _Http.basic({
  91. "id": 20240429161701,
  92. "content": {
  93. "sys_datacommentid": item.sys_datacommentid
  94. }
  95. }).then(res => {
  96. console.log("删除评论", res)
  97. wx.showToast({
  98. title: getApp().globalData.Language.getMapText(res.code == '1' ? '删除成功' : res.msg),
  99. icon: "none"
  100. });
  101. if (res.code == '1') {
  102. _Http[this.data.ownerid].updateCommentList();
  103. }
  104. })
  105. }
  106. })
  107. },
  108. }
  109. })