import React, { useEffect, useState } from "react"; import Popup from "@components/Popup"; import styles from "./styles.module.scss"; import lockedImg from "@assets/game/bonus_box.png"; import unlockImg from "@assets/game/bonus_box.png"; import LazyImage from "@components/LazyImage"; import { isLandscape, stringFormat } from "@utils/helpers"; import useFreeWithdraw from "@hooks/useFreeWithdraw"; import { useOrientation } from "react-use"; import MainButton from "@components/Buttons/MainButton"; const i18n = global.i18n; const WGameWithdrawTips = ({ onLeave, currentAmount, totalAoumt, forceLandscape = false }) => { const [isShow, setIsShow] = useState(false); const [viewType, setViewType] = useState(0); const total = Number(totalAoumt) || 0; const current = Number(currentAmount) || 0; const lackMoney = Math.max(total - current, 0).toFixed(2); const { openWithdrawInGame } = useFreeWithdraw(); const orientation = useOrientation(); // /bindsms {phone,code,password,repassword} const hide = () => { setIsShow(false); global.hideDropCoins?.(); } const onClose = () => { hide(); } const onLeaveClick = () => { onLeave?.(); hide(); } const openWithdraw = () => { hide(); openWithdrawInGame(); // adjust 游戏内点击引导提款弹窗 global.tracker?.trackEvent?.("click_withdraw_panel"); global.tracker?.trackEvent?.("click_withdraw_panel_count"); } useEffect(() => { const gameWithdrawTips = { show: (type) => { setViewType(type); setIsShow(true); }, hide: () => { setIsShow(false); global.hideDropCoins?.(); }, }; global.gameWithdrawTips = gameWithdrawTips; return () => { if (global.gameWithdrawTips === gameWithdrawTips) delete global.gameWithdrawTips; } }, []) /// 未达到提现条件 const renderLeaveTips = () => { return (
{i18n.t("gameLeaveTips.leave_tips.title")}
{stringFormat(i18n.t("gameLeaveTips.leave_tips.title"), [lackMoney])}
{i18n.t("gameLeaveTips.leave_tips.tips")}
{i18n.t("gameLeaveTips.leave_tips.tips2")}
{i18n.t("gameLeaveTips.playMore")}
{i18n.t("gameLeaveTips.leave")}
); } /// 提现未达到要求 const renderNotEnough = () => { return (
{''}
{i18n.t("gameLeaveTips.not_enough.title")}
{i18n.t("gameLeaveTips.not_enough.tips")} {`${global.DOLLAR}${lackMoney}`} {i18n.t("gameLeaveTips.not_enough.tips2")}
{i18n.t("gameLeaveTips.ok")}
); } /// 提现已解锁 const renderUnlocked = () => { return (
{i18n.t("gameLeaveTips.withdraw.title")}
{i18n.t("gameLeaveTips.withdraw.tips")}
{i18n.t("gameLeaveTips.withdraw.tips2")}
{i18n.t("gameLeaveTips.withdraw.now")}
{i18n.t("gameLeaveTips.withdraw.later")}
); } const renderView = () => { switch (viewType) { case 1: return renderLeaveTips(); case 2: return renderNotEnough(); case 3: return renderUnlocked(); default: return <> } } return ( <> {renderView()} ) } export default WGameWithdrawTips;