You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.4 KiB

8 months ago
8 months ago
8 months ago
  1. <!-- 抽奖动画 -->
  2. <template>
  3. <view v-if="show" class="luckyAnimation">
  4. <div class="loader"></div>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. num : 1,
  12. show : false
  13. }
  14. },
  15. destroyed() {
  16. if (this.interval) {
  17. clearInterval(this.interval);
  18. }
  19. },
  20. methods: {
  21. start() {
  22. this.show = true;
  23. this.num = 1;
  24. this.interval = setInterval(() => {
  25. if (this.num <= 0) {
  26. this.show = false
  27. this.$emit('close')
  28. clearInterval(this.interval);
  29. }
  30. this.num--;
  31. }, 500)
  32. },
  33. }
  34. }
  35. </script>
  36. <style lang="scss" scoped>
  37. .luckyAnimation {
  38. position: fixed;
  39. left: 0;
  40. top: 0;
  41. display: flex;
  42. align-items: center;
  43. justify-content: center;
  44. height: 100vh;
  45. width: 100%;
  46. z-index: 200;
  47. .loader {
  48. height: 15px;
  49. aspect-ratio: 4;
  50. --_g: no-repeat radial-gradient(farthest-side, #000, 90%, #0000);
  51. background:
  52. var(--_g) left,
  53. var(--_g) right;
  54. background-size: 25% 100%;
  55. display: grid;
  56. }
  57. .loader:before,
  58. .loader:after {
  59. content: "";
  60. height: inherit;
  61. aspect-ratio: 1;
  62. grid-area: 1/1;
  63. margin: auto;
  64. border-radius: 50%;
  65. transform-origin: -100% 50%;
  66. background: #fff;
  67. animation: l49 1s infinite linear;
  68. }
  69. .loader:after {
  70. transform-origin: 200% 50%;
  71. --s: -1;
  72. animation-delay: -.5s;
  73. }
  74. @keyframes l49 {
  75. 58%,
  76. 100% {
  77. transform: rotate(calc(var(--s, 1)*1turn))
  78. }
  79. }
  80. }
  81. </style>