my-feedback.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="mf-page" :style="{ '--font-scale': fontScale }">
  3. <view class="mf-list" v-if="list.length > 0">
  4. <view class="mf-item" v-for="(item, idx) in list" :key="item.id">
  5. <view class="mf-item-head">
  6. <text class="mf-badge" :class="item.feedbackType === 'suggestion' ? 'mf-badge-suggestion' : 'mf-badge-question'">{{ typeText(item) }}</text>
  7. <text class="mf-time">{{ formatTime(item.createdAt) }}</text>
  8. </view>
  9. <text class="mf-content">{{ item.content }}</text>
  10. <view class="mf-answer">
  11. <text class="mf-answer-label">解答</text>
  12. <text class="mf-answer-text" v-if="isAnswered(item)">{{ item.aiAnswer }}</text>
  13. <text class="mf-answer-text mf-answer-muted" v-else-if="isPending(item)">解答生成中,请稍后刷新查看</text>
  14. <text class="mf-answer-text mf-answer-muted" v-else>解答暂不可用</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="mf-empty" v-else-if="!loading">
  19. <text class="mf-empty-icon">💬</text>
  20. <text class="mf-empty-text">还没有提交过反馈</text>
  21. <text class="mf-empty-hint">在健康报告详情页可以向我们提出疑问或建议</text>
  22. </view>
  23. <view class="mf-loading" v-else>
  24. <text class="mf-loading-text">加载中...</text>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { getMyReportFeedbacks } from '../../utils/api.js'
  30. import fontScaleMixin from '@/mixins/font-scale.js'
  31. export default {
  32. mixins: [fontScaleMixin],
  33. data: function() {
  34. return {
  35. list: [],
  36. loading: false,
  37. reportId: null
  38. }
  39. },
  40. onLoad: function(options) {
  41. if (options && options.reportId) {
  42. this.reportId = Number(options.reportId)
  43. }
  44. },
  45. onShow: function() {
  46. this.loadList()
  47. },
  48. onPullDownRefresh: function() {
  49. var self = this
  50. this.loadList(function() {
  51. uni.stopPullDownRefresh()
  52. })
  53. },
  54. methods: {
  55. loadList: function(done) {
  56. var self = this
  57. this.loading = true
  58. var payload = {}
  59. if (this.reportId) payload.reportId = this.reportId
  60. getMyReportFeedbacks(payload).then(function(res) {
  61. if (res.code === 200) {
  62. self.list = res.data || []
  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.loading = false
  70. if (done) done()
  71. })
  72. },
  73. typeText: function(item) {
  74. return item.feedbackType === 'suggestion' ? '建议' : '疑问'
  75. },
  76. isAnswered: function(item) {
  77. return item.aiStatus === 'answered' && !!item.aiAnswer
  78. },
  79. isPending: function(item) {
  80. return item.aiStatus === 'pending'
  81. },
  82. formatTime: function(v) {
  83. if (!v) return ''
  84. var s = String(v)
  85. if (s.length >= 19) return s.substring(0, 19).replace('T', ' ')
  86. return s.substring(0, 10)
  87. }
  88. }
  89. }
  90. </script>
  91. <style scoped lang="scss">
  92. .mf-page {
  93. min-height: 100vh;
  94. background: $app-surface-subtle;
  95. padding: 20rpx;
  96. box-sizing: border-box;
  97. }
  98. .mf-item {
  99. background: $app-surface;
  100. border-radius: 16rpx;
  101. padding: 24rpx;
  102. margin-bottom: 20rpx;
  103. }
  104. .mf-item-head {
  105. display: flex;
  106. justify-content: space-between;
  107. align-items: center;
  108. margin-bottom: 14rpx;
  109. }
  110. .mf-badge {
  111. font-size: calc(22rpx * var(--font-scale, 1));
  112. padding: 4rpx 16rpx;
  113. border-radius: 24rpx;
  114. }
  115. .mf-badge-question {
  116. color: $uni-info;
  117. background: $tint-sky-soft-2;
  118. }
  119. .mf-badge-suggestion {
  120. color: $status-warning-4;
  121. background: #FDF4E7;
  122. }
  123. .mf-time {
  124. font-size: calc(22rpx * var(--font-scale, 1));
  125. color: $facade-text-ghost-light;
  126. }
  127. .mf-content {
  128. display: block;
  129. font-size: calc(28rpx * var(--font-scale, 1));
  130. color: $facade-text-strong;
  131. line-height: 1.6;
  132. word-break: break-all;
  133. margin-bottom: 18rpx;
  134. }
  135. .mf-answer {
  136. background: $facade-fill-blue-ghost;
  137. border-radius: 16rpx;
  138. padding: 18rpx;
  139. }
  140. .mf-answer-label {
  141. display: block;
  142. font-size: calc(22rpx * var(--font-scale, 1));
  143. color: $status-success;
  144. margin-bottom: 8rpx;
  145. }
  146. .mf-answer-text {
  147. font-size: calc(26rpx * var(--font-scale, 1));
  148. color: $facade-text-strong;
  149. line-height: 1.7;
  150. word-break: break-all;
  151. }
  152. .mf-answer-muted {
  153. color: $facade-text-muted;
  154. }
  155. .mf-empty {
  156. padding: 160rpx 60rpx 0;
  157. display: flex;
  158. flex-direction: column;
  159. align-items: center;
  160. }
  161. .mf-empty-icon {
  162. font-size: calc($uni-font-size-5xl * var(--font-scale, 1));
  163. margin-bottom: 24rpx;
  164. }
  165. .mf-empty-text {
  166. font-size: calc(30rpx * var(--font-scale, 1));
  167. color: $facade-text-body;
  168. margin-bottom: 12rpx;
  169. }
  170. .mf-empty-hint {
  171. font-size: calc(24rpx * var(--font-scale, 1));
  172. color: $text-ghost-soft;
  173. text-align: center;
  174. line-height: 1.6;
  175. }
  176. .mf-loading {
  177. padding: 160rpx 0;
  178. display: flex;
  179. justify-content: center;
  180. }
  181. .mf-loading-text {
  182. font-size: calc(26rpx * var(--font-scale, 1));
  183. color: $facade-text-muted;
  184. }
  185. </style>