123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- /**
- * 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 <ChatRoomList/>
- case 1:
- return <View>
- <Text>1</Text>
- </View>
- case 2:
- return <View>
- <Text>2</Text>
- </View>
- case 3:
- return <View>
- <Text>3</Text>
- </View>
- case 4:
- return <View>
- <Text>4</Text>
- </View>
- }
- }
- render() {
- return (
- <View style={{flex: 1, alignItems: 'center'}}>
- <BaseNavigationBar
- dataSources = {this.state.navigationBarMenu}
- selectedIndex = {this.state.currentIndex}
- didClickedMineItem = {() => {
- this.goToMinePage()
- }}
- didSelectedItem = {(index) => {
- this.setState({currentIndex:index})
- }}
- />
- {this.getPage()}
-
- </View>
- );
- }
- }
|