MilestoneCelebration.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="celebration-overlay" v-if="visible" @click="dismiss" @touchmove.stop.prevent :style="{ '--font-scale': fontScale }">
  3. <!-- CSS粒子 -->
  4. <view
  5. class="celebration-particle"
  6. v-for="p in particles"
  7. :key="p.id"
  8. :style="{
  9. left: p.left + '%',
  10. animationDelay: p.delay + 's',
  11. animationDuration: p.duration + 's',
  12. background: p.color,
  13. width: p.size + 'rpx',
  14. height: p.size + 'rpx'
  15. }">
  16. </view>
  17. <!-- 文字 -->
  18. <view class="celebration-content">
  19. <text class="celebration-title">{{ title }}</text>
  20. <text class="celebration-subtitle">{{ subtitle }}</text>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import fontScaleMixin from '@/mixins/font-scale.js'
  26. export default {
  27. mixins: [fontScaleMixin],
  28. props: {
  29. visible: { type: Boolean, default: false },
  30. title: { type: String, default: '' },
  31. subtitle: { type: String, default: '' },
  32. particles: { type: Array, default: function() { return [] } }
  33. },
  34. methods: {
  35. dismiss: function() {
  36. this.$emit('dismiss')
  37. }
  38. }
  39. }
  40. </script>
  41. <style scoped lang="scss">
  42. .celebration-overlay {
  43. position: fixed;
  44. top: 0;
  45. left: 0;
  46. right: 0;
  47. bottom: 0;
  48. z-index: 9998;
  49. background: rgba(0,0,0,0.6);
  50. display: flex;
  51. align-items: center;
  52. justify-content: center;
  53. overflow: hidden;
  54. }
  55. .celebration-particle {
  56. position: absolute;
  57. top: -20rpx;
  58. border-radius: 50%;
  59. animation: particleFall linear forwards;
  60. opacity: 0.9;
  61. }
  62. .celebration-content {
  63. display: flex;
  64. flex-direction: column;
  65. align-items: center;
  66. gap: 16rpx;
  67. z-index: 1;
  68. animation: celebrationTextIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  69. }
  70. .celebration-title {
  71. font-size: calc($uni-font-size-display * var(--font-scale, 1));
  72. font-weight: $uni-font-weight-extra-heavy;
  73. color: $app-surface;
  74. text-shadow: 0 4rpx 20rpx rgba(0,0,0,0.3);
  75. }
  76. .celebration-subtitle {
  77. font-size: calc(32rpx * var(--font-scale, 1));
  78. color: rgba(255,255,255,0.9);
  79. }
  80. </style>
  81. <style>
  82. @keyframes particleFall {
  83. 0% { transform: translateY(-20rpx) rotate(0deg); opacity: 0.9; }
  84. 50% { opacity: 1; }
  85. 100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
  86. }
  87. @keyframes celebrationTextIn {
  88. 0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  89. 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  90. }
  91. </style>