Advertisement
enkf

Untitled

Jan 27th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.08 KB | None | 0 0
  1. import React from 'react';
  2. import {
  3. StyleSheet,
  4. View,
  5. Text,
  6. TouchableOpacity,
  7. BackHandler,
  8. Image,
  9. ScrollView,
  10. ActivityIndicator,
  11. FlatList,
  12. ImageBackground
  13. } from 'react-native';
  14. import AsyncStorage from '@react-native-community/async-storage';
  15. import {
  16. Container,
  17. Header,
  18. CardItem,
  19. Left,
  20. Body,
  21. Thumbnail,
  22. Card
  23. } from 'native-base';
  24. import { withNavigation } from 'react-navigation';
  25. import Axios from 'axios';
  26.  
  27. class Home extends React.Component {
  28.  
  29. constructor(props) {
  30. super(props);
  31. this.state = {
  32. isLoading: false,
  33. id: '',
  34. card_member:'',
  35. member_code: '',
  36. referral_code: '',
  37. name: '',
  38. place: '',
  39. date_of_birth: '',
  40. religion: '',
  41. address:'',
  42. phone_number: '',
  43. phone_home: '',
  44. phone_office: '',
  45. image: '',
  46. email: '',
  47. password: '',
  48. token: '',
  49. data : [],
  50. renders: []
  51.  
  52. };
  53. }
  54.  
  55. ComponentWillMount() {
  56. BackHandler.addEventListener('hardwareBackPress', () => {
  57. if (!this.onMainScreen()) {
  58. this.goBack();
  59. return true;
  60. }
  61. return false;
  62. });
  63. }
  64.  
  65. async componentDidMount() {
  66. const resToken = await AsyncStorage.getItem('token')
  67. const token = JSON.parse(resToken);
  68. // api profile
  69. console.log(headers);
  70. Axios({
  71. method: 'get',
  72. url: 'http://192.168.56.1/vzuu/public/api/members',
  73. dataType: 'json',
  74. headers: {
  75. 'Accept': 'application/json',
  76. 'Content-Type': 'application/json',
  77. 'Authorization': 'Bearer ' + token.data.success.token,
  78. },
  79.  
  80. })
  81.  
  82. .then(response => {
  83. console.log(response.data);
  84. setTimeout(() => { this.setState({ loading: false }) }, 100)
  85. this.setState({
  86. data: response.data.results.members,
  87. })
  88. console.log(this.state.data);
  89. })
  90. .catch(function(error) {
  91. console.log(error);
  92. })
  93. }
  94.  
  95. render() {
  96. return (
  97. <Container>
  98. <View stye={styles.container}>
  99. <Header style={{ backgroundColor: '#E91E63' }} />
  100. {/* <ImageBackground style={styles.imgBackground} source={require('../asset/images/vzuu.jpg')} > */}
  101.  
  102. {/* {this.state.isLoading
  103. ? <ActivityIndicator color='#E91E63' size='large' />
  104. : */}
  105. <ScrollView>
  106. <View>
  107.  
  108. <View style={{ flex: 1, alignItems: 'center' }}>
  109. <Text style={{ fontSize: 16 }}>{this.state.curTime}</Text>
  110. </View>
  111. {/* <CardItem> */}
  112. <View style={{ marginTop: 50 }}></View>
  113.  
  114. <View style={{flex: 1}}>
  115. <Left>
  116. <Image style={styles.img} source={{ uri :"http://192.168.56.1/vzuu/public/storage" +this.state.image.replace('public','')}} />
  117. <Body>
  118. <View>
  119. <Text style={styles.text}>{this.state.name}</Text>
  120. </View>
  121. <View>
  122. <Text style={styles.text}>{this.state.phone_number}</Text>
  123. </View>
  124. </Body>
  125. </Left>
  126. </View>
  127.  
  128.  
  129. <View
  130. style={{
  131. flexDirection: 'row',
  132. flexWrap: 'wrap',
  133. marginHorizontal: 50,
  134. marginTop: 50,
  135. }}></View>
  136. <View
  137. style={{
  138. flexDirection: 'row',
  139. flexWrap: 'wrap',
  140. marginHorizontal: 18,
  141. marginTop: 18,
  142. }}>
  143. <View
  144. style={{
  145. justifyContent: 'space-between',
  146. flexDirection: 'row',
  147. width: '100%',
  148. marginBottom: 18,
  149. }}>
  150. <View>
  151. <TouchableOpacity onPress={() => this.props.navigation.navigate('treatment')}>
  152. <View
  153. style={{
  154. width: 100,
  155. height: 100,
  156. borderWidth: 1,
  157. borderColor: '#EFEFEF',
  158. borderRadius: 18,
  159. }}>
  160. <Image
  161. source={require('../asset/images/color/service.png')}
  162. style={{ height: 80, width: 100, flex: 1 }}
  163. />
  164. </View>
  165. <Text
  166. style={{
  167. fontSize: 12,
  168. fontWeight: 'bold',
  169. textAlign: 'center',
  170. color: '#E91E63',
  171. }}>
  172. Treatment
  173. </Text>
  174. </TouchableOpacity>
  175. </View>
  176. <View>
  177. <TouchableOpacity onPress={() => this.props.navigation.navigate('booking')}>
  178. <View
  179. style={{
  180. width: 100,
  181. height: 100,
  182. borderWidth: 1,
  183. borderColor: '#EFEFEF',
  184. borderRadius: 18,
  185. }}>
  186. <Image
  187. source={require('../asset/images/color/booking.png')}
  188. style={{ height: 80, width: 100, flex: 1 }}
  189. />
  190. </View>
  191. <Text
  192. style={{
  193. fontSize: 12,
  194. fontWeight: 'bold',
  195. textAlign: 'center',
  196. color: '#E91E63',
  197. }}>
  198. Booking
  199. </Text>
  200. </TouchableOpacity>
  201. </View>
  202. <View>
  203. <TouchableOpacity onPress={() => this.props.navigation.navigate('promotion')}>
  204. <View
  205. style={{
  206. width: 100,
  207. height: 100,
  208. borderWidth: 1,
  209. borderColor: '#EFEFEF',
  210. borderRadius: 18,
  211. }}>
  212. <Image
  213. source={require('../asset/images/color/promo.png')}
  214. style={{ height: 80, width: 100, flex: 1 }}
  215. />
  216. </View>
  217. <Text
  218. style={{
  219. fontSize: 12,
  220. fontWeight: 'bold',
  221. textAlign: 'center',
  222. color: '#E91E63',
  223. }}>
  224. Promotion
  225. </Text>
  226. </TouchableOpacity>
  227. </View>
  228. </View>
  229. </View>
  230.  
  231. <View
  232. style={{
  233. flexDirection: 'row',
  234. flexWrap: 'wrap',
  235. marginHorizontal: 18,
  236. marginTop: 18,
  237. }}>
  238. <View
  239. style={{
  240. justifyContent: 'space-between',
  241. flexDirection: 'row',
  242. width: '100%',
  243. marginBottom: 18,
  244. }}>
  245. <View>
  246. <TouchableOpacity onPress={() => this.props.navigation.navigate('point')}>
  247. <View
  248. style={{
  249. width: 100,
  250. height: 100,
  251. borderWidth: 1,
  252. borderColor: '#EFEFEF',
  253. borderRadius: 18,
  254. }}>
  255. <Image
  256. source={require('../asset/images/color/point.png')}
  257. style={{ height: 80, width: 100, flex: 1 }}
  258. />
  259. </View>
  260. <Text
  261. style={{
  262. fontSize: 12,
  263. fontWeight: 'bold',
  264. textAlign: 'center',
  265. color: '#E91E63',
  266. }}>
  267. Point
  268. </Text>
  269. </TouchableOpacity>
  270. </View>
  271. <View>
  272. <TouchableOpacity>
  273. <View
  274. style={{
  275. width: 100,
  276. height: 100,
  277. borderWidth: 1,
  278. borderColor: '#EFEFEF',
  279. borderRadius: 18,
  280. }}>
  281. <Image
  282. source={require('../asset/images/color/spin.png')}
  283. style={{ height: 80, width: 100, flex: 1 }}
  284. />
  285. </View>
  286. <Text
  287. style={{
  288. fontSize: 12,
  289. fontWeight: 'bold',
  290. textAlign: 'center',
  291. color: '#E91E63',
  292. }}>
  293. Spin
  294. </Text>
  295. </TouchableOpacity>
  296. </View>
  297. <View>
  298. <TouchableOpacity onPress={() => this.props.navigation.navigate('contact')}>
  299. <View
  300. style={{
  301. width: 100,
  302. height: 100,
  303. borderWidth: 1,
  304. borderColor: '#EFEFEF',
  305. borderRadius: 18,
  306. }}>
  307. <Image
  308. source={require('../asset/images/color/contact.png')}
  309. style={{ height: 80, width: 100, flex: 1 }}
  310. />
  311. </View>
  312. <Text
  313. style={{
  314. fontSize: 12,
  315. fontWeight: 'bold',
  316. textAlign: 'center',
  317. color: '#E91E63',
  318. }}>
  319. Contact
  320. </Text>
  321. </TouchableOpacity>
  322. </View>
  323. </View>
  324. </View>
  325. </View>
  326. </ScrollView>
  327.  
  328. {/* } */}
  329. {/* </ImageBackground> */}
  330. </View>
  331. </Container>
  332. );
  333. }
  334. }
  335.  
  336.  
  337. export default withNavigation(Home);
  338. const styles = StyleSheet.create({
  339. container: {
  340. flex: 1,
  341. justifyContent: 'center',
  342. alignItems: 'center',
  343. },
  344. text: { fontSize: 18, fontWeight:'bold', color: '#E91E63', alignItems: 'center', justifyContent: 'center' },
  345. imgBackground : {
  346. width: '100%',
  347. height: '95%',
  348. },
  349. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement