Compare commits

...

4 Commits

Author SHA1 Message Date
路 范
a3e41aee85 Merge branch 'master' of http://118.178.224.202:3000/ewide/zsxt_nbzs_h5 2021-09-17 11:38:33 +08:00
路 范
2c1de9b107 update埋点 2021-09-17 11:35:29 +08:00
路 范
0e6b6d7ffa Merge branch 'master' of http://118.178.224.202:3000/ewide/zsxt_nbzs_h5 2021-09-16 17:00:18 +08:00
路 范
1165188074 add pdf预览功能demo 2021-09-16 17:00:05 +08:00
3 changed files with 130 additions and 23 deletions

View File

@@ -3,9 +3,13 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<title>房屋征收</title>
<script type="text/javascript" src="https://d.alicdn.com/alilog/mlog/aplus.js?id=202951085"></script>
<script type="text/javascript" src="//jssdk.yyhj.zjzwfw.gov.cn/jsbridge/v2.0.0/bridge.min.js"></script>
<!-- 引入ZWJSBridge -->
<script type="text/javascript" src="//assets.zjzwfw.gov.cn/assets/ZWJSBridge/1.0.1/zwjsbridge.js"></script>
</head>
<body>
@@ -13,7 +17,7 @@
<!-- built files will be auto injected -->
<script>
// console.log("初始页面");
(function(w, d, s, q, i) {
(function (w, d, s, q, i) {
w[q] = w[q] || [];
var f = d.getElementsByTagName(s)[0];
var j = d.createElement(s);
@@ -46,6 +50,7 @@
arguments: [{
is_auto: false
}, {
isMini: true,
miniAppId: "2001833218", //'应用开发管理平台-应用 ID
miniAppName: "房屋征收"
}]

View File

@@ -289,15 +289,15 @@ export default {
idCard: "加载中...",
userName: "加载中...",
policiesRegulationsLists: {
totalCount: 0
}
totalCount: 0,
},
},
ticket: "8a118afe7bda7976017bf14c94de35e0-ticket"
};
},
async created() {
this.onInit();
console.log("this", this);
this.setLocationAplus();
},
methods: {
// 获取数据
@@ -308,10 +308,11 @@ export default {
dataType: "JSON",
type: "POST",
data: {
ticket: this.ticket
ticket: this.$route.query.ticket,
//ticket: "8a118a427bda7bed017bed084ec10622-ticket"
},
appKey: "es4b8zmz+2001833218+dehllx",
onSuccess: data => {
onSuccess: (data) => {
console.log("首页数据", data);
if (data.data && data.data.success == true) {
this.data = data.data.data;
@@ -327,16 +328,16 @@ export default {
} else console.log("用户无数据,不展示");
}
},
onFail: err => {
onFail: (err) => {
console.log("用户无数据,不展示");
}
},
});
},
// 跳转项目详情
gotoProject(type) {
this.$router.push({
name: "projectSelect",
params: { type: type, ticket: this.ticket }
params: { type: type, ticket: this.$route.query.ticket },
});
},
// 加载项目数统计信息
@@ -356,21 +357,58 @@ export default {
// 设置用户信息埋点
aplus_queue.push({
action: "aplus.setMetaInfo",
arguments: ["_hold", "BLOCK"]
arguments: ["_hold", "BLOCK"],
});
aplus_queue.push({
action: "aplus.setMetaInfo",
arguments: ["_user_nick", userName] // this.userInfoData.username],
arguments: ["_user_nick", userName], // this.userInfoData.username],
});
aplus_queue.push({
action: "aplus.setMetaInfo",
arguments: ["_user_id", Userid]
arguments: ["_user_id", Userid],
});
aplus_queue.push({
action: "aplus.setMetaInfo",
arguments: ["_hold", "START"]
arguments: ["_hold", "START"],
});
}
}
},
setLocationAplus() {
ZWJSBridge.onReady(() => {
console.log("初始化完成后执行bridge方法");
ZWJSBridge.getUserType()
.then((result1) => {
console.log(result1);
//经纬度
ZWJSBridge.getLocation()
.then((result2) => {
console.log(result2);
debugger;
aplus_queue.push({
action: "aplus.sendPV",
arguments: [
{
is_auto: false,
},
{
isMini: true,
miniAppId: "2001833218", //'应用开发管理平台-应用 ID
miniAppName: "房屋征收",
long: result2.longitude,
lati: result2.latitude,
userType: result1.userType,
},
],
});
})
.catch((error) => {
console.log(error);
});
})
.catch((error) => {
console.log(error);
});
});
},
},
};
</script>

View File

@@ -15,13 +15,15 @@
import pdf from "vue-pdf";
import jquery from "jquery";
import html2canvas from "html2canvas";
import axios from "axios";
import request from "@/common/util";
export default {
components: {
pdf
pdf,
},
data() {
return {
url: ""
url: "",
};
},
created() {
@@ -30,7 +32,7 @@ export default {
},
mounted() {
// 截图
html2canvas(this.$refs.content).then(canvas => {
html2canvas(this.$refs.content).then((canvas) => {
canvas.id = "mycanvas";
const base64 = canvas.toDataURL("image/png");
jquery("a").prop("href", base64);
@@ -39,12 +41,74 @@ export default {
methods: {
onInit() {
this.onLoadData();
request({
url: "http://localhost:5566/agreement/info",
method: "post",
data: {
ticket: "8a1188557bda7894017bed584f803119-ticket",
id: "C655515B-FD91-48F2-BD79-EAABAFB7077C",
},
headers: { "Content-Type": "application/json; charset=UTF-8" },
responseType: "arraybuffer", //一定要设置响应类型否则页面会是空白pdf
}).then((result) => {
const binaryData = [];
binaryData.push(result.data);
//获取blob链接
this.url = window.URL.createObjectURL(
new Blob(binaryData, { type: "application/pdf" })
);
// if (pdfUrl) {
// this.handlePrint(pdfUrl);
// }
});
// axios({
// method: "post",
// url: "http://10.19.94.9:7099/api/agreement/info",
// responseType: "blob",
// data: {
// ticket: "8a1188557bda7894017bed584f803119-ticket",
// id: "C655515B-FD91-48F2-BD79-EAABAFB7077C",
// },
// }).then((res) => {
// debugger;
// console.log(res);
// if (!res) {
// return;
// }
// let blob = new Blob([res.data], {
// type: "application/octet-stream",
// });
// let url = window.URL.createObjectURL(blob);
// let link = document.createElement("a");
// link.style.display = "none";
// link.href = url;
// document.body.appendChild(link);
// link.click();
// });
},
handlePrint(pdf) {
if (document.getElementById("print-iframe")) {
document.body.removeChild(document.getElementById("print-iframe"));
}
//判断iframe是否存在不存在则创建iframe
let iframe = document.getElementById("print-iframe");
if (!iframe) {
iframe = document.createElement("IFRAME");
let doc = null;
iframe.setAttribute("src", pdf);
iframe.setAttribute("id", "print-iframe");
document.body.appendChild(iframe);
doc = iframe.contentWindow.document;
doc.close();
iframe.contentWindow.focus();
}
iframe.contentWindow.print();
},
onLoadData() {
console.log(this.$route.params);
this.url = this.$route.params.url;
}
}
// console.log(this.$route.params);
// this.url = this.$route.params.url;
},
},
};
</script>
<style lang="less" scoped>