tab-transition.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="tab-transition-overlay" :style="'background:' + bgGradient">
  3. <view class="transition-content" :class="{ 'fade-out': fadeOut }">
  4. <!-- Large dimension character -->
  5. <text class="dim-char" :style="'color:' + dimConfig.color">{{ dimConfig.char }}</text>
  6. <!-- Icon -->
  7. <text class="dim-icon">{{ dimConfig.icon }}</text>
  8. <!-- Dimension label -->
  9. <text class="dim-label" :style="'color:' + dimConfig.color">{{ dimConfig.label }}</text>
  10. <!-- Animated energy bar -->
  11. <view class="energy-bar-track">
  12. <view class="energy-bar-fill" :style="'background:' + dimConfig.color"></view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. var DIM_MAP = {
  19. action: { char: '行', icon: '🌿', color: '#10B981', label: '知行合一' },
  20. body: { char: '身', icon: '🌏', color: '#8D6E63', label: '主动健康' },
  21. wisdom: { char: '智', icon: '⚡', color: '#6366F1', label: '赋能未来' },
  22. mind: { char: '心', icon: '🔥', color: '#FF6B9D', label: '大爱传承' },
  23. wealth: { char: '富', icon: '💧', color: '#F59E0B', label: '利他创富' }
  24. }
  25. export default {
  26. props: {
  27. dimCode: {
  28. type: String,
  29. required: true
  30. }
  31. },
  32. data() {
  33. return {
  34. fadeOut: false
  35. }
  36. },
  37. computed: {
  38. dimConfig: function() {
  39. return DIM_MAP[this.dimCode] || DIM_MAP['action']
  40. },
  41. bgGradient: function() {
  42. var cfg = this.dimConfig
  43. var hex = cfg.color
  44. var r = parseInt(hex.slice(1, 3), 16)
  45. var g = parseInt(hex.slice(3, 5), 16)
  46. var b = parseInt(hex.slice(5, 7), 16)
  47. return 'linear-gradient(160deg, #FFF7ED 0%, rgba(' + r + ',' + g + ',' + b + ',0.4) 100%)'
  48. }
  49. },
  50. mounted() {
  51. var self = this
  52. setTimeout(function() {
  53. self.fadeOut = true
  54. }, 800)
  55. }
  56. }
  57. </script>
  58. <style scoped>
  59. .tab-transition-overlay {
  60. position: fixed;
  61. top: 0;
  62. left: 0;
  63. right: 0;
  64. bottom: 0;
  65. z-index: 9998;
  66. display: flex;
  67. align-items: center;
  68. justify-content: center;
  69. }
  70. .transition-content {
  71. display: flex;
  72. flex-direction: column;
  73. align-items: center;
  74. opacity: 0;
  75. animation: tab-fade-in 0.2s ease forwards;
  76. }
  77. .transition-content.fade-out {
  78. animation: tab-fade-out 0.3s ease forwards;
  79. }
  80. @keyframes tab-fade-in {
  81. from {
  82. opacity: 0;
  83. transform: scale(0.92);
  84. }
  85. to {
  86. opacity: 1;
  87. transform: scale(1);
  88. }
  89. }
  90. @keyframes tab-fade-out {
  91. from {
  92. opacity: 1;
  93. transform: scale(1);
  94. }
  95. to {
  96. opacity: 0;
  97. transform: scale(0.92);
  98. }
  99. }
  100. .dim-char {
  101. font-size: 120rpx;
  102. font-weight: 700;
  103. line-height: 1.2;
  104. margin-bottom: 8rpx;
  105. }
  106. .dim-icon {
  107. font-size: 48rpx;
  108. line-height: 1;
  109. margin-bottom: 16rpx;
  110. }
  111. .dim-label {
  112. font-size: 32rpx;
  113. font-weight: 500;
  114. line-height: 1;
  115. margin-bottom: 40rpx;
  116. opacity: 0.8;
  117. }
  118. .energy-bar-track {
  119. width: 200rpx;
  120. height: 4rpx;
  121. background: rgba(0, 0, 0, 0.08);
  122. border-radius: 2rpx;
  123. overflow: hidden;
  124. }
  125. .energy-bar-fill {
  126. width: 0%;
  127. height: 100%;
  128. border-radius: 2rpx;
  129. animation: bar-grow 0.6s ease 0.2s forwards;
  130. }
  131. @keyframes bar-grow {
  132. from {
  133. width: 0%;
  134. }
  135. to {
  136. width: 100%;
  137. }
  138. }
  139. </style>