<template>
  <div class="dialog-bg" v-if="show && (title || content || (buttonList && buttonList.length))">
    <div class="content">
      <div class="content-detail-bg">
        <div class="content-detail">
          <div class="title" v-if="title">{{ title }}</div>
          <div class="subtitle" v-if="content">{{ content }}</div>
          <div class="handle-btn-box" v-if="buttonList && buttonList.length">
            <div
              class="handle-btn"
              v-for="item in buttonList"
              :key="item"
              @click="item.click()"
            >
              {{ item.text }}
            </div>
          </div>
        </div>
      </div>
      <div class="iconfont icon-guanbi" @click="close"></div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    show: Boolean,
    title:{
      type: String,
      default: "提示"
    },
    content:{
      type: String,
      default: "提示内容"
    },
    buttonList:{
      type: Object,
      default(){
        return [
            {
              text: "btn1",
              click: function () {
                console.log("click1");
              },
            },
            {
              text: "btn1",
              click: function () {
                console.log("click2");
              },
            },
          ]
      }
    },
    cancel:{
      type: Function,
      default(){
        console.log("cancel");
      }
    },
  },
  data() {
    return {};
  },
  methods: {
    close() {
      this.$emit("update:show", false);
      this.cancel && this.cancel();
    },
  },
};
</script>

<style scoped lang="scss">
.dialog-bg {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 99;
  background: rgba(0, 0, 0, 0.85);
}

.dialog-bg .content {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 75%;
  .content-detail-bg {
    background: #12b4bb;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid #54fefe;
    box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.5);
    padding: 8px 10px;
    .content-detail {
      background: white;
      border-radius: 10px;
      text-align: center;
      padding: 10px 13px;
      .title {
        color: #21252B;
        font-weight: 600;
        font-size: 20px;
        padding-top: 15px;
      }
      .subtitle {
        color: #21252B;
        font-size: 15px;
        padding: 20px 0 30px;
        white-space: pre-wrap;
      }
      .handle-btn-box {
        display: flex;
        padding-bottom: 15px;
        justify-content: center;
        .handle-btn {
          box-sizing: border-box;
          height: 40px;
          line-height: 40px;
          text-align: center;
          color: white;
          font-size: 16px;
          font-weight: 600;
          border-radius: 20px;
          background: #12b4bb;
          box-shadow: inset 0px 3px 3px 0px rgba(255, 255, 255, 0.8);
          flex: 1;
          max-width: 165px;
          margin-right: 15px;
          &:last-child {
            margin-right: 0px;
          }
        }
      }
    }
  }
}

.dialog-bg .content .icon-guanbi {
  margin: 40px auto 0;
  color: white;
  opacity: 0.8;
  padding: 15px;
  font-size: 28px;
  height: 28px;
  width: 28px;
}
</style>
