evaluate.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view class="u-flex u-f-d-c">
  3. <!-- <view class="u-font-24 u-m-t-14" style="color: #a6a6a6;">我的评价 </view> -->
  4. <view class="u-m-t-60">
  5. <u-rate size="56" gutter="18" active-color="#f6db4d" :count="count" v-model="form.score"></u-rate>
  6. <view class="u-font-28 u-flex u-box-active6" style="color: #a6a6a6;">
  7. <view v-for="(index,key) in text" :key="key" :class="key==0?'':'u-m-l-20'">{{index}}</view>
  8. </view>
  9. </view>
  10. <!-- <view class="u-m-t-26 u-m-b-14 m-w" style="height: 1px; background: #d9d9d9;"></view> -->
  11. <view class=" m-w textar u-m-l-6" style=" background:#FFFFFF;">
  12. <textarea v-model="form.content" maxlength="300" placeholder="请输入300字以内的评价" />
  13. </view>
  14. <view class="eva-btn" @click="submit"> 评论</view>
  15. <u-toast ref="evast" />
  16. </view>
  17. </template>
  18. <script>
  19. import {
  20. commentsave
  21. } from '@/api/index'
  22. export default {
  23. data() {
  24. return {
  25. count: 5,
  26. text: ['极差', '较差', '一般', '不错', '很棒'],
  27. form: {
  28. score: undefined,
  29. respondentUserId: null,
  30. respondentUsername: null,
  31. content: undefined,
  32. }
  33. }
  34. },
  35. onLoad(option) {
  36. this.form.respondentUserId = option.userId
  37. this.form.respondentUsername = option.username
  38. },
  39. methods: {
  40. submit() {
  41. const {
  42. content,
  43. score
  44. } = this.form
  45. if (content && score) {
  46. commentsave(this.form)
  47. .then(({
  48. data,
  49. message,
  50. code
  51. }) => {
  52. if (code == 200) {
  53. this.$refs.evast.show({
  54. title: "评价成功",
  55. type: 'success',
  56. callback: () => {
  57. uni.navigateBack(1)
  58. }
  59. })
  60. } else {
  61. this.$refs.evast.show({
  62. title: "评价失败",
  63. type: 'info',
  64. })
  65. }
  66. })
  67. } else {
  68. this.$refs.evast.show({
  69. title: '请评价和评论',
  70. type: 'error',
  71. })
  72. }
  73. },
  74. }
  75. }
  76. </script>
  77. <style>
  78. .textar {
  79. box-sizing: border-box;
  80. width: 690rpx !important;
  81. height: 300rpx;
  82. background: #F2F2F2;
  83. margin-top: 65rpx;
  84. }
  85. .textar textarea {
  86. box-sizing: border-box;
  87. width: 100%;
  88. height: 300rpx;
  89. background: #F2F2F2;
  90. padding: 30rpx;
  91. }
  92. .eva-btn {
  93. width: 690rpx;
  94. height: 90rpx;
  95. background: #4A8BFF;
  96. border-radius: 4rpx;
  97. font-size: 28rpx;
  98. font-family: Microsoft YaHei-3970(82674968);
  99. font-weight: bold;
  100. color: #FFFFFF;
  101. line-height: 90rpx;
  102. text-align: center;
  103. margin-top: 36rpx;
  104. }
  105. </style>