<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.options.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: #FDFCEE;
    box-sizing: border-box;
    border-radius: 10px;
    box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.5);
    padding: 8px 10px;
    .content-detail {
      border: 2px solid #C9C6AD;
      border-radius: 10px;
      text-align: center;
      padding: 10px 13px;
      // box-sizing: border-box;
      .title {
        color: #21252B;
        font-weight: 600;
        font-size: 20px;
        padding-top: 15px;
      }
      .subtitle {
        color: #21252B;
        font-size: 15px;
        padding: 20px 0 30px;
      }
      .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: #000000;
          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: rgba(255, 255, 255, 0.8);
  opacity: 0.8;
  padding: 15px;
  font-size: 28px;
  height: 28px;
  width: 28px;
}
</style>
