3
0

u-loading-page.vue 3.9 KB

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