body-section.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="body-section">
  3. <!-- 最新健康报告 -->
  4. <view class="section-card" v-if="healthReport">
  5. <view class="section-header">
  6. <text class="section-title">📋 最新健康报告</text>
  7. </view>
  8. <view class="report-card" @click="goReportDetail">
  9. <text class="report-score">{{ healthReport.overallScore || '--' }}</text>
  10. <text class="report-label">综合健康分</text>
  11. </view>
  12. <view class="report-meta">
  13. <text class="report-date">报告日期:{{ formatDate(healthReport.reportDate) }}</text>
  14. </view>
  15. </view>
  16. <view class="section-card" v-else-if="!loading && childId">
  17. <view class="empty-state">
  18. <text class="empty-text">暂无健康报告</text>
  19. <text class="empty-sub">规划师录入后将自动显示</text>
  20. </view>
  21. </view>
  22. <!-- 七维健康图 -->
  23. <view class="section-card" v-if="dimensionOverview && dimensionOverview.dimensions">
  24. <view class="section-header">
  25. <text class="section-title">📊 七维健康图</text>
  26. </view>
  27. <RadarChart
  28. :dimensions="dimensionOverview.dimensions.map(function(d) { return { label: d.label, key: d.dimension } })"
  29. :scores="dimensionOverview.dimensions.map(function(d) { return d.score })"
  30. fillColor="#FF8C42"
  31. gridColor="#FED7AA"
  32. labelColor="#9A3412"
  33. :width="580"
  34. :height="400" />
  35. </view>
  36. <!-- 最近打卡 -->
  37. <view class="section-card" v-if="checkinList.length > 0">
  38. <view class="section-header">
  39. <text class="section-title">🏃 最近打卡</text>
  40. </view>
  41. <view class="checkin-item" v-for="item in checkinList" :key="item.id">
  42. <text class="checkin-type">{{ item.typeName || item.type }}</text>
  43. <text class="checkin-time">{{ formatDate(item.createTime) }}</text>
  44. </view>
  45. </view>
  46. <!-- 非孩子成员提示 -->
  47. <view class="section-card" v-if="!childId && !loading">
  48. <view class="empty-state">
  49. <text class="empty-text">该成员暂无健康数据</text>
  50. </view>
  51. </view>
  52. <!-- 加载中 -->
  53. <view class="loading" v-if="loading">加载中...</view>
  54. </view>
  55. </template>
  56. <script>
  57. import RadarChart from '../RadarChart.vue'
  58. import { getHealthAnalysis, getDimensionOverview, getCheckinList } from '../../utils/api.js'
  59. export default {
  60. components: { RadarChart },
  61. props: {
  62. memberId: { type: [Number, String], default: null },
  63. childId: { type: [Number, String], default: null },
  64. memberType: { type: String, default: '' },
  65. memberInfo: { type: Object, default: null },
  66. sandboxData: { type: Object, default: null },
  67. energyMap: { type: Object, default: null }
  68. },
  69. data: function() {
  70. return {
  71. loading: true,
  72. healthReport: null,
  73. dimensionOverview: null,
  74. checkinList: []
  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. getHealthAnalysis(this.childId).then(function(res) {
  88. if (res.code === 200 && res.data) {
  89. self.healthReport = res.data
  90. }
  91. }).catch(function(e) { console.log('加载健康分析失败', e) })
  92. getDimensionOverview({ childId: this.childId }).then(function(res) {
  93. if (res.code === 200 && res.data) {
  94. self.dimensionOverview = res.data
  95. }
  96. }).catch(function(e) { console.log('加载维度概览失败', e) })
  97. getCheckinList({ childId: this.childId, page: 1, size: 3 }).then(function(res) {
  98. if (res.code === 200 && res.data) {
  99. self.checkinList = Array.isArray(res.data) ? res.data : (res.data.records || [])
  100. }
  101. }).catch(function(e) { console.log('加载打卡记录失败', e) })
  102. this.loading = false
  103. },
  104. formatDate: function(dateStr) {
  105. if (!dateStr) return ''
  106. var d = new Date(dateStr)
  107. return d.getFullYear() + '-' + (d.getMonth()+1) + '-' + d.getDate()
  108. },
  109. goReportDetail: function() {
  110. uni.navigateTo({ url: '/pages/body-detail/health-report?childId=' + this.childId })
  111. }
  112. }
  113. }
  114. </script>
  115. <style scoped>
  116. .body-section {}
  117. .section-card {
  118. background: #fff;
  119. border-radius: 24rpx;
  120. padding: 24rpx;
  121. margin-bottom: 20rpx;
  122. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  123. }
  124. .section-header {
  125. margin-bottom: 16rpx;
  126. }
  127. .section-title {
  128. font-size: 30rpx;
  129. font-weight: bold;
  130. color: #333;
  131. }
  132. .report-card {
  133. display: flex;
  134. flex-direction: column;
  135. align-items: center;
  136. padding: 20rpx 0;
  137. }
  138. .report-score {
  139. font-size: 72rpx;
  140. font-weight: bold;
  141. color: #FF8C42;
  142. }
  143. .report-label {
  144. font-size: 24rpx;
  145. color: #999;
  146. margin-top: 8rpx;
  147. }
  148. .report-meta {
  149. padding-top: 12rpx;
  150. border-top: 1rpx solid #f0f0f0;
  151. }
  152. .report-date {
  153. font-size: 24rpx;
  154. color: #999;
  155. }
  156. .checkin-item {
  157. display: flex;
  158. flex-direction: row;
  159. justify-content: space-between;
  160. padding: 16rpx 0;
  161. border-bottom: 1rpx solid #f5f5f5;
  162. }
  163. .checkin-type {
  164. font-size: 28rpx;
  165. color: #333;
  166. }
  167. .checkin-time {
  168. font-size: 24rpx;
  169. color: #999;
  170. }
  171. .empty-state {
  172. padding: 30rpx 0;
  173. text-align: center;
  174. }
  175. .empty-text {
  176. font-size: 28rpx;
  177. color: #999;
  178. }
  179. .empty-sub {
  180. font-size: 24rpx;
  181. color: #ccc;
  182. margin-top: 8rpx;
  183. }
  184. .loading {
  185. text-align: center;
  186. padding: 40rpx;
  187. color: #999;
  188. }
  189. </style>