|
|
@@ -5,7 +5,7 @@ import {LOCAL_GAME_INFO, LOCAL_GAME_URL, LOCAL_SIGN} from "@constants/localkey";
|
|
|
import {localStorageGet, openFullScreen} from "@utils/helpers";
|
|
|
import React, {useEffect, useState} from "react";
|
|
|
import {useDispatch, useSelector} from "react-redux";
|
|
|
-import {getGameLike, getRoute, isLogined, updateGameLike} from "@features/mainSlice";
|
|
|
+import {getGameCardInfo, getGameLike, getRoute, isLogined, updateGameLike} from "@features/mainSlice";
|
|
|
import BreadCrumb from "@layout/BreadCrumb";
|
|
|
import {useThemeProvider} from "@contexts/themeContext";
|
|
|
import {getHallConnState} from "@features/socketSlice";
|
|
|
@@ -15,14 +15,16 @@ import SvgIcon from "@components/SvgIcon";
|
|
|
import useGameIFrame from "@hooks/useGameIFrame";
|
|
|
import MTooltip from "@components/MTooltip";
|
|
|
import {updatePageGameLike} from "@features/pageSlice";
|
|
|
-import {reqUpdateFavoInfo} from "@features/api";
|
|
|
+import {reqGameCardInfo, reqUpdateFavoInfo} from "@features/api";
|
|
|
import Popup from "@components/Popup";
|
|
|
+import LoadingIn from "@components/Loading/LoadingIn";
|
|
|
const i18n=global.i18n;
|
|
|
|
|
|
const WDGame=()=>{
|
|
|
// const {pathname}=useLocation();
|
|
|
const {preLocation,gameID} = useThemeProvider();
|
|
|
const gameid=gameID;
|
|
|
+ const gameCardInfo=useSelector(getGameCardInfo(gameid))
|
|
|
const [gameURL, setGameURL] = useState("");
|
|
|
const [gameInfo, setGameInfo] = useState({});
|
|
|
const prePathname=preLocation.pathname==null?"/casino":preLocation.pathname;
|
|
|
@@ -86,7 +88,9 @@ const WDGame=()=>{
|
|
|
const parseURL=()=>{
|
|
|
let key=LOCAL_GAME_URL+gameid;
|
|
|
let sign=localStorageGet(LOCAL_SIGN);
|
|
|
- let url=localStorageGet(key);
|
|
|
+ // let url=localStorageGet(key);
|
|
|
+ let url=gameCardInfo.link;
|
|
|
+ if (gameCardInfo.level>0)url+="&level="+gameCardInfo.level;
|
|
|
if (url==null)return;
|
|
|
if (url.indexOf("?")===-1)url=url+"?sign="+sign;
|
|
|
else url=url+"&sign="+sign;
|
|
|
@@ -94,13 +98,14 @@ const WDGame=()=>{
|
|
|
}
|
|
|
const parseInfo=()=>{
|
|
|
if (gameid==="")return;
|
|
|
- let local=localStorageGet(LOCAL_GAME_INFO+gameid);
|
|
|
- if (local!=null&&local!==""){
|
|
|
- let info=JSON.parse(local);
|
|
|
- if (info!=null){
|
|
|
- setGameInfo(info.data);
|
|
|
- }
|
|
|
- }
|
|
|
+ // let local=localStorageGet(LOCAL_GAME_INFO+gameid);
|
|
|
+ // if (local!=null&&local!==""){
|
|
|
+ // let info=JSON.parse(local);
|
|
|
+ // if (info!=null){
|
|
|
+ // setGameInfo(info.data);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ setGameInfo(gameCardInfo);
|
|
|
}
|
|
|
const getRouteChain=()=>{
|
|
|
let chain=[];
|
|
|
@@ -137,8 +142,9 @@ const WDGame=()=>{
|
|
|
if(isLogin)dispatch(reqUpdateFavoInfo(info));
|
|
|
}
|
|
|
useEffect(()=>{
|
|
|
- parseURL();
|
|
|
- parseInfo();
|
|
|
+ if (Number(gameid)>0&&gameCardInfo==null){
|
|
|
+ dispatch(reqGameCardInfo(gameid));
|
|
|
+ }
|
|
|
return ()=>{
|
|
|
}
|
|
|
},[gameid])
|
|
|
@@ -147,6 +153,12 @@ const WDGame=()=>{
|
|
|
setIsGameLoad(false);
|
|
|
}
|
|
|
},[isConnected])
|
|
|
+ useEffect(()=>{
|
|
|
+ if (gameCardInfo!=null){
|
|
|
+ parseURL();
|
|
|
+ parseInfo();
|
|
|
+ }
|
|
|
+ },gameCardInfo);
|
|
|
const renderTopNavBar=()=>{
|
|
|
let chain=getRouteChain();
|
|
|
let brand=gameInfo.brand?gameInfo.brand:"";
|
|
|
@@ -165,6 +177,7 @@ const WDGame=()=>{
|
|
|
if (gameInfo&&gameInfo.title!=null){
|
|
|
title=gameInfo.title;
|
|
|
}
|
|
|
+ let play_num=gameInfo.play_num!=null?gameInfo.play_num:0;
|
|
|
return (
|
|
|
<div className={`${styles.game_area} ${movieMode?styles.movie_mode:''}`}>
|
|
|
<div className={`${styles.game_action_wrap} ${styles.game_action_wrap_top}`}></div>
|
|
|
@@ -190,7 +203,9 @@ const WDGame=()=>{
|
|
|
<div className={styles.action_item_con}>
|
|
|
<button className={`${styles.action_item} ${isLike===1?styles.active_star:''}`} onClick={handleLike}>
|
|
|
<SvgIcon className={styles.icon} herf={"icon_Favorites1"}></SvgIcon>
|
|
|
- {38}
|
|
|
+ {
|
|
|
+ play_num>0?play_num:''
|
|
|
+ }
|
|
|
</button>
|
|
|
<button className={styles.action_item} onClick={()=>{
|
|
|
setOpenShare(true);
|
|
|
@@ -258,13 +273,19 @@ const WDGame=()=>{
|
|
|
)
|
|
|
}
|
|
|
return (
|
|
|
- <Spring type={"slideUp"}>
|
|
|
- <div className={`${styles.container} page-max-width-wrap`}>
|
|
|
- {renderTopNavBar()}
|
|
|
- {renderGame()}
|
|
|
- {renderShareBox()}
|
|
|
- </div>
|
|
|
- </Spring>
|
|
|
+ <>
|
|
|
+ {
|
|
|
+ gameCardInfo==null?<LoadingIn></LoadingIn>:(
|
|
|
+ <Spring type={"slideUp"}>
|
|
|
+ <div className={`${styles.container} page-max-width-wrap`}>
|
|
|
+ {renderTopNavBar()}
|
|
|
+ {renderGame()}
|
|
|
+ {renderShareBox()}
|
|
|
+ </div>
|
|
|
+ </Spring>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ </>
|
|
|
)
|
|
|
}
|
|
|
export default WDGame;
|