WealthEnergyRing.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="wealth-ring" :style="{ '--font-scale': fontScale }">
  3. <view class="ring-wrap">
  4. <!-- SVG 环形进度 -->
  5. <svg class="ring-svg" viewBox="0 0 200 200">
  6. <!-- 背景轨道 -->
  7. <circle cx="100" cy="100" r="88" fill="none" stroke="#FEF3C7" stroke-width="14" />
  8. <!-- 进度弧线 -->
  9. <circle
  10. class="ring-progress"
  11. cx="100" cy="100" r="88" fill="none"
  12. stroke="url(#ringGradient)" stroke-width="14" stroke-linecap="round"
  13. :stroke-dasharray="circumference" :stroke-dashoffset="progressOffset" />
  14. <defs>
  15. <linearGradient id="ringGradient" x1="0%" y1="0%" x2="100%" y2="0%">
  16. <stop offset="0%" stop-color=BrandColors.wealth />
  17. <stop offset="100%" stop-color="#FBBF24" />
  18. </linearGradient>
  19. </defs>
  20. </svg>
  21. <!-- 中心文字 -->
  22. <view class="ring-center">
  23. <text class="ring-score">{{ score }}</text>
  24. <text class="ring-total">/ 100</text>
  25. <text class="ring-level">{{ levelText }}</text>
  26. </view>
  27. <!-- 水波纹 -->
  28. <view class="ripple-1"></view>
  29. <view class="ripple-2"></view>
  30. </view>
  31. <view class="ring-slogan">
  32. <text class="ring-slogan-text">富足源于利他与坚持</text>
  33. <text class="ring-delta" v-if="delta > 0">较上月 ↑ {{ delta }}%</text>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { BrandColors } from '../../../utils/brand-colors.js'
  39. import fontScaleMixin from '@/mixins/font-scale.js'
  40. export default {
  41. mixins: [fontScaleMixin],
  42. name: 'WealthEnergyRing',
  43. props: {
  44. score: {
  45. type: Number,
  46. default: 0
  47. },
  48. delta: {
  49. type: Number,
  50. default: 0
  51. }
  52. },
  53. computed: {
  54. circumference() {
  55. // 2 * Math.PI * 88 ≈ 552.92
  56. return 552.92
  57. },
  58. progressOffset() {
  59. var pct = Math.max(0, Math.min(100, this.score)) / 100
  60. return Math.round(552.92 * (1 - pct))
  61. },
  62. levelText() {
  63. var s = this.score
  64. if (s >= 70) return '富足'
  65. if (s >= 30) return '成长'
  66. return '播种'
  67. }
  68. }
  69. }
  70. </script>
  71. <style scoped lang="scss">
  72. .wealth-ring {
  73. margin: 20rpx $uni-space-lg;
  74. background: linear-gradient(135deg, $uni-primary-pale 0%, $status-warning-soft 100%);
  75. border-radius: 24rpx;
  76. padding: 40rpx $uni-space-page $uni-space-lg;
  77. display: flex;
  78. flex-direction: column;
  79. align-items: center;
  80. box-shadow: 0 4rpx 16rpx rgba(245, 158, 11, 0.12);
  81. }
  82. .ring-wrap {
  83. position: relative;
  84. width: 360rpx;
  85. height: 360rpx;
  86. }
  87. .ring-svg {
  88. width: 360rpx;
  89. height: 360rpx;
  90. transform: rotate(-90deg);
  91. position: relative;
  92. z-index: 2;
  93. }
  94. .ring-progress {
  95. transition: stroke-dashoffset 0.8s ease;
  96. filter: drop-shadow(0 2rpx 4rpx rgba(245, 158, 11, 0.3));
  97. }
  98. .ring-center {
  99. position: absolute;
  100. top: 0;
  101. left: 0;
  102. right: 0;
  103. bottom: 0;
  104. display: flex;
  105. flex-direction: column;
  106. align-items: center;
  107. justify-content: center;
  108. z-index: 3;
  109. }
  110. .ring-score {
  111. font-size: calc($uni-font-size-5xl * var(--font-scale, 1));
  112. font-weight: bold;
  113. color: $status-warning-strong;
  114. line-height: 1.1;
  115. }
  116. .ring-total {
  117. font-size: calc(24rpx * var(--font-scale, 1));
  118. color: $status-warning-strong-2;
  119. opacity: 0.7;
  120. }
  121. .ring-level {
  122. margin-top: 8rpx;
  123. font-size: calc(28rpx * var(--font-scale, 1));
  124. color: $status-warning-2;
  125. font-weight: 600;
  126. letter-spacing: 2rpx;
  127. }
  128. .ripple-1,
  129. .ripple-2 {
  130. position: absolute;
  131. top: 0;
  132. left: 0;
  133. width: 360rpx;
  134. height: 360rpx;
  135. border-radius: 50%;
  136. border: 3rpx solid rgba(245, 158, 11, 0.25);
  137. animation: ripple 3s ease-out infinite;
  138. pointer-events: none;
  139. }
  140. .ripple-2 {
  141. animation-delay: 1.5s;
  142. }
  143. @keyframes ripple {
  144. 0% {
  145. opacity: 0.6;
  146. transform: scale(0.9);
  147. }
  148. 100% {
  149. opacity: 0;
  150. transform: scale(1.2);
  151. }
  152. }
  153. .ring-slogan {
  154. margin-top: 24rpx;
  155. display: flex;
  156. flex-direction: column;
  157. align-items: center;
  158. }
  159. .ring-slogan-text {
  160. font-size: calc(26rpx * var(--font-scale, 1));
  161. color: $status-warning-strong;
  162. letter-spacing: 2rpx;
  163. }
  164. .ring-delta {
  165. margin-top: 8rpx;
  166. font-size: calc(24rpx * var(--font-scale, 1));
  167. color: $status-warning-2;
  168. font-weight: 500;
  169. }
  170. </style>