loading.vue 2.2 KB

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