积分 电子证书

积分 电子证书微调
This commit is contained in:
amypeng 2026-06-04 15:37:15 +08:00
parent 9717f240cd
commit b1adb9af94
3 changed files with 8 additions and 19 deletions

View File

@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react';
import { Modal, Button, Form, Input } from 'antd';
import cookie from 'react-cookies';
import { getZoneUrl } from 'educoder';
import IconImg from '../img/user/icon1.png';
import TemplateImg from '../img/user/template.png';
@ -55,6 +56,7 @@ function UserAward({ visible , onCancel , onSure , member , id, form }) {
if(!document.fonts.check('64px sanjikai')) {
try {
const font = new FontFace('sanjikai', 'url(/fonts/SanJiXingKaiJianTi-Cu-2.ttf)');
const font = new FontFace('sanjikai', `url(${process.env.PUBLIC_URL}/fonts/SanJiXingKaiJianTi-Cu-2.ttf)`);
await font.load();
document.fonts.add(font);
} catch (e) {
@ -64,7 +66,7 @@ function UserAward({ visible , onCancel , onSure , member , id, form }) {
if(!document.fonts.check('18px alibabaReg')) {
try {
const font = new FontFace('alibabaReg', 'url(/fonts/ALIBABA-PUHUITI-REGULAR.TTF)');
const font = new FontFace('alibabaReg', `url(${process.env.PUBLIC_URL}/fonts/ALIBABA-PUHUITI-REGULAR.TTF)`);
await font.load();
document.fonts.add(font);
} catch (e) {
@ -111,25 +113,14 @@ function UserAward({ visible , onCancel , onSure , member , id, form }) {
ctx.textBaseline = 'middle';
ctx.fillText(awardDate, 240, 1008);
// TODO
const dataUrl = canvas.toDataURL('image/png');
const link = document.createElement('a');
link.download = `荣誉证书_${memberName}_${new Date().getTime()}.png`;
link.href = dataUrl;
link.click();
const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png'));
const formData = new FormData();
formData.append('file', blob, `member_${member.id}.png`);
formData.append('file', blob, `${realName}_电子荣誉证书.png`);
formData.append('type', 'resource');
const uploadRes = await fetch(`${httpUrl}/file/common/upload`, {
const uploadRes = await fetch(`${getZoneUrl(`/api/file/common/upload`)}`, {
method: 'POST',
body: formData,
headers: {
// Authorization: '6d72497d7f197eb9dc8a15db038881cd31afea7a',
Authorization: cookie.load('autologin_trustie'),
},
credentials: 'include',
});

View File

@ -29,7 +29,6 @@ function UserEdit({ visible, onCancel, form, onSure, type, zoneName, choosed, hi
validateFields((err, values) => {
if (!err) {
let temp = Object.assign({}, values, { imageUrl: imageUrl })
console.log('vvv', temp);
if (onSure) {
onSure(temp);
}

View File

@ -107,7 +107,6 @@ function ZoneUser(props){
const pid = setInterval(() => {
setTimeNum(prev => {
const newVal = prev - 1;
console.log('ttt', newVal);
if (newVal <= 0) {
clearInterval(pid);
setSuccessVisible(false);
@ -257,14 +256,14 @@ function ZoneUser(props){
function pointsCustom(item) {
if(item.disabled) return;
console.log('iii', item)
if(item.key == 'certificate') {
if(!item.exist) {
setAwardVisible(true);
} else {
let url = memberInfo.pointsEvent?.sourceData;
console.log('uuu', url)
window.open(url, '_blank');
const link = document.createElement('a');
link.href = url;
link.click();
}
} else if(item.key == 'doc') {
setDocVisible(true);