2 Commits bb280d53b0 ... ee294b903c

Author SHA1 Message Date
  zhaojing ee294b903c fix:合并企业信息 1 year ago
  zhaojing 15e75510a8 fix:登录完善 1 year ago

+ 18 - 17
src/app.tsx

@@ -18,32 +18,33 @@ export async function getInitialState(): Promise<{
 }> {
   const { location } = history;
   var token = localStorage.getItem('token');
-  // if (location.pathname.indexOf('login') == -1 && !token) {
-  //   history.push('/login');
-  // }
+  if (location.pathname.indexOf('login') == -1 && !token) {
+    history.push('/login');
+  }
   if (location.pathname.indexOf('login') > -1 && token) {
     history.push('/home');
   }
-  //debugger;
-  let currentUser = {
-    appId: 'wxda2ef261ac3cca32',
-    companyId: '17fe48afcdde4d6797583c6d6270a035', // ff80c708fe72446eb790b764c3a7b66b,
-    loginType: 'app',
-    manageUserType: 3,
-    name: '赵静',
-    openId: 'oDcGY5Qq3Vk-7WKTNsn-lLGNT118',
-    phone: '13810794283',
-    projectId: 'Pj1101080259', //  Pj1101099999
-    userId: 'db445a9cd7be4341a14448928014605c',
-  };
-  let projectId = 'Pj1101080259'; //  Pj1101099999
+  debugger;
+  let currentUser = {};
+  // let currentUser = {
+  //   appId: 'wxda2ef261ac3cca32',
+  //   companyId: '17fe48afcdde4d6797583c6d6270a035', // ff80c708fe72446eb790b764c3a7b66b,
+  //   loginType: 'app',
+  //   manageUserType: 3,
+  //   name: '赵静',
+  //   openId: 'oDcGY5Qq3Vk-7WKTNsn-lLGNT118',
+  //   phone: '13810794283',
+  //   projectId: 'Pj1101080259', //  Pj1101099999
+  //   userId: 'db445a9cd7be4341a14448928014605c',
+  // };
+  let projectId = ''; //  Pj1101099999
   if (location.pathname.indexOf('login') == -1 && token) {
     var localUser = localStorage.getItem('user') || '';
     currentUser = JSON.parse(localUser);
     projectId = currentUser?.projectId;
   }
   let companyConfig = {};
-  if (currentUser.userId) {
+  if (currentUser?.userId) {
     const res = await queryTenantData(currentUser);
     companyConfig = res.data;
   }

+ 13 - 2
src/layouts/index.jsx

@@ -10,7 +10,8 @@ import Head from '@/sagacare_components/head';
 
 export default (props) => {
   const { menuVisible, closeMenu, toggleMenu } = useModel('controller');
-  const { initialState, setInitialState } = useModel('@@initialState');
+  const { initialState, refresh } = useModel('@@initialState');
+  const location = useLocation();
   const { changeLastBuildId, changeLastFloorId } = useModel('sagacare_buildFloor');
   //todo
   const [notifyList] = useState([
@@ -72,6 +73,16 @@ export default (props) => {
     });
   };
 
+  useEffect(() => {
+    if (menuVisible) {
+      refresh();
+    }
+  }, [menuVisible, refresh]);
+
+  useEffect(() => {
+    refresh();
+  }, [refresh]);
+
   useEffect(async () => {
     //关闭
     document.querySelector('#root').addEventListener('click', closeNotify, true);
@@ -89,10 +100,10 @@ export default (props) => {
     };
   }, []);
 
-  const location = useLocation();
   useEffect(() => {
     //console.log('location', location);
   }, [location]);
+
   return (
     <div className={styles.layout}>
       <div className={styles.header}>

+ 1 - 1
src/pages/Home/index.tsx

@@ -12,7 +12,7 @@ const Runtime: React.FC = () => {
   return (
     <div className={styles.homewrap}>
       <div className={styles.left}>
-        <span className={styles.userName}>你好,{initialState?.companyConfig?.name}</span>
+        <span className={styles.userName}>你好,{initialState?.currentUser?.name}</span>
       </div>
       <div className={styles.right}>
         <NavMenu></NavMenu>

+ 19 - 2
src/pages/Login/index.jsx

@@ -12,7 +12,10 @@ export default () => {
   const wsRef = useRef();
   const [expireTime, setExpireTime] = useState(); //过期时间
   const [qrCodeId, setQrCodeId] = useState(); //生成二维码id
-
+  const [expireSign, setExpireSign] = useState(false); //生成二维码id
+  // const createTime = useRef();
+  // const nowTime = useRef();
+  const setTimer = useRef();
   const getqrCodeInfo = () => {
     qrCodeInfo()
       .then((res) => {
@@ -30,6 +33,20 @@ export default () => {
 
   useEffect(() => {
     if (!qrCodeId) return;
+    setExpireSign(false);
+
+    clearInterval(setTimer.current);
+    setTimer.current = setTimeout(() => {
+      //过期
+      setExpireSign(true);
+    }, 180000);
+    return () => {
+      clearInterval(setTimer.current);
+    };
+  }, [qrCodeId]);
+
+  useEffect(() => {
+    if (!qrCodeId) return;
     if (qrcodeRef.current) {
       qrcodeRef.current.makeCode(qrCodeId);
     } else {
@@ -93,7 +110,7 @@ export default () => {
           <img src={loginLogo} style={{ height: 110 }}></img>
         </div>
         <div className={styles.qrcodeWrap}>
-          {expireTime < new Date().getTime() && (
+          {expireSign && (
             <div className={styles.qrCover}>
               <ReloadOutlined style={{ fontSize: '25px' }} onClick={reloadQrcode} />
             </div>

+ 1 - 1
src/pages/Login/index.less

@@ -4,7 +4,7 @@
   justify-content: center;
   width: 100%;
   height: 100%;
-  background: blue;
+  // background: blue;
   border-radius: 24px;
   .loginBox {
     width: 360px;

+ 0 - 1
src/pages/Member/index.tsx

@@ -219,7 +219,6 @@ const Member: React.FC = () => {
 
     queryUserList(paramObj)
       .then((res) => {
-        debugger;
         setLoading(false);
         var uarr = res.content || [];
         var count = res.count || 0;

+ 0 - 1
src/pages/Member/invalid/index.jsx

@@ -54,7 +54,6 @@ export default (props) => {
 
     queryUserList(paramObj)
       .then((res) => {
-        debugger;
         setLoading(false);
         var uarr = res.content || [];
         var count = res.count || 0;