No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

128 líneas
4.1 KiB

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