wisdom-section.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="wisdom-section">
  3. <!-- 最新测评结果 -->
  4. <view class="section-card" v-if="latestResult">
  5. <view class="section-header">
  6. <text class="section-title">🧠 最新测评结果</text>
  7. </view>
  8. <view class="result-overview" @click="goResultDetail">
  9. <text class="result-score">{{ latestResult.score || '--' }}</text>
  10. <text class="result-dimension">{{ latestResult.dimensionName || latestResult.title || '综合测评' }}</text>
  11. </view>
  12. <view class="result-date">测评日期:{{ formatDate(latestResult.createTime || latestResult.testDate) }}</view>
  13. </view>
  14. <view class="section-card" v-else-if="!loading && memberId">
  15. <view class="empty-state">
  16. <text class="empty-text">暂无测评记录</text>
  17. <text class="empty-sub">完成测评后结果将显示在这里</text>
  18. </view>
  19. </view>
  20. <!-- 测评历史 -->
  21. <view class="section-card" v-if="historyList.length > 0">
  22. <view class="section-header">
  23. <text class="section-title">📋 测评历史</text>
  24. </view>
  25. <view class="history-item" v-for="item in historyList" :key="item.id" @click="goResultDetail">
  26. <text class="history-title">{{ item.title || item.dimensionName || '测评' }}</text>
  27. <text class="history-score">{{ item.score || '--' }}</text>
  28. <text class="history-date">{{ formatDate(item.createTime || item.testDate) }}</text>
  29. </view>
  30. </view>
  31. <!-- 非孩子成员提示 -->
  32. <view class="section-card" v-if="!memberId && !loading">
  33. <view class="empty-state">
  34. <text class="empty-text">该成员暂无测评数据</text>
  35. </view>
  36. </view>
  37. <!-- 加载中 -->
  38. <view class="loading" v-if="loading">加载中...</view>
  39. </view>
  40. </template>
  41. <script>
  42. import { getAssessmentLatestResult, getAssessmentHistory } from '../../utils/api.js'
  43. export default {
  44. props: {
  45. memberId: {
  46. type: [Number, String],
  47. default: null
  48. },
  49. memberType: {
  50. type: String,
  51. default: ''
  52. },
  53. memberInfo: {
  54. type: Object,
  55. default: null
  56. },
  57. sandboxData: {
  58. type: Object,
  59. default: null
  60. },
  61. energyMap: {
  62. type: Object,
  63. default: null
  64. }
  65. },
  66. data: function() {
  67. return {
  68. loading: true,
  69. latestResult: null,
  70. historyList: []
  71. }
  72. },
  73. mounted: function() {
  74. if (this.memberId) {
  75. this.loadData()
  76. } else {
  77. this.loading = false
  78. }
  79. },
  80. methods: {
  81. loadData: function() {
  82. var self = this
  83. getAssessmentLatestResult(this.memberId).then(function(res) {
  84. if (res.code === 200 && res.data) {
  85. self.latestResult = res.data
  86. }
  87. }).catch(function(e) {
  88. console.log('加载测评结果失败', e)
  89. })
  90. getAssessmentHistory(this.memberId, 5).then(function(res) {
  91. if (res.code === 200 && res.data) {
  92. self.historyList = Array.isArray(res.data) ? res.data : (res.data.records || [])
  93. }
  94. }).catch(function(e) {
  95. console.log('加载测评历史失败', e)
  96. })
  97. this.loading = false
  98. },
  99. formatDate: function(dateStr) {
  100. if (!dateStr) return ''
  101. var d = new Date(dateStr)
  102. return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
  103. },
  104. goResultDetail: function() {
  105. uni.navigateTo({
  106. url: '/pages/wisdom/assessment-detail?memberId=' + this.memberId
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style scoped>
  113. .wisdom-section {}
  114. .section-card {
  115. background: #fff;
  116. border-radius: 24rpx;
  117. padding: 24rpx;
  118. margin-bottom: 20rpx;
  119. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  120. }
  121. .section-header {
  122. margin-bottom: 16rpx;
  123. }
  124. .section-title {
  125. font-size: 30rpx;
  126. font-weight: bold;
  127. color: #333;
  128. }
  129. .result-overview {
  130. display: flex;
  131. flex-direction: column;
  132. align-items: center;
  133. padding: 20rpx 0;
  134. }
  135. .result-score {
  136. font-size: 72rpx;
  137. font-weight: bold;
  138. color: #6366F1;
  139. }
  140. .result-dimension {
  141. font-size: 28rpx;
  142. color: #555;
  143. margin-top: 8rpx;
  144. }
  145. .result-date {
  146. font-size: 24rpx;
  147. color: #999;
  148. padding-top: 12rpx;
  149. border-top: 1rpx solid #f0f0f0;
  150. margin-top: 8rpx;
  151. }
  152. .history-item {
  153. display: flex;
  154. flex-direction: row;
  155. justify-content: space-between;
  156. padding: 14rpx 0;
  157. border-bottom: 1rpx solid #f5f5f5;
  158. }
  159. .history-title {
  160. font-size: 26rpx;
  161. color: #333;
  162. flex: 1;
  163. }
  164. .history-score {
  165. font-size: 26rpx;
  166. color: #6366F1;
  167. width: 80rpx;
  168. text-align: center;
  169. }
  170. .history-date {
  171. font-size: 22rpx;
  172. color: #999;
  173. width: 140rpx;
  174. text-align: right;
  175. }
  176. .empty-state {
  177. padding: 30rpx 0;
  178. text-align: center;
  179. }
  180. .empty-text {
  181. font-size: 28rpx;
  182. color: #999;
  183. }
  184. .empty-sub {
  185. font-size: 24rpx;
  186. color: #ccc;
  187. margin-top: 8rpx;
  188. }
  189. .loading {
  190. text-align: center;
  191. padding: 40rpx;
  192. color: #999;
  193. }
  194. </style>