diff --git a/app/zone/pay/[zid]/[product_id]/[moment_id]/page.jsx b/app/zone/pay/[zid]/[product_id]/[moment_id]/page.jsx index a9bb355..2a6a0d8 100644 --- a/app/zone/pay/[zid]/[product_id]/[moment_id]/page.jsx +++ b/app/zone/pay/[zid]/[product_id]/[moment_id]/page.jsx @@ -16,6 +16,7 @@ export default function Pay({ params }) { //超粉商品数据 const [superfanshipData, setSuperfanshipData] = useState(); const [isFetching, setIsFetching] = useState(true); + const [superCheched, setSuperCheched] = useState({ index: 0 }); const getBase = useCallback( (webviewBase) => { let searchParamsObj = null; @@ -50,6 +51,7 @@ export default function Pay({ params }) { body: JSON.stringify(body), } ); + console.log("JSON.stringify(body)", JSON.stringify(body)); const temData = await response.json(); if (temData.ret === -1) { Toast.show({ @@ -87,6 +89,10 @@ export default function Pay({ params }) { ); const temData = await response.json(); if (temData.ret === -1) return; + const superfanPriceList = temData.data?.superfan_price_list; + if (superfanPriceList) { + setSuperCheched({ index: 0, ...superfanPriceList[0] }); + } setSuperfanshipData(temData.data); } catch (error) { console.error(error); @@ -95,22 +101,33 @@ export default function Pay({ params }) { //轮询请求 useEffect(() => { - setTimeout(() => { + // debugger; + const timer = setTimeout(() => { getData(); getSuperfanshipData(); }, 500); - const intervalId = setInterval(() => { - getData(); - getSuperfanshipData(); - }, 2000); - return () => clearInterval(intervalId); + // const intervalId = setInterval(() => { + // getData(); + // getSuperfanshipData(); + // }, 2000); + return () => clearTimeout(timer); }, []); //是否勾选购买超粉switch组件 const [checked, setChecked] = useState( params.product_id === "h5_zone_superfanship" ? true : false ); - + const superId = superfanshipData?.superfan_price_list + ? superCheched?.period == 1 + ? "h5_zone_superfanship_year" + : superCheched?.period == 2 + ? "h5_zone_superfanship_half_year" + : superCheched?.period == 3 + ? "h5_zone_superfanship_season" + : superCheched?.period == 4 + ? "h5_zone_superfanship_month" + : "h5_zone_superfanship_eternal" + : "h5_zone_superfanship"; //创建订单 const [isLoading, setIsLoading] = useState(false); const createOrder = async (type = "alipay_h5") => { @@ -120,7 +137,7 @@ export default function Pay({ params }) { ...base, zid: parseInt(params.zid), moment_id: parseInt(params.moment_id), - product_id: checked ? "h5_zone_superfanship" : params.product_id, + product_id: checked ? superId : params.product_id, pay_type: type, redirect_url: type === "yeepay_wxpay_h5" ? window.location.href : "", from: searchParams.get("base") ? "web" : "app", @@ -174,6 +191,10 @@ export default function Pay({ params }) { } }; + const handleSelectSuper = (it) => { + setSuperCheched(it); + }; + if (isFetching) { return (
@@ -215,7 +236,7 @@ export default function Pay({ params }) {

¥{" "} {checked - ? (superfanshipData?.price / 100).toFixed(2) + ? (superCheched?.price || data?.price) / 100 : (data?.price / 100).toFixed(2)}

@@ -228,10 +249,60 @@ export default function Pay({ params }) {

有效期:

- {checked ? superfanshipData?.validity : data?.validity} + {checked + ? superCheched?.period == 1 + ? "一年" + : superCheched?.period == 2 + ? "半年" + : superCheched?.period == 3 + ? "三个月" + : superCheched?.period == 4 + ? "一个月" + : "永久" + : data?.validity}

+ + {checked && ( +
+ {superfanshipData?.superfan_price_list + ?.filter((it) => it.enable) + ?.map((it, index) => ( +
handleSelectSuper({ index, ...it })} + className={`flex-col justify-center items-center p-4 text-center border-[#${ + superCheched?.index == index ? "FF669E" : "ffffff80" + }] bg-[#${ + superCheched?.index == index ? "ff669e38" : "ffffff81a" + }] border-[2px] rounded-xl max-h-max`} + > +

+ {it.period == 0 + ? "永久" + : it.period == 1 + ? "年度" + : it.period == 2 + ? "半年" + : it.period == 3 + ? "季度" + : "月度"} + 超粉 +

+

+ ¥{it.price / 100} +

+ {it.is_superfanship_give_wechat ? ( +

+ (赠送微信) +

+ ) : ( + "" + )} +
+ ))} +
+ )} {params.product_id === "h5_zone_moment" && superfanshipData && (
@@ -263,20 +334,24 @@ export default function Pay({ params }) { />
)} - {params.product_id === "h5_zone_superfanship" && - superfanshipData?.is_superfanship_give_wechat === 1 && ( -
- - - -

- 额外附赠空间主人私人微信 -

-
- )} + {params.product_id === "h5_zone_superfanship" && ( + <> + {superfanshipData?.is_superfanship_give_wechat === 1 && ( +
+ + + +

+ 额外附赠空间主人私人微信 +

+
+ )} + + )} + {checked ? (

购买须知: