<template>
  <a-modal
    centered
    class="promotionDesc-modal"
    :footer="null"
    :maskClosable="false"
    :title="modalTit"
    v-model="isShow"
    @cancel="isShow=false"
    :width="500">
    <div class="promotionDesc-con">
      <img src="@/assets/iphone.png" alt="图片走丢了" srcset="">
      <div class="promotionDescCon" v-if="showType==='IMAGE_CONTENT'" v-html="mainContent"></div>
      <div class="promotionDescCon" v-if="showType=='VIDEO'" >
        <video width="100%" height="auto" controls loop controlsList="nodownload">
          <source :src="mainContent" type="video/mp4"></source>
        </video>
      </div>
    </div>
    <div class="btn-cont">
      <!-- <a-button id="promotionDesc-modal-back" @click="isShow = false" style="margin-right:10px;">下载图片</a-button> -->
      <a-button type="primary" id="promotionDesc-modal-back" @click="isShow = false">关闭</a-button>
    </div>
  </a-modal>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
export default {
  name: 'PromotionDescModal',
  mixins: [commonMixin],
  props: {
    openModal: { //  弹框显示状态
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      modalTit: '促销展示',
      isShow: this.openModal, //  是否打开弹框
      mainContent: '', // 主要显示内容
      showType: undefined//
    }
  },
  methods: {
    pageInit (con) {
      this.showType = con.type
      this.mainContent = con.con
    }
  },
  watch: {
    //  父页面传过来的弹框状态
    openModal (newValue, oldValue) {
      this.isShow = newValue
    },
    //  重定义的弹框状态
    isShow (newValue, oldValue) {
      if (!newValue) {
        this.$emit('close')
      }
    }
  }
}
</script>

<style lang="less" scoped>
  .promotionDesc-modal{
    /deep/.ant-modal-body{
       text-algin:center !important;
    }

    .promotionDesc-con{
      width:340px;
      margin:0 auto;
      position:relative;
      text-align: center;
      img{
         width:81%;
         height:auto;
       }
       .promotionDescCon{
         position: absolute;
         left:15%;
         top:12.5%;
         width: 70%;
         max-height:420px;
         overflow-y: scroll;
         scrollbar-width:none;
         -ms-overflow-style: none;
       }
       .promotionDescCon::-webkit-scrollbar{
           display:none;
       }
    }

    .btn-cont {
      text-align: center;
      margin: 30px 0 0px;
    }
  }
</style>
