diff --git a/src/components/payment/Payment.tsx b/src/components/payment/Payment.tsx index 6167e6a..d44f072 100644 --- a/src/components/payment/Payment.tsx +++ b/src/components/payment/Payment.tsx @@ -97,7 +97,9 @@ export default function Payment(props: IPaymentProps) { const [value, setValue] = useState('MATERIAL');//单选 服务包类型 const onChange = (e: any) => { setValue(e.target.value); - getPackageList(e.target.value, packPage); + // getPackageList(e.target.value, packPage); + setPackPage(1); + getPackageList(e.target.value, 1); // setSelectedRowKeys([]); }; const [packList, setPackList] = useState([]); diff --git a/src/components/recharge/RechargeHead.tsx b/src/components/recharge/RechargeHead.tsx index 5a232aa..e752ec2 100644 --- a/src/components/recharge/RechargeHead.tsx +++ b/src/components/recharge/RechargeHead.tsx @@ -5,19 +5,43 @@ import { useEffect, useState, useContext } from "react"; import { Axios, DevUserId } from "../../util/AjaxUtils.ts"; import { EventSourcePolyfill } from 'event-source-polyfill'; import { GlobalContext, GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts"; - +import { + get, + +} from "../../util/AjaxUtils.ts"; +import { useDispatch } from 'react-redux' type SseMsg = { msg: string; type: string; } export default function RechargeHead() { - + const dispath = useDispatch() const [isPaymentModalOpen, setIsPaymentModalOpen] = useState(false); const globalContext = useContext(GlobalContext); const globalDispatchContext = useContext(GlobalDispatchContext); const [messageApi] = message.useMessage(); + const getMyPackNum = () => { + get({ + messageApi, + url: `/api/proj/servicepkg/packageorder/count/self`, + onBefore() { + }, + onSuccess({ data }) { + dispath({ + type: 'upPackNum', + val: { + ALL: data.ALL, + MATERIAL: data.MATERIAL, + } + }) + }, + onFinally() { + + } + }) + } // sse const initSse = () => { let evtSource; @@ -36,6 +60,8 @@ export default function RechargeHead() { reloadUser(messageApi, globalDispatchContext).then(() => { setIsPaymentModalOpen(false); }); + getMyPackNum() + } }; } diff --git a/src/layout/head/Head.tsx b/src/layout/head/Head.tsx index 0e87362..c1064c0 100644 --- a/src/layout/head/Head.tsx +++ b/src/layout/head/Head.tsx @@ -1,6 +1,8 @@ import './head.css' // import { NodeJS } from 'types/node'; -import { useDispatch } from 'react-redux' +import { useDispatch, + // useSelector + } from 'react-redux' import BalanceHead from '../../components/balance/BalanceHead.tsx'; import RechargeHead from '../../components/recharge/RechargeHead.tsx'; import { Empty, Dropdown, MenuProps, message, Modal, Space, Spin, Input, Table, Form, Button, InputNumber } from "antd"; @@ -162,7 +164,7 @@ export default function Head() { const [icModal, setIcModal] = useState(false) //查看邀请码详情弹窗 const [selectIc, setSelectIc] = useState('') //选中的邀请码 // const redxuState: any = useSelector(state => state) - // const couponModal = redxuState.couponModal + // const packNum = redxuState.packNum // 消息通知弹窗 const [noticeModal, setNoticeModal] = useState(false) // 客服弹窗 @@ -763,9 +765,33 @@ export default function Head() { const reloadUserInterval = async () => { await reloadUser(messageApi, globalDispatchContext); }; + // 我的套餐包统计 + const getMyPackNum = () => { + get({ + messageApi, + url: `/api/proj/servicepkg/packageorder/count/self`, + onBefore() { + + }, + onSuccess({ data }) { + // console.log(data); + dispath({ + type: 'upPackNum', + val: { + ALL:data.ALL, + MATERIAL:data.MATERIAL, + } + }) + }, + onFinally() { + + } + }) + } useEffect(() => { getUnRead() setInterval(reloadUserInterval, 5 * 60 * 1000); + getMyPackNum() }, []) @@ -906,26 +932,27 @@ export default function Head() { {/*
*/}
- {/*
{ + {/*
{ setPackageModal(true) setPackPage(1); getPickList(1) + }} >
套餐包
- 全托管:100件 - 写材料:100件 + 全托管 : {packNum.ALL}件 + 写材料 : {packNum.MATERIAL}件
*/} diff --git a/src/route/proj/ProjNew.tsx b/src/route/proj/ProjNew.tsx index 00d8e4a..97c95cd 100644 --- a/src/route/proj/ProjNew.tsx +++ b/src/route/proj/ProjNew.tsx @@ -44,8 +44,31 @@ interface DataType { packageOrderId: string; } - +import { useDispatch } from 'react-redux' export default function ProjNew() { + const dispath = useDispatch() + // 更新redux的套餐包信息 + const getMyPackNum = () => { + get({ + messageApi, + url: `/api/proj/servicepkg/packageorder/count/self`, + onBefore() { + + }, + onSuccess({ data }) { + dispath({ + type: 'upPackNum', + val: { + ALL: data.ALL, + MATERIAL: data.MATERIAL, + } + }) + }, + onFinally() { + + } + }) + } const [debounceTimer, setDebounceTimer] = useState(null); // 创建一个 ref 来引用推荐列表容器 const recommendListRef = useRef(null); @@ -492,7 +515,7 @@ export default function ProjNew() {
-
系统全称*
+
系统全称*
name="projName" rules={[ @@ -602,7 +625,7 @@ export default function ProjNew() { // position: 'relative', // background: 'pink', }}> - 产权所属者* + 产权所属者*
@@ -613,9 +636,9 @@ export default function ProjNew() {
- 产权联系人* + 产权联系人*
name="contacts" @@ -635,9 +658,9 @@ export default function ProjNew() {
-
系统版本*
+
系统版本*
name="projVersion" @@ -668,7 +691,7 @@ export default function ProjNew() {
-
系统语言*
+
系统语言*
name="backendCodeLang" rules={[ @@ -796,7 +819,7 @@ export default function ProjNew() { style={{ display: selectPack ? 'none' : 'unset', position: 'absolute', right: 23, // fontSize: 16, - color: packList.length ? '#1F79FF' : '#676767', cursor: 'pointer', + color: packList.length ? '#1F79FF' : '#676767', cursor: 'pointer', // background:'pink', width: 290, textAlign: 'right', @@ -853,7 +876,7 @@ export default function ProjNew() {
{ @@ -914,7 +937,7 @@ export default function ProjNew() {
知识产权
*/} - +
{ messageApi.success('扣款成功'); }); + getMyPackNum() }, onFinally() { setLoading(false); diff --git a/src/store/index.ts b/src/store/index.ts index 47ef4c4..6212418 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -19,7 +19,11 @@ const baseState = { projName:'', projStatus:'', newRefun:false, - newCorrection:false + newCorrection:false, + packNum:{ + ALL:0, + MATERIAL:0, + } } // 创建仓库 @@ -70,6 +74,9 @@ const reducer = (state = baseState, action: any) => { if (action.type == 'newCorrection') { nstate.newCorrection = action.val } + if (action.type == 'upPackNum') { + nstate.packNum = action.val + } return nstate } const store = createStore(reducer)