|
@@ -26,11 +26,12 @@ const CardPage = () => {
|
|
|
const searchParams = useSearchParams();
|
|
|
const swiperRef = React.useRef<SwiperClass | null>(null);
|
|
|
|
|
|
- // const [act, setAct] = React.useState(0);
|
|
|
+ const [act, setAct] = React.useState(0);
|
|
|
const [amount, setAmount] = React.useState<any>({});
|
|
|
const [visible, setVisible] = React.useState<boolean>(false);
|
|
|
const [shopInfo, setShopInfo] = React.useState<ShopInfo>({} as ShopInfo);
|
|
|
const [loading, setLoading] = React.useState(false);
|
|
|
+ const [canClaim, setCanClaim] = React.useState<number[]>([]);
|
|
|
|
|
|
const shop_id = React.useMemo(() => {
|
|
|
return Number(searchParams.get("shop_id"));
|
|
@@ -52,28 +53,38 @@ const CardPage = () => {
|
|
|
|
|
|
if (res?.code === 200 && res?.data?.products) {
|
|
|
let actKey = 0;
|
|
|
+ let canClaimArray: number[] = [];
|
|
|
res.data.products.sort((a: any, b: any) => {
|
|
|
return a.pay - b.pay;
|
|
|
});
|
|
|
+
|
|
|
const result = res.data.products.map((item: ShopProductItem, idx: number) => {
|
|
|
item.btnType = BtnTypeEnum.DISABLED;
|
|
|
//|| item.is_suss === -1
|
|
|
if (item.days <= 0) {
|
|
|
item.btnType = BtnTypeEnum.DEPOSITE;
|
|
|
}
|
|
|
- if (!actKey && item.days > 0 && item.is_suss === 0) {
|
|
|
- actKey = idx;
|
|
|
+ if (item.days > 0 && item.is_suss === 0) {
|
|
|
+ canClaimArray.push(idx);
|
|
|
+ if (!actKey) {
|
|
|
+ actKey = idx;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if (item.days > 0 && item.is_suss === 0) {
|
|
|
item.btnType = BtnTypeEnum.CANCLAIM;
|
|
|
}
|
|
|
|
|
|
return item;
|
|
|
});
|
|
|
+
|
|
|
//自动滚动到第一个买了的商品
|
|
|
setTimeout(() => {
|
|
|
+ setAct(actKey);
|
|
|
swiperRef.current?.slideToLoop(actKey, 0, false);
|
|
|
}, 100);
|
|
|
+
|
|
|
+ setCanClaim(canClaimArray);
|
|
|
setShopInfo({ ...res.data, products: result || [] });
|
|
|
}
|
|
|
} finally {
|
|
@@ -87,10 +98,25 @@ const CardPage = () => {
|
|
|
if (type === -1) swiperRef.current.slidePrev();
|
|
|
}
|
|
|
};
|
|
|
+ const redPointInfo = React.useMemo(() => {
|
|
|
+ const min = Math.min(...canClaim);
|
|
|
+ const max = Math.max(...canClaim);
|
|
|
+ const result = {
|
|
|
+ prev: false,
|
|
|
+ next: false,
|
|
|
+ };
|
|
|
+ if (act > min) {
|
|
|
+ result.prev = true;
|
|
|
+ }
|
|
|
+ if (act < max) {
|
|
|
+ result.next = true;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }, [act]);
|
|
|
|
|
|
- const data = React.useMemo(() => {
|
|
|
- return [1, 2, 3, 4, 5];
|
|
|
- }, []);
|
|
|
+ // const data = React.useMemo(() => {
|
|
|
+ // return [1, 2, 3, 4, 5];
|
|
|
+ // }, []);
|
|
|
|
|
|
const getActiveInfo = (itemData: ShopProductItem) => {
|
|
|
const amountInfo = itemData.activity_reward.find((item: ShopActivityRewardItem) => {
|
|
@@ -119,7 +145,7 @@ const CardPage = () => {
|
|
|
return;
|
|
|
}
|
|
|
if (itemData.btnType === BtnTypeEnum.DEPOSITE) {
|
|
|
- router.push(`/deposit`);
|
|
|
+ router.push(`/deposit?target_id=${shop_id}`);
|
|
|
return;
|
|
|
}
|
|
|
if (itemData.btnType !== BtnTypeEnum.CANCLAIM) {
|
|
@@ -172,10 +198,10 @@ const CardPage = () => {
|
|
|
onSwiper={(swiper) => {
|
|
|
swiperRef.current = swiper;
|
|
|
}}
|
|
|
- // onSlideChange={(swiper) => {
|
|
|
- // setAct(swiper.realIndex);
|
|
|
- // }}
|
|
|
- loop={data.length > 3}
|
|
|
+ onSlideChange={(swiper) => {
|
|
|
+ setAct(swiper.realIndex);
|
|
|
+ }}
|
|
|
+ loop={shopInfo?.products?.length > 3 || false}
|
|
|
modules={[Pagination]}
|
|
|
// loopAdditionalSlides={2}
|
|
|
pagination={{
|
|
@@ -210,7 +236,7 @@ const CardPage = () => {
|
|
|
"pr-[.12rem] pt-[.02rem] text-[.1rem]"
|
|
|
)}
|
|
|
>
|
|
|
- {item.is_buy && "Já foi comprado"}
|
|
|
+ {item.days > 0 && "Já foi comprado"}
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className={styles.cardContainerOut}>
|
|
@@ -248,7 +274,7 @@ const CardPage = () => {
|
|
|
</div>
|
|
|
<div className="flex-1 text-[.1rem]">
|
|
|
<div className={styles.text_1}>
|
|
|
- Nnuerário
|
|
|
+ Numerário
|
|
|
</div>
|
|
|
<div
|
|
|
className={clsx(
|
|
@@ -371,6 +397,7 @@ const CardPage = () => {
|
|
|
onClick={() => doChange(-1)}
|
|
|
>
|
|
|
<i className="iconfont icon-xiangyou1"></i>
|
|
|
+ {redPointInfo.prev && <div className={styles.redCircle}></div>}
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
@@ -378,6 +405,7 @@ const CardPage = () => {
|
|
|
onClick={() => doChange(1)}
|
|
|
>
|
|
|
<i className="iconfont icon-xiangyou1"></i>
|
|
|
+ {redPointInfo.next && <div className={styles.redCircle}></div>}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|