Forráskód Böngészése

搭建Rudex架构项目

Arison 5 éve
szülő
commit
095f26ee39

+ 2 - 1
index.js

@@ -3,7 +3,8 @@
  */
 
 import {AppRegistry} from 'react-native';
-import App from './App';
+
 import {name as appName} from './app.json';
+import App from "./units/App";
 
 AppRegistry.registerComponent(appName, () => App);

+ 229 - 0
package-lock.json

@@ -1069,6 +1069,27 @@
         }
       }
     },
+    "@react-navigation/core": {
+      "version": "3.4.2",
+      "resolved": "https://registry.npm.taobao.org/@react-navigation/core/download/@react-navigation/core-3.4.2.tgz?cache=0&sync_timestamp=1565660537040&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40react-navigation%2Fcore%2Fdownload%2F%40react-navigation%2Fcore-3.4.2.tgz",
+      "integrity": "sha1-vsVj6U/eQPurNzDNyX8ir7sqFJg=",
+      "requires": {
+        "hoist-non-react-statics": "^3.3.0",
+        "path-to-regexp": "^1.7.0",
+        "query-string": "^6.4.2",
+        "react-is": "^16.8.6"
+      }
+    },
+    "@react-navigation/native": {
+      "version": "3.5.0",
+      "resolved": "https://registry.npm.taobao.org/@react-navigation/native/download/@react-navigation/native-3.5.0.tgz?cache=0&sync_timestamp=1565661552163&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40react-navigation%2Fnative%2Fdownload%2F%40react-navigation%2Fnative-3.5.0.tgz",
+      "integrity": "sha1-9dFuCEWsJtEUfRyqSB8YoAdA564=",
+      "requires": {
+        "hoist-non-react-statics": "^3.0.1",
+        "react-native-safe-area-view": "^0.14.1",
+        "react-native-screens": "^1.0.0 || ^1.0.0-alpha"
+      }
+    },
     "@types/babel__core": {
       "version": "7.1.2",
       "resolved": "https://registry.npm.taobao.org/@types/babel__core/download/@types/babel__core-7.1.2.tgz",
@@ -1405,6 +1426,22 @@
       "integrity": "sha1-8OAD2cqef1nHpQiUXXsu+aBKVC8=",
       "dev": true
     },
+    "axios": {
+      "version": "0.19.0",
+      "resolved": "https://registry.npm.taobao.org/axios/download/axios-0.19.0.tgz",
+      "integrity": "sha1-jgm/89kSLhM/e4EByPvdAO09Krg=",
+      "requires": {
+        "follow-redirects": "1.5.10",
+        "is-buffer": "^2.0.2"
+      },
+      "dependencies": {
+        "is-buffer": {
+          "version": "2.0.3",
+          "resolved": "https://registry.npm.taobao.org/is-buffer/download/is-buffer-2.0.3.tgz",
+          "integrity": "sha1-Ts8/z3ScvR5HJonhCaxmJhol5yU="
+        }
+      }
+    },
     "babel-jest": {
       "version": "24.8.0",
       "resolved": "https://registry.npm.taobao.org/babel-jest/download/babel-jest-24.8.0.tgz",
@@ -2055,6 +2092,11 @@
         }
       }
     },
+    "debounce": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npm.taobao.org/debounce/download/debounce-1.2.0.tgz",
+      "integrity": "sha1-RKVAq8DqmUMBjcDqqVzOh/Zc0TE="
+    },
     "debug": {
       "version": "2.6.9",
       "resolved": "https://registry.npm.taobao.org/debug/download/debug-2.6.9.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-2.6.9.tgz",
@@ -2073,6 +2115,12 @@
       "resolved": "https://registry.npm.taobao.org/decode-uri-component/download/decode-uri-component-0.2.0.tgz",
       "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
     },
