/** * 删除账号页面 * @邠心vbe on 2025/06/27 */ import React, { Component } from 'react'; import { View, StyleSheet, ScrollView } from 'react-native'; import CheckBoxText from '../../components/CheckBoxText'; import Button from '../../components/Button'; import apiUser from '../../api/apiUser'; import Dialog from '../../components/Dialog'; import { PageList } from '../Router'; import TextView from '../../components/TextView'; import { getStorageJsonSync, setStorage, setStorageJson } from '../../utils/storage'; import { setAccessToken } from '../../api/http'; export default class DeleteAccount extends Component { constructor(props) { super(props); this.state = { checkValue1: false, checkValue2: false, checkValue3: false }; } deleteAccount() { Dialog.showDialog({ title: $t('profile.deleteAccount'), message: $t('profile.confirmDeleteAccount'), ok: $t('nav.confirm'), callback: button => { if (button == Dialog.BUTTON_OK) { this.deleteMyAccount(); } } }) } deleteMyAccount(again=false) { Dialog.showProgressDialog(); apiUser.deleteAccount({ secondConfirm: again }).then(res => { toastShort($t('profile.deleteAccountSuccess')) Dialog.dismissLoading(); this.requestLogout(); /*setTimeout(() => { startPage(PageList.login); }, 500);*/ }).catch(err => { Dialog.dismissLoading(); //toastShort(err) setTimeout(() => { if (err.code == 5334) { Dialog.showDialog({ title: $t('profile.deleteAccount'), message: err.msg, ok: $t("nav.confirm"), callback: button => { if (button == Dialog.BUTTON_OK) { setTimeout(() => { this.deleteMyAccount(true); }, 500) } } }) } else { Dialog.showResultDialog(err.msg); } }, 500); }) } async requestLogout() { const data = await getStorageJsonSync('loginData'); if (data && data.email) { delete data.password setStorageJson('loginData', data); setStorage('RegisterTokenDate', ""); } global.userInfo = {} /*this.setState({ isLogin: false, userInfo: {} });*/ Dialog.dismissLoading(); setAccessToken(''); startPage(PageList.home); } render() { const styles = delStyle(); return ( We’re sorry to see you go. Please be aware that any remaining credits in your account will be forfeited and are non-refundable if you choose to delete your account. To proceed with account deletion, please confirm your decision by pressing the "Delete Account" button. Once confirmed, your account and all associated data will be permanently deleted and can not be recovered. This action is irreversible. Please Confirm The Following this.setState({checkValue1: newValue})} flexText={true} text={"I understand that my remaining credits will be forfeited and are non-refundable."} disabled={false} textStyle={{fontSize: 12}}/> this.setState({checkValue2: newValue})} flexText={true} text={"I confirm that my account and all associated data will be permanently deleted."} disabled={false} textStyle={{fontSize: 12}}/> this.setState({checkValue3: newValue})} flexText={true} text={"I acknowledge that this action is irreversible and can not be undone."} disabled={false} textStyle={{fontSize: 12}}/>