123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- import React, {Component} from 'react';
- import {StyleSheet, View, Text, DeviceEventEmitter, TouchableOpacity, ToastAndroid} from 'react-native';
- import {Button} from '@ant-design/react-native';
- import ReadUHF from "../../utils/ReadUHF";
- class DesktopHome extends Component {
- constructor(props) {
- super(props);
- this.state = {
- data: [3, 4, 5],
- };
- }
- componentDidMount() {
- ReadUHF.changeFlag(0)
- DeviceEventEmitter.addListener('MsgFromAndroid', this._addCode);
- }
- componentWillUnmount() {
- ReadUHF.stopRead()
- }
- _addCode = (item) => {
- console.log(111111111111,item)
- // let str = '{"userData":"6a173f0fd2a140cf20204fbaa6d1c0158518031da248f306535dc6d10026a7c985671ae611afb4c151feb5712eba3d52",' +
- // '"assetID":"4330012800000002178203" ,"model":"002型","manufacturer":"北京公司","kind":"电压互感器"}'
- // let str = '{"name": "cxh", "sex": "man" }';
- // console.log(2333333333,str)
- const str = JSON.parse(item)
- console.log(22222222222,str, str['kind'])
- let {data} = this.state;
- data.push(item)
- this.setState({data})
- }
- _start = () => {
- let {isStart} = this.state;
- ReadUHF.doRead()
- this.setState({isStart: !isStart})
- }
- render() {
- return (
- <View style={styles.container}>
- {
- this.state.data.map((item, index) => {
- return (
- <Text key={index}>{item}</Text>
- )
- })
- }
- <Button onPress={() => this._start()}
- type="primary"
- >
- 开始
- </Button>
- </View>
- );
- }
- }
- const styles = StyleSheet.create({
- container: {
- flex: 1
- },
- userContainer: {
- height: 50,
- backgroundColor: '#7ff0ed',
- flexDirection: 'row',
- },
- userImg: {
- fontFamily: 'iconfont',
- color: '#fff',
- paddingLeft: 10,
- paddingTop: 5,
- fontSize: 35,
- },
- userInfo: {
- marginBottom: 5,
- paddingTop: 5,
- paddingLeft: 10,
- flex: 1
- },
- userInfoText: {
- color: '#fff',
- },
- loginOut: {
- flexDirection: 'row',
- width: 80,
- paddingTop: 15,
- justifyContent: 'center',
- backgroundColor: '#23d1ff'
- },
- loginOutText: {
- color: '#fff',
- fontSize: 16,
- },
- gridView: {
- marginTop: 0,
- flex: 0,
- padding: 0
- },
- itemContainer: {
- justifyContent: 'flex-end',
- padding: 20,
- alignItems: 'center',
- textAlign: 'center',
- borderRightWidth: 1,
- borderBottomWidth: 1,
- borderColor: '#eaeaea'
- },
- iconFont: {
- color: '#5eafe4',
- fontFamily: 'iconfont',
- fontSize: 30,
- textAlign: 'center',
- marginBottom: 5
- },
- sizeFont: {
- color: 'black',
- fontFamily: 'iconfont',
- fontSize: 12,
- textAlign: 'center',
- marginBottom: 5
- },
- })
- export default DesktopHome;
|