WealthSubScores.vue 3.8 KB

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