修改zonePay

This commit is contained in:
al 2024-07-24 17:11:25 +08:00
parent de8888895f
commit ee2b68facc
2 changed files with 26 additions and 17 deletions

2
.gitignore vendored
View File

@ -33,3 +33,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
package-lock.json

View File

@ -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);