+    "deep-diff": {
+      "version": "0.3.8",
+      "resolved": "https://registry.npm.taobao.org/deep-diff/download/deep-diff-0.3.8.tgz",
+      "integrity": "sha1-wB3mPvsO7JeYgB1Ax+Da4ltYLIQ=",
+      "dev": true
+    },
     "deep-is": {
       "version": "0.1.3",
       "resolved": "https://registry.npm.taobao.org/deep-is/download/deep-is-0.1.3.tgz",
@@ -2698,6 +2746,24 @@
         "locate-path": "^3.0.0"
       }
     },
+    "follow-redirects": {
+      "version": "1.5.10",
+      "resolved": "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.5.10.tgz",
+      "integrity": "sha1-e3qfmuov3/NnhqlP9kPtB/T/Xio=",
+      "requires": {
+        "debug": "=3.1.0"
+      },
+      "dependencies": {
+        "debug": {
+          "version": "3.1.0",
+          "resolved": "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-3.1.0.tgz",
+          "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
+          "requires": {
+            "ms": "2.0.0"
+          }
+        }
+      }
+    },
     "for-in": {
       "version": "1.0.2",
       "resolved": "https://registry.npm.taobao.org/for-in/download/for-in-1.0.2.tgz",
@@ -3456,6 +3522,14 @@
         }
       }
     },
+    "hoist-non-react-statics": {
+      "version": "3.3.0",
+      "resolved": "https://registry.npm.taobao.org/hoist-non-react-statics/download/hoist-non-react-statics-3.3.0.tgz",
+      "integrity": "sha1-sJF48BIhhPuVrPUl2q7LTY9FlYs=",
+      "requires": {
+        "react-is": "^16.7.0"
+      }
+    },
     "hosted-git-info": {
       "version": "2.7.1",
       "resolved": "http://registry.npm.taobao.org/hosted-git-info/download/hosted-git-info-2.7.1.tgz",
@@ -6510,6 +6584,21 @@
       "resolved": "https://registry.npm.taobao.org/path-parse/download/path-parse-1.0.6.tgz",
       "integrity": "sha1-1i27VnlAXXLEc37FhgDp3c8G0kw="
     },
+    "path-to-regexp": {
+      "version": "1.7.0",
+      "resolved": "https://registry.npm.taobao.org/path-to-regexp/download/path-to-regexp-1.7.0.tgz",
+      "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=",
+      "requires": {
+        "isarray": "0.0.1"
+      },
+      "dependencies": {
+        "isarray": {
+          "version": "0.0.1",
+          "resolved": "https://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz?cache=0&sync_timestamp=1562592096220&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fisarray%2Fdownload%2Fisarray-0.0.1.tgz",
+          "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
+        }
+      }
+    },
     "path-type": {
       "version": "2.0.0",
       "resolved": "https://registry.npm.taobao.org/path-type/download/path-type-2.0.0.tgz",
@@ -6712,6 +6801,16 @@
       "integrity": "sha1-yzroBuh0BERYTvFUzo7pjUA/PjY=",
       "dev": true
     },
+    "query-string": {
+      "version": "6.8.2",
+      "resolved": "https://registry.npm.taobao.org/query-string/download/query-string-6.8.2.tgz",
+      "integrity": "sha1-Nst+RSrhGktenv7oM3XglUQHsvY=",
+      "requires": {
+        "decode-uri-component": "^0.2.0",
+        "split-on-first": "^1.0.0",
+        "strict-uri-encode": "^2.0.0"
+      }
+    },
     "randomatic": {
       "version": "3.1.1",
       "resolved": "https://registry.npm.taobao.org/randomatic/download/randomatic-3.1.1.tgz",
@@ -6786,6 +6885,11 @@
       "resolved": "https://registry.npm.taobao.org/react-is/download/react-is-16.8.6.tgz?cache=0&sync_timestamp=1565043796738&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freact-is%2Fdownload%2Freact-is-16.8.6.tgz",
       "integrity": "sha1-W7weLSkUHJ+9/tRWND/ivEMKahY="
     },
