zhejiushizhuce 2 år sedan
förälder
incheckning
8dcb73cfab

+ 2 - 2
src/App.js

@@ -154,7 +154,7 @@ const App = () => {
         if (userID>0){
         if (userID>0){
             dispatch(connectHall(hallServerUrl));
             dispatch(connectHall(hallServerUrl));
             localStorageSet(LOCAL_WHEEL_INVITE_CODE,"");
             localStorageSet(LOCAL_WHEEL_INVITE_CODE,"");
-            localStorageSet(LOCAL_ACTIVITY_C,"");
+            // localStorageSet(LOCAL_ACTIVITY_C,"");
             //Mail红点屏蔽
             //Mail红点屏蔽
             dispatch(reqMailCheck());
             dispatch(reqMailCheck());
         }
         }
@@ -180,10 +180,10 @@ const App = () => {
     }
     }
     const appInitData=()=>{
     const appInitData=()=>{
         // scroll to top on route change
         // scroll to top on route change
+        checkInviteCode();
         loadFont();
         loadFont();
         //请求routes
         //请求routes
         startReqRoutes();
         startReqRoutes();
-        checkInviteCode();
         appRef.current && appRef.current.scrollTo(0, 0);
         appRef.current && appRef.current.scrollTo(0, 0);
         preventDefault();
         preventDefault();
         reProgressierInstallBanner();
         reProgressierInstallBanner();

+ 7 - 1
src/api/request.js

@@ -3,7 +3,7 @@
 import {BASE_API} from "./config";
 import {BASE_API} from "./config";
 import axios from "axios";
 import axios from "axios";
 import {getHttpMsg, localStorageGet} from "@utils/helpers";
 import {getHttpMsg, localStorageGet} from "@utils/helpers";
-import {LOCAL_SIGN} from "@constants/localkey";
+import {LOCAL_ACTIVITY_C, LOCAL_SIGN} from "@constants/localkey";
 import {toast} from "react-toastify";
 import {toast} from "react-toastify";
 import LZString, {compress, compressToEncodedURIComponent, compressToUTF16, decompressFromBase64} from "lz-string";
 import LZString, {compress, compressToEncodedURIComponent, compressToUTF16, decompressFromBase64} from "lz-string";
 
 
@@ -12,11 +12,17 @@ const getSign=()=>{
     const sign=localStorageGet(LOCAL_SIGN,"");
     const sign=localStorageGet(LOCAL_SIGN,"");
     return sign;
     return sign;
 }
 }
+const getC=()=>{
+    let c=localStorageGet(LOCAL_ACTIVITY_C,"");
+    return c;
+}
 const getComParams=()=>{
 const getComParams=()=>{
     let params={};
     let params={};
     if (global.BFP!=null)params.bfp=global.BFP;
     if (global.BFP!=null)params.bfp=global.BFP;
     let sign=getSign();
     let sign=getSign();
     if (sign!=null&&sign!="")params.sign=sign;
     if (sign!=null&&sign!="")params.sign=sign;
+    let c=getC();
+    if (c!=null&&c!=="")params.c=c;
     params.device=global.device;
     params.device=global.device;
     params.width=global.width;
     params.width=global.width;
     params.height=global.height;
     params.height=global.height;

+ 9 - 0
src/assets/singlesvg/xiai_bai.svg

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="1024px" height="1024px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <!-- Generator: Sketch 63.1 (92452) - https://sketch.com -->
+    <title>工具icon/Tool_m1/0045_xiai</title>
+    <desc>Created with Sketch.</desc>
+    <g id="工具icon/Tool_m1/0045_xiai" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" fill-opacity="1">
+        <path d="M889.719887,220.682425 C987.325728,330.70861 982.733326,498.493677 879.257805,602.918326 L534.727021,950.496397 C528.706993,956.589464 520.527484,960.009809 512,960.000034 C503.473963,960.012492 495.294658,956.595879 489.272979,950.506529 L144.742195,602.918326 C41.2666742,498.493677 36.6742718,330.70861 134.280113,220.682425 C231.885955,110.656241 397.688687,96.7169643 512,188.926966 C626.311313,96.7169643 792.114045,110.656241 889.719887,220.682425 Z M534.727021,255.340254 C522.177222,267.998348 501.832821,267.998348 489.283022,255.340254 C449.707883,215.194793 395.856708,192.691814 339.734608,192.847934 C254.194972,192.845922 177.077501,244.829364 144.343956,324.55711 C111.610412,404.284856 129.707551,496.054805 190.196236,557.072387 L512,881.722423 L833.803764,557.072387 C887.300457,503.189081 908.219947,424.595924 888.674843,350.925321 C869.12974,277.254719 812.092657,219.711225 739.068596,199.990776 C666.044535,180.270328 588.139717,201.372206 534.727021,255.340254 Z M383.015457,273.874035 C387.000093,286.834656 378.53038,300.244827 364.102598,303.824266 C278.791726,324.978578 228.549429,404.532023 252.09844,481.167633 C256.083076,494.128254 247.613364,507.538425 233.185582,511.117863 C230.758919,511.720091 228.322815,512 225.943364,512 C214.055551,512 203.149734,504.917462 199.835498,494.128254 C184.576797,444.465665 191.752919,392.436575 220.060832,347.625736 C248.359303,302.814898 294.390349,270.591469 349.674816,256.884425 C364.102598,253.304987 379.03082,260.913414 383.015457,273.874035 Z" id="形状" fill="#FFFFFF" fill-rule="nonzero"></path>
+    </g>
+</svg>

+ 15 - 0
src/assets/singlesvg/xiai_hong.svg

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="1024px" height="1024px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <!-- Generator: Sketch 63.1 (92452) - https://sketch.com -->
+    <title>工具icon/Tool_M/0049_xiai_hong</title>
+    <desc>Created with Sketch.</desc>
+    <defs>
+        <linearGradient x1="0%" y1="6.8877551%" x2="100%" y2="93.1122449%" id="linearGradient-1">
+            <stop stop-color="#FF7F7F" offset="0%"></stop>
+            <stop stop-color="#E00000" offset="100%"></stop>
+        </linearGradient>
+    </defs>
+    <g id="工具icon/Tool_M/0049_xiai_hong" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
+        <path d="M332.584149,128 C387.910938,128 443.248113,145.17786 489.96482,179.924443 C504.079538,190.427592 523.179588,190.6581 537.47087,180.415525 C642.193981,105.400189 788.253795,115.753007 881.780683,211.243471 C982.058541,314.240478 985.922172,480.436779 893.350806,587.993837 L887.787748,594.485645 L887.787748,594.485645 L542.96512,947.416012 C528.205425,962.524311 505.201238,964.027023 488.800215,951.931454 L483.598136,947.395968 L142.393769,597.715263 L133.492876,587.993837 L133.492876,587.993837 C37.9614692,480.446801 40.9215095,312.42648 142.393769,208.517462 C194.905923,154.738933 263.745036,128 332.584149,128 Z M394.034943,244.918639 C389.66512,229.096154 373.293818,219.807692 357.471333,224.177515 C296.842635,240.911243 246.361866,280.25 215.327842,334.955621 C184.283463,389.661243 176.413641,453.178994 193.147369,513.807692 C196.781984,526.97929 208.742043,535.62574 221.779025,535.62574 C224.388493,535.62574 227.060091,535.284024 229.721333,534.548817 C245.543818,530.178994 254.83228,513.807692 250.462457,497.985207 C224.637014,404.427515 279.736126,307.307692 373.293818,281.482249 C389.116304,277.112426 398.404765,260.741124 394.034943,244.918639 Z" id="形状" fill="url(#linearGradient-1)" fill-rule="nonzero"></path>
+    </g>
+</svg>

+ 14 - 0
src/components/GameItem/index.jsx

@@ -8,9 +8,15 @@ import {localStorageSet} from "@utils/helpers";
 import {LOCAL_GAME_URL} from "@constants/localkey";
 import {LOCAL_GAME_URL} from "@constants/localkey";
 import Imgix from "@components/Imgix";
 import Imgix from "@components/Imgix";
 import LazyImgix from "@components/Imgix/LazyImgix";
 import LazyImgix from "@components/Imgix/LazyImgix";
+import {ReactComponent as UNLikeIcon} from "@assets/singlesvg/xiai_bai.svg";
+import {ReactComponent as LikeIcon} from "@assets/singlesvg/xiai_hong.svg";
+import {useDispatch, useSelector} from "react-redux";
+import {getGameLike, updateGameLike} from "@features/mainSlice";
 
 
 const GameItem=({data,handleRoom,...props})=>{
 const GameItem=({data,handleRoom,...props})=>{
     const navigate=useNavigate();
     const navigate=useNavigate();
+    const like=useSelector(getGameLike(data.id));
+    const dispatch=useDispatch();
     const renderOlicon=()=>{
     const renderOlicon=()=>{
         return (
         return (
             <svg xmlns="http://www.w3.org/2000/svg" width="9" height="10" viewBox="0 0 9 10" fill="none"><path d="M7.78243 7.00126C7.98931 8.18376 7.16525 9.0422 6.01681 9.23532C4.90775 9.42188 3.09993 9.42188 1.99087 9.23532C0.842435 9.04251 0.0183723 8.18438 0.225247 7.00157C0.400872 5.99813 1.25118 5.37282 2.28993 5.42657C3.04868 5.46594 3.51493 5.56469 4.05462 5.56469C4.60056 5.56469 4.96431 5.46594 5.71743 5.42657C6.75587 5.37219 7.60712 5.99782 7.78243 7.00126ZM3.86275 0.907195C4.95368 0.907195 5.83837 1.79157 5.83837 2.88313C5.83837 3.9747 4.95368 4.85907 3.86275 4.85907C2.7715 4.85907 1.88681 3.97438 1.88681 2.88313C1.88681 1.79188 2.7715 0.907195 3.86275 0.907195Z" fill="url(#paint0_linear_451_3515)"></path><path d="M7.42806 5.14407C7.95931 5.2425 8.59868 5.525 8.85493 6.28813C9.09181 6.99375 8.81275 7.54688 8.49493 7.91282C8.39368 8.02938 8.19087 7.92813 8.24118 7.78532C8.37181 7.41594 8.42431 6.94407 8.21993 6.42157C8.02118 5.91313 7.65337 5.59282 7.31962 5.39563C7.18025 5.31344 7.26681 5.11407 7.42806 5.14407ZM5.63118 0.938442C5.47243 0.825317 5.58681 0.582817 5.77868 0.631255C5.98087 0.682192 6.189 0.761567 6.38306 0.883442C7.02337 1.28657 7.33993 1.99969 7.22712 2.79188C7.17462 3.16157 7.01056 3.44907 6.82587 3.66625C6.70431 3.80969 6.46431 3.69032 6.51431 3.51157C6.63181 3.09219 6.6665 2.55657 6.44056 1.96813C6.25431 1.48344 5.93587 1.15625 5.63118 0.938442Z" fill="#26AB4B"></path><defs><linearGradient id="paint0_linear_451_3515" x1="5.21662" y1="0.333274" x2="5.21662" y2="9.37524" gradientUnits="userSpaceOnUse"><stop stop-color="#85F25E"></stop><stop offset="1" stop-color="#33EF00"></stop></linearGradient></defs></svg>
             <svg xmlns="http://www.w3.org/2000/svg" width="9" height="10" viewBox="0 0 9 10" fill="none"><path d="M7.78243 7.00126C7.98931 8.18376 7.16525 9.0422 6.01681 9.23532C4.90775 9.42188 3.09993 9.42188 1.99087 9.23532C0.842435 9.04251 0.0183723 8.18438 0.225247 7.00157C0.400872 5.99813 1.25118 5.37282 2.28993 5.42657C3.04868 5.46594 3.51493 5.56469 4.05462 5.56469C4.60056 5.56469 4.96431 5.46594 5.71743 5.42657C6.75587 5.37219 7.60712 5.99782 7.78243 7.00126ZM3.86275 0.907195C4.95368 0.907195 5.83837 1.79157 5.83837 2.88313C5.83837 3.9747 4.95368 4.85907 3.86275 4.85907C2.7715 4.85907 1.88681 3.97438 1.88681 2.88313C1.88681 1.79188 2.7715 0.907195 3.86275 0.907195Z" fill="url(#paint0_linear_451_3515)"></path><path d="M7.42806 5.14407C7.95931 5.2425 8.59868 5.525 8.85493 6.28813C9.09181 6.99375 8.81275 7.54688 8.49493 7.91282C8.39368 8.02938 8.19087 7.92813 8.24118 7.78532C8.37181 7.41594 8.42431 6.94407 8.21993 6.42157C8.02118 5.91313 7.65337 5.59282 7.31962 5.39563C7.18025 5.31344 7.26681 5.11407 7.42806 5.14407ZM5.63118 0.938442C5.47243 0.825317 5.58681 0.582817 5.77868 0.631255C5.98087 0.682192 6.189 0.761567 6.38306 0.883442C7.02337 1.28657 7.33993 1.99969 7.22712 2.79188C7.17462 3.16157 7.01056 3.44907 6.82587 3.66625C6.70431 3.80969 6.46431 3.69032 6.51431 3.51157C6.63181 3.09219 6.6665 2.55657 6.44056 1.96813C6.25431 1.48344 5.93587 1.15625 5.63118 0.938442Z" fill="#26AB4B"></path><defs><linearGradient id="paint0_linear_451_3515" x1="5.21662" y1="0.333274" x2="5.21662" y2="9.37524" gradientUnits="userSpaceOnUse"><stop stop-color="#85F25E"></stop><stop offset="1" stop-color="#33EF00"></stop></linearGradient></defs></svg>
@@ -51,6 +57,9 @@ const GameItem=({data,handleRoom,...props})=>{
             else onEnterGame();
             else onEnterGame();
         }
         }
     }
     }
+    const handleLike=()=>{
+        dispatch(updateGameLike({id:data.id,like:(1-like)}));
+    }
     // return (
     // return (
     //     <div className={styles.grid_item}>
     //     <div className={styles.grid_item}>
     //         <button onClick={()=>{
     //         <button onClick={()=>{
@@ -99,6 +108,11 @@ const GameItem=({data,handleRoom,...props})=>{
                 {/*<Imgix className={`lazyload ${styles.game_img}`} src={data.img} alt={"game-icon"} width={192}></Imgix>*/}
                 {/*<Imgix className={`lazyload ${styles.game_img}`} src={data.img} alt={"game-icon"} width={192}></Imgix>*/}
                 <LazyImgix className={`lazyload ${styles.game_img}`} src={data.img} alt={"game-icon"} width={384}></LazyImgix>
                 <LazyImgix className={`lazyload ${styles.game_img}`} src={data.img} alt={"game-icon"} width={384}></LazyImgix>
             </button>
             </button>
+            <button className={styles.favorite_con} onClick={handleLike}>
+                {
+                    like?(<LikeIcon></LikeIcon>):(<UNLikeIcon></UNLikeIcon>)
+                }
+            </button>
         </div>
         </div>
     )
     )
 }
 }

+ 15 - 0
src/components/GameItem/styles.module.scss

@@ -72,4 +72,19 @@
       }
       }
     }
     }
   }
   }
