Home.js 7.7 KB

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