+    "react-lifecycles-compat": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npm.taobao.org/react-lifecycles-compat/download/react-lifecycles-compat-3.0.4.tgz",
+      "integrity": "sha1-TxonOv38jzSIqMUWv9p4+HI1I2I="
+    },
     "react-native": {
       "version": "0.59.9",
       "resolved": "https://registry.npm.taobao.org/react-native/download/react-native-0.59.9.tgz",
@@ -7007,6 +7111,80 @@
         }
       }
     },
+    "react-native-safe-area-view": {
+      "version": "0.14.7",
+      "resolved": "https://registry.npm.taobao.org/react-native-safe-area-view/download/react-native-safe-area-view-0.14.7.tgz",
+      "integrity": "sha1-4d0cTSWpBnffLBU0f93bIwa6WXE=",
+      "requires": {
+        "hoist-non-react-statics": "^2.3.1"
+      },
+      "dependencies": {
+        "hoist-non-react-statics": {
+          "version": "2.5.5",
+          "resolved": "https://registry.npm.taobao.org/hoist-non-react-statics/download/hoist-non-react-statics-2.5.5.tgz",
+          "integrity": "sha1-xZA89AnA39kI84jmGdhrnBF0y0c="
+        }
+      }
+    },
+    "react-native-screens": {
+      "version": "1.0.0-alpha.23",
+      "resolved": "https://registry.npm.taobao.org/react-native-screens/download/react-native-screens-1.0.0-alpha.23.tgz",
+      "integrity": "sha1-JdfqTRG9pPzeLR2nrlAnHGqmNuA=",
+      "requires": {
+        "debounce": "^1.2.0"
+      }
+    },
+    "react-native-tab-view": {
+      "version": "1.4.1",
+      "resolved": "https://registry.npm.taobao.org/react-native-tab-view/download/react-native-tab-view-1.4.1.tgz",
+      "integrity": "sha1-8RPNh0hYCPDJkavsk39w+jgEeLk=",
+      "requires": {
+        "prop-types": "^15.6.1"
+      }
+    },
+    "react-navigation": {
+      "version": "3.11.1",
+      "resolved": "https://registry.npm.taobao.org/react-navigation/download/react-navigation-3.11.1.tgz",
+      "integrity": "sha1-umlq1rUSCIqXogzH5qJQxT293SY=",
+      "requires": {
+        "@react-navigation/core": "~3.4.1",
+        "@react-navigation/native": "~3.5.0",
+        "react-navigation-drawer": "~1.2.1",
+        "react-navigation-stack": "~1.4.0",
+        "react-navigation-tabs": "~1.1.4"
+      }
+    },
+    "react-navigation-drawer": {
+      "version": "1.2.1",
+      "resolved": "https://registry.npm.taobao.org/react-navigation-drawer/download/react-navigation-drawer-1.2.1.tgz",
+      "integrity": "sha1-e9Xv7ufS9hHT67CTPgyOjrfK/lI=",
+      "requires": {
+        "react-native-tab-view": "^1.2.0"
+      }
+    },
+    "react-navigation-stack": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npm.taobao.org/react-navigation-stack/download/react-navigation-stack-1.4.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freact-navigation-stack%2Fdownload%2Freact-navigation-stack-1.4.0.tgz",
+      "integrity": "sha1-ac2wKepO5Yd9fpM7MRfckLyEHrI="
+    },
+    "react-navigation-tabs": {
+      "version": "1.1.4",
+      "resolved": "https://registry.npm.taobao.org/react-navigation-tabs/download/react-navigation-tabs-1.1.4.tgz",
+      "integrity": "sha1-AKMSJQ3zxRnGC3gVpSOs5e4RFjo=",
+      "requires": {
+        "hoist-non-react-statics": "^2.5.0",
+        "prop-types": "^15.6.1",
+        "react-lifecycles-compat": "^3.0.4",
+        "react-native-tab-view": "^1.4.1"
+      },
+      "dependencies": {
+        "hoist-non-react-statics": {
+          "version": "2.5.5",
+          "resolved": "https://registry.npm.taobao.org/hoist-non-react-statics/download/hoist-non-react-statics-2.5.5.tgz",
+          "integrity": "sha1-xZA89AnA39kI84jmGdhrnBF0y0c="
+        }
+      }
+    },
     "react-proxy": {
       "version": "1.1.8",
       "resolved": "https://registry.npm.taobao.org/react-proxy/download/react-proxy-1.1.8.tgz",
@@ -7016,6 +7194,19 @@
         "react-deep-force-update": "^1.0.0"
       }
     },
