tab-transition.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. import { BrandColors } from '../utils/brand-colors.js'
  19. var DIM_MAP = {
  20. action: { char: '行', icon: '🌿', color: BrandColors.success, label: '人际和谐' },
  21. body: { char: '身', icon: '🌏', color: BrandColors.brownWarm, label: '根基永因' },
  22. wisdom: { char: '智', icon: '⚡', color: BrandColors.wisdom, label: '赋能未来' },
  23. mind: { char: '心', icon: '🔥', color: BrandColors.mind, label: '大爱传承' },
  24. wealth: { char: '富', icon: '💧', color: BrandColors.wealth, label: '利他创富' }
  25. }
  26. export default {
  27. props: {
  28. dimCode: {
  29. type: String,
  30. required: true
  31. }
  32. },
  33. data() {
  34. return {
  35. mountedAt: 0
  36. }
  37. },
  38. computed: {
  39. dimConfig: function() {
  40. return DIM_MAP[this.dimCode] || DIM_MAP['action']
  41. },
  42. bgGradient: function() {
  43. var cfg = this.dimConfig
  44. var hex = cfg.color
  45. var r = parseInt(hex.slice(1, 3), 16)
  46. var g = parseInt(hex.slice(3, 5), 16)
  47. var b = parseInt(hex.slice(5, 7), 16)
  48. return 'linear-gradient(160deg, #FFF7ED 0%, rgba(' + r + ',' + g + ',' + b + ',0.4) 100%)'
  49. }
  50. },
  51. mounted() {
  52. this.mountedAt = Date.now()
  53. var self = this
  54. // 最多 1.5 秒强制关闭
  55. setTimeout(function() {
  56. self.$emit('close')
  57. }, 1500)
  58. },
  59. methods: {
  60. // 父组件数据加载完成后调用,过渡页至少停留 800ms
  61. markReady: function() {
  62. var elapsed = Date.now() - this.mountedAt
  63. if (elapsed >= 800) {
  64. this.$emit('close')
  65. } else {
  66. var self = this
  67. setTimeout(function() {
  68. self.$emit('close')
  69. }, 800 - elapsed)
  70. }
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped>
  76. .tab-transition-overlay {
  77. position: fixed;
  78. top: 0;
  79. left: 0;
  80. right: 0;
  81. bottom: 0;
  82. z-index: 9998;
  83. display: flex;
  84. align-items: center;
  85. justify-content: center;
  86. }
  87. .transition-content {
  88. display: flex;
  89. flex-direction: column;
  90. align-items: center;
  91. opacity: 0;
  92. animation: tab-fade-in 0.2s ease forwards;
  93. }
  94. .transition-content.fade-out {
  95. animation: tab-fade-out 0.3s ease forwards;
  96. }
  97. @keyframes tab-fade-in {
  98. from {
  99. opacity: 0;
  100. transform: scale(0.92);
  101. }
  102. to {
  103. opacity: 1;
  104. transform: scale(1);
  105. }
  106. }
  107. @keyframes tab-fade-out {
  108. from {
  109. opacity: 1;
  110. transform: scale(1);
  111. }
  112. to {
  113. opacity: 0;
  114. transform: scale(0.92);
  115. }
  116. }
  117. .dim-char {
  118. font-size: 120rpx;
  119. font-weight: 700;
  120. line-height: 1.2;
  121. margin-bottom: 8rpx;
  122. }
  123. .dim-icon {
  124. font-size: 48rpx;
  125. line-height: 1;
  126. margin-bottom: 16rpx;
  127. }
  128. .dim-label {
  129. font-size: 32rpx;
  130. font-weight: 500;
  131. line-height: 1;
  132. margin-bottom: 40rpx;
  133. opacity: 0.8;
  134. }
  135. .energy-bar-track {
  136. width: 200rpx;
  137. height: 4rpx;
  138. background: rgba(0, 0, 0, 0.08);
  139. border-radius: 2rpx;
  140. overflow: hidden;
  141. }
  142. .energy-bar-fill {
  143. width: 0%;
  144. height: 100%;
  145. border-radius: 2rpx;
  146. animation: bar-grow 0.6s ease 0.2s forwards;
  147. }
  148. @keyframes bar-grow {
  149. from {
  150. width: 0%;
  151. }
  152. to {
  153. width: 100%;
  154. }
  155. }
  156. </style>