|
|
@@ -11,7 +11,15 @@ import SmallLoading from "@components/SmallLoading";
|
|
|
import {reqPaymentOrder} from "@features/api";
|
|
|
import {useNavigate} from "react-router-dom";
|
|
|
import {ROUTE_PATH} from "@constants/routes";
|
|
|
+import RadioBtn from "@components/RadioBtn";
|
|
|
+import img_bonus from "@assets/pay/topup_bonus.png";
|
|
|
+import styled from 'styled-components/macro';
|
|
|
+import {stringFormat} from "@utils/helpers";
|
|
|
const i18n=global.i18n;
|
|
|
+const PPBanner=styled.div`
|
|
|
+ background: url(${img_bonus});
|
|
|
+ background-size: 100% 100%;
|
|
|
+`
|
|
|
const BRDeposit=()=>{
|
|
|
const dispatch = useDispatch();
|
|
|
const navigate=useNavigate();
|
|
|
@@ -21,6 +29,7 @@ const BRDeposit=()=>{
|
|
|
const orderStatus=useSelector(getPaymentOrderStatus);
|
|
|
const [selectedID,setSelectedID]=useState("0");
|
|
|
const isLogin=useSelector(isLogined);
|
|
|
+ const [selectedPromotion,setSelectedPromotion]=useState(false);
|
|
|
const getSelectedConfig=()=>{
|
|
|
let selected=null;
|
|
|
if (config){
|
|
|
@@ -97,6 +106,13 @@ const BRDeposit=()=>{
|
|
|
if (item){
|
|
|
price=Number(item.money);
|
|
|
give=Number(item.give);
|
|
|
+ if (selectedPromotion){
|
|
|
+ let activity=item.activity;
|
|
|
+ if (activity){
|
|
|
+ price=Number(activity.money);
|
|
|
+ give=Number(activity.give);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
let total=price+give;
|
|
|
return (
|
|
|
@@ -124,6 +140,13 @@ const BRDeposit=()=>{
|
|
|
list.map((item,index)=>{
|
|
|
let price=Number(item.money);
|
|
|
let give=Number(item.give);
|
|
|
+ if (selectedPromotion){
|
|
|
+ let activity=item.activity;
|
|
|
+ if (activity){
|
|
|
+ price=Number(activity.money);
|
|
|
+ give=Number(activity.give);
|
|
|
+ }
|
|
|
+ }
|
|
|
let extra="+"+Math.floor(give*100/price)+'%';
|
|
|
return (
|
|
|
<button key={index} className={`${styles.list_btn} ${selectedID===item.id?styles.active:''}`}
|
|
|
@@ -169,21 +192,74 @@ const BRDeposit=()=>{
|
|
|
gear=JSON.parse(payItem.gear);
|
|
|
gear=gear[0];
|
|
|
}
|
|
|
+ let money=payItem.money;
|
|
|
+ let id=gear.id;
|
|
|
+ let gift_id=payItem.gift_id;
|
|
|
+ if (selectedPromotion){
|
|
|
+ let activity=payItem.activity;
|
|
|
+ if (activity!=null){
|
|
|
+ money=activity.money;
|
|
|
+ // id=activity.id;
|
|
|
+ gift_id=activity.gift_id;
|
|
|
+ }
|
|
|
+ }
|
|
|
onGetPaymentOder({
|
|
|
- price:payItem.money,
|
|
|
+ price:money,
|
|
|
goodsName:"chip",
|
|
|
- payType:gear.id,
|
|
|
- GiftsID:payItem.gift_id
|
|
|
+ payType:id,
|
|
|
+ GiftsID:gift_id
|
|
|
})
|
|
|
}}>
|
|
|
{orderStatus===REQ_STATUS.LOADING?(<SmallLoading fill={"#fff"}/>):i18n.t("deposit.pay_btn")}
|
|
|
</button>
|
|
|
)
|
|
|
}
|
|
|
+ const renderPromotions=()=>{
|
|
|
+ let payItem=getSelectedConfig();
|
|
|
+ let percent=0;
|
|
|
+ let bonus=0;
|
|
|
+ if (payItem){
|
|
|
+ let activity=payItem.activity;
|
|
|
+ if (activity){
|
|
|
+ let price=Number(activity.money);
|
|
|
+ bonus=Number(activity.give);
|
|
|
+ percent=Math.floor(bonus*100/price);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ <div className={styles.promotion}>
|
|
|
+ {
|
|
|
+ selectedPromotion?(
|
|
|
+ <PPBanner className={styles.banner}>
|
|
|
+ <div className={styles.info_con}>
|
|
|
+ <div className={styles.percent_tips}>{stringFormat(i18n.t("deposit.promotions.banner_tips"),[percent+"%"])}</div>
|
|
|
+ <div className={styles.big_percent}>{percent+"%"}</div>
|
|
|
+ </div>
|
|
|
+ <div className={styles.info_bonus}>
|
|
|
+ <div>{i18n.t("deposit.promotions.bonus_title")}</div>
|
|
|
+ <div className={styles.bonus_value_con}>
|
|
|
+ <div>{percent+"%"}</div>
|
|
|
+ <div className={styles.bonus_value}>{global.DOLLAR+" +"+bonus}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </PPBanner>
|
|
|
+ ):(<></>)
|
|
|
+ }
|
|
|
+ <div className={styles.select_item}>
|
|
|
+ <RadioBtn className={styles.text} selected={selectedPromotion} value={"promotion"} onChange={(value)=>{
|
|
|
+ setSelectedPromotion(!selectedPromotion);
|
|
|
+ }}>
|
|
|
+ {i18n.t("deposit.promotions.tips")}
|
|
|
+ </RadioBtn>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
return (
|
|
|
<Spring type="slideUp" className={styles.container}>
|
|
|
{renderFirst()}
|
|
|
{renderDeposits()}
|
|
|
+ {renderPromotions()}
|
|
|
{renderDepositBtn()}
|
|
|
</Spring>
|
|
|
)
|