This commit is contained in:
lyp 2025-03-07 09:04:36 +08:00
parent 22b6fa4f8f
commit 890ef56f53
3 changed files with 68 additions and 68 deletions

View File

@ -5,43 +5,43 @@ import { useEffect, useState, useContext } from "react";
import { Axios, DevUserId } from "../../util/AjaxUtils.ts"; import { Axios, DevUserId } from "../../util/AjaxUtils.ts";
import { EventSourcePolyfill } from 'event-source-polyfill'; import { EventSourcePolyfill } from 'event-source-polyfill';
import { GlobalContext, GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts"; import { GlobalContext, GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts";
import { // import {
get, // get,
} from "../../util/AjaxUtils.ts"; // } from "../../util/AjaxUtils.ts";
import { useDispatch } from 'react-redux' // import { useDispatch } from 'react-redux'
type SseMsg = { type SseMsg = {
msg: string; msg: string;
type: string; type: string;
} }
export default function RechargeHead() { export default function RechargeHead() {
const dispath = useDispatch() // const dispath = useDispatch()
const [isPaymentModalOpen, setIsPaymentModalOpen] = useState(false); const [isPaymentModalOpen, setIsPaymentModalOpen] = useState(false);
const globalContext = useContext(GlobalContext); const globalContext = useContext(GlobalContext);
const globalDispatchContext = useContext(GlobalDispatchContext); const globalDispatchContext = useContext(GlobalDispatchContext);
const [messageApi] = message.useMessage(); const [messageApi] = message.useMessage();
const getMyPackNum = () => { // const getMyPackNum = () => {
get<any>({ // get<any>({
messageApi, // messageApi,
url: `/api/proj/servicepkg/packageorder/count/self`, // url: `/api/proj/servicepkg/packageorder/count/self`,
onBefore() { // onBefore() {
}, // },
onSuccess({ data }) { // onSuccess({ data }) {
dispath({ // dispath({
type: 'upPackNum', // type: 'upPackNum',
val: { // val: {
ALL: data.ALL, // ALL: data.ALL,
MATERIAL: data.MATERIAL, // MATERIAL: data.MATERIAL,
} // }
}) // })
}, // },
onFinally() { // onFinally() {
} // }
}) // })
} // }
// sse // sse
const initSse = () => { const initSse = () => {
let evtSource; let evtSource;
@ -60,7 +60,7 @@ export default function RechargeHead() {
reloadUser(messageApi, globalDispatchContext).then(() => { reloadUser(messageApi, globalDispatchContext).then(() => {
setIsPaymentModalOpen(false); setIsPaymentModalOpen(false);
}); });
getMyPackNum() // getMyPackNum()
} }
}; };

View File

@ -766,32 +766,32 @@ export default function Head() {
await reloadUser(messageApi, globalDispatchContext); await reloadUser(messageApi, globalDispatchContext);
}; };
// 我的套餐包统计 // 我的套餐包统计
const getMyPackNum = () => { // const getMyPackNum = () => {
get<any>({ // get<any>({
messageApi, // messageApi,
url: `/api/proj/servicepkg/packageorder/count/self`, // url: `/api/proj/servicepkg/packageorder/count/self`,
onBefore() { // onBefore() {
}, // },
onSuccess({ data }) { // onSuccess({ data }) {
// console.log(data); // // console.log(data);
dispath({ // dispath({
type: 'upPackNum', // type: 'upPackNum',
val: { // val: {
ALL:data.ALL, // ALL:data.ALL,
MATERIAL:data.MATERIAL, // MATERIAL:data.MATERIAL,
} // }
}) // })
}, // },
onFinally() { // onFinally() {
} // }
}) // })
} // }
useEffect(() => { useEffect(() => {
getUnRead() getUnRead()
setInterval(reloadUserInterval, 5 * 60 * 1000); setInterval(reloadUserInterval, 5 * 60 * 1000);
getMyPackNum() // getMyPackNum()
}, []) }, [])

View File

@ -44,31 +44,31 @@ interface DataType {
packageOrderId: string; packageOrderId: string;
} }
import { useDispatch } from 'react-redux' // import { useDispatch } from 'react-redux'
export default function ProjNew() { export default function ProjNew() {
const dispath = useDispatch() // const dispath = useDispatch()
// 更新redux的套餐包信息 // 更新redux的套餐包信息
const getMyPackNum = () => { // const getMyPackNum = () => {
get<any>({ // get<any>({
messageApi, // messageApi,
url: `/api/proj/servicepkg/packageorder/count/self`, // url: `/api/proj/servicepkg/packageorder/count/self`,
onBefore() { // onBefore() {
}, // },
onSuccess({ data }) { // onSuccess({ data }) {
dispath({ // dispath({
type: 'upPackNum', // type: 'upPackNum',
val: { // val: {
ALL: data.ALL, // ALL: data.ALL,
MATERIAL: data.MATERIAL, // MATERIAL: data.MATERIAL,
} // }
}) // })
}, // },
onFinally() { // onFinally() {
} // }
}) // })
} // }
const [debounceTimer, setDebounceTimer] = useState<any>(null); const [debounceTimer, setDebounceTimer] = useState<any>(null);
// 创建一个 ref 来引用推荐列表容器 // 创建一个 ref 来引用推荐列表容器
const recommendListRef = useRef<HTMLDivElement>(null); const recommendListRef = useRef<HTMLDivElement>(null);
@ -1094,7 +1094,7 @@ export default function ProjNew() {
reloadUser(messageApi, globalDispatchContext).then(() => { reloadUser(messageApi, globalDispatchContext).then(() => {
messageApi.success('扣款成功'); messageApi.success('扣款成功');
}); });
getMyPackNum() // getMyPackNum()
}, },
onFinally() { onFinally() {
setLoading(false); setLoading(false);