app-loading.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view>
  3. <view v-if="type === 'global'" class="app-loading app-loading-global">
  4. <view class="app-loading-image app-loading-global-image" :style="{'background-image': `url(${background})`}"></view>
  5. <text :style="{'color': color}" class="app-loading-global-text" v-if="text">{{text}}</text>
  6. </view>
  7. <view v-else-if="type === 'toast'" class="app-loading app-loading-toast">
  8. <view class="app-loading-image app-loading-toast-image"
  9. :style="{'background-image': `url(${background})`}"
  10. ></view>
  11. <text :style="{'color': color}" class="app-loading-toast-text" v-if="text">{{text}}</text>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'app-loading',
  18. props: {
  19. type: {
  20. type: String,
  21. default() {
  22. return "";
  23. }
  24. },
  25. text: {
  26. type: String,
  27. default() {
  28. return "";
  29. }
  30. },
  31. color: {
  32. type: String,
  33. default() {
  34. return "";
  35. }
  36. },
  37. backgroundImage: {
  38. type: String,
  39. default() {
  40. return "";
  41. }
  42. },
  43. },
  44. computed: {
  45. background: function() {
  46. return this.backgroundImage;
  47. }
  48. }
  49. }
  50. </script>
  51. <style scoped lang="scss">
  52. .app-loading {
  53. position: fixed;
  54. z-index: 1501;
  55. }
  56. .app-loading-toast {
  57. top: 50%;
  58. left:50%;
  59. transform: translate(-50%, -50%);
  60. }
  61. .app-loading-global {
  62. top: 0;
  63. width: 100%;
  64. height: 100%;
  65. background-color: rgba(31,31,31, .5);
  66. }
  67. .app-loading-global-text {
  68. position: absolute;
  69. top: 50%;
  70. left: 50%;
  71. transform: translate(-50%, -50%);
  72. }
  73. .app-loading-global-image {
  74. position: absolute;
  75. top: 40%;
  76. left: 50%;
  77. width: #{80rpx};
  78. height: #{80rpx};
  79. border-radius: 50%;
  80. transform: translate(-50%, -50%);
  81. }
  82. .app-loading-toast-image {
  83. width: #{130rpx};
  84. height: #{130rpx};
  85. border-radius: 50%;
  86. }
  87. .app-loading-toast {
  88. width: #{80rpx};
  89. height: #{80rpx};
  90. background-color: rgba(0, 0, 0, 0.5);
  91. border-radius: #{20rpx};
  92. color: white;
  93. display: flex;
  94. flex-direction: column;
  95. flex-wrap: nowrap;
  96. justify-content:center;
  97. align-items: center;
  98. }
  99. .app-loading-toast-text {
  100. font-size:#{30rpx};
  101. }
  102. .app-loading-image {
  103. opacity: .8;
  104. background-size: 100% 100%;
  105. }
  106. </style>