zhejiushizhuce 2 жил өмнө
parent
commit
455a0b9007

+ 2 - 0
src/App.js

@@ -119,6 +119,8 @@ const App = () => {
             dispatch(reqWithdrawBaseInfo());
             //turnplate
             // dispatch(reqTurnplateIndex());
+            //rest code
+            localStorageSet(LOCAL_WHEEL_INVITE_CODE,"")
         }
         else
         {

+ 2 - 0
src/api/config.js

@@ -55,3 +55,5 @@ export const APP_CUSTOMER_LEAVEMSG="api/user/message";
 export const APP_TURNPLATE_INDEX=BASE_PREFIX+"turnplate/index";
 export const APP_TURNPLATE_KAN=BASE_PREFIX+"turnplate/kan";
 export const APP_TURNPLATE_BONUS=BASE_PREFIX+"turnplate/bonus";
+//帮别人砍
+export const APP_TURNPLATE_HELP=BASE_PREFIX+"turnplate/help";

+ 2 - 0
src/components/SmallLoading/styles.module.scss

@@ -6,6 +6,8 @@
   flex: 1;
   height: 100%;
   width: 100%;
+  min-width: 6rem;
+  min-height: 1.4rem;
   //align-self: stretch;
   box-sizing: border-box;
   svg{

+ 22 - 7
src/features/api.js

@@ -16,7 +16,7 @@ import {
     APP_PAYMENT_ORDER,
     APP_RECHARGE_CONFIG,
     APP_REGISTER,
-    APP_ROUTES, APP_TURNPLATE_BONUS, APP_TURNPLATE_INDEX, APP_TURNPLATE_KAN,
+    APP_ROUTES, APP_TURNPLATE_BONUS, APP_TURNPLATE_HELP, APP_TURNPLATE_INDEX, APP_TURNPLATE_KAN,
     APP_WITHDRAW_BASE_INFO,
     APP_WITHDRAW_INFO,
     APP_WITHDRAW_TAX,
@@ -365,16 +365,13 @@ export const reqTurnplateIndex=createAsyncThunk(
 export const reqTurnplateKan=createAsyncThunk(
     APP_TURNPLATE_KAN,
     async (arg,thunkAPI)=>{
-        let act=localStorageGet(LOCAL_WHEEL_INVITE_CODE);
+        // let act=localStorageGet(LOCAL_WHEEL_INVITE_CODE);
         let params={
             url:APP_TURNPLATE_KAN
         }
-        if (act!=null&&act!==""){
-            params.params={
-                act:act
-            }
-        }
+        let ishelp=false;
         const response=await Http.get(params);
+        response.ishelp=ishelp;
         return response;
     }
 )
@@ -385,6 +382,24 @@ export const reqTurnplateBonus=createAsyncThunk(
             url:APP_TURNPLATE_BONUS
         }
         const response=await Http.get(params);
+        if (response&&response.code===200){
+            thunkAPI.dispatch(reqGameInfo());
+            thunkAPI.dispatch(reqTurnplateIndex());
+        }
+        return response;
+    }
+)
+export const reqTurnplateHelp=createAsyncThunk(
+    APP_TURNPLATE_HELP,
+    async (arg,thunkAPI)=>{
+        let act=localStorageGet(LOCAL_WHEEL_INVITE_CODE);
+        let params={
+            url:APP_TURNPLATE_HELP,
+            params:{
+                act:act
+            }
+        }
+        const response=await Http.get(params);
         return response;
     }
 )

+ 57 - 5
src/features/turnplateSlice.js

@@ -1,6 +1,15 @@
 import {createSlice} from "@reduxjs/toolkit";
-import {buildReqReducer, reqGameList, reqTurnplateBonus, reqTurnplateIndex, reqTurnplateKan} from "@features/api";
+import {
+    buildReqReducer,
+    reqGameList,
+    reqTurnplateBonus,
+    reqTurnplateHelp,
+    reqTurnplateIndex,
+    reqTurnplateKan
+} from "@features/api";
 import {REQ_STATUS} from "@api/config";
+import {getHttpMsg} from "@utils/helpers";
+import {toast} from "react-toastify";
 const reducerTurnplateIndex=(state,action,arg)=>{
     let payload=action.payload;
     if (payload&&payload.code===200){
@@ -27,9 +36,17 @@ const reducerTurnplateKan=(state,action,arg)=>{
     //     "msg": "success",
     //     "code": 200
     // }
+    let callback=arg;
     if (payload&&payload.code===200){
-        let callback=arg;
-        if (callback)callback(payload.data);
+        if (callback)callback(payload.data,payload.code);
+    }
+    else
+    {
+        let msg=getHttpMsg(payload);
+        if (msg!=null&&msg!==""){
+            toast.error(msg);
+        }
+        if (callback)callback(payload.data,payload.code);
     }
 }
 const turnplateKanStatus=(state,status,arg)=>{
@@ -37,13 +54,40 @@ const turnplateKanStatus=(state,status,arg)=>{
 }
 const reducerTurnplateBonus=(state,action,arg)=>{
     let payload=action.payload;
+    let msg=getHttpMsg(payload);
     if (payload&&payload.code===200){
-
+        if (msg!=null&&msg!==""){
+            toast.success(msg);
+        }
+    }
+    else {
+        if (msg!=null&&msg!==""){
+            toast.error(msg);
+        }
     }
 }
 const turnplateBonusStatus=(state,status,arg)=>{
     state.status.TURNPLATE_BONUS=status;
 }
+const reducerTurnplateHelp=(state,action,arg)=>{
+    let payload=action.payload;
+    let callback=arg;
+    let msg=getHttpMsg(payload);
+    if (payload&&payload.code===200){
+        if (callback)callback(payload.data);
+        if (msg!=null&&msg!==""){
+            toast.success(msg);
+        }
+    }
+    else
+    {
+        if (msg!=null&&msg!==""){
+            toast.error(msg);
+        }
+        if (callback)callback(payload.data);
+    }
+    state.helpdone=true;
+}
 export const Turnplate=createSlice({
     name: 'turnplate',
     initialState: {
@@ -55,7 +99,8 @@ export const Turnplate=createSlice({
         status:{
             TURNPLATE_KAN:REQ_STATUS.NONE,
             TURNPLATE_BONUS:REQ_STATUS.NONE
-        }
+        },
+        helpdone:false
     },
     reducers: {
         updateTimes:((state, action) => {
@@ -77,6 +122,7 @@ export const Turnplate=createSlice({
         buildReqReducer(builder,reqTurnplateIndex,reducerTurnplateIndex,null);
         buildReqReducer(builder,reqTurnplateKan,reducerTurnplateKan,turnplateKanStatus);
         buildReqReducer(builder,reqTurnplateBonus,reducerTurnplateBonus,turnplateBonusStatus);
+        buildReqReducer(builder,reqTurnplateHelp,reducerTurnplateHelp,null);
     },
 })
 export const {updateTimes,updateCollect} = Turnplate.actions;
@@ -98,6 +144,9 @@ export const getTotalAmount=(state)=>{
     }
     else return 0;
 }
+export const getIsHelp=(state)=>{
+    return state.turnplate.helpdone;
+}
 export const getNumbers=(state)=>{
     if (state.turnplate.numbers){
         let numbers=state.turnplate.numbers;
@@ -112,4 +161,7 @@ export const getNumbers=(state)=>{
     }
     return [];
 }
+export const getBonusStatus=(state)=>{
+    return state.turnplate.status.TURNPLATE_BONUS;
+}
 export default Turnplate.reducer;

+ 2 - 36
src/layout/Navbar/index.jsx

@@ -248,40 +248,6 @@ const PageHeader = () => {
     const {isMobile,showHeader,setShowHeader} = useThemeProvider();
     const [showMHeader, setShowMHeader] = useState(true);
     let lastscroll=0;
-    //body node
-    const bodyNode = document.body;
-    // 配置观察器选项
-    const config = { childList: true, subtree: true }; // 观察子节点的变化,并包括子树中的所有节点
-
-// 创建一个 MutationObserver 实例并传入回调函数
-    const observer = new MutationObserver((mutationsList, observer) => {
-        // 迭代每一个变化
-        for(const mutation of mutationsList) {
-            if (mutation.type === 'childList') {
-                // 如果是子节点变化
-                mutation.addedNodes.forEach(node => {
-                    // console.log('一个节点被添加到了 body 中。');
-                    // 这里可以进行相应的操作
-                    // if (node.className==="progressier-install-banner"){
-                    //     const root = document.querySelector('#root');
-                    //     if (root){
-                    //         root.classList.add("progressier_bar_open");
-                    //     }
-                    // }
-                });
-                mutation.removedNodes.forEach(node => {
-                    // console.log('一个节点从 body 中移除了。');
-                    // 这里可以进行相应的操作
-                    // if (node.className==="progressier-install-banner"){
-                    //     const root = document.querySelector('#root');
-                    //     if (root){
-                    //         root.classList.remove("progressier_bar_open");
-                    //     }
-                    // }
-                });
-            }
-        }
-    });
 
     const checkNavActive=(lv)=>{
         if (currRoute&&currRoute.lv)return currRoute.lv.startsWith(lv);
@@ -324,7 +290,8 @@ const PageHeader = () => {
         // 这里的代码会在组件挂载时执行
         // console.log('Component mounted');
         window.addEventListener('scroll', handleScroll);
-        observer.observe(bodyNode, config);
+        // console.log("ProgressierInstallBannerProgressierInstallBanner");
+        // console.log(window.ProgressierInstallBanner)
         if (barRef.current) {
             resizeObserver.observe(barRef.current);
         }
@@ -335,7 +302,6 @@ const PageHeader = () => {
             if (barRef.current) {
                 resizeObserver.unobserve(barRef.current);
             }
-            observer.disconnect();
         };
     }, []);
     // }, [pathname]);

+ 3 - 0
src/layout/Routes/index.jsx

@@ -61,6 +61,9 @@ const CHashRouter=(props)=>{
     const navigate = useNavigate()
     //多hash 切到最后一个
     let {pathname,hash,search}=hlocation;
+    if (hash!=null){
+        hash=hash.split("?").shift();
+    }
     let paths=pathname.split("#");
     pathname=paths.shift();
     let hashs=hash.split("#");

+ 5 - 1
src/widgets/WCashWheel/WCashWheelHeader.jsx

@@ -8,6 +8,8 @@ import WShare from "@widgets/WCashWheel/WShare/WShare";
 import {getTurnplate} from "@features/turnplateSlice";
 import {localStorageGet, localStorageSet} from "@utils/helpers";
 import {LOCAL_WHEEL_RETAIN} from "@constants/localkey";
+import {ROUTE_PATH} from "@constants/routes";
+import {useNavigate} from "react-router";
 const i18n=global.i18n;
 const WCashWheelHeader=({...props})=>{
     const route=props.route;
@@ -17,6 +19,7 @@ const WCashWheelHeader=({...props})=>{
     const turnplate=useSelector(getTurnplate);
     const [openRetain,setOpenRetain]=useState(false);
     const [openShare,setOpenShare]=useState(false);
+    const navigate=useNavigate();
     const onCheckClose=()=>{
         let isclose=true;
         if (isLogin){
@@ -36,7 +39,8 @@ const WCashWheelHeader=({...props})=>{
             }
         }
         if (isclose){
-            close();
+            // close();
+            navigate("",{replace:true});
         }
     }
     const renderHeader=()=>{

+ 66 - 19
src/widgets/WCashWheel/WWheel/WWheel.jsx

@@ -13,16 +13,17 @@ import spin_4 from "@assets/wheel/spin-4.png";
 import spin_5 from "@assets/wheel/spin-5.png";
 import draw from "@assets/wheel/draw.png";
 import {useDispatch, useSelector} from "react-redux";
-import {getTurnplate, updateCollect, updateTimes} from "@features/turnplateSlice";
-import {formatCash, formatTime} from "@utils/helpers";
+import {getIsHelp, getTurnplate, updateCollect, updateTimes} from "@features/turnplateSlice";
+import {formatCash, formatTime, localStorageGet} from "@utils/helpers";
 import SvgIcon from "@components/SvgIcon";
 import {ReactComponent as ShareIcon} from '@assets/singlesvg/share.svg';
 import {isLogined} from "@features/mainSlice";
 import {useNavigate} from "react-router";
 import {ROUTE_PATH} from "@constants/routes";
-import {reqTurnplateKan} from "@features/api";
+import {reqTurnplateHelp, reqTurnplateKan} from "@features/api";
 import CountUp from "react-countup";
 import WPopInfo from "@widgets/WCashWheel/WPopInfo/WPopInfo";
+import {LOCAL_WHEEL_INVITE_CODE} from "@constants/localkey";
 const i18n=global.i18n;
 const spinImgSrc=[
     null,
@@ -43,7 +44,8 @@ const turnObj={
     result:null,
     resTimer:null,
     flashTimer:null,
-    resetTimer:null
+    resetTimer:null,
+    ishelp:false
 };
 const WWheel=({openShare,showShare=true,onClose=null})=>{
     let turnplate=useSelector(getTurnplate);
@@ -73,6 +75,7 @@ const WWheel=({openShare,showShare=true,onClose=null})=>{
     const [collect,setCollect]=useState(0);
     const [isLock,setIsLock]=useState(false);
     const [openPopInfo,setOpenPopInfo]=useState(false);
+    const isHelpdone=useSelector(getIsHelp);
     const loadImgs=()=>{
         let totalCount=spinImgSrc.length;
         let loadedCount=0;
@@ -120,15 +123,31 @@ const WWheel=({openShare,showShare=true,onClose=null})=>{
             },1000);
         }
     }
-    const onTurnResult=(data)=>{
+    const onTurnResult=(data,code=200)=>{
+        if (code!==200){
+            resetWheel(0);
+            return;
+        }
+        let type=data.type;
+        let curr_amount=turnplate.collect_amount;
         let collect_amount=data.collect_amount;
-        let ids=[0,4];
-        let index=Math.floor(Math.random()*ids.length);
-        let id=ids[index];
+        let change=(collect_amount-curr_amount);
+        let id=-1;
+        if (type===1){
+            id=5;
+        }
+        else if (type===2){
+            let ids=[0,4];
+            let index=Math.floor(Math.random()*ids.length);
+            id=ids[index];
+        }
         turnObj.result={
+            type:type,
             reward:id,
-            amount:collect_amount
+            amount:collect_amount,
+            change:change
         };
+        // turnObj.ishelp=ishelp;
     }
     const startSpin=()=>{
         // if (!isLogin){
@@ -195,7 +214,7 @@ const WWheel=({openShare,showShare=true,onClose=null})=>{
             transition:`transform ${stopduring}s cubic-bezier(0.250, 0.460, 0.455, 0.995)`,
         };
         setDrawStyle(roteStyle);
-        playRes();
+        playRes(angle);
     }
     const flashDraw=()=>{
         let show=false;
@@ -205,14 +224,19 @@ const WWheel=({openShare,showShare=true,onClose=null})=>{
             drawWheel(result)
         },260)
     }
-    const playRes=()=>{
+    const playRes=(angle=0)=>{
         clearResTimer();
         let during=(stopduring+0.5)*1000;
         turnObj.resTimer=setTimeout(()=>{
             flashDraw();
-            setCollect(turnObj.result.amount);
-            startReset();
-            dispatch(updateCollect({collect_amount:turnObj.result.amount}))
+            if (turnObj.result.type===2){
+                setCollect(turnObj.result.change);
+            }
+            else if (turnObj.result.type===1){
+
+            }
+            if(!turnObj.ishelp)dispatch(updateCollect({collect_amount:turnObj.result.amount}))
+            startReset(angle);
         },during)
     }
     // const
@@ -226,23 +250,34 @@ const WWheel=({openShare,showShare=true,onClose=null})=>{
             turnObj.flashTimer=null;
         }
     }
-    const startReset=()=>{
+    const startReset=(angle=0)=>{
         turnObj.resetTimer=setTimeout(()=>{
-            resetWheel();
+            checkShowPopInfo();
+            resetWheel(angle);
         },resetduring*1000)
     }
-    const resetWheel=()=>{
+    const checkShowPopInfo=()=>{
+        let type=2;
+        if (turnObj.result){
+            type=turnObj.result.type;
+        }
+        if(type===2)setOpenPopInfo(true);
+    }
+    const resetWheel=(angle=0)=>{
+        clearTurnTimer();
         turnObj.result=null;
         turnObj.count=0;
+        turnObj.ishelp=false;
+        if (angle==null)angle=0;
+        else angle=angle%360;
         let roteStyle={
-            transform:"rotate(0deg)",
+            transform:"rotate("+angle+"deg)",
             transition:``,
         };
         setDrawStyle(roteStyle);
         drawWheel(null);
         setCollect(0);
         setIsLock(false);
-        setOpenPopInfo(true);
         clearResTimer();
     }
     const clearResetTimer=()=>{
@@ -310,8 +345,20 @@ const WWheel=({openShare,showShare=true,onClose=null})=>{
             }
         }
     }
+    const onHelpResult=(data)=>{
+        console.log(data);
+    }
+    const checkHelpOther=()=>{
+        let act=localStorageGet(LOCAL_WHEEL_INVITE_CODE);
+        if (act!=null&&act!==""){
+            if (!isHelpdone){
+                dispatch(reqTurnplateHelp(onHelpResult));
+            }
+        }
+    }
     useEffect(()=>{
         loadImgs();
+        checkHelpOther();
         return ()=>{
             clearTurnTimer();
             clearCDTimer();

+ 29 - 5
src/widgets/WCashWheel/index.jsx

@@ -3,8 +3,8 @@ import WWheel from "@widgets/WCashWheel/WWheel/WWheel";
 import Spring from "@components/Spring";
 import cash_2 from "@assets/wheel/cash_2.png";
 import coin from "@assets/wheel/pix_2.png";
-import {useSelector} from "react-redux";
-import {getMyRecord, getRecord, getTurnplate} from "@features/turnplateSlice";
+import {useDispatch, useSelector} from "react-redux";
+import {getBonusStatus, getMyRecord, getRecord, getTurnplate} from "@features/turnplateSlice";
 import {formatCash, stringFormat} from "@utils/helpers";
 import React, {useEffect, useState} from "react";
 import {Autoplay, EffectCube,EffectCoverflow} from "swiper";
@@ -18,6 +18,8 @@ import {useNavigate} from "react-router";
 import {ROUTE_PATH} from "@constants/routes";
 import SmallLoading from "@components/SmallLoading";
 import WRetainPop from "@widgets/WCashWheel/WRetainPop/WRetainPop";
+import {reqTurnplateBonus} from "@features/api";
+import {REQ_STATUS} from "@api/config";
 const i18n=global.i18n;
 const StyledSwiper=styled(Swiper)`
 .swiper-wrapper{
@@ -36,6 +38,8 @@ const WCashWheel=({close})=>{
     const [openShare,setOpenShare]=useState(false);
     const isLogin=useSelector(isLogined);
     const navigate=useNavigate();
+    const dispatch = useDispatch();
+    const bonusStatus=useSelector(getBonusStatus);
     useEffect(() => {
         if (swiper) {
             swiper.update();
@@ -50,6 +54,19 @@ const WCashWheel=({close})=>{
         if (!phone.startsWith("55"))phone="55"+phone;
         return phone;
     }
+    const checkClickWD=()=>{
+        let collect=turnplate.collect_amount;
+        let total=turnplate.total_amount;
+        if (collect>=total){
+            if (bonusStatus!==REQ_STATUS.LOADING){
+                dispatch(reqTurnplateBonus());
+            }
+        }
+        else
+        {
+            setOpenInfoBox(true);
+        }
+    }
     const renderCashMain=()=>{
         let collect=turnplate.collect_amount;
         // collect=9556;
@@ -87,10 +104,17 @@ const WCashWheel=({close})=>{
                         </CountUp>
                         {/*<div className={styles.cash_text}>{global.DOLLAR+" "+formatCash(collect)}</div>*/}
                         <button className={styles.cash_btn} disabled={!isEnableCash} onClick={()=>{
-                            setOpenInfoBox(true);
+                            // setOpenInfoBox(true);
+                            checkClickWD();
                         }}>
-                            <img className={styles.icon} src={coin}/>
-                            {i18n.t("turnplate.cash_btn")}
+                            {
+                                bonusStatus===REQ_STATUS.LOADING?(<SmallLoading fill={"#fff"}/>):(
+                                    <>
+                                        <img className={styles.icon} src={coin}/>
+                                        {i18n.t("turnplate.cash_btn")}
+                                    </>
+                                )
+                            }
                         </button>
                     </div>
                     <div className={styles.progress}>