import React,{Component} from 'react';
import {Button, View,OpenData} from '@tarojs/components'
import Taro from '@tarojs/taro';
import { AtIcon } from 'taro-ui'

import 'taro-ui/dist/style/components/icon.scss';

import './index.less';

class UserFloatingLayer extends Component{
  constructor(props) {
    super(props);
    this.state={
      userInfor:{}
    }
  }

  componentDidMount() {
    let userInfor = Taro.getStorageSync('userInfor');
    this.setState({
      userInfor
    })
  }

  render() {
    return(
      <View className='userFloatingLayer'>
        <View className='userAvatarUrl'>
          <OpenData type='userAvatarUrl'/>
        </View>
        <View className='userNickName'>
          {this.state.userInfor.name}
          <View className='welcome' onClick={()=>{
            Taro.setStorageSync("token", "");
            Taro.setStorageSync('userInfor', "");
            Taro.closeSocket();
            Taro.reLaunch({
              url: '/pages/login/index'
            })
          }}>退出</View>
        </View>
      </View>
    );
  }
}

export default UserFloatingLayer;
