wisdom-section.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 && childId">
  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="!childId && !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. childId: {
  50. type: [Number, String],
  51. default: null
  52. },
  53. memberType: {
  54. type: String,
  55. default: ''
  56. },
  57. memberInfo: {
  58. type: Object,
  59. default: null
  60. },
  61. sandboxData: {
  62. type: Object,
  63. default: null
  64. },
  65. energyMap: {
  66. type: Object,
  67. default: null
  68. }
  69. },
  70. data: function() {
  71. return {
  72. loading: true,
  73. latestResult: null,
  74. historyList: []
  75. }
  76. },
  77. mounted: function() {
  78. if (this.childId) {
  79. this.loadData()
  80. } else {
  81. this.loading = false
  82. }
  83. },
  84. methods: {
  85. loadData: function() {
  86. var self = this
  87. getAssessmentLatestResult(this.childId).then(function(res) {
  88. if (res.code === 200 && res.data) {
  89. self.latestResult = res.data
  90. }
  91. }).catch(function(e) {
  92. console.log('加载测评结果失败', e)
  93. })
  94. getAssessmentHistory(this.childId, 5).then(function(res) {
  95. if (res.code === 200 && res.data) {
  96. self.historyList = Array.isArray(res.data) ? res.data : (res.data.records || [])
  97. }
  98. }).catch(function(e) {
  99. console.log('加载测评历史失败', e)
  100. })
  101. this.loading = false
  102. },
  103. formatDate: function(dateStr) {
  104. if (!dateStr) return ''
  105. var d = new Date(dateStr)
  106. return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
  107. },
  108. goResultDetail: function() {
  109. uni.navigateTo({
  110. url: '/pages/wisdom/assessment-detail?childId=' + this.childId
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style scoped>
  117. .wisdom-section {}
  118. .section-card {
  119. background: #fff;
  120. border-radius: 24rpx;
  121. padding: 24rpx;
  122. margin-bottom: 20rpx;
  123. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  124. }
  125. .section-header {
  126. margin-bottom: 16rpx;
  127. }
  128. .section-title {
  129. font-size: 30rpx;
  130. font-weight: bold;
  131. color: #333;
  132. }
  133. .result-overview {
  134. display: flex;
  135. flex-direction: column;
  136. align-items: center;
  137. padding: 20rpx 0;
  138. }
  139. .result-score {
  140. font-size: 72rpx;
  141. font-weight: bold;
  142. color: #6366F1;
  143. }
  144. .result-dimension {
  145. font-size: 28rpx;
  146. color: #555;
  147. margin-top: 8rpx;
  148. }
  149. .result-date {
  150. font-size: 24rpx;
  151. color: #999;
  152. padding-top: 12rpx;
  153. border-top: 1rpx solid #f0f0f0;
  154. margin-top: 8rpx;
  155. }
  156. .history-item {
  157. display: flex;
  158. flex-direction: row;
  159. justify-content: space-between;
  160. padding: 14rpx 0;
  161. border-bottom: 1rpx solid #f5f5f5;
  162. }
  163. .history-title {
  164. font-size: 26rpx;
  165. color: #333;
  166. flex: 1;
  167. }
  168. .history-score {
  169. font-size: 26rpx;
  170. color: #6366F1;
  171. width: 80rpx;
  172. text-align: center;
  173. }
  174. .history-date {
  175. font-size: 22rpx;
  176. color: #999;
  177. width: 140rpx;
  178. text-align: right;
  179. }
  180. .empty-state {
  181. padding: 30rpx 0;
  182. text-align: center;
  183. }
  184. .empty-text {
  185. font-size: 28rpx;
  186. color: #999;
  187. }
  188. .empty-sub {
  189. font-size: 24rpx;
  190. color: #ccc;
  191. margin-top: 8rpx;
  192. }
  193. .loading {
  194. text-align: center;
  195. padding: 40rpx;
  196. color: #999;
  197. }
  198. </style>