index.jsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Created by ZN on 2018/5/03.
  3. * 可配置属性:
  4. * show:为true是才显示,false不显示
  5. * text:显示在图标下的文字
  6. * img:自定义图标
  7. */
  8. import React, {Component} from 'react';
  9. /*import PropTypes from 'prop-types';*/
  10. import style from './index.less';
  11. import wnIcon from '@common/images/wn.png';
  12. import icon from '@common/images/loading.gif';
  13. import Notify from '@commonComp/Notify';
  14. import ReactDom from 'react-dom';
  15. /*const propTypes = {
  16. text: PropTypes.string,
  17. show: PropTypes.bool,
  18. shadeIsShow: PropTypes.bool
  19. };
  20. const defaultProps = {
  21. text: '拼命加载中...',
  22. shadeIsShow: true
  23. };*/
  24. // function Loading(props) {
  25. // const {text, img, show} = props;
  26. // return (
  27. // <div className={style['loading']} style={{display: show ? 'block' : 'none'}}>
  28. // {props.shadeIsShow?<div className={style['cover']}/>:''}
  29. // <div className={style['info']}>
  30. // <img src={img}/>
  31. // <p>{text}</p>
  32. // </div>
  33. // </div>
  34. // )
  35. // }
  36. class Loading extends React.Component{
  37. render(){
  38. const {text,show,type} = this.props;
  39. const domNode = document.getElementById('root');
  40. return ReactDom.createPortal(<React.Fragment>
  41. <div className={style['loading']} style={{display: show ? 'block' : 'none'}}>
  42. {/*{this.props.shadeIsShow?<div className={style['cover']}/>:null}*/}
  43. <div className={style['cover']}/>
  44. {type==='warning'?Notify.info(text,0, false,false):<div className={style['info']}>
  45. <img src={icon}/>
  46. <p>{text}</p>
  47. </div>}
  48. </div>
  49. </React.Fragment>,domNode
  50. )
  51. }
  52. }
  53. export default Loading;