Przeglądaj źródła

监听 code 777 打开充值

zhejiushizhuce 2 lat temu
rodzic
commit
e1e1887287
3 zmienionych plików z 26 dodań i 4 usunięć
  1. 10 2
      src/App.js
  2. 7 0
      src/api/request.js
  3. 9 2
      src/features/mainSlice.js

+ 10 - 2
src/App.js

@@ -44,11 +44,11 @@ import Layout from "@layout/Layout";
 import {
     getBFP,
     getFetchStatus,
-    getHallServerUrl, getKickState, getPromoteInstall,
+    getHallServerUrl, getKickState, getOpenPay, getPromoteInstall,
     getUserID,
     getUserInfo,
     isLogined,
-    updateCurrGame
+    updateCurrGame, updateOpenPay
 } from '@features/mainSlice';
 import {useDispatch, useSelector} from "react-redux";
 import {REQ_STATUS} from "@api/config";
@@ -97,6 +97,7 @@ const App = () => {
     const {preLocation,gameID}=usePreviousRoute();
     const serverKick=useSelector(getKickState);
     const promoteInstall=useSelector(getPromoteInstall);
+    const openPay=useSelector(getOpenPay);
     const muiTheme = createTheme({
         direction: direction,
     });
@@ -287,6 +288,13 @@ const App = () => {
             },time);
         }
     },[promoteInstall])
+    //监听打开pay
+    useEffect(()=>{
+        if (openPay===1){
+            navigate(ROUTE_PATH.PAY,{replace:true});
+            dispatch(updateOpenPay(0));
+        }
+    },[openPay])
     //app Effect
 
     const renderLayout=()=>{

+ 7 - 0
src/api/request.js

@@ -38,6 +38,13 @@ const checkResponse=(data)=>{
                 }
             });
         }
+        else if (data.code===777){
+            let action={
+                type:"main/updateOpenPay",
+                payload:1,
+            }
+            if (global.dispatch)global.dispatch(action);
+        }
     }
 }
 const service = axios.create({

+ 9 - 2
src/features/mainSlice.js

@@ -418,7 +418,8 @@ export const Main=createSlice({
         favorites:[],
         gameID:0,
         serverKick:0,
-        promoteInstall:0
+        promoteInstall:0,
+        openPay:0
     },
     reducers: {
         logout:(state, action)=>{
@@ -471,6 +472,9 @@ export const Main=createSlice({
         },
         updateServerKick:(state,action)=>{
             state.serverKick=action.payload;
+        },
+        updateOpenPay:(state,action)=>{
+            state.openPay=action.payload;
         }
     },
     extraReducers: (builder) => {
@@ -491,7 +495,7 @@ export const Main=createSlice({
         buildReqReducer(builder,reqFavoGet,reducerFavoGet,null);
     },
 })
-export const {logout,updateUserInfo,updateUserScore,updateAddScore,updateGameLike,updateCurrGame,updateServerKick} = Main.actions;
+export const {logout,updateUserInfo,updateUserScore,updateAddScore,updateGameLike,updateCurrGame,updateServerKick,updateOpenPay} = Main.actions;
 //数据获取
 export const getFetchStatus=(state)=>{
     return state.main.status;
@@ -660,6 +664,9 @@ export const getKickState=(state)=>{
 export const getPromoteInstall=(state)=>{
     return state.main.promoteInstall;
 }
+export const getOpenPay=(state)=>{
+    return state.main.openPay;
+}
 //数据获取
 export default Main.reducer;