tiefen_space_h5/app/my/setting/deleteAccount/page.js

174 lines
5.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import React, { useState, useEffect, useRef } from "react";
import { Button,Dialog,Toast } from "antd-mobile";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faAngleLeft,
} from "@fortawesome/free-solid-svg-icons";
import { useRouter } from "next/navigation";
import { formatDeadline } from "@/utils/tools";
import requireAPI from "@/utils/requireAPI";
export default function DeleteAccount() {
const [deadline, setDeadline] = useState();
const router = useRouter();
const showMobal = useRef()
useEffect(() => {
checkAccountStatus();
}, []);
//查询用户是否在注销中
const checkAccountStatus = async () => {
try {
const _data = await requireAPI("POST", "/api/account_cancellation/list_by_mid");
if (_data.ret === -1) {
Toast.show({
icon: "fail",
content: _data.msg,
position: "top",
});
return;
}
if (_data.data.status === 0) setDeadline(_data.data.due_time);
} catch (error) {
console.error(error);
}
};
//提交注销申请
const handleDeleteAccount = async () => {
try {
const _data = await requireAPI("POST", "/api/account/cancel");
console.log("requireAPI",_data)
if (_data.ret === -1) {
Toast.show({
icon: "fail",
content: _data.msg,
position: "top",
});
return;
}
checkAccountStatus();
showMobal.current?.close();
} catch (error) {
console.error(error);
}
};
//取消注销
const undoDeleteAccount = async () => {
try {
const _data = await requireAPI("POST", "/api/account/abort_cancellation");
if (_data.ret === -1) {
Toast.show({
icon: "fail",
content: _data.msg,
position: "top",
});
return;
}
setDeadline();
} catch (error) {
console.error(error);
}
};
const handleShowDialog = () => {
showMobal.current = Dialog.show({
title: "您确认要注销此账号吗?",
content:
"注销后无法恢复,请仔细阅读《注销必看须知》后确认。",
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: "submit",
text: "确认",
style: { color: "#ffffff80" },
onClick: handleDeleteAccount,
},
{
key: "close",
text: "取消",
bold: true,
style: { color: "#fff" },
onClick: () => {
showMobal.current?.close();
},
},
],
],
});
// if (result) {
// Toast.show({ content: "点击了确认", position: "bottom" });
// }
};
return (
<div>
<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 absolute">
<FontAwesomeIcon
icon={faAngleLeft}
size="xl"
onClick={() => {
router.back();
}}
/>
</div>
<p className="text-base text-center leading-9">帐号注销</p>
</div>
{/* 内容 */}
<div className="pt-16 p-4">
<p className="text-white text-lg font-medium">注销必看须知:</p>
<div className="bg-[#13121F] rounded-2xl p-3 mt-2">
<p className="text-white text-base font-medium">1账号个人信息</p>
<p className="text-[#FFFFFFB2] text-base">
账号注销后您将永远失去该账户的所有内容且无法恢复包括但不限于个人资料信息访问记录关注列表私信聊天记录等
</p>
<p className="text-white text-base font-medium mt-2">
2账号资产与权益
</p>
<p className="text-[#FFFFFFB2] text-base">
账号注销后您将失去所有账号使用期间获得的资产与权益且无法恢复包括但不限于您的金币钻石会员特权以及其他已付费的订单商品等
</p>
<p className="text-white text-base font-medium mt-2">3注销时间</p>
<p className="text-[#FFFFFFB2] text-base">
您发起注销账户申请后我们将在7个自然日后完全清除您的账号信息在此期间您可以随时在本页面撤销该申请
</p>
<p className="text-white text-base font-medium mt-2">4其他</p>
<p className="text-[#FFFFFFB2] text-base">
平台入驻创作者请联系运营进行注销
</p>
</div>
{deadline && (
<p className="text-[#F53030] text-base font-medium mt-2">
您的账号将于{formatDeadline(deadline)}
注销如需取消注销请点击下方取消注销
</p>
)}
<div className="mt-16">
<Button
shape="rounded"
size="middle"
block
onClick={deadline?undoDeleteAccount:handleShowDialog}
style={{ "--background-color": "#FF669E", color: "#FFFFFF" }}
>
{deadline ? "取消注销" : "确认注销账号"}
</Button>
</div>
</div>
</div>
);
}