/** * 切换聊天 */ import React, { Component } from 'react'; import { Row, Col, Popover, Tooltip } from "antd"; import IM from '../IM'; import { connect } from "dva"; import { color } from 'echarts'; import '../../Command/command.less'; import eventCenter from "@common/events"; // 引入 EventEmitter' @connect((state) => ({ mapStyle: state.command.mapStyle })) export default class SwitchChat extends Component { constructor(props) { super(props); this.state = { //im数据 clicked: false, imStatus: false, conversationID: props.conversationID }; } componentDidMount() { const that = this; eventCenter.addListener('changeImStatus', (result)=>{ if (result = "change") { that.setState({ imStatus: !that.state.imStatus }) } else { that.setState({ imStatus: result }) } }); } componentWillReceiveProps(nextProps) { console.log('SwitchChat-render', JSON.stringify(nextProps)); if (this.state.imStatus != nextProps.imStatus || this.state.conversationID != nextProps.conversationID) { this.setState({ imStatus: nextProps.imStatus || false, conversationID: nextProps.conversationID }); } } handleVisibleChange = imStatus => { this.setState({ imStatus }); this.props.onClick() }; changeSwitchStatus=()=>{ this.setState({ imStatus: !this.state.imStatus }) } _onClose=()=>{ const { imStatus, conversationID } = this.state; this.setState({ imStatus: !imStatus }); } render() { console.log('SwitchChat-render'); const { mapStyle } = this.props const { imStatus, conversationID } = this.state; const content = (