u-loading-page.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <u-transition
  3. :show="loading"
  4. :custom-style="{
  5. position: 'fixed',
  6. top: 0,
  7. left: 0,
  8. right: 0,
  9. bottom: 0,
  10. backgroundColor: bgColor,
  11. display: 'flex',
  12. 'z-index':9999,
  13. }"
  14. >
  15. <view class="u-loading-page">
  16. <view class="u-loading-page__warpper">
  17. <view class="u-loading-page__warpper__loading-icon">
  18. <image
  19. v-if="image"
  20. :src="image"
  21. class="u-loading-page__warpper__loading-icon__img"
  22. mode="widthFit"
  23. :style="{
  24. width: $u.addUnit(iconSize),
  25. height: $u.addUnit(iconSize)
  26. }"
  27. ></image>
  28. <u-loading-icon
  29. v-else
  30. :mode="loadingMode"
  31. :size="$u.addUnit(iconSize)"
  32. :color="loadingColor"
  33. ></u-loading-icon>
  34. </view>
  35. <slot>
  36. <text
  37. class="u-loading-page__warpper__text"
  38. :style="{
  39. fontSize: $u.addUnit(fontSize),
  40. color: color,
  41. }"
  42. >{{ loadingText }}</text
  43. >
  44. </slot>
  45. </view>
  46. </view>
  47. </u-transition>
  48. </template>
  49. <script>
  50. import props from "./props.js";
  51. /**
  52. * loadingPage 加载动画
  53. * @description 警此组件为一个小动画,目前用在uView的loadmore加载更多和switch开关等组件的正在加载状态场景。
  54. * @tutorial https://www.uviewui.com/components/loading.html
  55. * @property {String | Number} loadingText 提示内容 (默认 '正在加载' )
  56. * @property {String} image 文字上方用于替换loading动画的图片
  57. * @property {String} loadingMode 加载动画的模式,circle-圆形,spinner-花朵形,semicircle-半圆形 (默认 'circle' )
  58. * @property {Boolean} loading 是否加载中 (默认 false )
  59. * @property {String} bgColor 背景色 (默认 '#ffffff' )
  60. * @property {String} color 文字颜色 (默认 '#C8C8C8' )
  61. * @property {String | Number} fontSize 文字大小 (默认 19 )
  62. * @property {String | Number} iconSize 图标大小 (默认 28 )
  63. * @property {String} loadingColor 加载中图标的颜色,只能rgb或者十六进制颜色值 (默认 '#C8C8C8' )
  64. * @property {Object} customStyle 自定义样式
  65. * @example <u-loading mode="circle"></u-loading>
  66. */
  67. export default {
  68. name: "u-loading-page",
  69. mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
  70. data() {
  71. return {};
  72. },
  73. methods: {},
  74. };
  75. </script>
  76. <style lang="scss" scoped>
  77. @import "../../libs/css/components.scss";
  78. $text-color: rgb(200, 200, 200) !default;
  79. $text-size: 19px !default;
  80. $u-loading-icon-margin-bottom: 10px !default;
  81. .u-loading-page {
  82. @include flex(column);
  83. flex: 1;
  84. align-items: center;
  85. justify-content: center;
  86. &__warpper {
  87. margin-top: -150px;
  88. justify-content: center;
  89. align-items: center;
  90. /* #ifndef APP-NVUE */
  91. color: $text-color;
  92. font-size: $text-size;
  93. /* #endif */
  94. @include flex(column);
  95. &__loading-icon {
  96. margin-bottom: $u-loading-icon-margin-bottom;
  97. &__img {
  98. width: 40px;
  99. height: 40px;
  100. }
  101. }
  102. &__text {
  103. font-size: $text-size;
  104. color: $text-color;
  105. }
  106. }
  107. }
  108. </style>