Dialog.vue 2.41 KB
<template>
  <div class="mask" v-if="isShow">
    <div class="dialog-wrap">
      <div class="dialog">
        <div class="dialog-title">
          {{ title }}
          <div class="close" @click="closeHandle">
            <img src="@/assets/images/close.png" />
          </div>
        </div>
        <video id="aivideos" ref="aivideos" muted="false" controls autoplay class="video-box">
          <!-- <source src="/media/cc0-videos/flower.webm" type="video/webm" /> -->
          <source v-if="type == 1" src="../../../assets/images/video(1).mp4" type="video/mp4" />
          <source v-if="type == 2" :src="`https://img02.glsx.com.cn/weapp/resource/miniprogram/material/ai-practice.mp4?v=${version}`" type="video/mp4" />
        </video>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Dialog',
  props: {
    isShow: Boolean,
    title: String,
    type: String
  },
  data() {
    return {
      msg: ''
    }
  },
  mounted() {
    this.version = Math.random() * 10
  },
  watch: {
    isShow(val) {
      if (val) {
        this.$nextTick(() => {
          this.$refs.aivideos.muted = !val
        })
      }
    }
  },
  methods: {
    closeHandle() {
      this.$emit('closeDialog')
    }
  },
  beforeDestroy() {
    if (document.getElementById('aivideos')) document.getElementById('aivideos').muted = true
  }
}
</script>

<style lang="scss" scoped>
.mask {
  width: 100%;
  height: 100%;
  position: fixed;
  z-index: 99;
  left: 0px;
  top: 0px;
  background: rgba(0, 0, 0, 0.8);
}
.dialog-wrap {
  width: 61.11vw;
  height: 73.29vh;
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  background-image: url('../../../assets/images/bg-5.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  transform: translate(-50%, -50%);
  border-radius: 5px;
  padding: 3.9vh 3.67vw;
  box-sizing: border-box;
  .close {
    width: 20px;
    height: 20px;
    position: absolute;
    right: -23vw;
    top: -1vw;
    cursor: pointer;
  }
  .dialog-title {
    width: 13.19vw;
    height: 4.39vh;
    background-image: url('../../../assets/images/title-dialog.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    text-align: center;
    font-size: 20px;
    color: #ffffff;
    margin: 0 auto;
    position: relative;
    line-height: 4.39vh;
  }
  .video-box {
    width: 54vw;
    height: 63.29vh;
  }
}
video::-webkit-media-controls-fullscreen-button {
  display: none;
}
</style>