index.js
2.51 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
import React,{Component} from 'react';
import { connect } from 'dva'
import { Carousel,} from 'antd';
import styles from "./Swiper.css"
class SWiper extends Component{
constructor(){
super();
this.state={
slide: [],
moveend: 0,
movestart:0
}
}
componentDidMount(){
let that = this;
/* 轮播图接口 */
this.props.dispatch({
type:'home/getBanner',
payload: {
"bannerName":"",
"bannerStatus":1,
"proId":localStorage.getItem("project"),
"website":localStorage.getItem("website"),
"orgId":localStorage.getItem("orgId"),
},
callback(data){
that.setState({
slide:data
})
},
});
}
goPlan =(item)=>{
let storage = window.localStorage;
storage.setItem("riskName",item.bannerName)
storage.setItem("riskCode",item.bannerCode)
storage.setItem("calculationMethod",item.bannerLabel)
storage.setItem("selectd",1)
storage.setItem("seriNo",'')
//storage.setItem("recipients",false)
storage.setItem("riskIntroduce",'')
// storage.setItem("thumbnail",item.bannerPath)
storage.setItem("thumbnail",item.bannerUrl)
//storage.setItem("recipientsName",'')
let roleId =localStorage.getItem("roleId");
window.location.href= window.location.href.split('#')[0]+ '#/addplaneditor?riskName='+item.bannerName+'&riskCode='+item.bannerCode +'&calculationMethod='+ item.bannerLabel + '&riskIntroduce=&thumbnail='+item.bannerUrl+'&selectd=1&roleId='+ roleId +'&Id='+ localStorage.getItem('id') + '&seriNo='
}
render(){
return (
<Carousel
autoplay
>
{ this.state.slide !=='' && this.state.slide.map((item,index)=>{
const that = this;
return (<div className="swiper-slide" key={index} onTouchMove={(e) => {
this.setState({
moveend: e.touches[0].pageX
})
}}
onTouchEnd={() => {
if (this.state.moveend == 0) {
that.goPlan(item);
}
this.setState({
moveend: 0
})
}}
onTouchStart={(e) => {
this.setState({
moveend: 0
})
}} ><img src={item.bannerPath} alt="" style={{ width: '3.92rem',height:'1.8rem', borderRadius: '.12rem', }}
/> </div>)
})}
</Carousel>
)
}
}
export default connect()(SWiper)