FamilyMemberCard.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="family-member-card" :class="{ selected: isSelected, ['role-' + member.effectiveRole]: true }" @click="onClick" @longpress="onLongPress">
  3. <!-- 头像区域 -->
  4. <view class="card-avatar-wrap">
  5. <image class="card-avatar" :src="member.avatar || defaultAvatar" mode="aspectFill" />
  6. <!-- 待办角标 -->
  7. <view v-if="pendingCount > 0" class="card-pending-badge">
  8. <text class="badge-num">{{ pendingCount }}</text>
  9. </view>
  10. <!-- 关系标签徽章 -->
  11. <view class="card-relation-badge" :style="{ background: relationColor }">
  12. <text class="card-relation-text">{{ member.relationship || member.relativeLabel || member.roleLabel || '成员' }}</text>
  13. </view>
  14. <!-- 配偶标记 -->
  15. <view class="card-spouse-mark" v-if="member.isSpouse">
  16. <text class="spouse-icon">💍</text>
  17. </view>
  18. </view>
  19. <!-- 关系现状三色点:信任/亲密度/沟通 -->
  20. <view class="card-relation-dots">
  21. <view class="relation-dot" v-for="(color, idx) in relationDotColors" :key="idx" :style="{ background: color }"></view>
  22. </view>
  23. <!-- 昵称 -->
  24. <text class="card-nickname">{{ member.nickname }}</text>
  25. <!-- 辈分标签 -->
  26. <view class="card-generation-line" v-if="member.generation">
  27. <text class="card-generation-text">第{{ member.generation }}代</text>
  28. </view>
  29. <!-- 联系方式 -->
  30. <view class="card-contact-row" v-if="member.phone" @click.stop="onCall">
  31. <text class="contact-icon">📞</text>
  32. <text class="contact-phone">{{ member.phone }}</text>
  33. </view>
  34. <!-- 能量分数 -->
  35. <view class="card-energy" v-if="energyScore !== null && energyScore !== undefined">
  36. <text class="energy-value">{{ energyScore }}</text>
  37. <text class="energy-unit">分</text>
  38. </view>
  39. <!-- 选中标记 -->
  40. <view class="card-selected-mark" v-if="isSelected">
  41. <text class="mark-icon">✓</text>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import { BrandColors } from '../utils/brand-colors.js'
  47. export default {
  48. props: {
  49. member: { type: Object, required: true },
  50. isSelected: { type: Boolean, default: false },
  51. energyScore: { type: Number, default: null },
  52. pendingCount: { type: Number, default: 0 }
  53. },
  54. computed: {
  55. defaultAvatar: function() {
  56. return '/static/default-avatar.png'
  57. },
  58. relationColor: function() {
  59. var rel = this.member && this.member.relationship
  60. if (rel === '爸爸' || rel === '妈妈' || rel === '父亲' || rel === '母亲') return BrandColors.primary
  61. if (rel === '儿子' || rel === '女儿') return BrandColors.infoSky
  62. if (rel === '爷爷' || rel === '奶奶' || rel === '外公' || rel === '外婆') return BrandColors.textSlate
  63. if (rel === '哥哥' || rel === '姐姐' || rel === '弟弟' || rel === '妹妹') return BrandColors.success
  64. if (this.member && this.member.isSpouse) return BrandColors.pink
  65. var role = this.member && this.member.effectiveRole
  66. if (role === 'parent') return BrandColors.primary
  67. if (role === 'child') return BrandColors.infoSky
  68. if (role === 'teacher') return BrandColors.violet
  69. return '#9CA3AF'
  70. },
  71. // 关系现状三色点颜色:信任/亲密度/沟通(绿≥70 / 黄40-69 / 红<40 / 灰空)
  72. relationDotColors: function() {
  73. var m = this.member
  74. var empty = '#E5E7EB'
  75. if (!m) return [empty, empty, empty]
  76. var keys = ['trustScore', 'intimacyScore', 'communicationScore']
  77. return keys.map(function(k) {
  78. var v = Number(m[k]) || 0
  79. if (v <= 0) return empty
  80. if (v >= 70) return BrandColors.success
  81. if (v >= 40) return BrandColors.wealth
  82. return BrandColors.danger
  83. })
  84. }
  85. },
  86. methods: {
  87. onClick: function() {
  88. this.$emit('select', this.member)
  89. },
  90. onLongPress: function() {
  91. this.$emit('longpress', this.member)
  92. },
  93. onCall: function() {
  94. if (this.member && this.member.phone) {
  95. uni.makePhoneCall({ phoneNumber: this.member.phone })
  96. }
  97. }
  98. }
  99. }
  100. </script>
  101. <style scoped lang="scss">
  102. .family-member-card {
  103. display: flex;
  104. flex-direction: column;
  105. align-items: center;
  106. width: 110rpx;
  107. padding: 10rpx 8rpx;
  108. border-radius: 16rpx;
  109. background: $app-surface;
  110. border: 2rpx solid transparent;
  111. position: relative;
  112. flex-shrink: 0;
  113. }
  114. .family-member-card.selected {
  115. border-color: $brand-primary;
  116. box-shadow: 0 0 0 2rpx rgba(249, 115, 22, 0.15);
  117. }
  118. .card-avatar-wrap {
  119. position: relative;
  120. width: 64rpx;
  121. height: 64rpx;
  122. margin-bottom: 6rpx;
  123. }
  124. .card-avatar {
  125. width: 64rpx;
  126. height: 64rpx;
  127. border-radius: 50%;
  128. background: $facade-fill-gray-100;
  129. }
  130. .card-relation-badge {
  131. position: absolute;
  132. bottom: -4rpx;
  133. left: 50%;
  134. transform: translateX(-50%);
  135. padding: 1rpx 8rpx;
  136. border-radius: 8rpx;
  137. white-space: nowrap;
  138. max-width: 84rpx;
  139. }
  140. .card-relation-text {
  141. font-size: calc(16rpx * var(--font-scale, 1));
  142. color: $app-surface;
  143. font-weight: 500;
  144. line-height: 1.4;
  145. }
  146. .card-spouse-mark {
  147. position: absolute;
  148. top: -4rpx;
  149. right: -4rpx;
  150. width: 24rpx;
  151. height: 24rpx;
  152. display: flex;
  153. align-items: center;
  154. justify-content: center;
  155. }
  156. .spouse-icon {
  157. font-size: calc(18rpx * var(--font-scale, 1));
  158. }
  159. /* 待办角标 */
  160. .card-pending-badge {
  161. position: absolute;
  162. top: -6rpx;
  163. right: -6rpx;
  164. min-width: 32rpx;
  165. height: 32rpx;
  166. padding: 0 8rpx;
  167. background: #FF6B6B;
  168. color: #fff;
  169. font-size: calc(20rpx * var(--font-scale, 1));
  170. border-radius: 16rpx;
  171. text-align: center;
  172. line-height: 32rpx;
  173. font-weight: 500;
  174. }
  175. .badge-num {
  176. display: block;
  177. line-height: 1;
  178. }
  179. .card-relation-dots {
  180. display: flex;
  181. flex-direction: row;
  182. justify-content: center;
  183. margin-top: 4rpx;
  184. height: 12rpx;
  185. }
  186. .relation-dot {
  187. width: 12rpx;
  188. height: 12rpx;
  189. border-radius: 50%;
  190. margin: 0 4rpx;
  191. }
  192. .card-nickname {
  193. font-size: calc(22rpx * var(--font-scale, 1));
  194. color: $facade-text-gray-700;
  195. font-weight: 600;
  196. text-align: center;
  197. line-height: 1.3;
  198. max-width: 100rpx;
  199. overflow: hidden;
  200. text-overflow: ellipsis;
  201. white-space: nowrap;
  202. }
  203. .card-generation-line {
  204. margin-top: 2rpx;
  205. }
  206. .card-generation-text {
  207. font-size: calc(14rpx * var(--font-scale, 1));
  208. color: $facade-text-gray-400;
  209. }
  210. .card-contact-row {
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. margin-top: 2rpx;
  215. }
  216. .contact-icon {
  217. font-size: calc(18rpx * var(--font-scale, 1));
  218. }
  219. .contact-phone {
  220. font-size: calc(16rpx * var(--font-scale, 1));
  221. color: $status-info;
  222. margin-left: 2rpx;
  223. }
  224. .card-energy {
  225. display: flex;
  226. align-items: baseline;
  227. justify-content: center;
  228. margin-top: 2rpx;
  229. }
  230. .energy-value {
  231. font-size: calc(20rpx * var(--font-scale, 1));
  232. color: $brand-primary;
  233. font-weight: bold;
  234. }
  235. .energy-unit {
  236. font-size: calc(16rpx * var(--font-scale, 1));
  237. color: $facade-text-gray-400;
  238. margin-left: 2rpx;
  239. }
  240. .card-selected-mark {
  241. position: absolute;
  242. top: 4rpx;
  243. right: 4rpx;
  244. width: 24rpx;
  245. height: 24rpx;
  246. border-radius: 50%;
  247. background: $brand-primary;
  248. display: flex;
  249. align-items: center;
  250. justify-content: center;
  251. }
  252. .mark-icon {
  253. font-size: calc(16rpx * var(--font-scale, 1));
  254. color: $app-surface;
  255. font-weight: bold;
  256. }
  257. </style>