From ee2b68facc6210d32a476be41cece19264cab754 Mon Sep 17 00:00:00 2001 From: al Date: Wed, 24 Jul 2024 17:11:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9zonePay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + .../[zid]/[product_id]/[moment_id]/page.jsx | 41 +++++++++++-------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 8f322f0..eaaee16 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +package-lock.json \ No newline at end of file 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 cbc3d48..d5e0776 100644 --- a/app/zone/pay/[zid]/[product_id]/[moment_id]/page.jsx +++ b/app/zone/pay/[zid]/[product_id]/[moment_id]/page.jsx @@ -16,15 +16,19 @@ export default function Pay({ params }) { //超粉商品数据 const [superfanshipData, setSuperfanshipData] = useState(); const [isFetching, setIsFetching] = useState(true); - const getBase = useCallback((webviewBase)=>{ - let searchParamsObj=null; - let currentBaseCode = searchParams.get("base") - if(currentBaseCode){ - let currentBase = JSON.parse(currentBaseCode); - searchParamsObj={...currentBase}; - } - return searchParamsObj || webviewBase; - },[searchParams]); + const getBase = useCallback( + (webviewBase) => { + let searchParamsObj = null; + let currentBaseCode = searchParams.get("base"); + // console.log("currentBaseCode", currentBaseCode); + if (currentBaseCode) { + let currentBase = JSON.parse(currentBaseCode); + searchParamsObj = { ...currentBase }; + } + return searchParamsObj || webviewBase; + }, + [searchParams] + ); //获取当前选购的商品数据 const getData = async () => { try { @@ -36,6 +40,7 @@ export default function Pay({ params }) { product_id: params.product_id, ...base, }; + // console.log("body1", body); const signature = generateSignature(body); const response = await fetch( `/api/zone/get_cashier?signature=${signature}`, @@ -71,6 +76,7 @@ export default function Pay({ params }) { product_id: "h5_zone_superfanship", ...base, }; + // console.log("body2", body); const signature = generateSignature(body); const response = await fetch( `/api/zone/get_cashier?signature=${signature}`, @@ -96,11 +102,11 @@ export default function Pay({ params }) { getData(); getSuperfanshipData(); }, 500); - const intervalId = setInterval(() => { - getData(); - getSuperfanshipData(); - }, 2000); - return () => clearInterval(intervalId); + // const intervalId = setInterval(() => { + // getData(); + // getSuperfanshipData(); + // }, 2000); + // return () => clearInterval(intervalId); }, []); //是否勾选购买超粉switch组件 @@ -111,7 +117,8 @@ export default function Pay({ params }) { //创建订单 const [isLoading, setIsLoading] = useState(false); const createOrder = async (type = "alipay_h5") => { - const base = webviewBaseRequest(); + const webviewBase = webviewBaseRequest(); + const base = getBase(webviewBase); const body = { ...base, zid: parseInt(params.zid), @@ -119,9 +126,9 @@ export default function Pay({ params }) { product_id: checked ? "h5_zone_superfanship" : params.product_id, pay_type: type, redirect_url: type === "yeepay_wxpay_h5" ? window.location.href : "", - from: searchParams.get("base")?"web":"app", + from: searchParams.get("base") ? "web" : "app", }; - + // console.log("body", body); setIsLoading(true); const signature = generateSignature(body);