/** * Created by zack on 2018/4/19. */ import { View, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native' import React, {Component} from 'react' import BaseNavigationBar from '../base/BaseNavigationBar' import HttpTools from '../../network/HttpTools' import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../utils/DimensionsTools' import CAGameViewController from './Game/CAGameViewController'; import CAMiningViewController from './Mining/CAMiningViewController'; import CAVideoViewController from './Video/CAVideoViewController'; import {GlobalUserStorageTool, UserStorageKey} from '../../utils/GlobalUserStorageTool' import BaseNavigationBarStyle from '../base/BaseNavigationBarStyle' export default class PlayViewController extends Component { constructor(props) { super(props) this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this)); this.state = { navigationBarMenu: [ {title: '游戏', index: 0}, {title: '挖矿', index: 1}, {title: '视频', index: 2}, {title: '小麦', index: 3}, {title: '大米', index: 4}, ] } } componentDidMount() { this.props.navigator.setOnNavigatorEvent(event => { if (event.type === 'NavBarButtonPress') { if (event.id === 'add') { } }else if (event.type === 'ScreenChangedEvent') { if (event.id === 'willAppear') { this.showTabBar() }else if (event.id === 'willDisappear') { } } }) GlobalUserStorageTool.load(UserStorageKey.UserInfo, (ret) => { console.log("user info: " + ret) }, (error) => { }) } onNavigatorEvent(event) { console.log(event.type) let str = '' } hideTabBar() { this.props.navigator.toggleTabs({ to:'hidden', animated: true }) } showTabBar() { this.props.navigator.toggleTabs({ to:'shown', animated: true }) } onPressBannerBack(){ this.hideTabBar() this.props.navigator.push({ screen: 'CAVideoDetailView', title: '我的', backButtonTitle: '', passProps: { key: 'hahah' } }) } goToMinePage() { this.hideTabBar() GlobalUserStorageTool.load(UserStorageKey.UserInfo, (response) => { if (response && response.nickname) { //已经登录成功 this.props.navigator.push({ screen: 'MineViewController', title: '基本资料', backButtonTitle: '', navigatorStyle: BaseNavigationBarStyle, passProps: { UserInfo: response } }) } else { this.props.navigator.push({ screen: 'LoginViewController', title: '我的', backButtonTitle: '', navigatorStyle: { navBarHidden: true }, passProps: {} }) } }, (error) => { this.props.navigator.push({ screen: 'LoginByVerificationCodeViewController', title: '我的', backButtonTitle: '', navigatorStyle: { navBarHidden: true }, passProps: {} }) }) } render() { return ( { this.goToMinePage() }} didSelectedItem = {(index) => [ console.log("----" + index) ]} /> ); } } const styles = StyleSheet.create({ View: { width: ScreenDimensions.width, height: ScreenDimensions.height, backgroundColor: 'white' }, ScrollView: { marginTop: NavigationBarHeight.height, width: ScreenDimensions.width, height: ScreenDimensions.height - NavigationBarHeight.height - TabBarHeight.height, backgroundColor: '#ffffff', }, })