|
@@ -1,28 +1,47 @@
|
|
|
import styles from './styles.module.scss';
|
|
import styles from './styles.module.scss';
|
|
|
import {useDispatch, useSelector} from "react-redux";
|
|
import {useDispatch, useSelector} from "react-redux";
|
|
|
import {getUserInfo, isLogined} from "@features/mainSlice";
|
|
import {getUserInfo, isLogined} from "@features/mainSlice";
|
|
|
-import {getConfig, getCPFFirst, getFirstPay, getPaymentOrderStatus, getShowBonus} from "@features/paySlice";
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ getConfig,
|
|
|
|
|
+ getCPFFirst,
|
|
|
|
|
+ getFirstPay,
|
|
|
|
|
+ getFirstPayMulti, getGetSecondStatus,
|
|
|
|
|
+ getPaymentOrderStatus,
|
|
|
|
|
+ getShowBonus
|
|
|
|
|
+} from "@features/paySlice";
|
|
|
import fpayimg from "@assets/pay/fpayimg.png";
|
|
import fpayimg from "@assets/pay/fpayimg.png";
|
|
|
import img_sc from "@assets/pay/img_sc_66.png";
|
|
import img_sc from "@assets/pay/img_sc_66.png";
|
|
|
import React, {useState} from "react";
|
|
import React, {useState} from "react";
|
|
|
import Spring from "@components/Spring";
|
|
import Spring from "@components/Spring";
|
|
|
import {REQ_STATUS} from "@api/config";
|
|
import {REQ_STATUS} from "@api/config";
|
|
|
import SmallLoading from "@components/SmallLoading";
|
|
import SmallLoading from "@components/SmallLoading";
|
|
|
-import {reqPaymentOrder} from "@features/api";
|
|
|
|
|
|
|
+import {reqGetSecond, reqPaymentOrder} from "@features/api";
|
|
|
import {useNavigate} from "react-router-dom";
|
|
import {useNavigate} from "react-router-dom";
|
|
|
import {ROUTE_PATH} from "@constants/routes";
|
|
import {ROUTE_PATH} from "@constants/routes";
|
|
|
import RadioBtn from "@components/RadioBtn";
|
|
import RadioBtn from "@components/RadioBtn";
|
|
|
import img_bonus from "@assets/pay/topup_bonus.png";
|
|
import img_bonus from "@assets/pay/topup_bonus.png";
|
|
|
import styled from 'styled-components/macro';
|
|
import styled from 'styled-components/macro';
|
|
|
-import {formatCurrency, stringFormat} from "@utils/helpers";
|
|
|
|
|
|
|
+import {formatCurrency, formatTime, stringFormat} from "@utils/helpers";
|
|
|
import {APP_COUNTRY_CODE} from "@constants/app";
|
|
import {APP_COUNTRY_CODE} from "@constants/app";
|
|
|
import RUPaytypeSelect from "@widgets/WDeposit/RU/RUPaytypeSelect";
|
|
import RUPaytypeSelect from "@widgets/WDeposit/RU/RUPaytypeSelect";
|
|
|
import BRCPFSave from "@widgets/WDeposit/BR/BRCPFSave/BRCPFSave";
|
|
import BRCPFSave from "@widgets/WDeposit/BR/BRCPFSave/BRCPFSave";
|
|
|
|
|
+import {Swiper, SwiperSlide} from "swiper/react";
|
|
|
|
|
+import {Autoplay} from "swiper/modules";
|
|
|
const i18n=global.i18n;
|
|
const i18n=global.i18n;
|
|
|
const PPBanner=styled.div`
|
|
const PPBanner=styled.div`
|
|
|
background: url(${img_bonus});
|
|
background: url(${img_bonus});
|
|
|
background-size: 100% 100%;
|
|
background-size: 100% 100%;
|
|
|
`
|
|
`
|
|
|
|
|
+const StyledSwiper = styled(Swiper)`
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ padding: 0px 0px;
|
|
|
|
|
+ .swiper-wrapper{
|
|
|
|
|
+ transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
|
|
|
+ }
|
|
|
|
|
+ .swiper-slide{
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ }
|
|
|
|
|
+`
|
|
|
const BRDeposit=()=>{
|
|
const BRDeposit=()=>{
|
|
|
const dispatch = useDispatch();
|
|
const dispatch = useDispatch();
|
|
|
const navigate=useNavigate();
|
|
const navigate=useNavigate();
|
|
@@ -36,6 +55,9 @@ const BRDeposit=()=>{
|
|
|
const showBonus=useSelector(getShowBonus);
|
|
const showBonus=useSelector(getShowBonus);
|
|
|
const cpfFirst=useSelector(getCPFFirst);
|
|
const cpfFirst=useSelector(getCPFFirst);
|
|
|
const areaItem=global.getLocalAreaItem();
|
|
const areaItem=global.getLocalAreaItem();
|
|
|
|
|
+ const [swiper, setSwiper] = useState(null);
|
|
|
|
|
+ const firstPayMulti=useSelector(getFirstPayMulti);
|
|
|
|
|
+ const getSecondStatus=useSelector(getGetSecondStatus);
|
|
|
const getSelectedConfig=()=>{
|
|
const getSelectedConfig=()=>{
|
|
|
let selected=null;
|
|
let selected=null;
|
|
|
if (config){
|
|
if (config){
|
|
@@ -99,32 +121,113 @@ const BRDeposit=()=>{
|
|
|
return require(`@assets/pay/fpayimg_$.png`);
|
|
return require(`@assets/pay/fpayimg_$.png`);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- const renderFirst=()=>{
|
|
|
|
|
- if (firstpay==null)return (<></>);
|
|
|
|
|
- let price=Number(firstpay.goodsPrice);
|
|
|
|
|
- let give=Number(firstpay.give);
|
|
|
|
|
|
|
+ const getMultiInfo=()=>{
|
|
|
|
|
+ let items=[];
|
|
|
|
|
+ let status=-1;
|
|
|
|
|
+ if (firstPayMulti!=null){
|
|
|
|
|
+ if (firstPayMulti.items!=null){
|
|
|
|
|
+ // items=firstPayMulti.items;
|
|
|
|
|
+ let fitems=firstPayMulti.items;
|
|
|
|
|
+ for (let i=0;i<fitems.length;i++){
|
|
|
|
|
+ if (i===firstPayMulti.default)items.unshift(fitems[i]);
|
|
|
|
|
+ else items.push(fitems[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ let leftitem=firstPayMulti.leftitem;
|
|
|
|
|
+ if (leftitem!=null){
|
|
|
|
|
+ items.push(leftitem);
|
|
|
|
|
+ let timeleft=leftitem.timeleft;
|
|
|
|
|
+ status=timeleft<=0?1:0
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return {status,items};
|
|
|
|
|
+ }
|
|
|
|
|
+ const getSecondCallback=(payload)=>{
|
|
|
|
|
+ if (payload&&payload.code===200){
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ const onGetSecond=()=>{
|
|
|
|
|
+ if (getSecondStatus===REQ_STATUS.LOADING)return;
|
|
|
|
|
+ let data={};
|
|
|
|
|
+ data.callback=getSecondCallback;
|
|
|
|
|
+ dispatch(reqGetSecond(data))
|
|
|
|
|
+ }
|
|
|
|
|
+ const renderFirst=(item,status)=>{
|
|
|
|
|
+ // if (firstpay==null)return (<></>);
|
|
|
|
|
+ if (item==null)return (<></>);
|
|
|
|
|
+ let price=Number(item.money);
|
|
|
|
|
+ let give=Number(item.give);
|
|
|
|
|
+ let second_give=Number(item.second_give);
|
|
|
let total=price+give;
|
|
let total=price+give;
|
|
|
- let title=firstpay.goodsName==="firstpay"?i18n.t("deposit.banner.first_title"):i18n.t("deposit.banner.recommend_title");
|
|
|
|
|
|
|
+ // let title=firstpay.goodsName==="firstpay"?i18n.t("deposit.banner.first_title"):i18n.t("deposit.banner.recommend_title");
|
|
|
|
|
+ let title=i18n.t("deposit.banner.first_title");
|
|
|
|
|
+ let btnlabel=(<></>);
|
|
|
|
|
+ if (status===-1){btnlabel=(<>{global.DOLLAR + price}</>)}
|
|
|
|
|
+ else if (status===0){
|
|
|
|
|
+ let left_str=formatTime(item.timeleft)
|
|
|
|
|
+ btnlabel=(<>{left_str}</>)
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (status===1){
|
|
|
|
|
+ btnlabel=getSecondStatus===REQ_STATUS.LOADING?(<SmallLoading fill={"#fff"}/>):(<>{i18n.t("firstPay.label_claim")}</>)
|
|
|
|
|
+ }
|
|
|
return (
|
|
return (
|
|
|
<button className={styles.first_pay} onClick={() => {
|
|
<button className={styles.first_pay} onClick={() => {
|
|
|
- onGetPaymentOder({
|
|
|
|
|
- price: firstpay.goodsPrice,
|
|
|
|
|
- goodsName: firstpay.goodsName,
|
|
|
|
|
- payType: firstpay.gear.id,
|
|
|
|
|
- GiftsID: firstpay.GiftsID
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if (status===-1){
|
|
|
|
|
+ onGetPaymentOder({
|
|
|
|
|
+ price: item.money,
|
|
|
|
|
+ goodsName: "firstpay",
|
|
|
|
|
+ payType: item.id,
|
|
|
|
|
+ GiftsID: item.GiftsID
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (status===1){
|
|
|
|
|
+ onGetSecond();
|
|
|
|
|
+ }
|
|
|
}}>
|
|
}}>
|
|
|
<div className={styles.pay_info}>
|
|
<div className={styles.pay_info}>
|
|
|
<div className={styles.title}>{title}</div>
|
|
<div className={styles.title}>{title}</div>
|
|
|
<div className={styles.price_con}>
|
|
<div className={styles.price_con}>
|
|
|
- <div className={styles.total}>{global.DOLLAR + total}</div>
|
|
|
|
|
- <div className={styles.origin}>
|
|
|
|
|
- {global.DOLLAR + price}
|
|
|
|
|
- <div className={styles.ori_line}/>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ status === -1 ? (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <span className={styles.label}>{i18n.t("firstPay.today")}</span>
|
|
|
|
|
+ <span data-title={global.DOLLAR + total}
|
|
|
|
|
+ className={styles.p_text_f}>
|
|
|
|
|
+ {global.DOLLAR + total}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <span className={styles.label}>{i18n.t("firstPay.today")}</span>
|
|
|
|
|
+ <span data-title={global.DOLLAR + total}
|
|
|
|
|
+ className={styles.p_text_al}>
|
|
|
|
|
+ {global.DOLLAR + total}
|
|
|
|
|
+ <div className={styles.al_line}></div>
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ {/*<div className={styles.origin}>*/}
|
|
|
|
|
+ {/* {global.DOLLAR + price}*/}
|
|
|
|
|
+ {/* <div className={styles.ori_line}/>*/}
|
|
|
|
|
+ {/*</div>*/}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className={styles.price_con}>
|
|
|
|
|
+ <span className={styles.label}>{i18n.t("firstPay.day_2")}</span>
|
|
|
|
|
+ <span data-title={global.DOLLAR + second_give}
|
|
|
|
|
+ className={styles.p_text}>{global.DOLLAR + second_give}</span>
|
|
|
|
|
+ {/*<div className={styles.origin}>*/}
|
|
|
|
|
+ {/* {global.DOLLAR + price}*/}
|
|
|
|
|
+ {/* <div className={styles.ori_line}/>*/}
|
|
|
|
|
+ {/*</div>*/}
|
|
|
</div>
|
|
</div>
|
|
|
<button className={styles.price_btn}>
|
|
<button className={styles.price_btn}>
|
|
|
- {global.DOLLAR + price}
|
|
|
|
|
|
|
+ {/*{global.DOLLAR + price}*/}
|
|
|
|
|
+ {btnlabel}
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|
|
|
{/*<img className={styles.gift_img} src={fpayimg}/>*/}
|
|
{/*<img className={styles.gift_img} src={fpayimg}/>*/}
|
|
@@ -132,12 +235,38 @@ const BRDeposit=()=>{
|
|
|
<div className={styles.percent}>
|
|
<div className={styles.percent}>
|
|
|
<img src={img_sc} className={styles.percent}/>
|
|
<img src={img_sc} className={styles.percent}/>
|
|
|
<div className={styles.text}>
|
|
<div className={styles.text}>
|
|
|
- {'+' + Math.floor(give * 100 / price) + '%'}
|
|
|
|
|
|
|
+ {'+' + Math.floor((give+second_give) * 100 / price) + '%'}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</button>
|
|
</button>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
+ const renderMultiFirst=()=>{
|
|
|
|
|
+ if (firstPayMulti===null)return (<></>);
|
|
|
|
|
+ let {status,items}=getMultiInfo();
|
|
|
|
|
+ return (
|
|
|
|
|
+ <StyledSwiper onSwiper={setSwiper}
|
|
|
|
|
+ slidesPerView={1}
|
|
|
|
|
+ spaceBetween={15}
|
|
|
|
|
+ loop
|
|
|
|
|
+ autoplay={{delay: 5000, disableOnInteraction: false}}
|
|
|
|
|
+ effect="fade"
|
|
|
|
|
+ fadeEffect={{crossFade: true}}
|
|
|
|
|
+ modules={[Autoplay]}
|
|
|
|
|
+ speed={1000}
|
|
|
|
|
+ >
|
|
|
|
|
+ {
|
|
|
|
|
+ items.map((item,index)=>{
|
|
|
|
|
+ return (
|
|
|
|
|
+ <SwiperSlide key={index}>
|
|
|
|
|
+ {renderFirst(item,status)}
|
|
|
|
|
+ </SwiperSlide>
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ </StyledSwiper>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
const renderTitle = () => {
|
|
const renderTitle = () => {
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.title}>{i18n.t("deposit.list.title")}</div>
|
|
<div className={styles.title}>{i18n.t("deposit.list.title")}</div>
|
|
@@ -322,7 +451,8 @@ const BRDeposit=()=>{
|
|
|
}
|
|
}
|
|
|
return (
|
|
return (
|
|
|
<Spring type="slideUp" className={styles.container}>
|
|
<Spring type="slideUp" className={styles.container}>
|
|
|
- {renderFirst()}
|
|
|
|
|
|
|
+ {/*{renderFirst()}*/}
|
|
|
|
|
+ {renderMultiFirst()}
|
|
|
{renderDeposits()}
|
|
{renderDeposits()}
|
|
|
{renderPromotions()}
|
|
{renderPromotions()}
|
|
|
{renderDepositBtn()}
|
|
{renderDepositBtn()}
|