网络下载修复

master
许宏杰 1 year ago
parent 5721af2bb9
commit fc90a2a023

@ -46,6 +46,7 @@
"file-saver": "2.0.5", "file-saver": "2.0.5",
"fuse.js": "6.4.3", "fuse.js": "6.4.3",
"highlight.js": "9.18.5", "highlight.js": "9.18.5",
"html2canvas": "^1.4.1",
"js-beautify": "1.13.0", "js-beautify": "1.13.0",
"js-cookie": "3.0.1", "js-cookie": "3.0.1",
"jsencrypt": "3.0.0-rc.1", "jsencrypt": "3.0.0-rc.1",

@ -104,7 +104,7 @@
type="text" type="text"
icon="el-icon-download" icon="el-icon-download"
@click="handleCode(scope.row)" @click="handleCode(scope.row)"
>生成二维码</el-button >下载二维码</el-button
> >
<el-button <el-button
size="mini" size="mini"
@ -156,10 +156,14 @@
<el-dialog <el-dialog
title="WI-FI码" title="WI-FI码"
:visible.sync="wifiopen" :visible.sync="wifiopen"
width="400px" width="420px"
append-to-body append-to-body
> >
<img :src="imgs" alt="" class="codeImg" /> <div ref="downloadElement" style="padding: 20px 10px">
<img :src="code.imgs" alt="" class="codeImg" />
<div class="netName">WI-FI名称{{ code.netName }}</div>
</div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleUpload()"></el-button> <el-button type="primary" @click="handleUpload()"></el-button>
</div> </div>
@ -171,11 +175,16 @@
import { listNet, getNet, delNet, addNet, updateNet } from "@/api/netEwm/net"; import { listNet, getNet, delNet, addNet, updateNet } from "@/api/netEwm/net";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import { getCode } from "@/api/login.js"; import { getCode } from "@/api/login.js";
import html2canvas from "html2canvas";
export default { export default {
name: "Net", name: "Net",
data() { data() {
return { return {
wifiopen: false, wifiopen: false,
code: {
imgs: "",
netName: "",
},
imgs: null, imgs: null,
// //
loading: true, loading: true,
@ -217,26 +226,29 @@ export default {
}, },
methods: { methods: {
handleUpload() { handleUpload() {
// a const downloadElement = this.$refs.downloadElement;
const link = document.createElement("a"); // 使html2canvasCanvas
// hrefURL html2canvas(downloadElement).then((canvas) => {
link.href = this.imgs; // CanvasBase64
// const base64Image = canvas.toDataURL("image/png");
link.download = "downloaded_image.jpg";
// //
document.body.appendChild(link); const downloadLink = document.createElement("a");
// downloadLink.href = base64Image;
link.click(); downloadLink.download = "downloaded_image.png";
//
document.body.removeChild(link); //
downloadLink.click();
});
}, },
handleCode(row) { handleCode(row) {
let data = { let data = {
path: "pages/index/index", path: "pages/index/index",
shanghuId: row.shanghuId, shanghuId: row.id,
}; };
getCode(data).then((res) => { getCode(data).then((res) => {
this.imgs = "data:image/png;base64," + res.data; this.code.imgs = "data:image/png;base64," + res.data;
this.code.netName = row.netName;
this.wifiopen = true; this.wifiopen = true;
}); });
}, },
@ -304,6 +316,10 @@ export default {
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
if (!this.shanghuId) {
this.$modal.msgError("您不是商户!");
return;
}
this.$refs["form"].validate((valid) => { this.$refs["form"].validate((valid) => {
if (valid) { if (valid) {
if (this.form.id != null) { if (this.form.id != null) {
@ -355,4 +371,10 @@ export default {
width: 100%; width: 100%;
height: 350px; height: 350px;
} }
.netName {
margin-top: 6px;
text-align: center;
font-size: 16px;
font-weight: bold;
}
</style> </style>

Loading…
Cancel
Save