罗广聪

适配轮播图宽度,跳转注册页面样式

@@ -7,7 +7,8 @@ import { @@ -7,7 +7,8 @@ import {
7 Image, 7 Image,
8 TouchableOpacity, 8 TouchableOpacity,
9 ScrollView, 9 ScrollView,
10 - FlatList 10 + FlatList,
  11 + Dimensions
11 } from "react-native"; 12 } from "react-native";
12 import { StackNavigator, TabNavigator } from "react-navigation"; 13 import { StackNavigator, TabNavigator } from "react-navigation";
13 import Swiper from "react-native-swiper"; 14 import Swiper from "react-native-swiper";
@@ -110,13 +111,15 @@ export default class Home extends Component { @@ -110,13 +111,15 @@ export default class Home extends Component {
110 } 111 }
111 _swiper() { 112 _swiper() {
112 const { navigate } = this.props.navigation; 113 const { navigate } = this.props.navigation;
  114 + const {height, width} = Dimensions.get('window');
  115 + const imgHeight = width * 140 / 375;
113 return ( 116 return (
114 - <View style={{ height: 120 }}> 117 + <View style={{ height: imgHeight }}>
115 <Swiper 118 <Swiper
116 style={styles.swiperWrapper} 119 style={styles.swiperWrapper}
117 autoplay={true} 120 autoplay={true}
118 autoplayTimeout={6} 121 autoplayTimeout={6}
119 - height={120} 122 + height={imgHeight}
120 dotStyle={{ 123 dotStyle={{
121 width: 6, 124 width: 6,
122 height: 6 125 height: 6
@@ -135,7 +138,8 @@ export default class Home extends Component { @@ -135,7 +138,8 @@ export default class Home extends Component {
135 <Image 138 <Image
136 style={styles.slideImg} 139 style={styles.slideImg}
137 source={item.img} 140 source={item.img}
138 - resizeMode="contain" 141 + width={Dimensions.get('window').width}
  142 + resizeMode="stretch"
139 /> 143 />
140 </TouchableOpacity> 144 </TouchableOpacity>
141 ); 145 );
@@ -215,7 +219,8 @@ const styles = StyleSheet.create({ @@ -215,7 +219,8 @@ const styles = StyleSheet.create({
215 }, 219 },
216 swiperWrapper: {}, 220 swiperWrapper: {},
217 slide: { 221 slide: {
218 - height: 140, 222 + height: Dimensions.get('window').width*140/375,
  223 + width: Dimensions.get('window').width,
219 justifyContent: "center", 224 justifyContent: "center",
220 alignItems: "center", 225 alignItems: "center",
221 backgroundColor: "#92BBD9" 226 backgroundColor: "#92BBD9"
@@ -6,9 +6,9 @@ import { @@ -6,9 +6,9 @@ import {
6 View, 6 View,
7 ScrollView, 7 ScrollView,
8 TouchableOpacity, 8 TouchableOpacity,
9 - Image 9 + Image,
10 } from "react-native"; 10 } from "react-native";
11 -import { StackNavigator, TabNavigator } from 'react-navigation'; 11 +import { StackNavigator, TabNavigator } from "react-navigation";
12 import CommonWebView from "../../Components/CommonWebView"; 12 import CommonWebView from "../../Components/CommonWebView";
13 import Details from "./details"; 13 import Details from "./details";
14 14
@@ -21,33 +21,37 @@ export default class InsuranceCircle extends Component { @@ -21,33 +21,37 @@ export default class InsuranceCircle extends Component {
21 } 21 }
22 22
23 componentDidMount() { 23 componentDidMount() {
  24 + this.getArticles();
  25 + }
  26 +
  27 + getArticles() {
24 var that = this; 28 var that = this;
25 // 请求文章数据 29 // 请求文章数据
26 - return fetch(`https://devpay.brae.co/test/insurance/article`,{ 30 + return fetch(`https://devpay.brae.co/test/insurance/article`, {
27 method: "POST", 31 method: "POST",
28 headers: { 32 headers: {
29 - 'Accept': 'application/json', 33 + Accept: "application/json",
30 - 'Content-Type': 'application/json', 34 + "Content-Type": "application/json"
31 - }, 35 + }
32 }) 36 })
33 - .then((resp) => { 37 + .then(resp => {
34 if (resp.status === 200) { 38 if (resp.status === 200) {
35 return resp.json(); 39 return resp.json();
36 } else { 40 } else {
37 console.error("something went wrong!"); 41 console.error("something went wrong!");
38 } 42 }
39 }) 43 })
40 - .then((respJson) => { 44 + .then(respJson => {
41 - if (respJson.enmsg != 'ok') { 45 + if (respJson.enmsg != "ok") {
42 alert(respJson.cnmsg); 46 alert(respJson.cnmsg);
43 } else { 47 } else {
44 that.setState({ 48 that.setState({
45 - ListData: respJson.data.data 49 + ListData: respJson.data.data,
46 }); 50 });
47 - console.log('state.ListData',this.state.ListData); 51 + console.log("state.ListData", this.state.ListData);
48 } 52 }
49 }) 53 })
50 - .catch((err) => console.error(err)) 54 + .catch(err => console.error(err));
51 } 55 }
52 56
53 render() { 57 render() {
@@ -96,11 +100,11 @@ const styles = StyleSheet.create({ @@ -96,11 +100,11 @@ const styles = StyleSheet.create({
96 flex: 1, 100 flex: 1,
97 justifyContent: "flex-start", 101 justifyContent: "flex-start",
98 alignItems: "stretch", 102 alignItems: "stretch",
99 - backgroundColor: "#EFEFEF", 103 + backgroundColor: "#EFEFEF"
100 }, 104 },
101 scrollViewContainer: { 105 scrollViewContainer: {
102 // height: 300 106 // height: 300
103 - flex: 1, 107 + flex: 1
104 // marginBottom: 49, 108 // marginBottom: 49,
105 }, 109 },
106 scrollViewText: { 110 scrollViewText: {
@@ -117,7 +121,7 @@ const styles = StyleSheet.create({ @@ -117,7 +121,7 @@ const styles = StyleSheet.create({
117 paddingLeft: 13, 121 paddingLeft: 13,
118 paddingRight: 13, 122 paddingRight: 13,
119 paddingTop: 19, 123 paddingTop: 19,
120 - paddingBottom: 12, 124 + paddingBottom: 12
121 }, 125 },
122 itemTitle: { 126 itemTitle: {
123 fontSize: 17, 127 fontSize: 17,
@@ -9,7 +9,8 @@ import { @@ -9,7 +9,8 @@ import {
9 ScrollView, 9 ScrollView,
10 TextInput, 10 TextInput,
11 KeyboardAvoidingView, 11 KeyboardAvoidingView,
12 - AsyncStorage 12 + AsyncStorage,
  13 + Dimensions
13 } from "react-native"; 14 } from "react-native";
14 15
15 export default class Login extends Component { 16 export default class Login extends Component {
@@ -22,6 +23,7 @@ export default class Login extends Component { @@ -22,6 +23,7 @@ export default class Login extends Component {
22 nickname: "", 23 nickname: "",
23 profession: "", 24 profession: "",
24 id: "", 25 id: "",
  26 + registerDone: false,
25 // 处于登录页面还是注册页面 27 // 处于登录页面还是注册页面
26 isRegister: false, 28 isRegister: false,
27 IS_LOGIN: "", 29 IS_LOGIN: "",
@@ -47,6 +49,7 @@ export default class Login extends Component { @@ -47,6 +49,7 @@ export default class Login extends Component {
47 } 49 }
48 render() { 50 render() {
49 const { navigate } = this.props.navigation; 51 const { navigate } = this.props.navigation;
  52 + const { phone, password, nickname, profession } = this.state;
50 return ( 53 return (
51 <View style={styles.container}> 54 <View style={styles.container}>
52 <KeyboardAvoidingView behavior="padding" style={styles.KAVContainer}> 55 <KeyboardAvoidingView behavior="padding" style={styles.KAVContainer}>
@@ -140,7 +143,7 @@ export default class Login extends Component { @@ -140,7 +143,7 @@ export default class Login extends Component {
140 </TouchableOpacity> 143 </TouchableOpacity>
141 ) : ( 144 ) : (
142 <TouchableOpacity 145 <TouchableOpacity
143 - style={styles.confirmBtnRegister} 146 + style={[styles.confirmBtnRegister,{backgroundColor: (phone && password && nickname && profession) ? "#1B9341" : "#BBBBBB"}]}
144 onPress={() => { 147 onPress={() => {
145 this.register(); 148 this.register();
146 }} 149 }}
@@ -307,9 +310,9 @@ export default class Login extends Component { @@ -307,9 +310,9 @@ export default class Login extends Component {
307 const styles = StyleSheet.create({ 310 const styles = StyleSheet.create({
308 container: { 311 container: {
309 flex: 1, 312 flex: 1,
310 - paddingTop: 80, 313 + paddingTop: 50,
311 - justifyContent: "flex-start", 314 + justifyContent: "center",
312 - alignItems: "stretch", 315 + alignItems: "center",
313 backgroundColor: "#F5FCFF", 316 backgroundColor: "#F5FCFF",
314 paddingLeft: 38, 317 paddingLeft: 38,
315 paddingRight: 38 318 paddingRight: 38
@@ -322,7 +325,7 @@ const styles = StyleSheet.create({ @@ -322,7 +325,7 @@ const styles = StyleSheet.create({
322 fontSize: 26, 325 fontSize: 26,
323 color: "#030303", 326 color: "#030303",
324 alignSelf: "center", 327 alignSelf: "center",
325 - marginBottom: 77 328 + marginBottom: 50
326 }, 329 },
327 inputField: { 330 inputField: {
328 flexDirection: "row", 331 flexDirection: "row",
@@ -351,7 +354,7 @@ const styles = StyleSheet.create({ @@ -351,7 +354,7 @@ const styles = StyleSheet.create({
351 }, 354 },
352 confirmBtnLogin: { 355 confirmBtnLogin: {
353 marginTop: 30, 356 marginTop: 30,
354 - width: 299, 357 + width: Dimensions.get('window').width * 0.8,
355 height: 45, 358 height: 45,
356 backgroundColor: "#1B9341", 359 backgroundColor: "#1B9341",
357 borderRadius: 5, 360 borderRadius: 5,
@@ -360,9 +363,9 @@ const styles = StyleSheet.create({ @@ -360,9 +363,9 @@ const styles = StyleSheet.create({
360 }, 363 },
361 confirmBtnRegister: { 364 confirmBtnRegister: {
362 marginTop: 30, 365 marginTop: 30,
363 - width: 299, 366 + width: Dimensions.get('window').width * 0.8,
364 height: 45, 367 height: 45,
365 - backgroundColor: "#BBBBBB", 368 + // backgroundColor: "#BBBBBB",
366 borderRadius: 5, 369 borderRadius: 5,
367 alignItems: "center", 370 alignItems: "center",
368 justifyContent: "center" 371 justifyContent: "center"