index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="tui-cards-container" v-if="display">
  3. <view class="service-evaluation">
  4. <view class="header">
  5. <label class="header-label">请对本次服务进行评价</label>
  6. <view class="btn-close" @tap="handleClose">关闭</view>
  7. </view>
  8. <view class="main">
  9. <view class="main-evaluation-score">
  10. <image
  11. v-for="(item, index) in scoreList"
  12. :key="index"
  13. class="score-star"
  14. :data-score="item"
  15. :src="'/static/static/images/star' + (item > score ? '-grey' : '') + '.png'"
  16. @tap="handleScore"
  17. ></image>
  18. </view>
  19. <textarea
  20. class="main-textarea"
  21. cols="30"
  22. rows="10"
  23. @input="bindTextAreaInput"
  24. placeholder="请输入评语"
  25. placeholder-style="textarea-placeholder"
  26. ></textarea>
  27. </view>
  28. <view class="footer"><view class="btn" @tap="sendMessage" :disabled="score === 0 && !comment">提交评价</view></view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. scoreList: [1, 2, 3, 4, 5],
  37. score: 5,
  38. comment: ''
  39. };
  40. },
  41. components: {},
  42. props: {
  43. display: {
  44. type: Boolean,
  45. default: ''
  46. }
  47. },
  48. watch: {
  49. display: {
  50. handler: function(newVal) {},
  51. immediate: true
  52. }
  53. },
  54. onPageShow() {
  55. this.score=0;
  56. this.score='';
  57. // this.setData({
  58. // score: 0,
  59. // comment: ''
  60. // });
  61. },
  62. methods: {
  63. handleClose() {
  64. this.$emit('close', {
  65. detail: {
  66. key: '2'
  67. }
  68. });
  69. },
  70. handleScore(e) {
  71. let { score } = e.currentTarget.dataset;
  72. if (score === this.score) {
  73. score = 0;
  74. }
  75. this.score=score;
  76. // this.setData({
  77. // score
  78. // });
  79. },
  80. bindTextAreaInput(e) {
  81. this.comment= e.detail.value;
  82. // this.setData({
  83. // comment: e.detail.value
  84. // });
  85. },
  86. sendMessage() {
  87. this.$emit('sendCustomMessage', {
  88. detail: {
  89. payload: {
  90. // data 字段作为表示,可以自定义
  91. data: 'evaluation',
  92. description: '对本次服务的评价',
  93. // 获取骰子点数
  94. extension: JSON.stringify({
  95. score: this.score,
  96. comment: this.comment
  97. })
  98. }
  99. }
  100. });
  101. this.setData({
  102. score: 0,
  103. comment: ''
  104. });
  105. this.handleClose();
  106. }
  107. }
  108. };
  109. </script>
  110. <style>
  111. @import './index.css';
  112. </style>