File tree 3 files changed +37
-13
lines changed
3 files changed +37
-13
lines changed Original file line number Diff line number Diff line change 58
58
"classnames" : " ^2.2.5" ,
59
59
"immutable" : " ^3.8.1" ,
60
60
"prop-types" : " ^15.5.10" ,
61
+ "qrcode" : " ^1.2.0" ,
61
62
"react" : " ^15.3.0" ,
62
63
"react-dom" : " ^15.3.0" ,
63
64
"react-redux" : " ^4.4.5" ,
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
+ import QRCode from 'qrcode' ;
2
3
import style from './index.less' ;
3
4
import { transform , i18n , lan } from '../../unit/const' ;
4
5
import { isMobile } from '../../unit' ;
5
6
7
+
6
8
export default class Guide extends React . Component {
7
9
constructor ( ) {
8
10
super ( ) ;
9
11
this . state = {
10
12
isMobile : isMobile ( ) ,
13
+ QRCode : '' ,
11
14
} ;
12
15
}
13
- shouldComponentUpdate ( ) {
14
- return false ;
16
+ componentWillMount ( ) {
17
+ if ( this . state . isMobile ) {
18
+ return ;
19
+ }
20
+ QRCode . toDataURL ( location . href , { margin : 1 } )
21
+ . then ( dataUrl => this . setState ( { QRCode : dataUrl } ) ) ;
22
+ }
23
+ shouldComponentUpdate ( state ) {
24
+ if ( state . QRCode === this . state . QRCode ) {
25
+ return false ;
26
+ }
27
+ return true ;
15
28
}
16
29
render ( ) {
17
30
if ( this . state . isMobile ) {
@@ -57,13 +70,15 @@ export default class Guide extends React.Component {
57
70
</ p >
58
71
< div className = { style . space } > SPACE</ div >
59
72
</ div >
60
- < div className = { `${ style . guide } ${ style . qr } ` } >
61
- < img
62
- src = { `//game.weixin.qq.com/cgi-bin/comm/qrcode?s=10&m=1&d=${ location . href } ` }
63
- alt = { i18n . QRCode [ lan ] }
64
- title = { i18n . QRNotice [ lan ] }
65
- />
66
- </ div >
73
+ { this . state . QRCode !== '' ? (
74
+ < div className = { `${ style . guide } ${ style . qr } ` } >
75
+ < img
76
+ src = { this . state . QRCode }
77
+ alt = { i18n . QRCode [ lan ] }
78
+ />
79
+ < span > { i18n . QRNotice [ lan ] } </ span >
80
+ </ div >
81
+ ) : null }
67
82
</ div >
68
83
) ;
69
84
}
Original file line number Diff line number Diff line change 41
41
& .qr {
42
42
left : auto ;
43
43
top : 5% ;
44
- width : 190 px ;
44
+ width : 150 px ;
45
45
height :190px ;
46
46
opacity : .45 ;
47
- padding :0 0 40px 40px ;
48
47
text-align : right ;
48
+ cursor : none ;
49
+ span {
50
+ display : none ;
51
+ text-align : center ;
52
+ line-height : 40px ;
53
+ }
49
54
& :hover {
50
55
img {
51
- width : 100% ;
52
- height : 100% ;
56
+ width : 150px ;
57
+ height : 150px ;
58
+ }
59
+ span {
60
+ display : block ;
53
61
}
54
62
}
55
63
img {
You can’t perform that action at this time.
0 commit comments