<template>
  <Dialog
    :visible.sync="visible"
    :show-close="false"
    :append-to-body="true"
    :style="style"
    top="0px"
    custom-class="game-dialog"
    title=""
    width="542px"
    modal-append-to-body
  >
    <div class="bg"/>
    <div class="content">
      <div class="title">{{ title }}</div>
      <div class="message">{{ message }}</div>
      <div class="dialog-footer">
        <div v-audio class="btn" @click="visible = false">取 消</div>
        <div v-audio class="btn" type="primary" @click="confirm">确 定</div>
      </div>
      <div class="footer-tip">
        {{ tip }}
      </div>
    </div>
  </Dialog>
</template>

<script>
import {
  Dialog,
} from 'element-ui'
import { mapState } from 'vuex'
export default {
  components: {
    Dialog,
  },
  props: {
    title: {
      type: String,
      default: '',
    },
    message: {
      type: String,
      default: '',
    },
    tip: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      visible: false,
    }
  },
  computed: {
    ...mapState([
      'zoom',
    ]),
    style() {
      const { zoom } = this
      const style = {
        zoom,
      }
      const { innerWidth, innerHeight } = window
      if (innerWidth / innerHeight > 1080 / 608) {
        style.top = `120px`
      } else {
        style.top = `${(innerHeight / 2 - (184 * zoom)) / zoom}px`
      }
      return style
    },
  },
  methods: {
    confirm() {
      this.$emit('confirm')
      this.visible = false
    },
    show() {
      console.log('show')
      this.visible = true
    },
  },
}
</script>

<style lang="scss" scoped>
.bg {
  background-image: url(https://kuawai.s3.ap-east-1.amazonaws.com/resource/assets/Textures/tip/tip_bg_b.png);
  background-size: 100% 100%;
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
  top: 0;
  left: 0;
}
.content {
  position: relative;
  z-index: 2;
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  .title {
    text-align: center;
    font-size: 28px;
    font-weight: bold;
    color: #f5be5e;
    margin-top: 30px;
  }
  .message {
    text-align: center;
    color: #f5be5e;
    margin-top: 48px;
    font-size: 18px;
    flex: 1;
  }
  .dialog-footer {
    padding-bottom: 20px;
    display: flex;
    justify-content: center;
    .btn {
      background-image: url(https://kuawai.s3.ap-east-1.amazonaws.com/resource/assets/Textures/tip/tip_btn_b.png);
      background-size: 100% 100%;
      width: 150px;
      height: 40px;
      opacity: 0.80;
      text-align: center;
      line-height: 40px;
      color: #5e4926;
      font-size: 18px;
      font-weight: bold;
      margin: 0 36px;
      &:hover {
        opacity: 1;
      };
    }
  }
  .footer-tip {
    height: 30px;
    line-height: 30px;
    text-align: right;
    padding: 4px 16px;
    font-size: 12px;
    color: #bc9a6c;
  }
}
/deep/ .game-dialog {
  position: relative;
  background: transparent;
  height: 320px;
  padding: 0;
  .el-dialog__header {
    padding: 0;
  }
  .el-dialog__body {
    max-height: inherit;
    padding: 0;
    overflow: hidden;
    height: 100%;
    box-sizing: border-box;
  }
}
</style>
