综合办公系统
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.

uv-loading-page.vue 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="uv-loading-page uv-flex-column" v-if="showLoading" :style="[loadingPageStyle]">
  3. <image v-if="image!=''" :src="image" class="uv-loading-page__img" mode="widthFit" :style="[{
  4. width: $uv.addUnit(iconSize),
  5. height: $uv.addUnit(iconSize)
  6. }]"></image>
  7. <uv-loading-icon v-else :mode="loadingMode" :size="iconSize" :color="loadingColor"></uv-loading-icon>
  8. <slot>
  9. <text class="uv-loading-page__text" :style="[{
  10. fontSize: $uv.addUnit(fontSize),
  11. color: color
  12. }]">{{ loadingText }}</text>
  13. </slot>
  14. </view>
  15. </template>
  16. <script>
  17. import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
  18. import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
  19. import props from "./props.js";
  20. /**
  21. * loadingPage 加载动画
  22. * @description 警此组件为一个小动画,目前用在uvui的loadmore加载更多和switch开关等组件的正在加载状态场景。
  23. * @tutorial https://www.uvui.cn/components/loading.html
  24. *
  25. * @property {Boolean} loading 是否加载中 (默认 false )
  26. * @property {String | Number} loadingText 提示内容 (默认 '正在加载' )
  27. * @property {String} image 文字上方用于替换loading动画的图片
  28. * @property {String} loadingMode 加载动画的模式,circle-圆形,spinner-花朵形,semicircle-半圆形 (默认 'circle' )
  29. * @property {String} bgColor 背景色 (默认 '#ffffff' )
  30. * @property {String} color 文字颜色 (默认 '#C8C8C8' )
  31. * @property {String | Number} fontSize 文字大小 (默认 19 )
  32. * @property {String | Number} iconSize 图标大小 (默认 28 )
  33. * @property {String} loadingColor 加载中图标的颜色,只能rgb或者十六进制颜色值 (默认 '#C8C8C8' )
  34. * @property {String | Number} duration 关闭加载时的过渡时间,单位ms (默认 300 )
  35. *
  36. * @example <uv-loading mode="circle"></uv-loading>
  37. */
  38. export default {
  39. name: "uv-loading-page",
  40. mixins: [mpMixin, mixin, props],
  41. data() {
  42. return {
  43. showLoading: false,
  44. opacity: 1
  45. }
  46. },
  47. watch: {
  48. loading: {
  49. immediate: true,
  50. handler(newVal) {
  51. if (newVal) {
  52. this.showLoading = true;
  53. this.opacity = 1;
  54. } else {
  55. this.opacity = 0;
  56. this.$nextTick(() => {
  57. this.$uv.sleep(this.duration).then(res => {
  58. this.showLoading = false;
  59. })
  60. })
  61. }
  62. }
  63. }
  64. },
  65. computed: {
  66. loadingPageStyle() {
  67. const style = {
  68. 'position': 'fixed',
  69. 'top': '0',
  70. 'left': '0',
  71. 'right': '0',
  72. 'bottom': '0',
  73. 'zIndex': '999',
  74. 'background-color': this.bgColor,
  75. 'transition-duration': `${this.duration}ms`,
  76. 'opacity': this.opacity
  77. }
  78. return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle))
  79. }
  80. }
  81. }
  82. </script>
  83. <style scoped lang="scss">
  84. @import '@/uni_modules/uv-ui-tools/libs/css/components.scss';
  85. $uv-loading-icon-margin-bottom: 10px !default;
  86. .uv-loading-page {
  87. flex: 1;
  88. justify-content: center;
  89. align-items: center;
  90. padding-bottom: 150px;
  91. transition-property: opacity;
  92. &__text {
  93. margin-top: $uv-loading-icon-margin-bottom;
  94. }
  95. }
  96. </style>