tab-transition.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="tab-transition-overlay" :style="'background:' + bgGradient">
  3. <view class="transition-content">
  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. mountedAt: 0
  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. this.mountedAt = Date.now()
  52. var self = this
  53. // 最多 1.5 秒强制关闭
  54. setTimeout(function() {
  55. self.$emit('close')
  56. }, 1500)
  57. },
  58. methods: {
  59. // 父组件数据加载完成后调用,过渡页至少停留 800ms
  60. markReady: function() {
  61. var elapsed = Date.now() - this.mountedAt
  62. if (elapsed >= 800) {
  63. this.$emit('close')
  64. } else {
  65. var self = this
  66. setTimeout(function() {
  67. self.$emit('close')
  68. }, 800 - elapsed)
  69. }
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped>
  75. .tab-transition-overlay {
  76. position: fixed;
  77. top: 0;
  78. left: 0;
  79. right: 0;
  80. bottom: 0;
  81. z-index: 9998;
  82. display: flex;
  83. align-items: center;
  84. justify-content: center;
  85. }
  86. .transition-content {
  87. display: flex;
  88. flex-direction: column;
  89. align-items: center;
  90. opacity: 0;
  91. animation: tab-fade-in 0.2s ease forwards;
  92. }
  93. .transition-content.fade-out {
  94. animation: tab-fade-out 0.3s ease forwards;
  95. }
  96. @keyframes tab-fade-in {
  97. from {
  98. opacity: 0;
  99. transform: scale(0.92);
  100. }
  101. to {
  102. opacity: 1;
  103. transform: scale(1);
  104. }
  105. }
  106. @keyframes tab-fade-out {
  107. from {
  108. opacity: 1;
  109. transform: scale(1);
  110. }
  111. to {
  112. opacity: 0;
  113. transform: scale(0.92);
  114. }
  115. }
  116. .dim-char {
  117. font-size: 120rpx;
  118. font-weight: 700;
  119. line-height: 1.2;
  120. margin-bottom: 8rpx;
  121. }
  122. .dim-icon {
  123. font-size: 48rpx;
  124. line-height: 1;
  125. margin-bottom: 16rpx;
  126. }
  127. .dim-label {
  128. font-size: 32rpx;
  129. font-weight: 500;
  130. line-height: 1;
  131. margin-bottom: 40rpx;
  132. opacity: 0.8;
  133. }
  134. .energy-bar-track {
  135. width: 200rpx;
  136. height: 4rpx;
  137. background: rgba(0, 0, 0, 0.08);
  138. border-radius: 2rpx;
  139. overflow: hidden;
  140. }
  141. .energy-bar-fill {
  142. width: 0%;
  143. height: 100%;
  144. border-radius: 2rpx;
  145. animation: bar-grow 0.6s ease 0.2s forwards;
  146. }
  147. @keyframes bar-grow {
  148. from {
  149. width: 0%;
  150. }
  151. to {
  152. width: 100%;
  153. }
  154. }
  155. </style>