mind-section.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="mind-section">
  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 class="milestone-item" v-for="ms in milestones" :key="ms.id || ms.title">
  43. <text class="milestone-title">{{ ms.title }}</text>
  44. <text class="milestone-date">{{ ms.date }}</text>
  45. </view>
  46. </view>
  47. <!-- 加载中 -->
  48. <view class="loading" v-if="loading">加载中...</view>
  49. </view>
  50. </template>
  51. <script>
  52. import { getRelationshipScores, getContactList, getHealthAlerts, getMilestones } from '../../utils/api.js'
  53. export default {
  54. props: {
  55. memberId: { type: [Number, String], default: null },
  56. childId: { type: [Number, String], default: null },
  57. memberType: { type: String, default: '' },
  58. memberInfo: { type: Object, default: null },
  59. sandboxData: { type: Object, default: null },
  60. energyMap: { type: Object, default: null }
  61. },
  62. data: function() {
  63. return {
  64. loading: true,
  65. relationScores: null,
  66. contactList: [],
  67. healthAlerts: [],
  68. milestones: []
  69. }
  70. },
  71. mounted: function() {
  72. this.loadData()
  73. },
  74. methods: {
  75. loadData: function() {
  76. var self = this
  77. var familyId = (this.memberInfo && this.memberInfo.familyId) || ''
  78. if (familyId) {
  79. getRelationshipScores(familyId).then(function(res) {
  80. if (res.code === 200 && res.data) {
  81. self.relationScores = res.data
  82. }
  83. }).catch(function(e) { console.log('加载关系评分失败', e) })
  84. getContactList({ familyId: familyId }).then(function(res) {
  85. if (res.code === 200 && res.data) {
  86. self.contactList = Array.isArray(res.data) ? res.data : (res.data.records || [])
  87. }
  88. }).catch(function(e) { console.log('加载联系人失败', e) })
  89. getHealthAlerts(familyId).then(function(res) {
  90. if (res.code === 200 && res.data) {
  91. self.healthAlerts = Array.isArray(res.data) ? res.data : []
  92. }
  93. }).catch(function(e) { console.log('加载告警失败', e) })
  94. getMilestones(familyId, 30).then(function(res) {
  95. if (res.code === 200 && res.data) {
  96. self.milestones = Array.isArray(res.data) ? res.data : []
  97. }
  98. }).catch(function(e) { console.log('加载里程碑失败', e) })
  99. }
  100. this.loading = false
  101. },
  102. goContactDetail: function(contact) {
  103. uni.navigateTo({ url: '/pages/mind/contact-detail?id=' + contact.id })
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped>
  109. .mind-section {}
  110. .section-card {
  111. background: #fff;
  112. border-radius: 24rpx;
  113. padding: 24rpx;
  114. margin-bottom: 20rpx;
  115. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  116. }
  117. .section-header {
  118. margin-bottom: 16rpx;
  119. }
  120. .section-title {
  121. font-size: 30rpx;
  122. font-weight: bold;
  123. color: #333;
  124. }
  125. .score-item {
  126. display: flex;
  127. flex-direction: row;
  128. align-items: center;
  129. padding: 10rpx 0;
  130. }
  131. .score-label {
  132. font-size: 26rpx;
  133. color: #555;
  134. width: 160rpx;
  135. }
  136. .score-bar-bg {
  137. flex: 1;
  138. height: 20rpx;
  139. background: #f0f0f0;
  140. border-radius: 10rpx;
  141. overflow: hidden;
  142. }
  143. .score-bar-fill {
  144. height: 100%;
  145. background: linear-gradient(90deg, #FF6B9D, #FF9EC4);
  146. border-radius: 10rpx;
  147. }
  148. .score-value {
  149. font-size: 24rpx;
  150. color: #FF6B9D;
  151. width: 60rpx;
  152. text-align: right;
  153. }
  154. .contact-item {
  155. display: flex;
  156. flex-direction: row;
  157. justify-content: space-between;
  158. padding: 14rpx 0;
  159. border-bottom: 1rpx solid #f5f5f5;
  160. }
  161. .contact-name {
  162. font-size: 28rpx;
  163. color: #333;
  164. font-weight: bold;
  165. }
  166. .contact-relation {
  167. font-size: 24rpx;
  168. color: #999;
  169. }
  170. .contact-phone {
  171. font-size: 24rpx;
  172. color: #FF6B9D;
  173. }
  174. .alert-item {
  175. display: flex;
  176. flex-direction: row;
  177. padding: 10rpx 0;
  178. }
  179. .alert-type {
  180. font-size: 24rpx;
  181. color: #E74C3C;
  182. width: 100rpx;
  183. }
  184. .alert-desc {
  185. font-size: 26rpx;
  186. color: #555;
  187. flex: 1;
  188. }
  189. .milestone-item {
  190. display: flex;
  191. flex-direction: row;
  192. justify-content: space-between;
  193. padding: 10rpx 0;
  194. }
  195. .milestone-title {
  196. font-size: 26rpx;
  197. color: #333;
  198. }
  199. .milestone-date {
  200. font-size: 24rpx;
  201. color: #999;
  202. }
  203. .loading {
  204. text-align: center;
  205. padding: 40rpx;
  206. color: #999;
  207. }
  208. </style>