+    "react-redux": {
+      "version": "7.1.0",
+      "resolved": "https://registry.npm.taobao.org/react-redux/download/react-redux-7.1.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freact-redux%2Fdownload%2Freact-redux-7.1.0.tgz",
+      "integrity": "sha1-cq989JCnSs3FFuqcHdgOJa+eoLI=",
+      "requires": {
+        "@babel/runtime": "^7.4.5",
+        "hoist-non-react-statics": "^3.3.0",
+        "invariant": "^2.2.4",
+        "loose-envify": "^1.4.0",
+        "prop-types": "^15.7.2",
+        "react-is": "^16.8.6"
+      }
+    },
     "react-refresh": {
       "version": "0.2.0",
       "resolved": "https://registry.npm.taobao.org/react-refresh/download/react-refresh-0.2.0.tgz?cache=0&sync_timestamp=1565317893686&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freact-refresh%2Fdownload%2Freact-refresh-0.2.0.tgz",
@@ -7125,6 +7316,29 @@
         "util.promisify": "^1.0.0"
       }
     },
+    "redux": {
+      "version": "4.0.4",
+      "resolved": "https://registry.npm.taobao.org/redux/download/redux-4.0.4.tgz",
+      "integrity": "sha1-TuGusWS2PWobzFeuSqC25vp6N5Y=",
+      "requires": {
+        "loose-envify": "^1.4.0",
+        "symbol-observable": "^1.2.0"
+      }
+    },
+    "redux-logger": {
+      "version": "3.0.6",
+      "resolved": "https://registry.npm.taobao.org/redux-logger/download/redux-logger-3.0.6.tgz",
+      "integrity": "sha1-91VZZvMJjzyIYExEnPC69XeCdL8=",
+      "dev": true,
+      "requires": {
+        "deep-diff": "^0.3.5"
+      }
+    },
+    "redux-thunk": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npm.taobao.org/redux-thunk/download/redux-thunk-2.3.0.tgz",
+      "integrity": "sha1-UcLBmhhe1Rh6qpotCLZm0NZGdiI="
+    },
     "regenerate": {
       "version": "1.4.0",
       "resolved": "https://registry.npm.taobao.org/regenerate/download/regenerate-1.4.0.tgz",
@@ -7724,6 +7938,11 @@
       "resolved": "https://registry.npm.taobao.org/spdx-license-ids/download/spdx-license-ids-3.0.5.tgz?cache=0&sync_timestamp=1562834220236&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fspdx-license-ids%2Fdownload%2Fspdx-license-ids-3.0.5.tgz",
       "integrity": "sha1-NpS1gEVnpFjTyARYQqY1hjL2JlQ="
     },
+    "split-on-first": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npm.taobao.org/split-on-first/download/split-on-first-1.1.0.tgz",
+      "integrity": "sha1-9hCv7uOxK84dDDBCXnY5i3gkml8="
+    },
     "split-string": {
       "version": "3.1.0",
       "resolved": "https://registry.npm.taobao.org/split-string/download/split-string-3.1.0.tgz",
@@ -7803,6 +8022,11 @@
       "resolved": "https://registry.npm.taobao.org/stream-buffers/download/stream-buffers-2.2.0.tgz",
       "integrity": "sha1-kdX1Ew0c75bc+n9yaUUYh0HQnuQ="
     },
