feedback.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="feedback-page">
  3. <EmptyState
  4. v-if="invalid"
  5. icon="🎪"
  6. title="未找到对应沙龙"
  7. desc="缺少沙龙信息,请返回活动列表重新选择"
  8. action-text="返回列表"
  9. @action="goBackList"
  10. />
  11. <view v-else class="section-card">
  12. <text class="section-title">沙龙反馈</text>
  13. <text class="card-desc">分享你对本次沙龙的感受与建议</text>
  14. <view class="summary-box" v-if="salonTitle">
  15. <text class="summary-text">{{ salonTitle }}</text>
  16. </view>
  17. <view class="rate-box">
  18. <text class="form-label">整体评分</text>
  19. <view class="star-row">
  20. <text
  21. v-for="star in 5"
  22. :key="star"
  23. class="star"
  24. :class="star <= rating ? 'star-on' : 'star-off'"
  25. @click="setRating(star)"
  26. >★</text>
  27. <text class="rate-tip">{{ ratingText }}</text>
  28. </view>
  29. </view>
  30. <view class="form-item">
  31. <text class="form-label">留言建议(选填)</text>
  32. <textarea
  33. class="form-input textarea"
  34. v-model="comment"
  35. maxlength="500"
  36. placeholder="说说你对沙龙内容、讲师、场地的建议…"
  37. />
  38. </view>
  39. <button class="submit-btn" @click="handleSubmit" :loading="loading" :disabled="loading">提交反馈</button>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import { salonFeedback } from '@/utils/api.js'
  45. import { guardPage } from '@/utils/guard.js'
  46. import EmptyState from '@/components/empty-state.vue'
  47. export default {
  48. components: { EmptyState },
  49. data() {
  50. return {
  51. salonId: '',
  52. salonTitle: '',
  53. rating: 5,
  54. comment: '',
  55. loading: false,
  56. invalid: false
  57. }
  58. },
  59. onLoad(options) {
  60. if (!guardPage()) return
  61. this.salonId = options && options.salonId ? options.salonId : ''
  62. this.salonTitle = options && options.title ? decodeURIComponent(options.title) : ''
  63. if (!this.salonId) {
  64. this.invalid = true
  65. }
  66. },
  67. computed: {
  68. ratingText() {
  69. var map = { 1: '很差', 2: '较差', 3: '一般', 4: '满意', 5: '非常满意' }
  70. return map[this.rating] || ''
  71. }
  72. },
  73. methods: {
  74. goBackList() {
  75. var pages = getCurrentPages()
  76. if (pages.length > 1) {
  77. uni.navigateBack()
  78. } else {
  79. uni.redirectTo({ url: '/pages/salon/list' })
  80. }
  81. },
  82. setRating: function(star) {
  83. this.rating = star
  84. },
  85. handleSubmit: function() {
  86. var self = this
  87. if (self.loading) return
  88. self.loading = true
  89. var payload = {
  90. salonId: self.salonId,
  91. rating: self.rating,
  92. comment: (self.comment || '').trim()
  93. }
  94. salonFeedback(payload).then(function() {
  95. uni.showToast({ title: '提交成功', icon: 'success' })
  96. setTimeout(function() {
  97. uni.navigateBack({ delta: 1 })
  98. }, 1200)
  99. }).catch(function(err) {
  100. uni.showToast({ title: (err && err.message) || '提交失败', icon: 'none' })
  101. }).finally(function() {
  102. self.loading = false
  103. })
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped>
  109. .feedback-page { min-height: 100vh; background: #F5FAFE; padding: 32rpx; }
  110. .section-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; }
  111. .section-title { display: block; font-size: 32rpx; font-weight: 700; color: #1E3A5F; margin-bottom: 8rpx; border-left: 8rpx solid #2E6FA8; padding-left: 16rpx; }
  112. .card-desc { display: block; font-size: 26rpx; color: #3B5A78; margin-bottom: 24rpx; }
  113. .summary-box { background: #E8F3FC; border-radius: 8rpx; padding: 20rpx 24rpx; margin-bottom: 24rpx; border: 2rpx solid #C3D2DF; }
  114. .summary-text { display: block; font-size: 28rpx; color: #1E3A5F; font-weight: 600; }
  115. .rate-box { margin-bottom: 24rpx; }
  116. .form-label { display: block; font-size: 26rpx; color: #3B5A78; font-weight: 500; margin-bottom: 12rpx; }
  117. .star-row { display: flex; align-items: center; }
  118. .star { font-size: 56rpx; margin-right: 16rpx; }
  119. .star-on { color: #2E6FA8; }
  120. .star-off { color: #C3D2DF; }
  121. .rate-tip { font-size: 26rpx; color: #3B5A78; margin-left: 8rpx; }
  122. .form-item { margin-bottom: 24rpx; }
  123. .form-input { width: 100%; box-sizing: border-box; border: 2rpx solid #E3ECF4; border-radius: 8rpx; padding: 16rpx; font-size: 28rpx; color: #1E3A5F; background: #F5FAFE; }
  124. .textarea { height: 240rpx; }
  125. .submit-btn { width: 100%; height: 88rpx; line-height: 88rpx; background: #2E6FA8; color: #FFF; font-size: 30rpx; font-weight: 600; border-radius: 44rpx; border: none; margin-top: 24rpx; }
  126. .submit-btn:active { opacity: 0.85; }
  127. </style>