Home.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import React, {Component} from 'react';
  2. import {
  3. StyleSheet,
  4. View,
  5. Text,
  6. StatusBar,
  7. Image,
  8. ScrollView,
  9. } from 'react-native';
  10. import {Button, Provider} from '@ant-design/react-native';
  11. import {Cell, Section, TableView} from 'react-native-tableview-simple';
  12. import {Img} from '../../components';
  13. import {createAction} from '../../utils';
  14. import {connect} from 'react-redux';
  15. import SyncStorage from 'sync-storage';
  16. import Bugly from '../../utils/Bugly';
  17. import {ComponentsStyles} from '../../components/ComponentsStyles';
  18. @connect(auth => ({...auth}))
  19. class MineHome extends Component {
  20. constructor(props) {
  21. super(props);
  22. this.state = {
  23. currentPage: 1,
  24. version: '',
  25. };
  26. }
  27. static navigationOptions = {
  28. headerShown: false, //隐藏顶部导航栏
  29. };
  30. componentDidMount() {
  31. Bugly.getVersion((ver) => {
  32. this.setState({
  33. version: ver,
  34. });
  35. });
  36. }
  37. // 退出
  38. loginOut = () => {
  39. this.props.dispatch(createAction('auth/logout')());
  40. };
  41. onItemPress = (val) => {
  42. if (val === 'settingURL') {
  43. this.loginOut();
  44. } else {
  45. this.props.navigation.navigate(val);
  46. }
  47. };
  48. onCheckUpgrade = () => {
  49. Bugly.checkUpgrade();
  50. };
  51. render() {
  52. const credential = SyncStorage.get('credential');
  53. const baseURL = SyncStorage.get('baseURL');
  54. return (
  55. <View style={{flex: 1, marginTop: ComponentsStyles.top_margin}}>
  56. <StatusBar backgroundColor={'#f2f2f2'} barStyle='dark-content'/>
  57. <Provider>
  58. <ScrollView>
  59. {/* 头像 */}
  60. <View style={styles.headImg}>
  61. <Image style={styles.img} source={require('../../../assets/images/male_header.png')}>
  62. </Image>
  63. </View>
  64. <View>
  65. {/* 名字 */}
  66. <Text style={{
  67. color: '#333333',
  68. fontSize: 22,
  69. fontWeight: '900',
  70. textAlign: 'center',
  71. }}>{credential.username}</Text>
  72. <Text
  73. style={{
  74. fontSize: 14,
  75. fontWeight: '900',
  76. textAlign: 'center',
  77. marginTop: 5,
  78. }}>{credential.dept_name}</Text>
  79. <Text
  80. style={{
  81. fontSize: 14,
  82. fontWeight: '900',
  83. textAlign: 'center',
  84. marginTop: 5,
  85. }}>{baseURL}</Text>
  86. </View>
  87. {/* 功能 */}
  88. <TableView>
  89. <Section sectionTintColor='#f2f2f2'>
  90. <Cell
  91. accessory="DisclosureIndicator"
  92. cellStyle="RightDetail"
  93. title="修改密码"
  94. image={
  95. <Text style={styles.iconFont}>{'\ue60e'}</Text>
  96. }
  97. onPress={() => this.onItemPress('ChangePassword')}
  98. />
  99. <Cell
  100. accessory="DisclosureIndicator"
  101. cellStyle="RightDetail"
  102. title="隐私说明"
  103. image={
  104. <Text style={styles.iconFont}>{'\ue61c'}</Text>
  105. }
  106. onPress={() => this.onItemPress('Privacy')}
  107. />
  108. <Cell
  109. cellStyle="RightDetail"
  110. title="当前版本"
  111. detail={this.state.version}
  112. image={
  113. <Text style={styles.iconFont}>{'\ue6aa'}</Text>
  114. }
  115. />
  116. </Section>
  117. </TableView>
  118. {/* 退出登录 */}
  119. <Button onPress={this.loginOut} style={styles.button} type="warning">退出登录</Button>
  120. </ScrollView>
  121. </Provider>
  122. </View>
  123. );
  124. }
  125. }
  126. const styles = StyleSheet.create({
  127. centerView: {
  128. width: 3,
  129. backgroundColor: '#d7d7d7',
  130. borderRadius: 3,
  131. justifyContent: 'center',
  132. },
  133. headImg: {
  134. flexDirection: 'row',
  135. justifyContent: 'center',
  136. },
  137. img: {
  138. width: 70,
  139. height: 70,
  140. marginVertical: 20,
  141. borderRadius: 50,
  142. },
  143. iconFont: {
  144. fontFamily: 'iconfont',
  145. fontSize: 20,
  146. color: '#1E90FF',
  147. lineHeight: 30,
  148. },
  149. button: {
  150. marginHorizontal: 10,
  151. },
  152. });
  153. export default MineHome;