<template>
  <div class="common-dialog-wrraper" v-if="isShowDialog">
    <div class="dialog-mask"></div>
    <div class="dialog-container">
      <div class="dialog-content">{{content}}</div>
      <div v-show="needSubContent" class="dialog-sub-content" v-html="subContent"></div>
      <div class="dialog-footer v-hairline-top">
        <span :class="{'single-btn': isSingle}" @click="handlerAction(1)">{{cancleBtnText}}</span>
        <span v-show="!isSingle" class="confirm-btn v-hairline-left" @click="handlerAction(2)">{{confirmBtnText}}</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "common-dialog",
  data() {
    return {

    };
  },
  props: {
    content: {
      type: String,
      default: ''
    },
    needSubContent: {
      type: Boolean,
      default: false
    },
    subContent: {
      type: String,
      default: ''
    },
    cancleBtnText: {
      type: String,
      default: '取消'
    },
    confirmBtnText: {
      type: String,
      default: '确定'
    },
    isShowDialog: {
      type: Boolean,
      default: false
    },
    isSingle: {
      type: Boolean,
      default: false
    },
  },
  methods: {
    handlerAction(type) {
      this.$emit("handlerAction", type);
    }
  }
};
</script>
<style lang="less" scoped>
.common-dialog-wrraper {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 2019;
  .dialog-mask {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2020;
  }
  .dialog-container {
    z-index: 2021;
    position: absolute;
    top: 50%;
    left: 50%;
    overflow: hidden;
    width: 300px;
    font-size: 18px;
    -webkit-transition: 0.3s;
    transition: 0.3s;
    border-radius: 4px;
    background-color: #fff;
    -webkit-transform: translate3d(-50%, -50%, 0);
    transform: translate3d(-50%, -50%, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    .dialog-content {
      // margin: 30px 22px;
      margin: 30px;
      text-align: center;
      font-size: 18px;
      font-weight: 400;
      color: #373839;
    }
    .dialog-sub-content {
      margin: -16px 30px 30px;
      // margin: -16px 22px 30px;
      text-align: left;
      font-size: 14px;
      line-height: 24px;
      font-weight: 400;
      color: #676869;
    }
    .dialog-footer {
      height: 50px;
      display: flex;
      align-items: center;
      &.v-hairline-top::after {
        border-top-width: 1px;
      }
      span {
        display: inline-block;
        // width: 50%;
        flex: 1;
        height: 50px;
        line-height: 50px;
        font-size: 17px;
        text-align: center;
        color: #979899;
        &.v-hairline-left::after {
          border-left-width: 1px;
        }
        &.confirm-btn {
          color: #449284;
        }
        &.single-btn {
          color: #449284;
        }
      }
    }
  }

  [class*="v-hairline"] {
    position: relative;
    &::after {
      content: " ";
      position: absolute;
      pointer-events: none;
      box-sizing: border-box;
      top: -50%;
      left: -50%;
      right: -50%;
      bottom: -50%;
      -webkit-transform: scale(0.5);
      transform: scale(0.5);
      border: 0 solid #f0f1f2;
    }
  }
  &.shikan {
    .dialog-sub-content {
      text-align: center;
      font-size: 16px;
    }
  }
}
</style>
