公共服务平台-宣传物料

This commit is contained in:
lSun 2025-09-17 10:53:01 +08:00
parent cf09f1d57d
commit e02d9e8000
1 changed files with 25 additions and 34 deletions

View File

@ -95,6 +95,7 @@ import DialogModel from '@/components/DialogModel/index'
import {getMaterialListAPI} from '@/api/publicService/proMaterials'
import { encryptCBCTime } from '@/utils/aes'
import useBase64 from '@/utils/base64Utils.js'
import axios from 'axios'
export default {
name: 'ProMaterials',
@ -182,42 +183,32 @@ export default {
}
},
//
handleDownload(service) {
let url = service.filePath;
//
async handleDownload(service) {
try {
const response = await axios({
method: 'get',
url: process.env.VUE_APP_BASE_API + '/system/files/download',
params: {
filePath: service.fileDownloadPath
},
responseType: 'blob' // blob
});
// URL
if (!url.startsWith('http://') && !url.startsWith('https://')) {
if (url.startsWith('www.')) {
url = 'https://' + url;
} else {
url = 'https://' + url;
}
//
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', service.fileName || 'file'); //
document.body.appendChild(link);
link.click();
link.remove();
window.URL.revokeObjectURL(url); // URL
this.$message.success('下载成功');
} catch (error) {
this.$message.error('下载失败');
}
// a
const link = document.createElement('a');
link.href = url;
link.download = ''; // 'filename.zip'使
link.target = '_blank'; //
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link); //
alert('下载成功')
/*// 确保 URL 是完整的绝对路径
let url = service.filePath
// URL http:// https:// https://
if (!url.startsWith('http://') && !url.startsWith('https://')) {
// URL www. https://
if (url.startsWith('www.')) {
url = 'https://' + url
} else {
// https://
url = 'https://' + url
}
}
window.open(url, '_blank')*/
},
//
handleCardHover(serviceId) {