body-section.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 && memberId">
  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="!memberId && !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. memberType: { type: String, default: '' },
  64. memberInfo: { type: Object, default: null },
  65. sandboxData: { type: Object, default: null },
  66. energyMap: { type: Object, default: null }
  67. },
  68. data: function() {
  69. return {
  70. loading: true,
  71. healthReport: null,
  72. dimensionOverview: null,
  73. checkinList: []
  74. }
  75. },
  76. mounted: function() {
  77. if (this.memberId) {
  78. this.loadData()
  79. } else {
  80. this.loading = false
  81. }
  82. },
  83. methods: {
  84. loadData: function() {
  85. var self = this
  86. getHealthAnalysis(this.memberId).then(function(res) {
  87. if (res.code === 200 && res.data) {
  88. self.healthReport = res.data
  89. }
  90. }).catch(function(e) { console.log('加载健康分析失败', e) })
  91. getDimensionOverview({ memberId: this.memberId }).then(function(res) {
  92. if (res.code === 200 && res.data) {
  93. self.dimensionOverview = res.data
  94. }
  95. }).catch(function(e) { console.log('加载维度概览失败', e) })
  96. getCheckinList({ memberId: this.memberId, page: 1, size: 3 }).then(function(res) {
  97. if (res.code === 200 && res.data) {
  98. self.checkinList = Array.isArray(res.data) ? res.data : (res.data.records || [])
  99. }
  100. }).catch(function(e) { console.log('加载打卡记录失败', e) })
  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. goReportDetail: function() {
  109. uni.navigateTo({ url: '/pages/body-detail/health-report?memberId=' + this.memberId })
  110. }
  111. }
  112. }
  113. </script>
  114. <style scoped>
  115. .body-section {}
  116. .section-card {
  117. background: #fff;
  118. border-radius: 24rpx;
  119. padding: 24rpx;
  120. margin-bottom: 20rpx;
  121. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  122. }
  123. .section-header {
  124. margin-bottom: 16rpx;
  125. }
  126. .section-title {
  127. font-size: 30rpx;
  128. font-weight: bold;
  129. color: #333;
  130. }
  131. .report-card {
  132. display: flex;
  133. flex-direction: column;
  134. align-items: center;
  135. padding: 20rpx 0;
  136. }
  137. .report-score {
  138. font-size: 72rpx;
  139. font-weight: bold;
  140. color: #FF8C42;
  141. }
  142. .report-label {
  143. font-size: 24rpx;
  144. color: #999;
  145. margin-top: 8rpx;
  146. }
  147. .report-meta {
  148. padding-top: 12rpx;
  149. border-top: 1rpx solid #f0f0f0;
  150. }
  151. .report-date {
  152. font-size: 24rpx;
  153. color: #999;
  154. }
  155. .checkin-item {
  156. display: flex;
  157. flex-direction: row;
  158. justify-content: space-between;
  159. padding: 16rpx 0;
  160. border-bottom: 1rpx solid #f5f5f5;
  161. }
  162. .checkin-type {
  163. font-size: 28rpx;
  164. color: #333;
  165. }
  166. .checkin-time {
  167. font-size: 24rpx;
  168. color: #999;
  169. }
  170. .empty-state {
  171. padding: 30rpx 0;
  172. text-align: center;
  173. }
  174. .empty-text {
  175. font-size: 28rpx;
  176. color: #999;
  177. }
  178. .empty-sub {
  179. font-size: 24rpx;
  180. color: #ccc;
  181. margin-top: 8rpx;
  182. }
  183. .loading {
  184. text-align: center;
  185. padding: 40rpx;
  186. color: #999;
  187. }
  188. </style>