body-section.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. import { parseDate } from '../../utils/format.js'
  60. export default {
  61. components: { RadarChart },
  62. props: {
  63. memberId: { 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.memberId) {
  79. this.loadData()
  80. } else {
  81. this.loading = false
  82. }
  83. },
  84. methods: {
  85. loadData: function() {
  86. var self = this
  87. getHealthAnalysis(this.memberId).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({ memberId: this.memberId }).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({ memberId: this.memberId, 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 = parseDate(dateStr)
  107. if (!d) return ''
  108. return d.getFullYear() + '-' + (d.getMonth()+1) + '-' + d.getDate()
  109. },
  110. goReportDetail: function() {
  111. uni.navigateTo({ url: '/pages/body-detail/health-report?memberId=' + this.memberId })
  112. }
  113. }
  114. }
  115. </script>
  116. <style scoped>
  117. .body-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. .report-card {
  134. display: flex;
  135. flex-direction: column;
  136. align-items: center;
  137. padding: 20rpx 0;
  138. }
  139. .report-score {
  140. font-size: 72rpx;
  141. font-weight: bold;
  142. color: #FF8C42;
  143. }
  144. .report-label {
  145. font-size: 24rpx;
  146. color: #999;
  147. margin-top: 8rpx;
  148. }
  149. .report-meta {
  150. padding-top: 12rpx;
  151. border-top: 1rpx solid #f0f0f0;
  152. }
  153. .report-date {
  154. font-size: 24rpx;
  155. color: #999;
  156. }
  157. .checkin-item {
  158. display: flex;
  159. flex-direction: row;
  160. justify-content: space-between;
  161. padding: 16rpx 0;
  162. border-bottom: 1rpx solid #f5f5f5;
  163. }
  164. .checkin-type {
  165. font-size: 28rpx;
  166. color: #333;
  167. }
  168. .checkin-time {
  169. font-size: 24rpx;
  170. color: #999;
  171. }
  172. .empty-state {
  173. padding: 30rpx 0;
  174. text-align: center;
  175. }
  176. .empty-text {
  177. font-size: 28rpx;
  178. color: #999;
  179. }
  180. .empty-sub {
  181. font-size: 24rpx;
  182. color: #ccc;
  183. margin-top: 8rpx;
  184. }
  185. .loading {
  186. text-align: center;
  187. padding: 40rpx;
  188. color: #999;
  189. }
  190. </style>