<template> <div class="box"> <div class="content-box"> <div class="v-content"> <el-row :gutter="20"> <el-col :span="6" :xl="6" :lg="6" :md="8" :sm="8" :xs="12" v-for="(nav, i) in list" :key="i" class="list"> <div> <div class="profile-box"> <img class="profile-img" :src="nav.url" /> <div class="between" style="opacity:0.9;"> <a @click="downloadPdf(nav.link, nav.title)" class="center" style="cursor: pointer;"> <img class="x_z" src="@/assets/img/download.png" /> <span class="xz_text" style="margin-left:10px;">{{$t('Download.Download')}}</span> </a> </div> </div> <p class="v-text-size">{{nav.title}}</p> </div> </el-col> </el-row> </div> </div> </div> </template> <script> export default { name: "profile", data() { return { list: this.$t("downloadList.list") }; }, methods: { downloadPdf(pdfUrl, title) { const loading = this.$loading({ lock: true, text: this.$t('Download.loading') + '...', background: 'rgba(0, 0, 0, 0.7)' }); const xhr = new XMLHttpRequest(); xhr.open('GET', pdfUrl, true); xhr.responseType = 'blob'; xhr.onload = () => { if (xhr.status === 200) { const blob = new Blob([xhr.response], { type: 'application/pdf' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = title +'.pdf'; link.click(); URL.revokeObjectURL(url); setTimeout(() => { // 关闭Loading loading.close(); }, 1000); } }; xhr.send() } }, mounted() {}, created() { } }; </script> <style lang="scss" scoped> .content-box{ background: #F4FAFF; .v-content{ margin: auto; .list{ margin-bottom: 40px; height: 478px; } .profile-box{ position: relative; border-bottom-right-radius: 40px; overflow: hidden; .profile-img{ max-width: 100%; transform: scale(1); transition: transform .6s linear; cursor: pointer; &:hover{ transform: scale(1.1); transition: transform .6s linear; border: 1px solid #006ad7; } } .between{ width: 100%; height: 56px; // opacity: 0.9; padding: 0 20px; background-color: rgba(65,145,226,1); display: flex; align-items: center; justify-content: space-between; position: absolute; left: 0; bottom: 0; z-index: 10; .center{ display: flex; align-items: center; .x_z{ width: 24px; height: 24px; } .xz_text{ color: #fff; font-size: 16px; margin-left: 10px; } } } } .v-text-size{ height: 80px; font-size: 18px; text-align: center; padding-top: 20px; } } } </style>