loading.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="animations" v-if="is_loading">
  3. <view class="box">
  4. <view class="dot dot1"></view>
  5. <view class="dot dot2"></view>
  6. <view class="dot dot3"></view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. name: "loading-bounce",
  13. data() {
  14. return {};
  15. },
  16. methods:{
  17. switch_loading(){
  18. this.$store.commit("switch_loading")
  19. }
  20. },
  21. //实测直接在标签属性里写 $store.state.XX 拿不到数据 所以这里通过 计算属性去监听一下
  22. computed:{
  23. is_loading(){
  24. return this.$store.state.user.loading
  25. }
  26. }
  27. };
  28. </script>
  29. <style lang="scss" scoped>
  30. .animations{display: flex;align-items: center;justify-content: center;position: fixed;top: 40%;left: 0;right: 0;z-index: 3;}
  31. .box {
  32. width: 100rpx;
  33. height: 50rpx;
  34. position: relative;
  35. }
  36. .dot {
  37. width: 18rpx;
  38. height: 18rpx;
  39. background: #007aff;
  40. border-radius: 50%;
  41. position: absolute;
  42. top: calc(50% - 5rpx);
  43. }
  44. .dot1 {
  45. background: #1fa2ff;
  46. left: 0rpx;
  47. -webkit-animation: bounce 0.5s cubic-bezier(0.77, 0.47, 0.64, 0.28) alternate
  48. infinite;
  49. animation: bounce 0.5s cubic-bezier(0.77, 0.47, 0.64, 0.28) alternate infinite;
  50. }
  51. .dot2 {
  52. background: #12d8fa;
  53. left: 40rpx;
  54. -webkit-animation: bounce 0.5s 0.2s cubic-bezier(0.77, 0.47, 0.64, 0.28)
  55. alternate infinite;
  56. animation: bounce 0.5s 0.2s cubic-bezier(0.77, 0.47, 0.64, 0.28) alternate
  57. infinite;
  58. }
  59. .dot3 {
  60. background: #29ffc6;
  61. left: 80rpx;
  62. -webkit-animation: bounce 0.5s 0.4s cubic-bezier(0.77, 0.47, 0.64, 0.28)
  63. alternate infinite;
  64. animation: bounce 0.5s 0.4s cubic-bezier(0.77, 0.47, 0.64, 0.28) alternate
  65. infinite;
  66. }
  67. @-webkit-keyframes bounce {
  68. 0% {
  69. -webkit-transform: translateY(0);
  70. transform: translateY(0);
  71. }
  72. 100% {
  73. -webkit-transform: translateY(-20rpx);
  74. transform: translateY(-20rpx);
  75. }
  76. }
  77. @keyframes bounce {
  78. 0% {
  79. -webkit-transform: translateY(0);
  80. transform: translateY(0);
  81. }
  82. 100% {
  83. -webkit-transform: translateY(-20rpx);
  84. transform: translateY(-20rpx);
  85. }
  86. }
  87. </style>