u-loading-page.vue 3.1 KB

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