/** * V3版本Profile页面 * @邠心vbe on 2024/05/30 */ import React, { Component } from 'react'; import { View, StyleSheet, Image, ScrollView, StatusBar, Pressable } from 'react-native'; import Button, { ElevationObject } from '../../components/Button'; import TextView from '../../components/TextView'; import Dialog from '../../components/Dialog'; import apiUser from '../../api/apiUser'; import { setAccessToken } from '../../api/http'; import { getStorageJsonSync, setStorage, setStorageJson } from '../../utils/storage'; import utils from '../../utils/utils'; import { PageList } from '../Router'; import app from '../../../app.json'; import Svg, { Defs, Ellipse, G, LinearGradient, Path, Rect, Stop } from 'react-native-svg'; import ShadowView from '../../components/ShadowView'; import MyStatusBar from '../../components/MyStatusBar'; export default class ProfileV3 extends Component { constructor(props) { super(props); this.state = { isHide: false, userInfo: userInfo, totalVehicle: 0 }; } componentDidMount() { this.init(); this.props.navigation.addListener('focus', () => { this.init(); this.setState({ isHide: false }, () => { setTimeout(() => { MyStatusBar.setStatusBarTheme(MyStatusBar.LIGHT_STYLE); }, 100); }); }); this.props.navigation.addListener('blur', () => { this.setState({ isHide: true }) MyStatusBar.setStatusBarTheme(MyStatusBar.DARK_STYLE); }); } init() { getUserInfo(info => { this.setState({ userInfo: info }); }, true); } 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); }) } logout() { Dialog.showDialog({ title: $t('profile.signOut'), message: $t('profile.tipSignOut'), callback: btn => { if (btn == Dialog.BUTTON_OK) { Dialog.showProgressDialog(); setTimeout(() => { this.requestLogout(); }, 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: {} });*/ setAccessToken(''); goBack(); Dialog.dismissLoading(); } render() { return ( {/* */} goBack()}> Profile {this.state.userInfo.photoUrl ? : } {this.state.userInfo.nickName} Singapore {this.state.userInfo.email} {/* */} {/* */} {/* */} {/* */} {/* */} {/* */} {/* */} {/* */} {/* */}