You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.7 KiB

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