info.js
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React,{ Component } from 'react';
import html2canvas from 'html2canvas';
import share from '../../utils/share';
import shareHide from "../../utils/shareHide";
import styles from './poster.less'
class PosterInfo extends Component{
constructor(props) {
super(props);
this.state = {
info: {}
}
}
componentDidMount() {
document.title = '海报'
const posterImgWrap = this.posterImgWrap;
shareHide(false);
html2canvas(this.poster).then(function (canvas) {
var image = new Image();
image.src = canvas.toDataURL("image/png");
posterImgWrap.appendChild(image);
});
let info = {};
if (this.props.location.search !== '') {
const {
search
} = this.props.location;
const matchs = decodeURI(search).match(/imgpath=(.*)&position=(.*)&name=(.*)&phone=(.*)/i);
info.img = matchs[1];
info.position = matchs[2];
info.name = matchs[3];
info.phone = matchs[4];
}
share({
decodeUrl: window.location.href.split('#')[0],
title: '我是'+info.name + ',您身边的保险管家',
desc: '用我的专业为万千家庭带来保障',
shareUrl: window.location.href,
thumbnail: info.img
});
this.setState({
info
});
}
componentWillUnmount(){
document.title = ''
}
render() {
const { info } = this.state;
return (
<div className={styles.posterWrapper}>
<div className={styles.poster} ref={el => this.poster = el}>
<img src={info.img} alt="" />
<ul className={styles.info}>
<li>{info.position}</li>
<li>{info.name}</li>
<li>{info.phone}</li>
</ul>
<div className={styles.posterImg} ref={el=>this.posterImgWrap=el}></div>
</div>
{/* <ul className={styles.operation}>
<li className={styles.msg}>消息</li>
<li className={styles.moments}>朋友圈</li>
<li className={styles.download}>下载</li>
</ul> */}
</div>
)
}
}
export default PosterInfo;