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 { doFetch } from "@/utils/doFetch";
import { Avatar, Box, Stack } from "@mui/material";
import { useModel } from "@umijs/max";
import { useRequest } from "ahooks";
import { Input } from "antd";
import dayjs from "dayjs";
......@@ -9,6 +10,10 @@ import { Scrollbars } from "react-custom-scrollbars";
import "./index.less";
function OnlineChat({ trainId }) {
const {
initialState: { menuNum },
setInitialState,
} = useModel("@@initialState");
const currentUserId = localStorage.getItem("ID");
const [value, setvalue] = useState();
......@@ -34,6 +39,7 @@ function OnlineChat({ trainId }) {
}
}
};
const { data, loading, refresh } = useRequest(
async () => {
let res = await doFetch({
......@@ -48,6 +54,7 @@ function OnlineChat({ trainId }) {
scrollRef?.current?.scrollToBottom();
}, 10);
},
refreshDeps: [menuNum],
}
);
......
......@@ -16,9 +16,9 @@ import IconFont from "@/components/IconFont";
import Label from "@/components/label";
import difftime from "@/utils/difftime";
import AccessTimeFilledIcon from "@mui/icons-material/AccessTimeFilled";
import { history } from "@umijs/max";
import { history, useModel } from "@umijs/max";
import dayjs from "dayjs";
import { useState } from "react";
import { useEffect, useState } from "react";
// ----------------------------------------------------------------------
......@@ -35,9 +35,7 @@ ShopProductCard.propTypes = {
product: PropTypes.object,
};
export default function ShopProductCard({
product,
}) {
export default function ShopProductCard({ product }) {
const {
trainName,
picUrl,
......@@ -48,13 +46,52 @@ export default function ShopProductCard({
sectionNum,
experimentNum,
startTime,
unReadMsgCount,
trainId,
} = product;
const [confirm, setconfirm] = useState(false);
const [Numcount, setNumcount] = useState({});
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 (
<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">
{typeName && (
<Label
......
......@@ -28,7 +28,7 @@ export default function Nav({ openNav, onCloseNav }) {
const [navConfigs, setNavConfigs] = useState(navConfig);
const {
initialState: { nav, currentUser, menuNum},
initialState: { nav, currentUser, menuNum },
setInitialState,
} = useModel("@@initialState");
......@@ -50,55 +50,58 @@ export default function Nav({ openNav, onCloseNav }) {
});
useEffect(() => {
if(!data){
return
if (!data) {
return;
}
setNavConfigs((s) => {
let news = navConfig?.map((it) => {
return {
...it,
children: it?.children?.map((item, i) => {
const info = menuNum?.[item?.key ?? ""]?
{
info: (
<div
style={{
marginRight: 12,
backgroundColor: "#ff4800",
width: 20,
height: 20,
textAlign: "center",
lineHeight: "20px",
color: "#fff",
borderRadius: 12,
fontSize: 12,
}}
>
{menuNum[item?.key ?? ""]}
</div>
),
}
:data[item?.key ?? ""]
? {
info: (
<div
style={{
marginRight: 12,
backgroundColor: "#ff4800",
width: 20,
height: 20,
textAlign: "center",
lineHeight: "20px",
color: "#fff",
borderRadius: 12,
fontSize: 12,
}}
>
{data[item?.key]}
</div>
),
}
: {};
const info =
menuNum?.[item?.key ?? ""] === 0
? {}
: menuNum?.[item?.key ?? ""]
? {
info: (
<div
style={{
marginRight: 12,
backgroundColor: "#ff4800",
width: 20,
height: 20,
textAlign: "center",
lineHeight: "20px",
color: "#fff",
borderRadius: 12,
fontSize: 12,
}}
>
{menuNum[item?.key ?? ""]}
</div>
),
}
: data[item?.key ?? ""]
? {
info: (
<div
style={{
marginRight: 12,
backgroundColor: "#ff4800",
width: 20,
height: 20,
textAlign: "center",
lineHeight: "20px",
color: "#fff",
borderRadius: 12,
fontSize: 12,
}}
>
{data[item?.key]}
</div>
),
}
: {};
return {
...item,
...info,
......@@ -120,7 +123,7 @@ export default function Nav({ openNav, onCloseNav }) {
});
}
});
}, [data, currentUser?.type,menuNum]);
}, [data, currentUser?.type, menuNum]);
useEffect(() => {
if (openNav) {
......
......@@ -349,7 +349,7 @@ function Dolessons() {
{
key: "4",
label: "在线沟通",
children: <OnlineChat trainId={params?.id}></OnlineChat>,
children: active =="4" && <OnlineChat trainId={params?.id}></OnlineChat>,
},
];
......
......@@ -270,7 +270,7 @@ function Dolessons() {
{
key: "4",
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