mind-section.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="mind-section" v-if="hasFamily">
  3. <!-- 亲密关系评分 -->
  4. <view class="section-card" v-if="relationScores && relationScores.scores">
  5. <view class="section-header">
  6. <text class="section-title">💕 亲密关系评分</text>
  7. </view>
  8. <view class="score-item" v-for="(score, key) in relationScores.scores" :key="key">
  9. <text class="score-label">{{ score.label || key }}</text>
  10. <view class="score-bar-bg">
  11. <view class="score-bar-fill" :style="'width:' + (score.value || 0) + '%'"></view>
  12. </view>
  13. <text class="score-value">{{ score.value || 0 }}</text>
  14. </view>
  15. </view>
  16. <!-- 联系人 -->
  17. <view class="section-card" v-if="contactList.length > 0">
  18. <view class="section-header">
  19. <text class="section-title">📞 重要联系人</text>
  20. </view>
  21. <view class="contact-item" v-for="contact in contactList" :key="contact.id" @click="goContactDetail(contact)">
  22. <text class="contact-name">{{ contact.name }}</text>
  23. <text class="contact-relation">{{ contact.relation || '' }}</text>
  24. <text class="contact-phone">{{ contact.phone || '' }}</text>
  25. </view>
  26. </view>
  27. <!-- 健康告警 -->
  28. <view class="section-card" v-if="healthAlerts && healthAlerts.length > 0">
  29. <view class="section-header">
  30. <text class="section-title">⚠️ 健康告警</text>
  31. </view>
  32. <view class="alert-item" v-for="alert in healthAlerts" :key="alert.id">
  33. <text class="alert-type">{{ alert.type }}</text>
  34. <text class="alert-desc">{{ alert.description }}</text>
  35. </view>
  36. </view>
  37. <!-- 里程碑 -->
  38. <view class="section-card" v-if="milestones && milestones.length > 0">
  39. <view class="section-header">
  40. <text class="section-title">🎯 即将到来的里程碑</text>
  41. </view>
  42. <view
  43. class="milestone-item"
  44. v-for="(ms, idx) in milestones"
  45. :key="idx"
  46. >
  47. <text class="milestone-title">{{ ms.title }}</text>
  48. <text class="milestone-date">{{ ms.date }}</text>
  49. </view>
  50. </view>
  51. <!-- 加载中 -->
  52. <view class="loading" v-if="loading">加载中...</view>
  53. </view>
  54. <!-- FamilyEmptyState type="block" for no-family case -->
  55. <view v-else>
  56. <FamilyEmptyState type="block" />
  57. </view>
  58. </template>
  59. <script>
  60. import { getRelationshipScores, getContactList, getHealthAlerts, getMilestones } from '../../utils/api.js'
  61. export default {
  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. relationScores: null,
  73. contactList: [],
  74. healthAlerts: [],
  75. milestones: []
  76. }
  77. },
  78. computed: {
  79. hasFamily: function() {
  80. // 应急修复(2026-08-07,对齐 body/index.vue):store.familyId 在 familyId 后端派生改造后
  81. // 不再被写入,hasFamily 恒为 false 导致内容区被 v-else 空态吞掉。
  82. // 成员详情页必然处于家庭上下文中,基于 props 判断即可,store getter 仅兜底。
  83. if (this.memberId || (this.memberInfo && this.memberInfo.familyId)) {
  84. return true
  85. }
  86. return this.$store.getters.hasFamily
  87. }
  88. },
  89. mounted: function() {
  90. this.loadData()
  91. },
  92. methods: {
  93. loadData: function() {
  94. var self = this
  95. var familyId = (this.memberInfo && this.memberInfo.familyId) || ''
  96. if (familyId) {
  97. getRelationshipScores().then(function(res) {
  98. if (res.code === 200 && res.data) {
  99. self.relationScores = res.data
  100. }
  101. }).catch(function(e) { console.log('加载关系评分失败', e) })
  102. getContactList({}).then(function(res) {
  103. if (res.code === 200 && res.data) {
  104. self.contactList = Array.isArray(res.data) ? res.data : (res.data.records || [])
  105. }
  106. }).catch(function(e) { console.log('加载联系人失败', e) })
  107. getHealthAlerts().then(function(res) {
  108. if (res.code === 200 && res.data) {
  109. self.healthAlerts = Array.isArray(res.data) ? res.data : []
  110. }
  111. }).catch(function(e) { console.log('加载告警失败', e) })
  112. getMilestones(30).then(function(res) {
  113. if (res.code === 200 && res.data) {
  114. self.milestones = Array.isArray(res.data) ? res.data : []
  115. }
  116. }).catch(function(e) { console.log('加载里程碑失败', e) })
  117. }
  118. this.loading = false
  119. },
  120. goContactDetail: function(contact) {
  121. uni.navigateTo({ url: '/pages/mind/contact-detail?id=' + contact.id })
  122. }
  123. }
  124. }
  125. </script>
  126. <style scoped>
  127. .mind-section {}
  128. .section-card {
  129. background: #fff;
  130. border-radius: 24rpx;
  131. padding: 24rpx;
  132. margin-bottom: 20rpx;
  133. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  134. }
  135. .section-header {
  136. margin-bottom: 16rpx;
  137. }
  138. .section-title {
  139. font-size: 30rpx;
  140. font-weight: bold;
  141. color: #333;
  142. }
  143. .score-item {
  144. display: flex;
  145. flex-direction: row;
  146. align-items: center;
  147. padding: 10rpx 0;
  148. }
  149. .score-label {
  150. font-size: 26rpx;
  151. color: #555;
  152. width: 160rpx;
  153. }
  154. .score-bar-bg {
  155. flex: 1;
  156. height: 20rpx;
  157. background: #f0f0f0;
  158. border-radius: 10rpx;
  159. overflow: hidden;
  160. }
  161. .score-bar-fill {
  162. height: 100%;
  163. background: linear-gradient(90deg, #FF6B9D, #FF9EC4);
  164. border-radius: 10rpx;
  165. }
  166. .score-value {
  167. font-size: 24rpx;
  168. color: #FF6B9D;
  169. width: 60rpx;
  170. text-align: right;
  171. }
  172. .contact-item {
  173. display: flex;
  174. flex-direction: row;
  175. justify-content: space-between;
  176. padding: 14rpx 0;
  177. border-bottom: 1rpx solid #f5f5f5;
  178. }
  179. .contact-name {
  180. font-size: 28rpx;
  181. color: #333;
  182. font-weight: bold;
  183. }
  184. .contact-relation {
  185. font-size: 24rpx;
  186. color: #999;
  187. }
  188. .contact-phone {
  189. font-size: 24rpx;
  190. color: #FF6B9D;
  191. }
  192. .alert-item {
  193. display: flex;
  194. flex-direction: row;
  195. padding: 10rpx 0;
  196. }
  197. .alert-type {
  198. font-size: 24rpx;
  199. color: #E74C3C;
  200. width: 100rpx;
  201. }
  202. .alert-desc {
  203. font-size: 26rpx;
  204. color: #555;
  205. flex: 1;
  206. }
  207. .milestone-item {
  208. display: flex;
  209. flex-direction: row;
  210. justify-content: space-between;
  211. padding: 10rpx 0;
  212. }
  213. .milestone-title {
  214. font-size: 26rpx;
  215. color: #333;
  216. }
  217. .milestone-date {
  218. font-size: 24rpx;
  219. color: #999;
  220. }
  221. .loading {
  222. text-align: center;
  223. padding: 40rpx;
  224. color: #999;
  225. }
  226. </style>