/** * Created by zack on 2018/4/19. */ import { View, Text, StyleSheet, Image, TouchableOpacity, } from 'react-native' import React, {Component} from 'react' import BaseNavigationBar from '../base/BaseNavigationBar' import {GlobalUserStorageTool, UserStorageKey} from '../../utils/GlobalUserStorageTool' import BaseNavigationBarStyle from '../base/BaseNavigationBarStyle' import {heightPxToDp,widthPxToDp,deviceWidth} from '../../utils/ScreenUtils' import _const from '../../const/_const' import ChatMainTopLayout from './chatTopLayout' import ChatRoomList from "./tabPages/chatRoomList"; import ChatUtil from '../../utils/ChatUtils' export default class ChatViewController extends Component { constructor(props) { super(props) this.state = { navigationBarMenu: [ {title: '聊吧', index: 0}, {title: '找群', index: 1}, {title: '找同学', index: 2}, {title: '找老师', index: 3}, {title: '联系人', index: 4}, ], currentIndex:0, } } componentDidMount() { ChatUtil.connect().then(res=>{ console.log('chat:::::',res) ChatUtil.setSession().then(result=>{ console.log('sid:::',result) }) } ).catch(err=>{console.warn(err)}) console.log(GlobalUserStorageTool.load(UserStorageKey.UserInfo,(res)=>{console.log(res)},(err)=>{console.log(err)})) this.props.navigator.setOnNavigatorEvent(event => { if (event.type === 'NavBarButtonPress') { }else if (event.type === 'ScreenChangedEvent') { if (event.id === 'willAppear') { this.showTabBar() }else if (event.id === 'willDisappear') { } } }) } hideTabBar() { this.props.navigator.toggleTabs({ to:'hidden', animated: true }) } showTabBar() { this.props.navigator.toggleTabs({ to:'shown', animated: true }) } 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: { } }) }) } getPage=()=>{ const currentIndex=this.state.currentIndex switch (currentIndex){ case 0: return case 1: return 1 case 2: return 2 case 3: return 3 case 4: return 4 } } render() { return ( { this.goToMinePage() }} didSelectedItem = {(index) => { this.setState({currentIndex:index}) }} /> {this.getPage()} ); } }