罗广聪

中央文案 发现

@@ -17,6 +17,7 @@ import AllProduct from "./src/pages/Home/allProduct"; @@ -17,6 +17,7 @@ import AllProduct from "./src/pages/Home/allProduct";
17 import ProductTemplate from "./src/Components/ProductTemplate"; 17 import ProductTemplate from "./src/Components/ProductTemplate";
18 import ArticleTemplate from "./src/Components/articleTemplate"; 18 import ArticleTemplate from "./src/Components/articleTemplate";
19 import Details from "./src/pages/InsuranceCircle/details"; 19 import Details from "./src/pages/InsuranceCircle/details";
  20 +import Discover from "./src/pages/Discover/index";
20 21
21 // 底部导航栏配置,但也只是作为一个页面,加载到StackNavigator成为第一个页面 22 // 底部导航栏配置,但也只是作为一个页面,加载到StackNavigator成为第一个页面
22 const MainTabBar = TabNavigator({ 23 const MainTabBar = TabNavigator({
@@ -44,6 +45,20 @@ const MainTabBar = TabNavigator({ @@ -44,6 +45,20 @@ const MainTabBar = TabNavigator({
44 ) 45 )
45 } 46 }
46 }, 47 },
  48 + Discover: {
  49 + screen: Discover,
  50 + navigationOptions: {
  51 + title: "发现",
  52 + // header: null,
  53 + // tabBarVisible: false,
  54 + tabBarIcon: ({ focused }) =>
  55 + focused ? (
  56 + <Image source={require("./src/assets/tabbar/ic_discover_s.png")} />
  57 + ) : (
  58 + <Image source={require("./src/assets/tabbar/ic_discover_n.png")} />
  59 + )
  60 + }
  61 + },
47 InsuranceChurch: { 62 InsuranceChurch: {
48 screen: InsuranceChurch, 63 screen: InsuranceChurch,
49 navigationOptions: { 64 navigationOptions: {
@@ -89,7 +104,8 @@ const ProtectGod = StackNavigator( @@ -89,7 +104,8 @@ const ProtectGod = StackNavigator(
89 }, 104 },
90 ProductTemplate: { screen: ProductTemplate }, 105 ProductTemplate: { screen: ProductTemplate },
91 ArticleTemplate: { screen: ArticleTemplate }, 106 ArticleTemplate: { screen: ArticleTemplate },
92 - Details: { screen: Details } 107 + Details: { screen: Details },
  108 + Discover: { screen: Discover }
93 },{ 109 },{
94 navigationOptions: { 110 navigationOptions: {
95 // headerTintColor: "blue", 111 // headerTintColor: "blue",
@@ -80,7 +80,7 @@ @@ -80,7 +80,7 @@
80 </AdditionalOptions> 80 </AdditionalOptions>
81 </TestAction> 81 </TestAction>
82 <LaunchAction 82 <LaunchAction
83 - buildConfiguration = "Release" 83 + buildConfiguration = "Debug"
84 selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" 84 selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
85 selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" 85 selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
86 launchStyle = "0" 86 launchStyle = "0"
@@ -121,7 +121,9 @@ const styles = StyleSheet.create({ @@ -121,7 +121,9 @@ const styles = StyleSheet.create({
121 justifyContent: "flex-start", 121 justifyContent: "flex-start",
122 backgroundColor: "#EFEFEF" 122 backgroundColor: "#EFEFEF"
123 }, 123 },
124 - scrollViewContainer: {}, 124 + scrollViewContainer: {
  125 + marginBottom: 49,
  126 + },
125 headerContainer: {}, 127 headerContainer: {},
126 headerImage: { 128 headerImage: {
127 width: Dimensions.get("window").width, 129 width: Dimensions.get("window").width,
  1 +import React, { Component } from "react";
  2 +import {
  3 + StyleSheet,
  4 + WebView,
  5 + View,
  6 + Image,
  7 + Dimensions,
  8 + ScrollView,
  9 + Text,
  10 +} from "react-native";
  11 +import { StackNavigator, TabNavigator } from "react-navigation";
  12 +
  13 +export default class Discover extends Component {
  14 + constructor(props) {
  15 + super(props);
  16 + this.state = {
  17 + image: "",
  18 + };
  19 + }
  20 + componentWillMount() {
  21 + this.getImages();
  22 + }
  23 + getImages() {
  24 + let that = this,
  25 + id = this.state.id,
  26 + model = this.state.model;
  27 + return fetch(`https://devpay.brae.co/test/insurance/wallpaper`, {
  28 + method: "POST",
  29 + headers: {
  30 + Accept: "application/json",
  31 + "Content-Type": "application/json"
  32 + }
  33 + })
  34 + .then(resp => {
  35 + console.log("大爷",resp);
  36 + if (resp.status === 200) {
  37 + return resp.json();
  38 + } else {
  39 + console.error("something went wrong!");
  40 + }
  41 + })
  42 + .then(respJson => {
  43 + if (respJson.enmsg != "ok") {
  44 + alert(respJson.cnmsg);
  45 + } else {
  46 + that.setState({
  47 + image: respJson.data.image
  48 + });
  49 + console.log("图片文章", respJson.data);
  50 + }
  51 + });
  52 + }
  53 + render() {
  54 + const { image } = this.state;
  55 + return (
  56 + <View style={styles.container}>
  57 + {/* <Text>图片首页</Text> */}
  58 + <Image
  59 + style={styles.image}
  60 + source={{uri: image}}
  61 + resizeMode="contain"
  62 + >
  63 + <Text>中央文案</Text>
  64 + </Image>
  65 + </View>
  66 + );
  67 + }
  68 +}
  69 +
  70 +const styles = StyleSheet.create({
  71 + container: {
  72 + flex: 1,
  73 + backgroundColor: "white"
  74 + },
  75 + image: {
  76 + width: Dimensions.get("window").width,
  77 + height: Dimensions.get("window").height,
  78 + justifyContent: "center",
  79 + alignItems: "center",
  80 + }
  81 +});