<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.image" alt="" style="width: 90%" />
    </div>
    <div v-else-if="isVideo" style="text-align: center">
      <p>素材ID：{{ data.video.MediaId }}</p>
      <p>视频名称：{{ data.video.Title }}</p>
      <p>视频简介：{{ data.video.Description }}</p>
    </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.news" :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) {
      this.dialogFormVisible = true;
      this.title = '素材详情';
      this.data = row;
      if (row.msgType.dataCode == 'text') {
        this.isText = true;
      } else {
        if (row.materialType.dataCode == 'image') {
          this.isImage = true;
        } else if (row.materialType.dataCode == 'voice') {
          this.isVoice = true;
        } else if (row.materialType.dataCode == 'video') {
          this.isVideo = true;
        } else if (row.materialType.dataCode == 'news') {
          this.isNews = true;
        }
      }
      console.log(123, row);
    },
  },
};
</script>

<style scoped></style>
