修改zonePay
This commit is contained in:
parent
de8888895f
commit
ee2b68facc
|
@ -33,3 +33,5 @@ yarn-error.log*
|
|||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
package-lock.json
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue