|
@@ -361,7 +361,7 @@ const HbyInfo2 = (props: any) => {
|
|
|
type Props = {};
|
|
|
export type RedPacketModalProps = {
|
|
|
onClose: () => void;
|
|
|
- onOpen: () => void;
|
|
|
+ onOpen: (index?: number) => void;
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -386,11 +386,16 @@ const RedPacketModal = forwardRef<RedPacketModalProps, Props>(function RedPacket
|
|
|
|
|
|
const [redPacketInfo, setRedPacketInfo] = useState<any>({});
|
|
|
const [redAmount, setRedAmount] = useState<any>(0);
|
|
|
+ const activeIndex = useRef<number | null>(null);
|
|
|
const token = getToken();
|
|
|
useImperativeHandle(ref, () => {
|
|
|
return {
|
|
|
onClose: () => setVisible(false),
|
|
|
- onOpen: () => {
|
|
|
+ onOpen: (index?: number) => {
|
|
|
+ if (index !== null && index !== undefined) {
|
|
|
+ activeIndex.current = index;
|
|
|
+ }
|
|
|
+
|
|
|
getRedPacketInfo().then((res) => {
|
|
|
setVisible(true);
|
|
|
});
|
|
@@ -412,21 +417,31 @@ const RedPacketModal = forwardRef<RedPacketModalProps, Props>(function RedPacket
|
|
|
actList = redPacketInfo.data;
|
|
|
}
|
|
|
// 是否有已开始但是没领过的红包
|
|
|
- let isHasStartAct = actList.filter((aItem: any) => {
|
|
|
+ let packets = actList.filter((aItem: any) => {
|
|
|
return !!aItem.is_start && !aItem.is_receive;
|
|
|
});
|
|
|
- console.log(`🚀🚀🚀🚀🚀-> in RedPacketModal.tsx on 427`, actList);
|
|
|
|
|
|
- let isShowRed = isHasStartAct.length > 0;
|
|
|
- let isShowRedDetail = isHasStartAct.length === 0;
|
|
|
- let redInfo = isShowRed ? isHasStartAct[0] : {};
|
|
|
- let curAct = !!isShowRedDetail ? findCurrentActivity(actList) : actList[0];
|
|
|
- let iconList = JSON.parse(curAct.icon);
|
|
|
+ let current = null;
|
|
|
+ if (activeIndex.current !== null && activeIndex.current !== undefined) {
|
|
|
+ current = packets[activeIndex.current];
|
|
|
+ } else {
|
|
|
+ current = findCurrentActivity(packets);
|
|
|
+ }
|
|
|
+
|
|
|
+ let isShowRed = packets.length > 0;
|
|
|
+ let isShowRedDetail = packets.length === 0;
|
|
|
+ //
|
|
|
+ // let redInfo = isShowRed ? isHasStartAct[0] : {};
|
|
|
+ // if (activeIndex.current !== undefined && activeIndex.current !== null) {
|
|
|
+ // redInfo = isHasStartAct[activeIndex.current];
|
|
|
+ // }
|
|
|
+ // let curAct = isShowRedDetail ? findCurrentActivity(actList) : actList[0];
|
|
|
+ let iconList = JSON.parse(current.icon);
|
|
|
|
|
|
setIconLists(iconList);
|
|
|
+ setRedPacketInfo(current);
|
|
|
setIsShowRed(isShowRed);
|
|
|
setIsShowRedDetail(isShowRedDetail);
|
|
|
- setRedPacketInfo(redInfo);
|
|
|
} catch (error) {
|
|
|
console.log("redPacketInfo===>error:", error);
|
|
|
}
|