update:更新

This commit is contained in:
2021-09-17 16:37:07 +08:00
parent 82dde0078d
commit a2c54cfcaf
5 changed files with 103 additions and 240 deletions

View File

@@ -1,7 +1,8 @@
<template>
<div>
<pdf :src="url"></pdf>
<div ref="content" class="content">被保存的内容</div>
<div ref="content" class="content">
<pdf :src="url" class="PDF"></pdf>
</div>
<div class="bottom">
<a href="" download="">
<el-button type="primary">保存到相册</el-button>
@@ -19,44 +20,36 @@ import axios from "axios";
import request from "@/common/util";
export default {
components: {
pdf,
pdf
},
data() {
return {
url: "",
url: ""
};
},
created() {
this.onInit();
console.log("pdf");
},
mounted() {
// 截图
html2canvas(this.$refs.content).then((canvas) => {
canvas.id = "mycanvas";
const base64 = canvas.toDataURL("image/png");
jquery("a").prop("href", base64);
});
},
methods: {
onInit() {
this.onLoadData();
request({
url: "http://localhost:5566/agreement/info",
url: "http://10.19.94.9:7099/api/agreement/info",
method: "post",
data: {
ticket: "8a1188557bda7894017bed584f803119-ticket",
id: "C655515B-FD91-48F2-BD79-EAABAFB7077C",
ticket: "8a1188557bda7894017bf257a07e7ccb-ticket",
id: "C655515B-FD91-48F2-BD79-EAABAFB7077C"
},
headers: { "Content-Type": "application/json; charset=UTF-8" },
responseType: "arraybuffer", //一定要设置响应类型否则页面会是空白pdf
}).then((result) => {
responseType: "arraybuffer" //一定要设置响应类型否则页面会是空白pdf
}).then(result => {
const binaryData = [];
binaryData.push(result.data);
//获取blob链接
this.url = window.URL.createObjectURL(
new Blob(binaryData, { type: "application/pdf" })
);
jquery("a").prop("href", this.url);
// if (pdfUrl) {
// this.handlePrint(pdfUrl);
// }
@@ -107,16 +100,16 @@ export default {
onLoadData() {
// console.log(this.$route.params);
// this.url = this.$route.params.url;
},
},
}
}
};
</script>
<style lang="less" scoped>
.content {
text-align: center;
height: 200px;
line-height: 200px;
font-size: 30px;
margin-bottom: 20px;
}
.bottom {
text-align: center;