u-loading-page.vue 3.4 KB

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