|
@ -93,30 +93,55 @@ const QrCode = (props) => { |
|
|
}}> |
|
|
}}> |
|
|
{/* <a href={`${v.qrCode + '?filename=' + encodeURIComponent(v.name)}.png`}> */} |
|
|
{/* <a href={`${v.qrCode + '?filename=' + encodeURIComponent(v.name)}.png`}> */} |
|
|
<Button type="primary" onClick={() => { |
|
|
<Button type="primary" onClick={() => { |
|
|
const aa = (v) => { |
|
|
// const aa = (v) => {
|
|
|
const img = new Image(), |
|
|
// const img = new Image(),
|
|
|
canvas = createCanvas(460, 490), |
|
|
// canvas = createCanvas(460, 490),
|
|
|
ctx = canvas.getContext('2d') |
|
|
// ctx = canvas.getContext('2d')
|
|
|
img.crossOrigin = 'anonymous' |
|
|
// img.crossOrigin = 'anonymous'
|
|
|
img.onload = function () { |
|
|
// img.onload = function () {
|
|
|
const w = 460, h = 490 |
|
|
// const w = 460, h = 490
|
|
|
|
|
|
|
|
|
ctx.drawImage(img, 0, 0,460,490) |
|
|
// ctx.drawImage(img, 0, 0,460,490)
|
|
|
ctx.beginPath() |
|
|
// ctx.beginPath()
|
|
|
ctx.font = 'dcscsdcsd' |
|
|
// ctx.font = 'dcscsdcsd'
|
|
|
ctx.fillStyle = '#000' |
|
|
// ctx.fillStyle = '#000'
|
|
|
ctx.fillText('5315', w, h) |
|
|
// ctx.fillText('5315', w, h)
|
|
|
ctx.closePath() |
|
|
// ctx.closePath()
|
|
|
const save_link = document.createElement('a') |
|
|
// const save_link = document.createElement('a')
|
|
|
save_link.href = canvas.toDataURl('image/png') |
|
|
// save_link.href = canvas.toDataURl('image/png')
|
|
|
save_link.download = 'dcscds.png' |
|
|
// save_link.download = 'dcscds.png'
|
|
|
document.body.appendChild(save_link) |
|
|
// document.body.appendChild(save_link)
|
|
|
save_link.click() |
|
|
// save_link.click()
|
|
|
save_link.remove() |
|
|
// save_link.remove()
|
|
|
|
|
|
// }
|
|
|
|
|
|
// img.src = v
|
|
|
|
|
|
// }
|
|
|
|
|
|
// aa(v.qrCode)
|
|
|
|
|
|
// console.log(v.qrCode.replace('/[\r\n]/g',""));
|
|
|
|
|
|
|
|
|
|
|
|
function base64ToFile (url, name) { |
|
|
|
|
|
|
|
|
|
|
|
let mime = name.substring(name.lastIndexOf('.') + 1) |
|
|
|
|
|
let bstr = atob(url); |
|
|
|
|
|
let n = bstr.length; |
|
|
|
|
|
let u8arr = new Uint8Array(n); |
|
|
|
|
|
|
|
|
|
|
|
while (n--) { |
|
|
|
|
|
u8arr[n] = bstr.charCodeAt(n); |
|
|
} |
|
|
} |
|
|
img.src = v |
|
|
return new Blob([u8arr], { type: mime }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function downloadFile(url,name='15313'){ |
|
|
|
|
|
let a=document.createElement('a'); |
|
|
|
|
|
a.setAttribute('href',url) |
|
|
|
|
|
a.setAttribute('download',name) |
|
|
|
|
|
a.setAttribute('target','_blank') |
|
|
|
|
|
let b=document.createEvent('MouseEvents') |
|
|
|
|
|
b.initEvent('click',true,true) |
|
|
|
|
|
a.dispatchEvent |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
aa(v.qrCode) |
|
|
|
|
|
|
|
|
|
|
|
}}>下载二维码</Button> |
|
|
}}>下载二维码</Button> |
|
|
{/* </a> */} |
|
|
{/* </a> */} |
|
|