/** * 新版首页 * @邠心vbe on 2024/02/01 */ import React from 'react'; import {View, Text, StyleSheet, Image} from 'react-native'; import app from '../../../app.json'; import { PageList } from '../Router'; import Button from '../../components/Button'; import { Styles } from '../../components/Toolbar'; import TextView from '../../components/TextView'; import apiCharge from '../../api/apiCharge'; import { TouchableWithoutFeedback } from 'react-native-gesture-handler'; import { toTopupPage } from '../payment/PaymentConfig'; import utils from '../../utils/utils'; const DEBUG = app.debug && !app.product; export default DrawerView = ({isLogin=false, userInfo, onLogout, notificationCount=0, navigation}) => { const getCharging = () => { Dialog.showProgressDialog(); apiCharge.getUserCharging().then(res => { Dialog.dismissLoading(); if (res.data.sitePk) { utils.toChargeDetailPage(res.data.sitePk, 'view', PageList.home); //startPage(PageList.chargeDetailPage, {stationInfo: {id: res.data.sitePk}, action: 'view', from: PageList.home}); //startPage(PageList.chargeDetail, { stationInfo: {id: res.data.sitePk}, action: 'view'}); } else if (res.msg) { toastShort(res.msg); } else { toastShort($t("drawer.noChargingSession")); } }).catch((err) => { if (app.debug) console.log(err); Dialog.dismissLoading(); toastShort($t("drawer.noChargingSession")); }) } const logout = () => { Dialog.showDialog({ title: $t('profile.signOut'), message: $t('profile.tipSignOut'), callback: btn => { if (btn == Dialog.BUTTON_OK) { Dialog.showProgressDialog(); setTimeout(() => { if (onLogout) onLogout(); }, 500); } } }) } return ( { userInfo.photoUrl ? startPage(PageList.profile)}> : startPage(isLogin ? PageList.profile : PageList.login)}> } { isLogin ? : {/* */} {$t('drawer.charging')} } { isLogin && <> } {/*附加功能-开始*/} { (app.notifications.enable && isLogin) && } { (app.modules.bookmarks && isLogin) && } {/*附加功能-结束*/} { (app.modules.membership && isLogin) && } {/* */} { app.modules.support && } {/* */} { DEBUG && <> {$t('drawer.debugOnly')} } {/* isLogin ? toTopupPage()}> {currency}{userInfo.credit} {/* { startPage(PageList.referral); }}> Refer your friends to get $5 credit! *} : s */} {app.displayName + ' ' + app.versionName} {/* isLogin &&