index.js
1.57 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
import React from 'react';
import yaSDK from 'yoho-activity-sdk';
import './index.scss';
export default class BottomButton extends React.Component {
constructor(props) {
super(props);
}
render() {
const linkArr = this.props.links;
const login = this.props.login || false;
if (!linkArr || !linkArr.length) {
return null;
}
let jump = e => {
let $el = e.currentTarget;
let url = $el.getAttribute('data-url');
if (!url) {
return;
}
if (yaSDK.env !== 'app') {
const loginMatch = ['"islogin":"Y"', "'islogin':'Y'", 'islogin=Y'];
const filterMatch = loginMatch.filter(mch => {
return url.indexOf(mch) > -1;
});
if (filterMatch.length && !login) {
return yaSDK.goLogin();
}
}
yaSDK.link(e)
};
return (
<div className="comp-bottom-btns-wrap">
{
linkArr.map((link, idx) => {
return (
<span data-type='other' data-url={link.url}
className="button-item" key={idx} onClick={jump}>
<img className="btn-item-bg" src={link.bg}/>
</span>
)
})
}
</div>
)
}
}