WealthSubScores.vue 3.8 KB

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