Home.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. import React, {Component} from 'react';
  2. import {StyleSheet, View, Text, DeviceEventEmitter, TouchableOpacity, ToastAndroid, StatusBar} from 'react-native';
  3. import {FlatGrid} from 'react-native-super-grid';
  4. import {Badge,} from "@ant-design/react-native";
  5. import {createAction} from "../../utils";
  6. import {connect} from 'react-redux'
  7. import ReadUHF from "../../utils/ReadUHF";
  8. @connect(home => ({...home}))
  9. @connect(auth => ({...auth}))
  10. class DesktopHome extends Component {
  11. constructor(props) {
  12. super(props);
  13. const {refreshState} = this.props.home
  14. this.state = {
  15. refreshState: refreshState,
  16. };
  17. }
  18. componentDidMount() {
  19. this._fetchData();
  20. }
  21. _fetchData = () => {
  22. // this.props.dispatch(createAction('auth/tokenRefresh')());
  23. }
  24. _logout = () => {
  25. this.props.dispatch(createAction('auth/logout')());
  26. }
  27. render() {
  28. const {list, refreshState} = this.props.home
  29. const {userData} = this.props.auth
  30. const items = [
  31. {
  32. "icon": "\ue600",
  33. "title": "出库",
  34. "key": "3_1",
  35. "stack": "DeliverHome",
  36. "type": "Deliver",
  37. },
  38. {
  39. "icon": "\ue601",
  40. "title": "退货",
  41. "key": "3_2",
  42. "stack": "ReturnHome",
  43. "type": "Return",
  44. }, {
  45. "icon": "\ue645",
  46. "title": "窜货查询",
  47. "key": "3_3",
  48. "stack": "SearchHome"
  49. },
  50. {
  51. "icon": "\ue600",
  52. "title": "射频出库",
  53. "key": "3_4",
  54. "stack": "UHFDeliver",
  55. "type": "Deliver",
  56. },
  57. {
  58. "icon": "\ue601",
  59. "title": "射频退货",
  60. "key": "3_5",
  61. "stack": "UHFReturn",
  62. "type": "Return",
  63. },
  64. ]
  65. return (
  66. <View style={styles.container}>
  67. <FlatGrid
  68. style={styles.gridView}
  69. itemDimension={120}
  70. spacing={0}
  71. items={items}
  72. renderItem={({item}) => <ItemGrid name={item.title} icon={item.icon}
  73. navigation={this.props.navigation} stack={item.stack} type={item.type}
  74. />}
  75. />
  76. <View style={styles.userContainer}>
  77. <Text style={styles.userImg}>{"\ue602"}</Text>
  78. <View style={styles.userInfo}>
  79. <Text style={styles.userInfoText}>账号:{userData.username}</Text>
  80. <Text style={styles.userInfoText}>姓名:{userData.name}</Text>
  81. </View>
  82. <View style={styles.loginOut}>
  83. <TouchableOpacity onPress={() => this._logout()}>
  84. <Text style={styles.loginOutText}>注销登录</Text>
  85. </TouchableOpacity>
  86. </View>
  87. </View>
  88. </View>
  89. );
  90. }
  91. }
  92. class ItemGrid extends Component {
  93. constructor(props) {
  94. super(props);
  95. }
  96. doPress=()=>{
  97. DeviceEventEmitter.emit("MsgFromAndroid", {msg:'aaaa'});
  98. ReadUHF.changeFlag(1)
  99. ReadUHF.doRead()
  100. }
  101. render() {
  102. return (
  103. <View style={styles.itemContainer}>
  104. <TouchableOpacity
  105. onPress={() => this.props.navigation.navigate(this.props.stack,{type:this.props.type})}>
  106. {/*onPress={() => this.doPress()}>*/}
  107. <View>
  108. <Badge text={this.props.tips} size='small'>
  109. <Text style={styles.iconFont}>{this.props.icon}</Text>
  110. <View>
  111. <Text style={styles.sizeFont}>{this.props.name}</Text>
  112. </View>
  113. </Badge>
  114. </View>
  115. </TouchableOpacity>
  116. </View>
  117. )
  118. }
  119. }
  120. const styles = StyleSheet.create({
  121. container: {
  122. flex: 1
  123. },
  124. userContainer: {
  125. height: 50,
  126. backgroundColor: '#7ff0ed',
  127. flexDirection: 'row',
  128. },
  129. userImg: {
  130. fontFamily: 'iconfont',
  131. color: '#fff',
  132. paddingLeft: 10,
  133. paddingTop: 5,
  134. fontSize: 35,
  135. },
  136. userInfo: {
  137. marginBottom: 5,
  138. paddingTop: 5,
  139. paddingLeft: 10,
  140. flex: 1
  141. },
  142. userInfoText: {
  143. color: '#fff',
  144. },
  145. loginOut: {
  146. flexDirection: 'row',
  147. width: 80,
  148. paddingTop: 15,
  149. justifyContent: 'center',
  150. backgroundColor: '#23d1ff'
  151. },
  152. loginOutText: {
  153. color: '#fff',
  154. fontSize: 16,
  155. },
  156. gridView: {
  157. marginTop: 0,
  158. flex: 0,
  159. padding: 0
  160. },
  161. itemContainer: {
  162. justifyContent: 'flex-end',
  163. padding: 20,
  164. alignItems: 'center',
  165. textAlign: 'center',
  166. borderRightWidth: 1,
  167. borderBottomWidth: 1,
  168. borderColor: '#eaeaea'
  169. },
  170. iconFont: {
  171. color: '#5eafe4',
  172. fontFamily: 'iconfont',
  173. fontSize: 30,
  174. textAlign: 'center',
  175. marginBottom: 5
  176. },
  177. sizeFont: {
  178. color: 'black',
  179. fontFamily: 'iconfont',
  180. fontSize: 12,
  181. textAlign: 'center',
  182. marginBottom: 5
  183. },
  184. })
  185. export default DesktopHome;