<template>
  <view class="modal-mask" v-if="value">
    <view class="confirm-container">
      <view class="popup-title">{{ dialogInfo.title || $t('温馨提示') }}</view>
      <view class="popup-content">{{ dialogInfo.text }}</view>
      <view class="flex-row modal-footer">
        <view class="show-btn cencel-btn-pop" v-if="dialogInfo.showCancelButton" @tap="cancel">
          {{ dialogInfo.cancelBtnText || $t('取消') }}
        </view>
        <view class="show-btn ok-btn-pop" @tap="confirm">{{ dialogInfo.confirmBtnText || $t('确定') }}</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    value: {
      type: Boolean,
      default: false
    },
    dialogInfo: {
      type: Object,
      default: () => ({})
    }
  },
  methods: {
    cancel() {
      this.hide()
    },
    confirm() {
      this.hide()
      const { opType = null } = this.dialogInfo
      this.$emit("confirm", opType)
    },
    hide() {
      this.$emit("input", false)
    }
  }
};
</script>

<style lang="scss" scoped>
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;

  .confirm-container {
    background-color: #fff;
    padding: 48rpx;
    border-radius: 40rpx;
    width: 75%;

    .popup-title {
      font-weight: 600;
      font-size: 36rpx;
      color: #060809;
      text-align: center;
      margin-bottom: 26rpx;
      font-family: PingFangSC, PingFang SC;
    }

    .popup-content {
      text-align: center;
      font-weight: 400;
      font-size: 28rpx;
      color: #828384;
      margin-bottom: 42rpx;
      font-family: PingFangSC, PingFang SC;
      line-height: 40rpx;
    }
  }

  .modal-footer {
    width: 100%;
    align-items: center;

    .show-btn {
      border-radius: 40rpx;
      flex: 1;
      text-align: center;
      font-weight: 600;
      font-size: 32rpx;
      border-radius: 40rpx;
      height: 80rpx;
      line-height: 80rpx;

      &:active {
        opacity: 0.7;
      }
    }

    .cencel-btn-pop {
      color: #060809;
      background: #EBECEC;
      margin-right: 12rpx;
    }

    .ok-btn-pop {
      color: #FFFFFF;
      background: #060809;
    }
  }
}




@keyframes confirm-fadein {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes confirm-zoom {
  0% {
    transform: scale(0);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}
</style>