<template>
  <div class="popup" v-if="visabled">
    <div class="popup-ke">
      <div class="default-alert animated zoomIn">
        <div class="message_box">
          <div class="default-title">温馨提示</div>
          <div class="default-box">
            <div class="alert-text">{{ message }}</div>
            <div class="alert-btn-box">
              <div class="alert-btn">
                <div class="ensure-btn" @click="close">确认</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const props = defineProps({
  type: {
    type: Number,
    default: 0,
  },
})
const message = ref("成功");
const visabled = ref(false);
function open(data) {
  visabled.value = true;
  message.value = data;
}
function close() {
  visabled.value = false;
  if (props.type == 0) {
    router.push({
      path: "/index",
    });
  }
}
defineExpose({
  open,
  close,
});
</script>
<style scoped lang="scss">
@keyframes zoomIn {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}
.popup {
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  .popup-ke {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    .default-alert {
      width: 5.75rem;
      background: #f1a6a6;
      border-radius: 0.3rem;
      padding: 0.12rem;
      box-sizing: border-box;
      text-align: center;
      position: relative;
    }
    .animated {
      -webkit-animation-duration: 0.5s;
      animation-duration: 0.5s;
      -webkit-animation-fill-mode: both;
      animation-fill-mode: both;
    }
    .zoomIn {
      -webkit-animation-name: zoomIn;
      animation-name: zoomIn;
    }
  }
}
.message_box {
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-radius: 0.2rem;
  overflow: hidden;
  padding-bottom: 0.4rem;
  box-sizing: border-box;
  .default-title {
    font-weight: bold;
    font-size: 0.36rem;
    color: #333333;
    margin-top: 0.4rem;
  }
  .default-box {
    .alert-text {
      width: 5rem;
      font-size: 0.32rem;
      color: #333333;
      height: 1.7rem;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      margin: 0 auto;
    }
    .alert-btn-box {
      display: flex;
      align-items: center;
      justify-content: space-evenly;
      .ensure-btn {
        width: 3.2rem;
        height: 0.8rem;
        background: #ea3a3a;
        border-radius: 0.4rem;
        font-weight: bold;
        font-size: 0.32rem;
        color: #ffffff;
        line-height: 0.8rem;
      }
    }
  }
}
</style>
