index.js
2.39 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import React, { Component } from 'react'
import { connect } from 'dva'
import { Link } from 'dva/router'
import shareHide from "../../utils/shareHide";
import styles from './poster.less';
class Poster extends Component {
constructor(){
super()
this.state={
posterList: [],
selIdx: 0,
filterType: ['鸡汤', '节日', '产品'],
}
}
componentDidMount() {
document.title = '海报'
shareHide();
this.filter('鸡汤');
}
componentWillUnmount(){
document.title = ''
}
filter(type) {
const _this = this;
this.props.dispatch({
type: 'poster/getPosterList',
payload: {
reportType: type,
agentCode1: window.localStorage.getItem('orgId'),
agentCode2: window.localStorage.getItem('project')
},
callback(res) {
if (typeof res.data === 'object') {
_this.setState({
posterList: res.data
})
} else {
_this.setState({
posterList: []
})
}
}
})
}
render() {
const { posterList } = this.state;
const roleId = window.localStorage.getItem('roleId');
let position = '';
switch (roleId) {
case '2':
position = '客户经理';
break;
default:
position = '督训';
}
return (
<div className={styles.wrapper}>
<div className={styles.tabCon}>
<div className={styles.splitline}></div><ul className={styles.tags}>
{
this.state.filterType.map((el, i) => {
return <li className={this.state.selIdx===i?'on':''} key={i} onClick={() => {
this.filter(el);
this.setState({
selIdx:i
})
}}>{el}</li>
})
}
</ul>
<ul className={styles.pList}>
{
posterList.map((el, i) => {
return <li key={i}>
<Link to={{
pathname: "/poster/info",
search: '?imgpath=' + el.reportImage + '&position=' + position + '&name=' + window.localStorage.getItem('name') + '&phone=' + window.localStorage.getItem('number'),
}}><img alt="" src={el.reportImage} /></Link>
</li>
})
}
</ul>
</div>
</div>
)
}
}
export default connect(({ poster }) => ({ poster }))(Poster)