import React,{Component} from 'react'; import {Button, Icon, message, Upload} from 'antd'; import './index.less'; // const url1 = 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1601012352754&di=d33308119328f5ed987bd90031f98cfa&imgtype=0&src=http%3A%2F%2Fa2.att.hudong.com%2F27%2F81%2F01200000194677136358818023076.jpg'; // const url2 = 'https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1601001245&di=60b5e1a42beb791524b46d7e3677f1f4&src=http://a2.att.hudong.com/13/86/01300001285722131043860050752.jpg'; class ImgList extends Component{ constructor(props) { super(props); this.state={ seeMore: false, previewVisible: false, previewImage: '', rotateDeg: 0, fileList: props.fileList.map((v,i)=>{ v.index = i; // v.url = i%2 ? url1 : url2; return v }) || [], selectImgIndex: 0, //选择的图片索引 } this.handleCancel = this.handleCancel.bind(this); this.downImg = this.downImg.bind(this); this.upImg = this.upImg.bind(this); this.rotate = this.rotate.bind(this); } handleCancel(e) { e.stopPropagation(); this.setState({ previewVisible:false, previewImage: '', rotateDeg: 0, selectImgIndex: 0, },()=>{ document.getElementsByClassName('imgBox')[0].style.backgroundSize = 'contain'; }) } rotate() { let rotateDeg = this.state.rotateDeg + 90; this.setState({ rotateDeg, }) } upImg() { const {fileList} = this.state; let index = this.state.selectImgIndex - 1; if(index < 0){ message.warn('已经是第一张了哦') }else{ let file = fileList[index]; this.setState({ previewImage: file.url || file.thumbUrl, selectImgIndex: index, rotateDeg: 0, },()=>{ document.getElementsByClassName('imgBox')[0].style.backgroundSize = 'contain'; }) } } downImg() { const {fileList} = this.state; let index = this.state.selectImgIndex + 1; if(index >= fileList.length){ message.warn('已经是最后一张了哦') }else{ let file = fileList[index]; this.setState({ previewImage: file.url || file.thumbUrl, selectImgIndex: index, rotateDeg: 0, },()=>{ document.getElementsByClassName('imgBox')[0].style.backgroundSize = 'contain'; }) } } render() { const {fileList} = this.state; return (