Commit bc3f7250 authored by wuhao's avatar wuhao 🎯

shit

parent 7b82c2bf
Pipeline #3637 passed with stages
in 2 minutes and 29 seconds
import difftime from "@/utils/difftime"; import difftime from "@/utils/difftime";
import { doFetch } from "@/utils/doFetch"; import { doFetch } from "@/utils/doFetch";
import { Avatar, Box, Stack } from "@mui/material"; import { Avatar, Box, Stack } from "@mui/material";
import { useModel } from "@umijs/max";
import { useRequest } from "ahooks"; import { useRequest } from "ahooks";
import { Input } from "antd"; import { Input } from "antd";
import dayjs from "dayjs"; import dayjs from "dayjs";
...@@ -9,6 +10,10 @@ import { Scrollbars } from "react-custom-scrollbars"; ...@@ -9,6 +10,10 @@ import { Scrollbars } from "react-custom-scrollbars";
import "./index.less"; import "./index.less";
function OnlineChat({ trainId }) { function OnlineChat({ trainId }) {
const {
initialState: { menuNum },
setInitialState,
} = useModel("@@initialState");
const currentUserId = localStorage.getItem("ID"); const currentUserId = localStorage.getItem("ID");
const [value, setvalue] = useState(); const [value, setvalue] = useState();
...@@ -34,6 +39,7 @@ function OnlineChat({ trainId }) { ...@@ -34,6 +39,7 @@ function OnlineChat({ trainId }) {
} }
} }
}; };
const { data, loading, refresh } = useRequest( const { data, loading, refresh } = useRequest(
async () => { async () => {
let res = await doFetch({ let res = await doFetch({
...@@ -48,6 +54,7 @@ function OnlineChat({ trainId }) { ...@@ -48,6 +54,7 @@ function OnlineChat({ trainId }) {
scrollRef?.current?.scrollToBottom(); scrollRef?.current?.scrollToBottom();
}, 10); }, 10);
}, },
refreshDeps: [menuNum],
} }
); );
......
...@@ -16,9 +16,9 @@ import IconFont from "@/components/IconFont"; ...@@ -16,9 +16,9 @@ import IconFont from "@/components/IconFont";
import Label from "@/components/label"; import Label from "@/components/label";
import difftime from "@/utils/difftime"; import difftime from "@/utils/difftime";
import AccessTimeFilledIcon from "@mui/icons-material/AccessTimeFilled"; import AccessTimeFilledIcon from "@mui/icons-material/AccessTimeFilled";
import { history } from "@umijs/max"; import { history, useModel } from "@umijs/max";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { useState } from "react"; import { useEffect, useState } from "react";
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
...@@ -35,9 +35,7 @@ ShopProductCard.propTypes = { ...@@ -35,9 +35,7 @@ ShopProductCard.propTypes = {
product: PropTypes.object, product: PropTypes.object,
}; };
export default function ShopProductCard({ export default function ShopProductCard({ product }) {
product,
}) {
const { const {
trainName, trainName,
picUrl, picUrl,
...@@ -48,13 +46,52 @@ export default function ShopProductCard({ ...@@ -48,13 +46,52 @@ export default function ShopProductCard({
sectionNum, sectionNum,
experimentNum, experimentNum,
startTime, startTime,
unReadMsgCount,
trainId,
} = product; } = product;
const [confirm, setconfirm] = useState(false); const [confirm, setconfirm] = useState(false);
const [Numcount, setNumcount] = useState({});
const [shut, setshut] = useState(false); const [shut, setshut] = useState(false);
const {
initialState: { menuNum },
setInitialState,
} = useModel("@@initialState");
let { STUDY_TRAIN_LIST } = menuNum ?? {};
useEffect(() => {
if (!STUDY_TRAIN_LIST) {
return;
}
setNumcount((s) => ({
...s,
[STUDY_TRAIN_LIST.id]: STUDY_TRAIN_LIST?.unReadMsgCount,
}));
}, [STUDY_TRAIN_LIST]);
let num = Numcount?.[trainId] ?? unReadMsgCount;
return ( return (
<Card sx={{ borderRadius: 3 }} className="hovered" id="jikl"> <Card sx={{ borderRadius: 3 }} className="hovered" id="jikl">
<div
style={{
width: 24,
height: 24,
backgroundColor: "#ff4800",
position: "absolute",
right: 6,
top: 6,
zIndex: 999,
borderRadius: 30,
color: "#fff",
fontSize: 12,
display: !num ? "none" : "flex",
}}
className="center"
>
{num > 100 ? "99+" : num}
</div>
<Box sx={{ pt: "66%", position: "relative" }} className="center"> <Box sx={{ pt: "66%", position: "relative" }} className="center">
{typeName && ( {typeName && (
<Label <Label
......
...@@ -28,7 +28,7 @@ export default function Nav({ openNav, onCloseNav }) { ...@@ -28,7 +28,7 @@ export default function Nav({ openNav, onCloseNav }) {
const [navConfigs, setNavConfigs] = useState(navConfig); const [navConfigs, setNavConfigs] = useState(navConfig);
const { const {
initialState: { nav, currentUser, menuNum}, initialState: { nav, currentUser, menuNum },
setInitialState, setInitialState,
} = useModel("@@initialState"); } = useModel("@@initialState");
...@@ -50,16 +50,19 @@ export default function Nav({ openNav, onCloseNav }) { ...@@ -50,16 +50,19 @@ export default function Nav({ openNav, onCloseNav }) {
}); });
useEffect(() => { useEffect(() => {
if(!data){ if (!data) {
return return;
} }
setNavConfigs((s) => { setNavConfigs((s) => {
let news = navConfig?.map((it) => { let news = navConfig?.map((it) => {
return { return {
...it, ...it,
children: it?.children?.map((item, i) => { children: it?.children?.map((item, i) => {
const info = menuNum?.[item?.key ?? ""]? const info =
{ menuNum?.[item?.key ?? ""] === 0
? {}
: menuNum?.[item?.key ?? ""]
? {
info: ( info: (
<div <div
style={{ style={{
...@@ -78,7 +81,7 @@ export default function Nav({ openNav, onCloseNav }) { ...@@ -78,7 +81,7 @@ export default function Nav({ openNav, onCloseNav }) {
</div> </div>
), ),
} }
:data[item?.key ?? ""] : data[item?.key ?? ""]
? { ? {
info: ( info: (
<div <div
...@@ -120,7 +123,7 @@ export default function Nav({ openNav, onCloseNav }) { ...@@ -120,7 +123,7 @@ export default function Nav({ openNav, onCloseNav }) {
}); });
} }
}); });
}, [data, currentUser?.type,menuNum]); }, [data, currentUser?.type, menuNum]);
useEffect(() => { useEffect(() => {
if (openNav) { if (openNav) {
......
...@@ -349,7 +349,7 @@ function Dolessons() { ...@@ -349,7 +349,7 @@ function Dolessons() {
{ {
key: "4", key: "4",
label: "在线沟通", label: "在线沟通",
children: <OnlineChat trainId={params?.id}></OnlineChat>, children: active =="4" && <OnlineChat trainId={params?.id}></OnlineChat>,
}, },
]; ];
......
...@@ -270,7 +270,7 @@ function Dolessons() { ...@@ -270,7 +270,7 @@ function Dolessons() {
{ {
key: "4", key: "4",
label: "在线沟通", label: "在线沟通",
children: <OnlineChat trainId={params?.id}></OnlineChat>, children: active == "4" && <OnlineChat trainId={params?.id}></OnlineChat>,
}, },
]; ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment