u-loading-page.vue 3.2 KB

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