index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // import { getCommentDetail } from '../../../../services/good/comments/fetchCommentDetail';
  2. import Toast from 'tdesign-miniprogram/toast/index';
  3. Page({
  4. data: {
  5. serviceRateValue: 1,
  6. goodRateValue: 1,
  7. conveyRateValue: 1,
  8. isAnonymous: false,
  9. uploadFiles: [],
  10. gridConfig: {
  11. width: 218,
  12. height: 218,
  13. column: 3,
  14. },
  15. isAllowedSubmit: false,
  16. imgUrl: '',
  17. title: '',
  18. goodsDetail: '',
  19. imageProps: {
  20. mode: 'aspectFit',
  21. },
  22. },
  23. onLoad(options) {
  24. this.setData({
  25. imgUrl: options.imgUrl,
  26. title: options.title,
  27. goodsDetail: options.specs,
  28. });
  29. },
  30. onRateChange(e) {
  31. const { value } = e?.detail;
  32. const item = e?.currentTarget?.dataset?.item;
  33. this.setData({ [item]: value }, () => {
  34. this.updateButtonStatus();
  35. });
  36. },
  37. onAnonymousChange(e) {
  38. const status = !!e?.detail?.checked;
  39. this.setData({ isAnonymous: status });
  40. },
  41. handleSuccess(e) {
  42. const { files } = e.detail;
  43. this.setData({
  44. uploadFiles: files,
  45. });
  46. },
  47. handleRemove(e) {
  48. const { index } = e.detail;
  49. const { uploadFiles } = this.data;
  50. uploadFiles.splice(index, 1);
  51. this.setData({
  52. uploadFiles,
  53. });
  54. },
  55. onTextAreaChange(e) {
  56. const value = e?.detail?.value;
  57. this.textAreaValue = value;
  58. this.updateButtonStatus();
  59. },
  60. updateButtonStatus() {
  61. const { serviceRateValue, goodRateValue, conveyRateValue, isAllowedSubmit } = this.data;
  62. const { textAreaValue } = this;
  63. const temp = serviceRateValue && goodRateValue && conveyRateValue && textAreaValue;
  64. if (temp !== isAllowedSubmit) this.setData({ isAllowedSubmit: temp });
  65. },
  66. onSubmitBtnClick() {
  67. const { isAllowedSubmit } = this.data;
  68. if (!isAllowedSubmit) return;
  69. Toast({
  70. context: this,
  71. selector: '#t-toast',
  72. message: '评价提交成功',
  73. icon: 'check-circle',
  74. });
  75. wx.navigateBack();
  76. },
  77. });