<template>
  <a-modal
    centered
    class="promotionShow-modal"
    :footer="null"
    :maskClosable="false"
    :title="modalTit"
    v-model="isShow"
    @cancel="isShow=false"
    :width="500">
    <div class="promotionShow-con">
      <img src="@/assets/iphone.png" alt="图片走丢了" srcset="">
      <div class="promotionShowCon" v-if="showType==='IMAGE_CONTENT'" v-html="mainContent"></div>
      <div class="promotionShowCon" 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="promotionShow-modal-back" @click="isShow = false" style="margin-right:10px;">下载图片</a-button> -->
      <a-button id="promotionShow-modal-back" @click="isShow = false">关闭</a-button>
    </div>
  </a-modal>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
export default {
  name: 'PromotionShowModal',
  mixins: [commonMixin],
  props: {
    openModal: { //  弹框显示状态
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      modalTit: '促销展示', // 弹窗标题
      isShow: this.openModal, //  是否打开弹框
      mainContent: '', // 主要显示内容
      showType: undefined// 显示类型 VIDEO 视频 IMAGE_CONTENT图文
    }
  },
  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>
  .promotionShow-modal{
    /deep/.ant-modal-body{
       text-algin:center !important;
    }

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

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