+  & .favorite_con{
+    position: absolute;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    top: .27rem;
+    right: .34rem;
+    border-radius: 50%;
+    background: rgba(0, 0, 0, 0.65);
+    padding: 0.25rem;
+    svg{
+      width: 1.2rem;
+      height: 1.2rem;
+    }
+  }
 }
 }

+ 4 - 4
src/features/api.js

@@ -130,10 +130,10 @@ export const reqRegister=createAsyncThunk(
         if (act!=null&&act!==""){
         if (act!=null&&act!==""){
             data["act"]=act;
             data["act"]=act;
         }
         }
-        let c=localStorageGet(LOCAL_ACTIVITY_C);
-        if (c!=null&&c!==""){
-            data["c"]=c;
-        }
+        // let c=localStorageGet(LOCAL_ACTIVITY_C);
+        // if (c!=null&&c!==""){
+        //     data["c"]=c;
+        // }
         let params={
         let params={
             url:APP_REGISTER,
             url:APP_REGISTER,
             data:data
             data:data

+ 31 - 2
src/features/mainSlice.js

@@ -355,7 +355,8 @@ export const Main=createSlice({
         customLeaveMsgStatus:REQ_STATUS.NONE,
         customLeaveMsgStatus:REQ_STATUS.NONE,
         customServiceStatus:REQ_STATUS.NONE,
         customServiceStatus:REQ_STATUS.NONE,
         customerInfo:[],
         customerInfo:[],
-        hallServerUrl:''
+        hallServerUrl:'',
+        favorites:[]
     },
     },
     reducers: {
     reducers: {
         logout:(state, action)=>{
         logout:(state, action)=>{
@@ -378,6 +379,26 @@ export const Main=createSlice({
             if (score!=null){
             if (score!=null){
                 if(state.userInfo)state.userInfo.Score=state.userInfo.Score+Number(score);
                 if(state.userInfo)state.userInfo.Score=state.userInfo.Score+Number(score);
             }
             }
+        },
+        updateGameLike:(state, action)=>{
+            let payload=action.payload;
+            let id=payload.id;
+            let like=payload.like;
+            let favorites=state.favorites;
+            let index=favorites.indexOf(id);
+            if (like){
+                if (index===-1){
+                    favorites.push(id);
+                    state.favorites=favorites;
+                }
+            }
+            else {
+                let index=favorites.indexOf(id);
+                if (index!==-1){
+                    favorites.splice(index,1);
+                    state.favorites=favorites;
+                }
+            }
         }
         }
     },
     },
     extraReducers: (builder) => {
     extraReducers: (builder) => {
@@ -396,7 +417,7 @@ export const Main=createSlice({
         buildReqReducer(builder,reqCustomLeaveMsg,reducerCustomLeaveMsg,customLeaveMsgStatus);
         buildReqReducer(builder,reqCustomLeaveMsg,reducerCustomLeaveMsg,customLeaveMsgStatus);
     },
     },
 })
 })
-export const {logout,updateUserInfo,updateUserScore,updateAddScore} = Main.actions;
+export const {logout,updateUserInfo,updateUserScore,updateAddScore,updateGameLike} = Main.actions;
 //数据获取
 //数据获取
 export const getFetchStatus=(state)=>{
 export const getFetchStatus=(state)=>{
     return state.main.status;
     return state.main.status;
@@ -551,6 +572,14 @@ export const getCustomServiceStatus=(state)=>{
 export const getHallServerUrl=(state)=>{
 export const getHallServerUrl=(state)=>{
     return state.main.hallServerUrl;
     return state.main.hallServerUrl;
 }
 }
+export const getGameLikes=(state)=>{
+    return state.main.favorites;
+}
+export const getGameLike=(id)=>(state)=>{
+    let favorites=state.main.favorites;
+    if (favorites.includes(id))return 1;
+    return 0;
+}
 //数据获取
 //数据获取
 export default Main.reducer;
 export default Main.reducer;
 
 

+ 2 - 1
src/features/pageSlice.js

@@ -53,7 +53,8 @@ export const Page=createSlice({
     name: 'page',
     name: 'page',
     initialState: {
     initialState: {
         status:REQ_STATUS.NONE,
         status:REQ_STATUS.NONE,
-        pageData:{}
+        pageData:{},
+        favoriteKeys:[]
     },
     },
     reducers: {
     reducers: {
         updateGameList:((state, action) => {
         updateGameList:((state, action) => {

+ 13 - 4
src/widgets/ModuleGameSmallList/index.jsx

@@ -7,12 +7,21 @@ import {getUserInfo} from "@features/mainSlice";
 const ModuleGameSmallList=({data})=>{
 const ModuleGameSmallList=({data})=>{
     const {isMobile} = useThemeProvider();
     const {isMobile} = useThemeProvider();
     const user=useSelector(getUserInfo);
     const user=useSelector(getUserInfo);
+    let list=data.data;
+    let len=list!=null&&list.length>0?list.length:0;
     return (
     return (
-        <div className={``}>
-            <GameSmallList data={data} user={user}>
+        <>
+            {
+                len>0?(
+                    <div className={``}>
+                        <GameSmallList data={data} user={user}>
+
+                        </GameSmallList>
+                    </div>
+                ):(<></>)
+            }
+        </>
 
 
-            </GameSmallList>
-        </div>
     )
     )
 }
 }
 export default ModuleGameSmallList;
 export default ModuleGameSmallList;