<template>
    <div class="popup" v-if="isShow">
      <div class="box">
        <div class="loading"></div>
        <p>{{str}}</p>
      </div>
    </div>
</template>

<script>
  export default {
    name: 'Loading',
    data() {
      return {
        isShow: false,
        str: '初始化中',
        timer: null
      };
    },
    mounted() {
      uni.$on('showLoading', (type, str) => {
        if (type == true) {
          this.isShow = true;
          this.str = str;
        } else {
          this.isShow = false;
        }
      })
    },
    methods: {
      clickTow(){
        
      }
    },
  };
</script>

<style scoped lang="scss">
  .popup-enter-active,
  .popup-leave-active {
    transition: opacity 0.3s ease-in-out;
  }

  .popup-enter,
  .popup-leave-to {
    opacity: 0;
  }

  .popup {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    z-index: 99999999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background-color: rgba(0, 0, 0, 0.2);
    .box{
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      background-color: rgba(0, 0, 0, 0.5);
      color: #eee;
      height: 300rpx;
      width: 300rpx;
      border-radius: 20rpx;
      box-sizing: border-box;
      overflow: hidden;
    }
  }
  
  .loading {
    width: 80rpx;
    height: 80rpx;
    border: 6rpx solid #eee;
    border-top-color: transparent;
    border-radius: 100%;
    margin-bottom: 30rpx;
  
    animation: circle infinite 0.75s linear;
  }
  
  @keyframes circle {
    0% {
      transform: rotate(0);
    }
    100% {
      transform: rotate(360deg);
    }
  }
</style>