<template>
  <el-dialog
    v-model="dialogFormVisible"
    :title="title"
    width="500px"
    @close="close"
  >
    <div v-if="isText">
      <span>{{ data.textContent }}</span>
    </div>
    <div v-else-if="isImage" style="text-align: center">
      <img :src="data.url" alt="" style="width: 90%" />
    </div>
    <div v-else-if="isVideo" style="text-align: center">
      <img :src="data.cover_url" style="width: 90%" />
    </div>
    <div v-else-if="isVoice" style="text-align: center">
      <audio :src="data.voice"></audio>
    </div>
    <div v-else-if="isNews" style="text-align: center">
      <div v-for="(item, index) in data.content.news_item" :key="index">
        <p>标题：{{ item.title }}</p>
        <el-link target="_blank" :href="item.url" type="primary">
          点击查看
        </el-link>
      </div>
    </div>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      isText: false,
      isImage: false,
      isVoice: false,
      isVideo: false,
      isNews: false,
      dialogFormVisible: false,
      data: [],
    };
  },
  methods: {
    showMaterialData(row, type) {
      this.dialogFormVisible = true;
      this.title = '素材详情';
      this.data = row;
      if (type == 'image') {
        this.isImage = true;
      } else if (type == 'voice') {
        this.isVoice = true;
      } else if (type == 'video') {
        this.isVideo = true;
      } else if (type == 'news') {
        this.isNews = true;
      }
    },
  },
};
</script>

<style scoped></style>
