index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import React,{Component} from 'react';
  2. import { StyleSheet, Text, View ,Image} from 'react-native';
  3. import QRCode from 'react-native-qrcode';
  4. import {connect} from 'react-redux'
  5. import Device from '../../../tool/Device';
  6. class QrCode extends Component {
  7. constructor(props){
  8. super(props)
  9. }
  10. static navigationOptions ={
  11. title:'我的二维码'
  12. }
  13. render(){
  14. const {UserAction} = this.props
  15. const {id,username,head} = UserAction
  16. if(head){
  17. source = {
  18. uri:head,
  19. cache: 'force-cache'
  20. }
  21. }else{
  22. source = require('../../../../assets/icon.png')
  23. }
  24. return (
  25. <View style={styles.box}>
  26. <Image style={styles.bgImage} source={require('../../../../assets/2x/code-bg.png')}/>
  27. <View style={styles.bgImage}>
  28. <View style={styles.headBox}>
  29. <Image style={styles.head} source={source}/>
  30. <View style={styles.headTille}>
  31. <Text style={styles.nickName}>{username}</Text>
  32. <Text style={styles.ID}>ID:{id}</Text>
  33. </View>
  34. </View>
  35. <View style={styles.QRBox}>
  36. <QRCode
  37. value={id}
  38. size={Device.scale(225)}
  39. bgColor='black'
  40. fgColor='white'/>
  41. </View>
  42. <View style={styles.info}>
  43. <Text style={styles.info1}>扫一扫上面的二维码,加我汇聊</Text>
  44. </View>
  45. </View>
  46. </View>
  47. )
  48. }
  49. }
  50. const mapStateToProps = ({UserAction} )=> {
  51. return {UserAction}
  52. }
  53. export default connect(mapStateToProps)(QrCode);
  54. const styles = StyleSheet.create({
  55. view:{
  56. backgroundColor:"#000",
  57. height:Device.scale(50),
  58. },
  59. container: {
  60. flex: 1,
  61. backgroundColor: '#fff',
  62. alignItems: 'center',
  63. justifyContent: 'center',
  64. },
  65. box:{
  66. flex:1,
  67. justifyContent: 'center',
  68. },
  69. bgImage:{
  70. position:"absolute",
  71. top:Device.scale(65),
  72. width:Device.scale(328),
  73. height:Device.scale(443),
  74. left:'50%',
  75. marginLeft:-Device.scale(164)
  76. },
  77. headBox:{
  78. flexDirection:"row",
  79. alignItems: 'center',
  80. paddingLeft:Device.scale(39),
  81. paddingTop:Device.scale(42),
  82. },
  83. head:{
  84. width:Device.scale(64),
  85. height:Device.scale(64),
  86. borderRadius:Device.scale(9),
  87. },
  88. headTille:{
  89. marginLeft:Device.scale(15)
  90. },
  91. nickName:{
  92. lineHeight:Device.scale(31),
  93. fontSize:Device.scale(16),
  94. },
  95. ID:{
  96. lineHeight:Device.scale(29),
  97. fontSize:Device.scale(14),
  98. color:"#000",
  99. opacity:0.5,
  100. },
  101. QRBox:{
  102. flexDirection:"row",
  103. alignItems: 'center',
  104. justifyContent:'center',
  105. // marginLeft:54,
  106. marginTop:Device.scale(41),
  107. },
  108. qrCode:{
  109. width:Device.scale(255),
  110. height:Device.scale(255),
  111. },
  112. info:{
  113. alignItems: 'center',
  114. marginTop:Device.scale(25),
  115. },
  116. info1:{
  117. fontSize:Device.scale(12),
  118. color:"#000",
  119. opacity:0.5,
  120. }
  121. });