loading.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-gradual-blue" :isBack="true"><block slot="backText">返回</block><block slot="content">加载</block>
  4. <block slot="right">
  5. <view class="action">
  6. <view class="cu-load load-cuIcon" :class="!isLoad?'loading':'over'"></view>
  7. </view>
  8. </block>
  9. </cu-custom>
  10. <view class="cu-bar bg-white">
  11. <view class="action">
  12. <text class="cuIcon-title text-blue"></text>背景
  13. </view>
  14. </view>
  15. <view class="cu-load bg-blue" :class="!isLoad?'loading':'over'"></view>
  16. <view class="cu-bar bg-white margin-top">
  17. <view class="action">
  18. <text class="cuIcon-title text-blue"></text>加载状态
  19. </view>
  20. <view class="action">
  21. <switch @change="isLoading" :class="isLoad?'checked':''"></switch>
  22. </view>
  23. </view>
  24. <view class="cu-load bg-grey" :class="!isLoad?'loading':'over'"></view>
  25. <view class="cu-bar bg-white margin-top">
  26. <view class="action">
  27. <text class="cuIcon-title text-blue"></text>加载错误
  28. </view>
  29. </view>
  30. <view class="cu-load bg-red erro"></view>
  31. <view class="cu-bar bg-white margin-top">
  32. <view class="action">
  33. <text class="cuIcon-title text-blue"></text>弹框加载
  34. </view>
  35. <view class="action">
  36. <button class="cu-btn bg-green shadow" @tap="LoadModal">
  37. 点我
  38. </button>
  39. </view>
  40. </view>
  41. <view class="cu-load load-modal" v-if="loadModal">
  42. <!-- <view class="cuIcon-emojifill text-orange"></view> -->
  43. <image src="/static/logo.png" mode="aspectFit"></image>
  44. <view class="gray-text">加载中...</view>
  45. </view>
  46. <view class="cu-bar bg-white margin-top">
  47. <view class="action">
  48. <text class="cuIcon-title text-blue"></text>进度条加载
  49. </view>
  50. <view class="action">
  51. <button class="cu-btn bg-green shadow" @tap="LoadProgress">
  52. 点我
  53. </button>
  54. </view>
  55. </view>
  56. <view class="load-progress" :class="loadProgress!=0?'show':'hide'" :style="[{top:CustomBar+'px'}]">
  57. <view class="load-progress-bar bg-green" :style="[{transform: 'translate3d(-' + (100-loadProgress) + '%, 0px, 0px)'}]"></view>
  58. <view class="load-progress-spinner text-green"></view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. data() {
  65. return {
  66. CustomBar: this.CustomBar,
  67. isLoad:false,
  68. loadModal: false,
  69. loadProgress: 0
  70. };
  71. },
  72. methods: {
  73. isLoading(e) {
  74. this.isLoad = e.detail.value;
  75. },
  76. LoadModal(e) {
  77. this.loadModal = true;
  78. setTimeout(() => {
  79. this.loadModal = false;
  80. }, 2000)
  81. },
  82. LoadProgress(e) {
  83. this.loadProgress = this.loadProgress + 3;
  84. if (this.loadProgress < 100) {
  85. setTimeout(() => {
  86. this.LoadProgress();
  87. }, 100)
  88. } else {
  89. this.loadProgress = 0;
  90. }
  91. }
  92. }
  93. }
  94. </script>
  95. <style>
  96. </style>