mind-section.vue 5.7 KB

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