const taskIcon = require('@/assets/center/my-task.png');
const orderIcon = require('@/assets/center/order.png');
import PageContent from '@/components/PageContent';
import PageTitle from '@/components/PageTitle';
import { version } from '@/constants';
import { UnityAction } from '@/utils/utils';
import { useModel, useNavigate, useParams } from '@umijs/max';
import styles from './index.less';

const Center = () => {
  const { initialState } = useModel('@@initialState');
  const user = initialState?.user || {};
  const navigate = useNavigate();

  const { projectId } = useParams();

  const handleGoSystem = () => {
    navigate(`/system-daily/${projectId}`);
  };
  const handleSmartReport = () => {
    navigate(`/smart-report/${projectId}`);
  };

  const handleLogOutClick = () => {
    UnityAction.sendMsg('Logout');
  };
  const toMyTask = (type) => {
    localStorage.taskTab = type;
    navigate(`/center/my-task/${projectId}?user_id=${user.ID}`);
  };

  return (
    <PageContent>
      <PageTitle>个人中心</PageTitle>

      <div className={styles.head}>
        <div className={styles.profile} />
        <div className={styles.textContent}>
          <div className={styles.name}>{user?.CName}</div>
          <div className={styles.photo}>
            手机号：{user?.Mobile}
            <br />
            系统版本：
            {version}
          </div>
        </div>
      </div>
      <div className={styles.center}>
        <div
          className={styles.item}
          onClick={() => {
            toMyTask(1);
          }}
        >
          <img src={taskIcon} style={{ marginRight: '20px' }} />
          我的任务
        </div>
        <div
          className={styles.item}
          onClick={() => {
            toMyTask(2);
          }}
        >
          <img src={orderIcon} style={{ marginRight: '20px' }} />
          我的工单
        </div>
      </div>
      <div className={styles.bottomContent}>
        <div className={styles.lineItem} onClick={handleGoSystem}>
          系统报告 <div className={styles.arr}></div>
        </div>
        <div className={styles.lineItem} onClick={handleSmartReport}>
          智慧运营报告
          <div className={styles.arr}></div>
        </div>
        <div className={styles.lineItem}>问题反馈</div>
        <div className={styles.lineItem}>个人设置</div>
      </div>
      <div className={styles.loginOut} onClick={handleLogOutClick}>
        退出登录
      </div>
    </PageContent>
  );
};
export default Center;
