feedback-popup.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="fb-overlay" v-if="visible" @tap="close">
  3. <view class="fb-body" @tap.stop>
  4. <view class="fb-header">
  5. <text class="fb-title">报告反馈</text>
  6. <text class="fb-close" @tap="close">×</text>
  7. </view>
  8. <textarea class="fb-textarea" v-model="content" placeholder="请描述您的问题或建议..." maxlength="500" />
  9. <picker :value="typeIndex" :range="types" @change="onTypeChange">
  10. <view class="fb-picker">
  11. <text>{{ types[typeIndex] }}</text>
  12. <text class="fb-arrow">▼</text>
  13. </view>
  14. </picker>
  15. <view class="fb-actions">
  16. <view class="fb-btn fb-btn-cancel" @tap="close">取消</view>
  17. <view class="fb-btn fb-btn-submit" @tap="submit">提交反馈</view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import { submitFeedback } from '../utils/api.js'
  24. export default {
  25. props: {
  26. visible: Boolean,
  27. reportId: Number
  28. },
  29. data: function() {
  30. return {
  31. content: '',
  32. types: ['功能建议', '数据疑问', '内容错误', '其他'],
  33. typeIndex: 0,
  34. submitting: false
  35. }
  36. },
  37. methods: {
  38. onTypeChange: function(e) {
  39. this.typeIndex = e.detail.value
  40. },
  41. close: function() {
  42. this.$emit('close')
  43. },
  44. submit: function() {
  45. if (!this.content.trim()) {
  46. uni.showToast({ title: '请填写内容', icon: 'none' })
  47. return
  48. }
  49. if (this.submitting) return
  50. this.submitting = true
  51. var self = this
  52. var payload = {
  53. reportId: this.reportId,
  54. type: this.types[this.typeIndex],
  55. content: this.content.trim()
  56. }
  57. submitFeedback(payload).then(function(res) {
  58. if (res.code === 200) {
  59. uni.showToast({ title: '感谢反馈', icon: 'success' })
  60. self.content = ''
  61. self.typeIndex = 0
  62. self.close()
  63. } else {
  64. uni.showToast({ title: res.message || '提交失败', icon: 'none' })
  65. }
  66. }).catch(function() {
  67. uni.showToast({ title: '提交失败', icon: 'none' })
  68. }).then(function() {
  69. self.submitting = false
  70. })
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped>
  76. .fb-overlay {
  77. position: fixed;
  78. top: 0;
  79. left: 0;
  80. right: 0;
  81. bottom: 0;
  82. background: rgba(0,0,0,0.4);
  83. z-index: 999;
  84. display: flex;
  85. align-items: flex-end;
  86. }
  87. .fb-body {
  88. background: #fff;
  89. border-radius: 20rpx 20rpx 0 0;
  90. padding: 30rpx;
  91. width: 100%;
  92. box-sizing: border-box;
  93. }
  94. .fb-header {
  95. display: flex;
  96. justify-content: space-between;
  97. align-items: center;
  98. margin-bottom: 20rpx;
  99. }
  100. .fb-title {
  101. font-size: 32rpx;
  102. font-weight: 600;
  103. color: #333;
  104. }
  105. .fb-close {
  106. font-size: 40rpx;
  107. color: #999;
  108. padding: 0 10rpx;
  109. }
  110. .fb-textarea {
  111. width: 100%;
  112. height: 200rpx;
  113. border: 1rpx solid #eee;
  114. border-radius: 12rpx;
  115. padding: 20rpx;
  116. font-size: 26rpx;
  117. box-sizing: border-box;
  118. margin-bottom: 16rpx;
  119. }
  120. .fb-picker {
  121. display: flex;
  122. justify-content: space-between;
  123. align-items: center;
  124. padding: 20rpx;
  125. border: 1rpx solid #eee;
  126. border-radius: 12rpx;
  127. margin-bottom: 20rpx;
  128. font-size: 26rpx;
  129. color: #333;
  130. }
  131. .fb-arrow {
  132. color: #999;
  133. font-size: 22rpx;
  134. }
  135. .fb-actions {
  136. display: flex;
  137. }
  138. .fb-btn {
  139. flex: 1;
  140. text-align: center;
  141. padding: 20rpx;
  142. border-radius: 12rpx;
  143. font-size: 28rpx;
  144. }
  145. .fb-btn-cancel {
  146. border: 1rpx solid #ddd;
  147. color: #666;
  148. margin-right: 20rpx;
  149. }
  150. .fb-btn-submit {
  151. background: #4A9BD7;
  152. color: #fff;
  153. }
  154. </style>