MyselfMobile.js 3.79 KB
import React from 'react';
import { Button, List } from 'antd-mobile';
import 'antd-mobile/dist/antd-mobile.css';
// import ExamineMobile from './ExamineMobile';
import * as commonConfig from '../../utils/config';
import * as commonUtils from '../../utils/utils';
import CommobileBase from '../../mobile/common/CommobileBase';
import styles from '../mobile.less';
import setting from '../../assets/mobile/setting.png';
import mailList from '../../assets/mobile/mailList.png';
import recommendation from '../../assets/mobile/recommendation.png';
import CommobileListEvent from './CommobileListEvent';

// eslint-disable-next-line prefer-destructuring
const Item = List.Item;

class myselfMobile extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      sId: props.app.userinfo.sId,
      sUserName: props.app.userinfo.sUserName,
      sComponanyName: props.app.systemData.findIndex(item => item.sName === 'CbxCompanyName') > -1 ? props.app.systemData.filter(item => item.sName === 'CbxCompanyName')[0].sValue : '',
    };
  }
  btnOnclick = (value) => {
    const { dispatch } = this.props;
    const { sId } = this.state;
    if (value === 'loginOut') {
      const url = `${commonConfig.server_host}logout`;
      dispatch({ type: 'app/loginOut', payload: { url, sId, loginOutType: 'loginMobileOut' } });
    } else if (value === 'about') {
      window.open('about.html');
    } else {
      dispatch({
        type: 'content/onRouterMobile',
        payload: {
          url: `/indexMobile/${value}`,
        },
      });
    }
  }


  render() {
    const { sUserName, sComponanyName } = this.state;
    const { slaveData } = this.props;

    let sDepartName = '';
    if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyObject(sUserName)) {
      const findIndex = slaveData.findIndex(item => item.sEmployeeName === 'sUserName');
      if (findIndex > -1) {
        // eslint-disable-next-line prefer-destructuring
        sDepartName = slaveData[findIndex].sDepartName;
      } else {
        sDepartName = '暂无';
      }
    }

    const sUserNameFirst = sUserName.charAt(0);
    return (
      <div>
        <div className={styles.myselfContent}>
          <div className={styles.company}>{sComponanyName}</div>
          <div className={styles.textInfo}>
            <div className={styles.myselfNameFirst}>{sUserNameFirst}</div>
            <div className={styles.myselfName}>
              <div className={styles.myselfNameInfo}>{sUserName}</div>
              <div className={styles.companyInfo}>{sDepartName}</div>
            </div>
          </div>
        </div>
        <List className={styles.myselfList}>
          <Item
            thumb={mailList}
            arrow="horizontal"
            onClick={this.btnOnclick.bind(this, 'contacts')}
            style={{ margin: '10px 0' }}
          >
            企业通讯录
          </Item>
          <Item
            thumb={setting}
            onClick={this.btnOnclick.bind(this, 'revisePassword')}
            arrow="horizontal"
            style={{ margin: '10px 0' }}
          >
            修改密码
          </Item>
          <Item
            thumb={recommendation}
            onClick={() => {}}
            arrow="horizontal"
            style={{ margin: '10px 0' }}
          >
            推荐给好友
          </Item>
          <Item
            thumb={setting}
            onClick={this.btnOnclick.bind(this, 'about')}
            arrow="horizontal"
            style={{ margin: '10px 0' }}
          >
            关于软件
          </Item>
        </List>
        <Button
          onClick={this.btnOnclick.bind(this, 'loginOut')}
          style={{ color: 'red', margin: '50px 0 10px 0' }}
        >
          退出登录
        </Button>
      </div>
    );
  }
}

export default CommobileBase(CommobileListEvent(myselfMobile));