nc-loading.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view class="loading-layer" v-if="isShow" :style="layerBackground">
  3. <view class="loading-anim">
  4. <view class="box item"><view class="border out item color-base-border-top color-base-border-left"></view></view>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. name: 'ncLoading',
  11. props: {
  12. layerBackground: {
  13. type: Object,
  14. default() {
  15. return {};
  16. }
  17. },
  18. defaultShow: {
  19. type: Boolean,
  20. default: true
  21. }
  22. },
  23. data() {
  24. return {
  25. isShow: true
  26. };
  27. },
  28. created() {
  29. this.isShow = this.defaultShow;
  30. },
  31. methods: {
  32. show() {
  33. this.isShow = true;
  34. },
  35. hide() {
  36. this.isShow = false;
  37. }
  38. }
  39. };
  40. </script>
  41. <style lang="scss">
  42. @keyframes spin {
  43. from {
  44. transform: rotate(0deg);
  45. }
  46. to {
  47. transform: rotate(360deg);
  48. }
  49. }
  50. .loading-layer {
  51. width: 100%;
  52. height: 100%;
  53. position: fixed;
  54. top: 0;
  55. left: 0;
  56. z-index: 997;
  57. background: #fff;
  58. }
  59. .loading-anim {
  60. position: absolute;
  61. left: 50%;
  62. top: 40%;
  63. transform: translate(-50%, -50%);
  64. }
  65. .loading-anim > .item {
  66. position: relative;
  67. width: 0.3rem;
  68. height: 0.3rem;
  69. perspective: 8rem;
  70. transform-style: preserve-3d;
  71. transition: all 0.2s ease-out;
  72. }
  73. .loading-anim .border {
  74. position: absolute;
  75. border-radius: 50%;
  76. border: 0.03rem solid $primary-color;
  77. }
  78. .loading-anim .out {
  79. top: 15%;
  80. left: 15%;
  81. width: 70%;
  82. height: 70%;
  83. // border-left-color: red !important;
  84. border-right-color: rgba($color: #000000, $alpha: 0) !important;
  85. // border-top-color: rgba($color: #000000, $alpha: 0) !important;
  86. border-bottom-color: rgba($color: #000000, $alpha: 0) !important;
  87. animation: spin 0.6s linear normal infinite;
  88. }
  89. .loading-anim .in {
  90. top: 25%;
  91. left: 25%;
  92. width: 50%;
  93. height: 50%;
  94. border-top-color: transparent !important;
  95. border-bottom-color: transparent !important;
  96. animation: spin 0.8s linear infinite;
  97. }
  98. .loading-anim .mid {
  99. top: 40%;
  100. left: 40%;
  101. width: 20%;
  102. height: 20%;
  103. border-left-color: transparent;
  104. border-right-color: transparent;
  105. animation: spin 0.6s linear infinite;
  106. }
  107. </style>