重新加入轮询;修复bug;优化样式

This commit is contained in:
yezian 2024-08-05 18:05:29 +08:00
parent 5c89ea4f08
commit 463e530428
2 changed files with 31 additions and 28 deletions

View File

@ -23,19 +23,22 @@ export default function Vip() {
const [isVip, setIsVip] = useState(false);
const [name, setName] = 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");
if (currentBaseCode) {
let currentBase = JSON.parse(currentBaseCode);
searchParamsObj = { ...currentBase };
}
return searchParamsObj || webviewBase;
},
[searchParams]
);
const getUserData = async () => {
const webviewBase = webviewBaseRequest();
let base = getBase(webviewBase)
let base = getBase(webviewBase);
try {
const signature = generateSignature({
...base,
@ -73,9 +76,9 @@ export default function Vip() {
setTimeout(() => {
getUserData();
}, 500);
// const intervalId = setInterval(() => {
// getUserData();
// }, 2000);
const intervalId = setInterval(() => {
getUserData();
}, 2000);
return () => clearInterval(intervalId);
}, []);
@ -94,7 +97,7 @@ export default function Vip() {
product_id: "membership",
pay_type: type,
redirect_url: type === "yeepay_wxpay_h5" ? window.location.href : "",
from: searchParams.get("base")?"web":"app",
from: searchParams.get("base") ? "web" : "app",
};
//jsapi

View File

@ -20,7 +20,6 @@ export default function Pay({ params }) {
(webviewBase) => {
let searchParamsObj = null;
let currentBaseCode = searchParams.get("base");
// console.log("currentBaseCode", currentBaseCode);
if (currentBaseCode) {
let currentBase = JSON.parse(currentBaseCode);
searchParamsObj = { ...currentBase };
@ -40,7 +39,6 @@ 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}`,
@ -76,7 +74,6 @@ 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}`,
@ -102,11 +99,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
@ -128,7 +125,6 @@ export default function Pay({ params }) {
redirect_url: type === "yeepay_wxpay_h5" ? window.location.href : "",
from: searchParams.get("base") ? "web" : "app",
};
// console.log("body", body);
setIsLoading(true);
const signature = generateSignature(body);
@ -211,7 +207,11 @@ export default function Pay({ params }) {
{isLoading && (
<span className="absolute top-1/2 loading loading-spinner loading-lg z-20"></span>
)}
<div className="flex flex-col p-4 mt-20">
<div
className={`flex flex-col p-4 ${
searchParams.get("base") ? "" : "mt-20"
}`}
>
<h1 className="text-[#FF669E] text-4xl font-medium text-center my-10">
¥{" "}
{checked
@ -278,7 +278,7 @@ export default function Pay({ params }) {
</div>
)}
{checked ? (
<div className="flex flex-col mt-16">
<div className="flex flex-col mt-16 pb-48">
<p className="text-secondary text-base font-medium">购买须知</p>
<p className="text-secondary text-sm">
1开通超粉后可在有效期内免费查看当前空间内的所有动态内容
@ -293,7 +293,7 @@ export default function Pay({ params }) {
</p>
</div>
) : params.product_id === "h5_zone_moment" ? (
<div className="flex flex-col mt-16">
<div className="flex flex-col mt-16 pb-48">
<p className="text-secondary text-base font-medium">购买须知</p>
<p className="text-secondary text-sm">
1当前购买内容为本空间内特定单条动态的查阅权限如需要查阅空间内全部动态请开通超粉
@ -306,7 +306,7 @@ export default function Pay({ params }) {
</p>
</div>
) : (
<div className="flex flex-col mt-16">
<div className="flex flex-col mt-16 pb-48">
<p className="text-secondary text-base font-medium">购买须知</p>
<p className="text-secondary text-sm">
1本空间由空间主人自行创建加入空间前请确认相关风险避免上当受骗