WealthSubScores.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="wealth-sub-scores" :style="{ '--font-scale': fontScale }">
  3. <view class="section-header">
  4. <text class="title">{{ isParent ? '💧 财富维度构成' : '💧 富能量构成' }}</text>
  5. </view>
  6. <view class="sub-grid">
  7. <view class="drop-wrap" v-for="item in subItems" :key="item.key">
  8. <view class="drop">
  9. <view class="drop-fill" :style="{ height: item.score + '%' }"></view>
  10. <text class="drop-score">{{ item.score }}</text>
  11. </view>
  12. <text class="drop-label">{{ item.label }}</text>
  13. <text class="drop-weight">权重 {{ item.weight }}%</text>
  14. </view>
  15. </view>
  16. <view class="drop-tip" v-if="tipText">
  17. <text class="drop-tip-text">{{ tipText }}</text>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import fontScaleMixin from '@/mixins/font-scale.js'
  23. export default {
  24. mixins: [fontScaleMixin],
  25. name: 'WealthSubScores',
  26. props: {
  27. role: {
  28. type: String,
  29. default: 'parent'
  30. },
  31. skill: {
  32. type: Number,
  33. default: 0
  34. },
  35. altruism: {
  36. type: Number,
  37. default: 0
  38. },
  39. income: {
  40. type: Number,
  41. default: 0
  42. },
  43. fx: {
  44. type: Number,
  45. default: 0
  46. }
  47. },
  48. computed: {
  49. isParent() {
  50. return this.role === 'parent'
  51. },
  52. subItems() {
  53. if (this.isParent) {
  54. return [
  55. { key: 'skill', label: '个人能力', score: this.skill, weight: 25 },
  56. { key: 'altruism', label: '利他贡献', score: this.altruism, weight: 30 },
  57. { key: 'income', label: 'CF值积累', score: this.income, weight: 35 },
  58. { key: 'fx', label: '财务素养', score: this.fx, weight: 10 }
  59. ]
  60. }
  61. return [
  62. { key: 'skill', label: '学业能力', score: this.skill, weight: 25 },
  63. { key: 'altruism', label: '利他贡献', score: this.altruism, weight: 30 },
  64. { key: 'income', label: '积分积累', score: this.income, weight: 35 },
  65. { key: 'fx', label: '财务素养', score: this.fx, weight: 10 }
  66. ]
  67. },
  68. tipText() {
  69. var items = this.subItems
  70. var filtered = items.filter(function(item) {
  71. return item.score > 0
  72. })
  73. if (filtered.length < 2) return ''
  74. var best = filtered.reduce(function(a, b) {
  75. return a.score >= b.score ? a : b
  76. })
  77. var worst = filtered.reduce(function(a, b) {
  78. return a.score <= b.score ? a : b
  79. })
  80. if (best.key === worst.key) return '均衡发展,继续保持!'
  81. return best.label + '表现优秀,建议提升' + worst.label
  82. }
  83. }
  84. }
  85. </script>
  86. <style scoped lang="scss">
  87. .wealth-sub-scores {
  88. margin: 20rpx $uni-space-lg;
  89. padding: 24rpx;
  90. background: $app-surface;
  91. border-radius: 24rpx;
  92. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  93. }
  94. .section-header {
  95. margin-bottom: 20rpx;
  96. }
  97. .title {
  98. font-size: calc(30rpx * var(--font-scale, 1));
  99. font-weight: bold;
  100. color: $facade-text-strong;
  101. }
  102. .sub-grid {
  103. display: flex;
  104. justify-content: space-between;
  105. }
  106. .drop-wrap {
  107. flex: 1;
  108. margin: 0 8rpx;
  109. display: flex;
  110. flex-direction: column;
  111. align-items: center;
  112. }
  113. .drop-wrap:first-child {
  114. margin-left: 0;
  115. }
  116. .drop-wrap:last-child {
  117. margin-right: 0;
  118. }
  119. .drop {
  120. position: relative;
  121. width: 120rpx;
  122. height: 150rpx;
  123. border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  124. background: $status-warning-soft;
  125. overflow: hidden;
  126. display: flex;
  127. align-items: center;
  128. justify-content: center;
  129. }
  130. .drop-fill {
  131. position: absolute;
  132. bottom: 0;
  133. left: 0;
  134. right: 0;
  135. background: linear-gradient(180deg, $status-warning 0%, $status-warning-2 100%);
  136. transition: height 0.8s ease;
  137. }
  138. .drop-score {
  139. position: relative;
  140. z-index: 1;
  141. font-size: calc(40rpx * var(--font-scale, 1));
  142. font-weight: bold;
  143. color: $status-warning-strong;
  144. }
  145. .drop-label {
  146. margin-top: 12rpx;
  147. font-size: calc(24rpx * var(--font-scale, 1));
  148. color: $facade-text-strong;
  149. font-weight: 500;
  150. }
  151. .drop-weight {
  152. font-size: calc(20rpx * var(--font-scale, 1));
  153. color: $facade-text-muted;
  154. margin-top: 4rpx;
  155. }
  156. .drop-tip {
  157. margin-top: 20rpx;
  158. padding: 16rpx 20rpx;
  159. background: $uni-primary-pale;
  160. border-radius: 16rpx;
  161. }
  162. .drop-tip-text {
  163. font-size: calc(24rpx * var(--font-scale, 1));
  164. color: $status-warning-strong;
  165. }
  166. </style>