<template>
  <div>
    <el-dialog title="二维码预览" :visible.sync="dialogVisible" width="50%" top="5vh">
      <div class="dia_out">
        <!-- <el-image class="image_class" :src="url" /> -->
        <el-image class="image_class"  src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" />
      </div>

      <span slot="footer" class="dialog-footer">
        <el-button type="info" round @click="downLoadImage" >下载</el-button>
        <el-button type="primary" round @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { oSessionStorage } from "../utils/utils";
import { basePath } from "../utils/http";
export default {
  data() {
    return {
      dialogVisible: false,
      channelId: "",
      url: "http://10.113.248.3:8086/file/show?filePath=./images/cloud.bef3ccbc.jpg",
    };
  },
  mounted() {},
  methods: {
    downLoadImage() {
      window.open(`${basePath}/file/download/${this.channelId}`)
      // this.$http.getDown(`/file/download/${this.channelId}`, {}, (res) => {
      //   const url = window.URL.createObjectURL(new Blob([res.data])); // 创建一个URL对象
      //   const link = document.createElement("a"); // 创建一个a标签
      //   link.href = url; // 设置a标签的href属性为URL对象
      //   link.setAttribute("download", "file.pdf"); // 设置a标签的download属性为要保存的文件名
      //   document.body.appendChild(link); // 将a标签添加到DOM中
      //   link.click(); // 模拟点击a标签进行下载
      //   document.body.removeChild(link); // 下载完成后，移除a标签
      // });
    },
    open(val) {
      this.dialogVisible = true;
      this.channelId=val.channelId;
      this.url = basePath + "/file/show?filePath=" + val.poster;
      //   this.queryById();
    },
    //调用查询接口
    // queryById() {
    //   this.$http.get(`/sign/findById/${this.id}`, {}, (res) => {
    //     //  this.$toast.success({message:'成功'});
    //     if (res && res.code == 200) {
    //       //将值赋值给list
    //       this.channelList = res.data;
    //     } else {
    //       this.$message.error(res.msg);
    //     }
    //   });
    // },
  },
};
</script>
<style scope>
.image_class {
  width: 270px;
  height: 480px;
}
.dia_out {
  /* text-align: center; */
}
</style>
