tiefen_space_h5/app/my/wallet/page.js

184 lines
5.9 KiB
JavaScript
Raw Normal View History

2024-07-02 15:09:48 +08:00
"use client";
2024-07-22 16:07:41 +08:00
import React, { useEffect, useState } from "react";
2024-07-22 14:38:59 +08:00
import { Image, Divider, Toast } from "antd-mobile";
2024-07-02 15:09:48 +08:00
import { useRouter } from "next/navigation";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faAngleLeft,
faAngleRight,
faWallet,
faPrint,
faDollar,
} from "@fortawesome/free-solid-svg-icons";
2024-07-22 14:38:59 +08:00
import baseRequest from "@/utils/baseRequest";
import { get, save } from "@/utils/storeInfo";
2024-07-22 16:07:41 +08:00
import requireAPI from "@/utils/requireAPI";
2024-07-02 15:09:48 +08:00
export default function Wallet() {
2024-07-22 14:38:59 +08:00
const tokenCache = get("token");
const temToken = encodeURIComponent(tokenCache);
const mobilePhone = get("mobile_phone");
const base = baseRequest();
2024-07-02 15:09:48 +08:00
const router = useRouter();
2024-07-22 14:38:59 +08:00
const [data, setData] = useState("");
2024-07-02 15:09:48 +08:00
// 获取屏幕高度
// const scrollHeight = 600;
2024-07-22 14:38:59 +08:00
useEffect(() => {
2024-07-24 17:12:11 +08:00
getData();
2024-07-22 14:38:59 +08:00
}, []);
const getData = async () => {
try {
//获取账号基本信息
2024-07-24 17:12:11 +08:00
const _data = await requireAPI(
"POST",
"/api/account/list_by_mid",
null,
true
);
2024-07-22 16:07:41 +08:00
if (_data.ret === -1) {
2024-07-22 14:38:59 +08:00
Toast.show({
icon: "fail",
2024-07-22 16:07:41 +08:00
content: _data.msg,
2024-07-22 14:38:59 +08:00
position: "top",
});
return;
}
2024-07-22 16:07:41 +08:00
save("account", _data?.data.account);
setData(_data?.data.account);
2024-07-22 14:38:59 +08:00
} catch (error) {
console.error(error);
}
};
2024-07-02 15:09:48 +08:00
return (
<div className="">
<div className="p-4 fixed top-0 z-10 w-full">
<div className="w-9 h-9 flex items-center justify-center bg-[#FFFFFF1A] rounded-full float-left">
<FontAwesomeIcon
icon={faAngleLeft}
size="xl"
onClick={() => {
2024-07-10 16:50:53 +08:00
router.push("/my");
2024-07-02 15:09:48 +08:00
}}
/>
</div>
<p className="text-base text-center leading-9">我的钱包</p>
</div>
{/* 内容 */}
<div className="p-4 pt-24 bg-gradient-to-b from-[#FF669E] to-[#07050A]">
<div className="flex flex-row justify-around mt-2 w-full">
<div className="flex flex-col items-center w-1/4">
<Image
2024-07-24 19:08:22 +08:00
src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/icon_goldcoin.png"}
2024-07-02 15:09:48 +08:00
placeholder=""
width={48}
height={48}
/>
2024-07-24 17:12:11 +08:00
<p className="text-2xl font-semibold text-white">
{data?.gold_num || 0}
</p>
2024-07-02 15:09:48 +08:00
<p className="text-sm text-white">金币</p>
</div>
<Divider
direction="vertical"
style={{ height: "99px", borderColor: "#fff" }}
/>
<div className="flex flex-col items-center w-1/4">
<Image
2024-07-24 19:08:22 +08:00
src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/icon_diamond.png"}
2024-07-02 15:09:48 +08:00
placeholder=""
width={48}
height={48}
/>
2024-07-24 17:12:11 +08:00
<p className="text-2xl font-semibold text-white">
{data?.diamond_num || 0}
</p>
2024-07-02 15:09:48 +08:00
<p className="text-sm text-white">钻石</p>
</div>
</div>
<div className="relative px-4">
<div className="absolute top-8 left-0 w-full rounded-2xl px-4 bg-[#13121F]">
<div
2024-07-22 14:38:59 +08:00
onClick={() =>
// navigation.navigate("WebWithHeader", {
// title: "充值中心",
// uri: process.env.EXPO_PUBLIC_WEB_URL + "/pay",
// })
2024-07-24 17:12:11 +08:00
{
console.log("base,base", base);
router.push(
`/webView/${encodeURIComponent(
2024-07-25 19:52:30 +08:00
`/pay?base=${encodeURIComponent(JSON.stringify(base))}`
2024-07-24 17:12:11 +08:00
)}`
);
}
2024-07-22 14:38:59 +08:00
}
2024-07-02 15:09:48 +08:00
className="flex justify-between items-center py-4 w-full"
>
<div className="flex-row items-center">
<FontAwesomeIcon
icon={faWallet}
size="xl"
color="red"
2024-07-12 22:52:48 +08:00
className="w-[28px]"
2024-07-02 15:09:48 +08:00
/>
<span className="text-base text-white font-medium ml-2">
充值
</span>
</div>
2024-07-22 14:38:59 +08:00
<FontAwesomeIcon icon={faAngleRight} size="xl" />
2024-07-02 15:09:48 +08:00
</div>
<div
2024-07-22 14:38:59 +08:00
// onClick={() =>
2024-07-02 15:09:48 +08:00
// navigation.navigate("WebWithHeader", {
// title: "收支明细",
// uri: process.env.EXPO_PUBLIC_WEB_URL + "/bill/recharge",
// })
// }
onClick={() => {
router.push("/bill/recharge");
}}
className="flex justify-between items-center py-4"
>
<div className="flex-row items-center">
<FontAwesomeIcon
icon={faPrint}
size="xl"
color="#60a5fa"
2024-07-12 22:52:48 +08:00
className="w-[28px]"
2024-07-02 15:09:48 +08:00
/>
<span className="text-base text-white font-medium ml-2">
收支明细
</span>
</div>
2024-07-22 14:38:59 +08:00
<FontAwesomeIcon icon={faAngleRight} size="xl" />
2024-07-02 15:09:48 +08:00
</div>
<div
2024-07-22 14:38:59 +08:00
onClick={() =>
2024-07-24 17:12:11 +08:00
window &&
window.open(
2024-07-24 13:53:12 +08:00
`${process.env.NEXT_PUBLIC_WEB_URL}/withdrawal?mid=${data?.mid}&mobile_phone=${mobilePhone}&token=${temToken}`
2024-07-22 14:38:59 +08:00
)
}
2024-07-02 15:09:48 +08:00
className="flex justify-between items-center py-4"
>
<div className="flex-row items-center">
<FontAwesomeIcon
icon={faDollar}
size="xl"
color="#fb923c"
2024-07-12 22:52:48 +08:00
className="w-[28px]"
2024-07-02 15:09:48 +08:00
/>
<span className="text-base text-white font-medium ml-2">
提现
</span>
</div>
2024-07-22 14:38:59 +08:00
<FontAwesomeIcon icon={faAngleRight} size="xl" />
2024-07-02 15:09:48 +08:00
</div>
</div>
</div>
</div>
</div>
);
}