comment.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // pages/comment/comment.ts
  2. import { httpUtil } from "../../utils/restful"
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. veryGoodStatus: true,
  9. veryGoodUrls: '../../image/comment/comment_verygood_true.png',
  10. goodStatus: false,
  11. goodUrls: "../../image/comment/comment_good_false.png",
  12. notGoodStatus: false,
  13. notGoodUrl: "../../image/comment/comment_notgood_false.png",
  14. postFaultId: '',
  15. describe: ''
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad(options) {
  21. this.setData({
  22. postFaultId: options.faultId
  23. })
  24. },
  25. commitComment: function (e: any) {
  26. let content = e.detail.value['send - input'] ? e.detail.value['send - input'] : e.detail.value
  27. console.log("1====", content)
  28. this.setData({
  29. describe: content
  30. })
  31. this.postComment()
  32. },
  33. clickVeryGood() {
  34. this.setData({
  35. veryGoodStatus: true,
  36. veryGoodUrls: '../../image/comment/comment_verygood_true.png',
  37. goodStatus: false,
  38. goodUrls: "../../image/comment/comment_good_false.png",
  39. notGoodStatus: false,
  40. notGoodUrl: "../../image/comment/comment_notgood_false.png"
  41. })
  42. },
  43. clickGood() {
  44. this.setData({
  45. veryGoodStatus: false,
  46. veryGoodUrls: '../../image/comment/comment_verygood_false.png',
  47. goodStatus: true,
  48. goodUrls: "../../image/comment/comment_good_true.png",
  49. notGoodStatus: false,
  50. notGoodUrl: "../../image/comment/comment_notgood_false.png"
  51. })
  52. },
  53. clickNotGood() {
  54. this.setData({
  55. veryGoodStatus: false,
  56. veryGoodUrls: '../../image/comment/comment_verygood_false.png',
  57. goodStatus: false,
  58. goodUrls: "../../image/comment/comment_good_false.png",
  59. notGoodStatus: true,
  60. notGoodUrl: "../../image/comment/comment_notgood_true.png"
  61. })
  62. },
  63. postComment: function () {
  64. let params = {
  65. faultId: this.data.postFaultId,
  66. describe: this.data.describe
  67. }
  68. httpUtil.wxPost(httpUtil.interfaces.postComment, params).then((res => {
  69. console.log("提交评论成功:", res)
  70. wx.showToast({
  71. title: '提交成功',
  72. duration: 1000
  73. })
  74. setTimeout(function () {
  75. wx.navigateBack()
  76. }, 1000)
  77. })).catch((res) => {
  78. console.log("提交评论失败:", res)
  79. wx.showToast({
  80. title: '提交失败',
  81. duration: 1000
  82. })
  83. })
  84. }
  85. })