loading.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="mask mask-show" v-if="loadingShow" @touchmove.stop.prevent="preventTouchMove">
  3. <!-- 加载动画开始 -->
  4. <view class="preloader">
  5. <view class="loader"></view>
  6. </view>
  7. <!-- 加载动画结束 -->
  8. <view class="title">加载中...</view>
  9. </view>
  10. </template>
  11. <script scoped="true">
  12. import {
  13. mapState,
  14. mapMutations
  15. } from 'vuex';
  16. export default {
  17. computed: {
  18. ...mapState(['loadingShow'])
  19. },
  20. methods: {
  21. preventTouchMove() {
  22. console.log('stop user scroll it!');
  23. return;
  24. }
  25. }
  26. };
  27. </script>
  28. <style scoped>
  29. .mask {
  30. /* pointer-events: none; */
  31. position: fixed;
  32. z-index: 99999;
  33. top: 0;
  34. left: 0;
  35. right: 0;
  36. bottom: 0;
  37. height: 100vh;
  38. width: 100vw;
  39. display: flex;
  40. flex-direction: column;
  41. justify-content: center;
  42. align-items: center;
  43. flex-wrap: wrap;
  44. }
  45. .mask.mask-show {
  46. background: rgba(255, 255, 255, 0.3);
  47. }
  48. .title {
  49. color: #333;
  50. font-size: 28rpx;
  51. margin-top: 20rpx;
  52. }
  53. .loader {
  54. display: block;
  55. width: 120rpx;
  56. height: 120rpx;
  57. border-radius: 50%;
  58. border: 3rpx solid transparent;
  59. border-top-color: #9370db;
  60. -webkit-animation: spin 2s linear infinite;
  61. animation: spin 2s linear infinite;
  62. }
  63. .loader::before {
  64. content: "";
  65. position: absolute;
  66. top: 5rpx;
  67. left: 5rpx;
  68. right: 5rpx;
  69. bottom: 5rpx;
  70. border-radius: 50%;
  71. border: 3rpx solid transparent;
  72. border-top-color: #ba55d3;
  73. -webkit-animation: spin 3s linear infinite;
  74. animation: spin 3s linear infinite;
  75. }
  76. .loader::after {
  77. content: "";
  78. position: absolute;
  79. top: 15rpx;
  80. left: 15rpx;
  81. right: 15rpx;
  82. bottom: 15rpx;
  83. border-radius: 50%;
  84. border: 3rpx solid transparent;
  85. border-top-color: #ff00ff;
  86. -webkit-animation: spin 1.5s linear infinite;
  87. animation: spin 1.5s linear infinite;
  88. }
  89. @-webkit-keyframes spin {
  90. 0% {
  91. -webkit-transform: rotate(0deg);
  92. -ms-transform: rotate(0deg);
  93. transform: rotate(0deg);
  94. }
  95. 100% {
  96. -webkit-transform: rotate(360deg);
  97. -ms-transform: rotate(360deg);
  98. transform: rotate(360deg);
  99. }
  100. }
  101. @keyframes spin {
  102. 0% {
  103. -webkit-transform: rotate(0deg);
  104. -ms-transform: rotate(0deg);
  105. transform: rotate(0deg);
  106. }
  107. 100% {
  108. -webkit-transform: rotate(360deg);
  109. -ms-transform: rotate(360deg);
  110. transform: rotate(360deg);
  111. }
  112. }
  113. </style>