tiefen_space_h5/components/CheckVip/index.jsx

72 lines
1.9 KiB
React
Raw Normal View History

2024-12-25 21:18:17 +08:00
"use client";
import React from "react";
import { Dialog } from "antd-mobile";
import { checkRole } from "@/utils/auth";
2024-12-25 21:18:17 +08:00
// import { useRouter } from "next/navigation";
import baseRequest from "@/utils/baseRequest";
import { save } from "@/utils/storeInfo";
import { getUserInfo } from "@/api/public";
2024-12-26 21:03:58 +08:00
2024-12-25 21:18:17 +08:00
export default function CheckVip({ children, isVipToPassFun, router }) {
const base = baseRequest();
const handleCheck = async () => {
const isVip = await checkRole();
2024-12-25 21:18:17 +08:00
if (!isVip) {
const showMobal = Dialog.show({
title: "是否开通会员",
content: (
<div>
<div>会员可无限制保存图片查看原图一次开通永久有效</div>
</div>
),
bodyStyle: {
maxHeight: "none",
width: "80vw",
position: "fixed",
top: "200px",
left: "10vw",
"--text-color": "#fff",
color: "#fff",
},
// cancelText:"确认",
// confirmText:"取消",
style: {
"--text-color": "#fff",
},
closeOnAction: true,
actions: [
[
{
key: "close",
text: "取消",
bold: true,
style: { color: "#ffffff80" },
onClick: () => {
showMobal?.close();
},
},
{
key: "submit",
text: "确认",
style: { color: "#fff" },
onClick: () => {
showMobal.close();
router.push(
`/webView/${encodeURIComponent(
`/vip?base=${encodeURIComponent(JSON.stringify(base))}`
)}`
);
},
},
],
],
});
return;
} else {
isVipToPassFun();
}
};
return <div onClick={handleCheck}>{children}</div>;
}