From 10bf219820a35d9b7bb3a11e4e362b0f670cd15c Mon Sep 17 00:00:00 2001 From: wenlele Date: Tue, 17 Jan 2023 11:19:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectRegime/projectSituation.js | 4 +- .../projectRegime/containers/qrCode.js | 53 ++++++++++--------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/api/app/lib/controllers/projectRegime/projectSituation.js b/api/app/lib/controllers/projectRegime/projectSituation.js index 1ccb7be..c666f16 100644 --- a/api/app/lib/controllers/projectRegime/projectSituation.js +++ b/api/app/lib/controllers/projectRegime/projectSituation.js @@ -8,9 +8,9 @@ async function projectList (ctx, next) { const { limit, page, name, justStructure } = ctx.query; let options = { - // where: { + where: { - // }, + }, // include: [{ // as: 'company', // model: models.Company, diff --git a/web/client/src/sections/projectRegime/containers/qrCode.js b/web/client/src/sections/projectRegime/containers/qrCode.js index 263f406..99adc7a 100644 --- a/web/client/src/sections/projectRegime/containers/qrCode.js +++ b/web/client/src/sections/projectRegime/containers/qrCode.js @@ -6,6 +6,8 @@ import '../style.less'; import ProjectAddModel from '../components/projectAddModel' import { Model } from 'echarts'; import { login } from '../../auth/actions/auth'; +import { createCanvas, loadImage, registerFont } from 'canvas' + const QrCode = (props) => { const { dispatch, actions, user, loading } = props @@ -23,6 +25,7 @@ const QrCode = (props) => { + useEffect(() => { dispatch(projectRegime.getProjectList({ justStructure: true })).then(res => { if (res.success) { @@ -89,33 +92,33 @@ const QrCode = (props) => { justifyContent: 'center', alignItems: 'center', borderTop: '1px solid #3c383824' }}> {/* { + const aa = (v) => { + const img = new Image(), + canvas = createCanvas(460, 490), + ctx = canvas.getContext('2d') + img.crossOrigin = 'anonymous' + img.onload = function () { + const w = 460, h = 490 + + ctx.drawImage(img, 0, 0,460,490) + ctx.beginPath() + ctx.font = 'dcscsdcsd' + ctx.fillStyle = '#000' + ctx.fillText('5315', w, h) + ctx.closePath() + const save_link = document.createElement('a') + save_link.href = canvas.toDataURl('image/png') + save_link.download = 'dcscds.png' + document.body.appendChild(save_link) + save_link.click() + save_link.remove() } - aa(v.qrCode) + img.src = v + } + aa(v.qrCode) - }}>下载二维码 + }}>下载二维码 {/* */}