Renxy 2 سال پیش
والد
کامیت
9f33965b56
2فایلهای تغییر یافته به همراه30 افزوده شده و 8 حذف شده
  1. 25 8
      src/pages/MessageCenter/index.js
  2. 5 0
      src/pages/MessageCenter/index.less

+ 25 - 8
src/pages/MessageCenter/index.js

@@ -1,39 +1,54 @@
 import PageContent from '@/components/PageContent';
 import TabsContent from '@/components/TabsContent';
 import { getNotificationList } from '@/services/message';
+import { UnityAction } from '@/utils/utils';
 import { useParams, useRequest } from '@umijs/max';
 import { Button } from 'antd';
 import dayjs from 'dayjs';
+import { useState } from 'react';
 import styles from './index.less';
 const icon = require('@/assets/air-conditioner.png');
 
 const MessageCenter = () => {
   const { projectId } = useParams();
+  const [tab, setTab] = useState('1');
   const { data, run, loading } = useRequest(getNotificationList, {
     defaultParams: [{ projectId, msgType: 11 }], //, msgType: 工况:11, 自检:12
   });
-  console.log(data);
 
   const handleTabsChange = (tab) => {
+    setTab(tab);
     tab == '1'
       ? run({ projectId, msgType: 11 })
       : run({ projectId, msgType: 12 });
   };
 
+  const handleReadClick = () => {
+    UnityAction.sendMsg('notiReadAll', '');
+  };
+
+  const handlerSeeClick = () => {
+    UnityAction.sendMsg('noti', tab == '1' ? 'gongKuang' : 'ziJian');
+  };
+
   const renderItem = (item) => {
-    const time = item?.CreatedOn ? dayjs(item?.CreatedOn) : '';
+    const time = item?.CreatedOn
+      ? dayjs(item.CreatedOn).format('YYYY-MM-DD hh:mm:ss')
+      : '';
     return (
       <div className={`card-box ${styles.itemContent}`}>
         <img style={{ width: '30px', height: '30px' }} src={icon} />
         <div>
-          <div style={{ marginBottom: '30px' }}>
-            那么大了可能圣诞快乐那算啦到哪啦凯撒到啦
-          </div>
+          <div style={{ marginBottom: '30px' }}>{item.MsgBady}</div>
           <div>{time}</div>
         </div>
         <div className={styles.right}>
-          {item?.ReadStatus && <div className={styles.redPoint} />}
-          <Button type="primary">查看</Button>
+          <div
+            className={item?.ReadStatus ? styles.redPoint : styles.nonePoint}
+          />
+          <Button type="primary" onClick={handlerSeeClick}>
+            查看
+          </Button>
         </div>
       </div>
     );
@@ -57,7 +72,9 @@ const MessageCenter = () => {
           },
         ]}
       />
-      <div className={styles.allRead}>全部已读</div>
+      <div className={styles.allRead} onClick={handleReadClick}>
+        全部已读
+      </div>
     </PageContent>
   );
 };

+ 5 - 0
src/pages/MessageCenter/index.less

@@ -13,6 +13,10 @@
       height: 10px;
       border-radius: 5px;
     }
+    .nonePoint {
+      width: 10px;
+      height: 10px;
+    }
   }
 }
 .allRead {
@@ -20,4 +24,5 @@
   top: 20px;
   line-height: 24px;
   right: 60px;
+  cursor: pointer;
 }