mind-section.vue 5.7 KB

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