2024-07-02 23:08:38 +08:00
|
|
|
|
"use client";
|
|
|
|
|
|
2024-07-17 16:58:27 +08:00
|
|
|
|
import React, { useState, useEffect, useRef } from "react";
|
2024-08-21 11:30:19 +08:00
|
|
|
|
import { Button, Dialog, Toast } from "antd-mobile";
|
2024-07-02 23:08:38 +08:00
|
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
2024-08-21 11:30:19 +08:00
|
|
|
|
import { faAngleLeft } from "@fortawesome/free-solid-svg-icons";
|
2024-07-02 23:08:38 +08:00
|
|
|
|
import { useRouter } from "next/navigation";
|
|
|
|
|
import { formatDeadline } from "@/utils/tools";
|
2024-07-22 16:07:41 +08:00
|
|
|
|
import requireAPI from "@/utils/requireAPI";
|
2024-07-02 23:08:38 +08:00
|
|
|
|
export default function DeleteAccount() {
|
|
|
|
|
const [deadline, setDeadline] = useState();
|
|
|
|
|
const router = useRouter();
|
2024-08-21 11:30:19 +08:00
|
|
|
|
const showMobal = useRef();
|
2024-07-17 16:58:27 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
checkAccountStatus();
|
|
|
|
|
}, []);
|
|
|
|
|
//查询用户是否在注销中
|
|
|
|
|
const checkAccountStatus = async () => {
|
|
|
|
|
try {
|
2024-08-21 11:30:19 +08:00
|
|
|
|
const _data = await requireAPI(
|
|
|
|
|
"POST",
|
|
|
|
|
"/api/account_cancellation/list_by_mid"
|
|
|
|
|
);
|
2024-07-17 16:58:27 +08:00
|
|
|
|
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) {
|
2024-09-09 15:34:31 +08:00
|
|
|
|
// console.error(error);
|
2024-07-17 16:58:27 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//提交注销申请
|
|
|
|
|
const handleDeleteAccount = async () => {
|
|
|
|
|
try {
|
2024-07-22 16:07:41 +08:00
|
|
|
|
const _data = await requireAPI("POST", "/api/account/cancel");
|
2024-08-05 18:59:30 +08:00
|
|
|
|
// console.log("requireAPI",_data)
|
2024-07-17 16:58:27 +08:00
|
|
|
|
if (_data.ret === -1) {
|
|
|
|
|
Toast.show({
|
|
|
|
|
icon: "fail",
|
|
|
|
|
content: _data.msg,
|
|
|
|
|
position: "top",
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
checkAccountStatus();
|
|
|
|
|
showMobal.current?.close();
|
|
|
|
|
} catch (error) {
|
2024-09-09 15:34:31 +08:00
|
|
|
|
// console.error(error);
|
2024-07-17 16:58:27 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//取消注销
|
|
|
|
|
const undoDeleteAccount = async () => {
|
|
|
|
|
try {
|
2024-07-22 16:07:41 +08:00
|
|
|
|
const _data = await requireAPI("POST", "/api/account/abort_cancellation");
|
2024-07-17 16:58:27 +08:00
|
|
|
|
if (_data.ret === -1) {
|
|
|
|
|
Toast.show({
|
|
|
|
|
icon: "fail",
|
|
|
|
|
content: _data.msg,
|
|
|
|
|
position: "top",
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setDeadline();
|
|
|
|
|
} catch (error) {
|
2024-09-09 15:34:31 +08:00
|
|
|
|
// console.error(error);
|
2024-07-17 16:58:27 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const handleShowDialog = () => {
|
2024-08-21 11:30:19 +08:00
|
|
|
|
showMobal.current = Dialog.show({
|
2024-07-17 16:58:27 +08:00
|
|
|
|
title: "您确认要注销此账号吗?",
|
2024-08-21 11:30:19 +08:00
|
|
|
|
content: "注销后无法恢复,请仔细阅读《注销必看须知》后确认。",
|
2024-07-17 16:58:27 +08:00
|
|
|
|
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" });
|
|
|
|
|
// }
|
|
|
|
|
};
|
2024-07-02 23:08:38 +08:00
|
|
|
|
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}
|
2024-08-21 11:30:19 +08:00
|
|
|
|
style={{ maxWidth: "12px" }}
|
2024-07-02 23:08:38 +08:00
|
|
|
|
size="xl"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
router.back();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-07-17 16:58:27 +08:00
|
|
|
|
<p className="text-base text-center leading-9">帐号注销</p>
|
2024-07-02 23:08:38 +08:00
|
|
|
|
</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
|
2024-08-21 11:30:19 +08:00
|
|
|
|
onClick={deadline ? undoDeleteAccount : handleShowDialog}
|
2024-07-02 23:08:38 +08:00
|
|
|
|
style={{ "--background-color": "#FF669E", color: "#FFFFFF" }}
|
|
|
|
|
>
|
|
|
|
|
{deadline ? "取消注销" : "确认注销账号"}
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|