|
@@ -1,25 +1,13 @@
|
|
|
-import { CashbackTypes } from "@/api/cashback";
|
|
|
-import { UserInfoRep, UserVipInfo } from "@/api/user";
|
|
|
-import { getMoneyApi } from "@/api/userWallt";
|
|
|
-import { server } from "@/utils/server";
|
|
|
+"use client";
|
|
|
+import { userInfoApi } from "@/api/login";
|
|
|
+import { getUserMoneyApi, UserVipInfo } from "@/api/user";
|
|
|
+import { server } from "@/utils/client";
|
|
|
+import { useRequest } from "ahooks";
|
|
|
import ItemCom from "./component/ItemCom";
|
|
|
import ModalCom from "./component/ModalCom";
|
|
|
import "./page.scss";
|
|
|
import { ProfileHeader } from "./ProfileHeader";
|
|
|
|
|
|
-const getUserInfo = async () => {
|
|
|
- return server
|
|
|
- .request<UserInfoRep>({
|
|
|
- url: "/v1/api/user/user_info",
|
|
|
- method: "POST",
|
|
|
- next: { revalidate: 0 },
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res.code === 200) return res.data;
|
|
|
- return {};
|
|
|
- });
|
|
|
-};
|
|
|
-
|
|
|
/**
|
|
|
* @description 前台用户VIP信息 接口地址:https://app.apifox.com/link/project/4790544/apis/api-201160713
|
|
|
*/
|
|
@@ -28,52 +16,30 @@ const getVipApi = async () => {
|
|
|
.request<UserVipInfo>({
|
|
|
url: "/v1/api/user/user_vip_info",
|
|
|
method: "POST",
|
|
|
- cache: "no-cache",
|
|
|
})
|
|
|
.then((res) => {
|
|
|
if (res.code === 200) return res.data;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-const getCashBackApi = async () => {
|
|
|
- return server
|
|
|
- .request<CashbackTypes>({
|
|
|
- url: "/v1/api/front/activity_cash",
|
|
|
- method: "post",
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- return res.data;
|
|
|
- })
|
|
|
- .catch((error) => {
|
|
|
- return {
|
|
|
- rules: [],
|
|
|
- last_period: { end_time: 0, start_time: 0 },
|
|
|
- next_period: {
|
|
|
- end_time: 0,
|
|
|
- start_time: 0,
|
|
|
- },
|
|
|
- amount: 0,
|
|
|
- bet: 0,
|
|
|
- status: "expired",
|
|
|
- };
|
|
|
- });
|
|
|
-};
|
|
|
-export const dynamic = "force-dynamic";
|
|
|
-export const revalidate = 0;
|
|
|
-const Profile = async () => {
|
|
|
- const userInfo = await getUserInfo();
|
|
|
- const userMoney = await getMoneyApi();
|
|
|
- const userVip = await getVipApi();
|
|
|
- const cashback = await getCashBackApi();
|
|
|
- const max = cashback?.rules.reduce(
|
|
|
- (acc, item) => (acc > item.cashback ? acc : item.cashback),
|
|
|
- 0
|
|
|
- );
|
|
|
+const Profile = () => {
|
|
|
+ const { data: userInfo } = useRequest<any, any>(userInfoApi, {
|
|
|
+ pollingErrorRetryCount: 1,
|
|
|
+ pollingWhenHidden: false,
|
|
|
+ });
|
|
|
+ const { data: userMoney } = useRequest<any, any>(getUserMoneyApi, {
|
|
|
+ pollingErrorRetryCount: 1,
|
|
|
+ pollingWhenHidden: false,
|
|
|
+ });
|
|
|
+ const { data: userVip } = useRequest<any, any>(getVipApi, {
|
|
|
+ pollingErrorRetryCount: 1,
|
|
|
+ pollingWhenHidden: false,
|
|
|
+ });
|
|
|
|
|
|
return (
|
|
|
<div className="profile-box">
|
|
|
<ProfileHeader userInfo={userInfo} userMoney={userMoney} userVip={userVip!} />
|
|
|
- <ItemCom max={max} />
|
|
|
+ <ItemCom />
|
|
|
<ModalCom />
|
|
|
</div>
|
|
|
);
|