zhejiushizhuce 2 лет назад
Родитель
Сommit
6fa11e426f
2 измененных файлов с 35 добавлено и 5 удалено
  1. 24 2
      src/App.js
  2. 11 3
      src/widgets/WCheckIn/index.jsx

+ 24 - 2
src/App.js

@@ -48,7 +48,7 @@ import {
     getUserID,
     getUserInfo,
     isLogined,
-    updateCurrGame, updateOpenPay, getIsGuest, getPopBindPhone
+    updateCurrGame, updateOpenPay, getIsGuest, getPopBindPhone, getPopFirst
 } from '@features/mainSlice';
 import {useDispatch, useSelector} from "react-redux";
 import {REQ_STATUS} from "@api/config";
@@ -63,7 +63,7 @@ import {
 } from "@features/api";
 import LoadingScreen from "@components/LoadingScreen";
 import DropCoins from "@components/DropCoins";
-import {reqPayConfig} from "@features/paySlice";
+import {getFirstPayMulti, reqPayConfig} from "@features/paySlice";
 import {connectHall, disconnectHall, hallSendState} from "@features/actions/hallClient";
 import {toast} from "react-toastify";
 import {useBlocker} from "react-router";
@@ -110,6 +110,8 @@ const App = () => {
     const [isMaintain, setIsMaintain] = useState(false);
     //是否唤起选择area
     const [isSelectArea, setIsSelectArea] = useState(false);
+    const popFirst=useSelector(getPopFirst);
+    const firstPayMulti=useSelector(getFirstPayMulti);
     const muiTheme = createTheme({
         direction: direction,
     });
@@ -225,6 +227,19 @@ const App = () => {
         SoundHelp.loadAllAudioFile();
         // preventTouchMove();
     }
+    const checkFirstPay=()=>{
+        if (!popFirst)return;
+        if (firstPayMulti==null)return;
+        let key="first_open_time";
+        let now=Date.now();
+        let lst=Number(localStorageGet(key,0));
+        let delta=now-lst;
+        if (delta<86400000){
+            return false;
+        }
+        global.showFirstPay();
+        localStorageSet(key,Date.now());
+    }
     const checkOpenCheckin=()=>{
         if (userID>0){
             if (pathname==="/"){
@@ -234,20 +249,27 @@ const App = () => {
                     let lst=Number(localStorageGet(key,0));
                     let delta=now-lst;
                     if (delta<86400000){
+                        checkFirstPay();
                         return false;
                     }
                     dispatch(reqCheckinCheck((isCanCheckIn)=>{
+                        let is_check_first=true;
                         if(hash==null||hash===""){
                             if(isCanCheckIn===1){
                                 navigate(ROUTE_PATH.CHECK_IN,{replace:true});
                                 localStorageSet(key,Date.now());
+                                is_check_first=false;
                             }
                         }
+                        if (is_check_first){
+                            checkFirstPay();
+                        }
                     }));
                     return true;
                 }
             }
         }
+        checkFirstPay();
         return false;
     }
     const onCloseHallWheel=()=>{

+ 11 - 3
src/widgets/WCheckIn/index.jsx

@@ -11,7 +11,7 @@ import {ROUTE_PATH} from "@constants/routes";
 import {reqCheckinCheck, reqCheckinGet, reqRedpackCheck} from "@features/api";
 import {REQ_STATUS} from "@api/config";
 import SmallLoading from "@components/SmallLoading";
-import {formatTime} from "@utils/helpers";
+import {formatTime, localStorageGet, localStorageSet} from "@utils/helpers";
 import {getPopFirst} from "@features/mainSlice";
 import {getFirstPayMulti} from "@features/paySlice";
 const i18n=global.i18n;
@@ -94,11 +94,20 @@ const WCheckIn = ({close}) => {
     const checkFirstPay=()=>{
         if (!popFirst)return;
         if (firstPayMulti==null)return;
+        let key="first_open_time";
+        let now=Date.now();
+        let lst=Number(localStorageGet(key,0));
+        let delta=now-lst;
+        if (delta<86400000){
+            return false;
+        }
         global.showFirstPay();
+        localStorageSet(key,Date.now());
     }
     const onClose=()=>{
         setOpen(false);
         if(close)close();
+        checkFirstPay();
     }
     const onOpenPay=()=>{
         navigate("/"+ROUTE_PATH.PAY,{replace:true})
@@ -106,8 +115,7 @@ const WCheckIn = ({close}) => {
     const onCheckInCB=(payload)=>{
         if (payload&&payload.code===200){
             global.showDropCoins();
-            close();
-            checkFirstPay();
+            onClose();
         }
         // else if (payload&&payload.code===301)
         // {