import React, { Component } from 'react'; import 'antd-mobile/dist/antd-mobile.less'; import styles from './index.less'; import router from 'umi/router'; import html2canvas from 'html2canvas'; import { Toast } from 'antd-mobile'; class Jd extends Component { constructor(props) { super(props); this.state = { flag: false, imgUri: null, }; } componentWillMount = () => {}; componentDidMount = () => {}; componentWillUnmount = () => {}; open = () => { Toast.loading('生成中', 0); const certificate = document.getElementById('certificate'); const newCanvas = document.createElement('canvas'); const domWidth = parseInt(window.getComputedStyle(certificate).width); const domHeight = parseInt(window.getComputedStyle(certificate).height); newCanvas.width = domWidth; newCanvas.height = domHeight; newCanvas.style.width = domWidth + 'px'; newCanvas.style.height = domHeight + 'px'; const _this = this; html2canvas(certificate, { canvas: newCanvas, scale: 1, x: 0, y: 0, scrollX: 0, scrollY: 0, }).then(canvas => { const imgUri = canvas.toDataURL('image/png'); _this.setState({ imgUri, flag: true, }); Toast.hide(); }); }; closed = () => { this.setState({ flag: false, }); }; render() { const data = this.props.ckuCertificate; const { flag, imgUri } = this.state; return (
{data.pedigreeCertified ? (
{data.kennelEnName ?
{data.kennelEnName}
: null} {data.dogName ?
{data.dogName}
: null}
{data.dogBreedDesc} {data.dogBreed} / {data.dogGender} {data.dogGenderDesc}
{data.dogMemberName ? (
犬主人 {data.dogMemberName} {data.secondDogOwner ? ` / ${data.secondDogOwner}` : null}
) : null} {data.breeder ? (
繁殖人 {data.breeder} {data.secondBreeder ? ` / ${data.secondBreeder}` : null}
) : null} {data.kennleName ? (
出生犬舍 {data.kennleName}
) : null} {data.color ? (
毛色(中文) {data.color} {data.colorDesc}
) : null} {data.dogBirthday ? (
出生日期 {data.dogBirthday}
) : null} {data.dogGrade ? (
犬只等级 {data.dogGrade}
) : null} {data.identification ? (
身份鉴别号码 {data.identification}
) : null} {data.pedigreeCertified ? (
血统证书号码 {data.pedigreeCertified}
) : null}
签发日期{data.createDate}
会长签字
查看实体版证书
{/*
{ router.push('/ckuh5/description?certificateType=jd'); }} > 鉴定证书说明
*/}
@宠爱王国提供技术支持
) : null}
{data.businessBan === '1' ? ( 禁止繁殖 ) : null} {data.changeBan === '1' ? ( 禁止出口 ) : null}
{data.paperDogName} 
{data.dogBreedDesc}  {data.dogBreed} 
{data.dogGender}  {data.dogBirthday} 
{data.identification}  {data.color} 
{data.pedigreeCertifiedEn}  {data.pedigreeCertified} 
{data.dogMemberName} 
{data.identifySite} 
{data.identifyDate} 
{data.identifier} 
{data.createDate} 
{flag ? (
血统证书 长按上方图片保存证书
) : null}
); } } export default Jd;