+    "strict-uri-encode": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npm.taobao.org/strict-uri-encode/download/strict-uri-encode-2.0.0.tgz",
+      "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY="
+    },
     "string-length": {
       "version": "2.0.0",
       "resolved": "https://registry.npm.taobao.org/string-length/download/string-length-2.0.0.tgz",
@@ -7889,6 +8113,11 @@
         "has-flag": "^3.0.0"
       }
     },
+    "symbol-observable": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npm.taobao.org/symbol-observable/download/symbol-observable-1.2.0.tgz",
+      "integrity": "sha1-wiaIrtTqs83C3+rLtWFmBWCgCAQ="
+    },
     "symbol-tree": {
       "version": "3.2.4",
       "resolved": "https://registry.npm.taobao.org/symbol-tree/download/symbol-tree-3.2.4.tgz?cache=0&sync_timestamp=1560363067941&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsymbol-tree%2Fdownload%2Fsymbol-tree-3.2.4.tgz",

+ 9 - 2
package.json

@@ -7,8 +7,14 @@
     "test": "jest"
   },
   "dependencies": {
+    "axios": "^0.19.0",
     "react": "16.8.3",
-    "react-native": "0.59.9"
+    "react-native": "0.59.9",
+    "react-navigation": "^3.11.1",
+    "react-redux": "^7.1.0",
+    "redux": "^4.0.4",
+    "redux-thunk": "^2.3.0",
+    "whatwg-fetch": "^3.0.0"
   },
   "devDependencies": {
     "@babel/core": "^7.5.5",
@@ -16,7 +22,8 @@
     "babel-jest": "^24.8.0",
     "jest": "^24.8.0",
     "metro-react-native-babel-preset": "^0.55.0",
-    "react-test-renderer": "16.8.3"
+    "react-test-renderer": "16.8.3",
+    "redux-logger": "^3.0.6"
   },
   "jest": {
     "preset": "react-native"

+ 24 - 0
readme.md

@@ -0,0 +1,24 @@
+
+# RN文档
+
+## 安装组件
+
+- redux
+- redux-thunk
+- redux-logger
+
+
+react-native-tab-navigator
+
+
+
+## 项目目录
+
+actions
+components
+pages
+containers
+constants
+reducers
+store
+utils

+ 13 - 0
units/App.js

@@ -0,0 +1,13 @@
+import  React from 'react'
+import { Provider } from 'react-redux'
+
+import AppContainer from "./containers/AppContainer";
+import store from './store'
+
+export default class extends React.Component {
+    render () {
+        return (<Provider store={store}>
+            <AppContainer />
+        </Provider>)
+    }
+};

+ 7 - 0
units/actions/actionTypes.js

@@ -0,0 +1,7 @@
+
+//功能模块BI
+export const CHANGE_BTN_TEXT = 'CHANGE_BTN_TEXT';
+
+//功能模块A
+
+//功能模块B

+ 8 - 0
units/actions/bi/index.js

@@ -0,0 +1,8 @@
+import  * as T from "../actionTypes"
+
+export const changeBtnText=(text)=>{
+  return {
+      type:T.CHANGE_BTN_TEXT,
+      payload:text
+  }
+}

+ 39 - 0
units/components/pages/DetailsScreen.js

@@ -0,0 +1,39 @@
+/**
+ * Created by Arison on 2019/6/11.
+ */
+import React from "react";
+import { View, Button,Text } from "react-native";
+
+export class DetailsScreen extends React.Component {
+    static navigationOptions = {
+        title: 'DetailsScreen',
+        headerBackTitle:'返回',//设置返回此页面的返回按钮文案,有长度限制
+    }
+
+
+    render() {
+        return (
+            <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
+                <Text  style={{marginBottom: 10}}>Details Screen</Text>
+                <View   style={{margin: 3}}>
+                    <Button
+                        title="再次进入详情界面"
+                        onPress={() => this.props.navigation.push('Details')}
+                    ></Button>
+                </View>
+                <View   style={{margin: 3}}>
+                <Button
+                    title="跳转到主界面"
+                    onPress={() => this.props.navigation.navigate('Home')}
+                />
+                </View>
+                <View   style={{margin: 3}}>
+                <Button
+                    title="返回"
+                    onPress={() => this.props.navigation.goBack()}
+                />
+                </View>
+            </View>
+        );
+    }
+}

+ 102 - 0
units/components/pages/HomeScreen.js

@@ -0,0 +1,102 @@
+import React from "react";
+import {connect} from 'react-redux'
+import {View, Text, Button,TouchableHighlight,StyleSheet} from "react-native";
+import {changeBtnText} from "../../actions/bi/index";
+import YRHttpRequest from  "../../utils/network/fetch"
+import {API} from "../../utils/network/axios/api.config";
+
+class HomeScreen extends React.Component {
+
+    loadData=()=>{
+        //fetch请求
+        console.log("loadData():",API.TEST_GET);
+        YRHttpRequest.get(API.TEST_GET).then(res=>{
+            console.log("res.data=",res);
+        }).catch(err=>{
+            console.log("res.data=",err);
+        })
+        //axios请求
+        // console.log("loadData():",API.TEST_GET);
+        // sendGet({url:API.TEST_GET,params:{
+        //     name:'arison'
+        // }}).then(res=>{
+        //     console.log("res.data=",res);
+        // }).catch(err=>{
+        //     console.log("res.data=",err);
+        // })
+    }
+
+    render() {
+        const {navigation} = this.props;
+        return (
+            <View style={{flex: 1, alignItems: "center", justifyContent: "center"}}>
+                <Text style={{marginBottom: 10}}>Home Screen</Text>
+                <Button
+                    title="详情页"
+                    onPress={() => {
+                        navigation.navigate('Details', {name: '动态的'});
+                    }}
+                />
+
+                <Text style={{marginBottom: 10}}>{this.props.btnText}</Text>
+                <Button title="更新文字"
+                        onPress={() => {
+                             this.props.changeText("我的第一个ReactNative项目!");
+                        }}/>
+
+                <Button style={{marginBottom: 10}}
+                        title="断点调式" onPress={()=>{
+                    for (let i = 0; i < 10; i++) {
+                            console.log("i*i=",i*i);
+                    }
+                }}/>
+
+                <TouchableHighlight
+                    underlayColor="#FF00FF"
+                    activeOpacity={1}
+                    style={styles.button} onPress={this.loadData.bind(this)}>
+                    <Text style={styles.text} > Touch Here </Text>
+                </TouchableHighlight>
+
+            </View>
+        );
+    }
+}
+
+const styles = StyleSheet.create({
+    container: {
+        flex: 1,
+        justifyContent: 'center',
+        paddingHorizontal: 10
+    },
+    button: {
+        alignItems: 'center',
+        backgroundColor: '#DDDDDD',
+        borderRadius:5,
+        padding: 10,
+        margin:10
+    },
+    countContainer: {
+        alignItems: 'center',
+        padding: 10
+    },
+    countText: {
+        color: '#FF00FF'
+    },
+    text:{
+        fontWeight:'600',
+        color:'#FFFFFF'
+    }
+})
+
+const mapStateToProps = state => ({
+    btnText:state.pageMainReducer.btnText
+})
+
+const mapDispatchToProps = dispatch => ({
+    changeText:(text)=>{
+        dispatch(changeBtnText(text));
+    }
+})
+
+export default connect(mapStateToProps, mapDispatchToProps)(HomeScreen)

+ 25 - 0
units/containers/AppContainer.js

@@ -0,0 +1,25 @@
+import { createStackNavigator, createAppContainer } from "react-navigation";
+import HomeScreen from "../components/pages/HomeScreen";
+import {DetailsScreen} from "../components/pages/DetailsScreen";
+
+export const AppNavigator = createStackNavigator({
+    Home: {
+        screen: HomeScreen,
+        navigationOptions: {//在这里定义每个页面的导航属性,静态配置
+            title: "首页",
+            headerBackTitle:'返回主界面',//设置返回此页面的返回按钮文案,有长度限制
+        }
+    },
+    Details:{
+        screen:DetailsScreen,
+        navigationOptions : {
+            title: '详情',
+            headerBackTitle:'返回',//设置返回此页面的返回按钮文案,有长度限制
+        }
+    }
+}, {
+    initialRouteName: 'Home',
+});
+
+
+export default createAppContainer(AppNavigator);

+ 19 - 0
units/reducers/bi/pageMainReducer.js

@@ -0,0 +1,19 @@
+import * as T from "../../actions/actionTypes";
+
+const initialState = {
+    btnText: '',
+};
+
+const pageMainReducer = (state = initialState, action) => {
+    switch (action.type) {
+        case T.CHANGE_BTN_TEXT:
+            return {
+                ...state,
+                btnText: action.payload
+            };
+        default:
+            return state;
+    }
+};
+
+export default pageMainReducer;

+ 8 - 0
units/reducers/index.js

@@ -0,0 +1,8 @@
+import { combineReducers } from 'redux'
+import pageMainReducer from "./bi/pageMainReducer";
+
+const rootReducer = combineReducers({
+    pageMainReducer
+})
+
+export default rootReducer

+ 17 - 0
units/store/index.js

@@ -0,0 +1,17 @@
+/**
+ * Created by Arison on 2019/8/13.
+ */
+import {createStore, applyMiddleware} from 'redux'
+import AppReducers from '../reducers'
+import thunkMiddleware from 'redux-thunk'
+import loggerMiddleware from 'redux-logger'
+
+const middlewares=[
+    thunkMiddleware,
+    loggerMiddleware
+]
+
+const createStoreWithMiddleware = applyMiddleware(...middlewares)(createStore)
+const store = createStoreWithMiddleware(AppReducers)
+
+export default store

+ 30 - 0
units/utils/network/axios/api.config.js

@@ -0,0 +1,30 @@
+let env = 'dev'
+// if ((/env=online/.test(window.location.href))) {
+//     env = 'online'
+// } else if ((/env=dev/.test(window.location.href))) {
+//     env = 'dev'
+// } else {
+//     env = 'dev' // 默认环境
+// }
+const SERVER_URL_LIST = {
+    online: { // 正式环境
+        SERVER_URL1: '',
+        SERVER_URL2: '',
+        SERVER_URL3: ''
+    },
+    dev: { // 测试环境
+        SERVER_URL1: 'https://www.yundashi168.com/',
+        SERVER_URL2: '',
+        SERVER_URL3: ''
+    }
+}
+
+//项目根路径
+export const SERVER_URL = SERVER_URL_LIST[env].SERVER_URL1;
+
+export const API = {
+    TEST_GET: SERVER_URL + 'wxService/getParam/app/json',
+    }
+
+
+export default SERVER_URL_LIST[env]

+ 11 - 0
units/utils/network/axios/api.js

@@ -0,0 +1,11 @@
+import {sendGet, sendPost} from './axios.util'
+import {API} from './api.config'
+
+// export const login = () => sendPost({
+//     url: API.APP_LOGIN,
+//     params: {user_tel: '18995848321', password: '111111', client_type: 'H5'}
+// })
+
+export const testGet=()=>sendGet({
+    url:API.TEST_GET
+})

+ 56 - 0
units/utils/network/axios/axios.config.js

@@ -0,0 +1,56 @@
+/*axios拦截*/
+import axios from 'axios'
+import config from './api.config'
+
+
+// 配置 axios,并生成实例
+const creatAxios1 = axios.create({
+    baseURL: config.SERVER_URL1,
+    withCredentials: true
+})
+
+
+// 拦截器配置
+creatAxios1.interceptors.request.use(configData => { // 请求拦截 在发送请求之前做些什么
+                                                     // 请求成功做的事情 configData 中包含:url、method等信息
+    return configData
+}, error => { // 请求失败做的事情
+    return Promise.reject(error)
+})
+
+
+creatAxios1.interceptors.response.use(response => { // 响应拦截 对响应数据做点什么
+                                                    // 响应成功做的事情
+    response.data.code = Number(response.data.code) // 将接口返回的状态值 code 处理为数字
+    return response
+}, error => { // 响应失败做的事情
+    return Promise.reject(error)
+})
+
+
+
+function sendAll (arr) { // 顺序和请求发送的顺序相同,使用 axios.spread 分割成多个单独的响应对象
+    if (Object.prototype.toString.call(arr) === '[object Array]') {
+        return axios.all(arr).then(axios.spread(function (...res) { // axios.all 是axios的静态方法,不是实例上的方法
+            // 请求全部都执行完成
+            return Promise.resolve(res)
+        }))
+    } else {
+        const error = new Error('参数错误!')
+        try {
+            throw error
+        } catch (e) {
+            // console.log(e)
+        }
+    }
+}
+
+export default {
+    creatAxios1,
+    sendAll
+}
+
+
+
+
+

+ 40 - 0
units/utils/network/axios/axios.util.js

@@ -0,0 +1,40 @@
+import api from './axios.config'
+import config from './api.config'
+import React from 'react';
+
+
+function _apiFn(baseUrl) {
+    if (baseUrl === 'service2') {
+        api.creatAxios1.defaults.baseURL = config.SERVER_URL2
+    } else if (baseUrl === 'service3') {
+        api.creatAxios1.defaults.baseURL = config.SERVER_URL3
+    } else {
+        api.creatAxios1.defaults.baseURL = config.SERVER_URL1
+    }
+}
+
+export const sendGet = ({url, params, headers}) => { // get 请求
+    return api.creatAxios1.get(url, params, headers).then(res => res.data).catch(err => {
+        console.log(err);
+    });
+}
+
+export const sendPost = ({url, params, headers}) => { // post 请求
+    return api.creatAxios1.post(url, params, headers).then(res => res.data).catch(err => {
+        console.log(err);
+    });
+
+}
+
+/**
+ * 并发请求,同时发送多个请求,使用栗子:src/views/infoEntry/dragCard/dragCardService.js
+ * 顺序和请求发送的顺序相同
+ * @param {arr: [请求1,请求2...]}
+ */
+export const sendAll = ({arr}) => { // 并发请求
+    return new Promise((resolve, reject) => {
+        api.sendAll(arr).then(res => {
+            return resolve(res)
+        })
+    })
+}

+ 64 - 0
units/utils/network/fetch/index.js

@@ -0,0 +1,64 @@
+class YRHttpRequest {
+    get(url) {
+        return new Promise((resolve, reject) => {
+            fetch(url,{
+                headers: {
+                    'Content-Type': 'application/json'
+                },
+                method: 'GET'
+            })
+                .then(res => res)
+                .then(data => resolve(data))
+                .catch(err => reject(err))
+
+        })
+    }
+
+    // post方式
+    post(url, data) {
+        return new Promise((resolve, reject) => {
+            fetch(url,{
+                method: 'POST',
+                headers: {
+                    'Content-type': 'application/json'
+                },
+                body: JSON.stringify(data)
+            }).then(res=>res.data);
+        })
+    }
+
+
+    //put 修改
+    put(url, data) {
+        return new Promise((resolve, reject) => {
+            fetch(url, {
+                method: 'PUT',
+                headers: {
+                    'Content-type': 'application/json'
+                },
+                body: JSON.stringify(data)
+            })
+                .then(res => res.json())
+                .then(data => resolve(data))
+                .catch(err => reject(err))
+
+        })
+    }
+
+    //delete
+    delete(url, data) {
+        return new Promise((resolve, reject) => {
+            fetch(url, {
+                method: 'DELETE',
+                headers: {
+                    'Content-type': 'application/json'
+                },
+                body: JSON.stringify(data)
+            })
+                .then(res => res.json())
+                .then(data => resolve('数据删除成功!'))
+                .catch(err => reject(err))
+        })
+    }
+}
+export default new YRHttpRequest();//ES6导出