import { mapGetters } from 'vuex' import downloadFile from '~/utils/donwload-tools' export default { data() { return { fileId: '', fileData: {}, } }, computed: { ...mapGetters(['routePrefix', 'supplierInfo', 'authUserId']), fileType() { const mime = this.fileData.mime if (!mime) return 'other' if (mime.indexOf('image') > -1) return 'image' if (mime.indexOf('video') > -1) return 'video' return 'other' }, }, created() { this.fileId = this.$route.query.id this.fetchFileDetail() }, methods: { async fetchFileDetail() { try { const res = await this.$http.api.fetchFileDetail({ fileId: this.fileId, authUserId: this.authUserId, }) this.fileData = res.data } catch (error) { console.log(error) } }, // 下载文件 onDownload(row, $event) { console.log(row) let downUrl = '' if (row.packageType === 0) { downUrl = `${process.env.BASE_URL}/wx/data/path/package/zip?fileId=${row.id}&fileName=${encodeURIComponent(row.fileName)}&authUserId=${this.authUserId}` } else { downUrl = `${process.env.BASE_URL}/download/file?ossName=${row.ossName}&fileName=${encodeURIComponent(row.fileName)}` } downloadFile(downUrl, row.fileName, this, $event) }, }, }