├── .watchmanconfig ├── app ├── images │ ├── RMB.png │ ├── bg.png │ ├── bus.png │ ├── kf.png │ ├── ri.png │ ├── sc.png │ ├── wh.png │ ├── yj.png │ ├── yjj.png │ ├── back.png │ ├── left.png │ ├── moneys.png │ ├── prompt.png │ ├── right.png │ ├── side.png │ ├── tosts.png │ ├── user.png │ ├── complete.png │ ├── ic_back.png │ ├── ic_cart.png │ ├── ic_scan.jpg │ ├── passicon.png │ ├── executing.png │ ├── ic_search.jpg │ ├── ic_welcome.jpg │ ├── img_my_bg.png │ ├── uncomplete.png │ ├── ic_cart_press.png │ ├── tab │ │ ├── ic_tab_my.png │ │ ├── ic_tab_cart.png │ │ ├── ic_tab_fun.png │ │ ├── ic_tab_home.png │ │ ├── ic_tab_cart_press.png │ │ ├── ic_tab_category.png │ │ ├── ic_tab_fun_press.png │ │ ├── ic_tab_home_press.png │ │ ├── ic_tab_my_press.png │ │ ├── others │ │ │ ├── cart_focus.png │ │ │ ├── home_focus.png │ │ │ ├── cart_normal.png │ │ │ ├── faxian_focus.png │ │ │ ├── home_normal.png │ │ │ ├── category_focus.png │ │ │ ├── category_normal.png │ │ │ ├── faxian_normal.png │ │ │ ├── personal_focus.png │ │ │ └── personal_normal.png │ │ └── ic_tab_category_press.png │ └── img_default_head.png ├── actions │ ├── commonActions.js │ ├── foodCompareActions.js │ ├── foodsActions.js │ ├── articleActions.js │ ├── foodInfoActions.js │ ├── homeActions.js │ ├── preorderActions.js │ ├── orderActions.js │ ├── productActions.js │ ├── foodsListActions.js │ ├── cartActions.js │ ├── actionTypes.js │ ├── addressActions.js │ └── userActions.js ├── containers │ ├── SearchContainer.js │ ├── FoodCompareContainer.js │ ├── MyContainer.js │ ├── FoodInfoContainer.js │ ├── FunContainer.js │ ├── HomeContainer.js │ ├── CartContainer.js │ ├── AddressContainer.js │ ├── OrderContainer.js │ ├── UserContainer.js │ ├── FoodsListContainer.js │ ├── LoginContainer.js │ ├── AddressCreateContainer.js │ ├── PreorderContainer.js │ ├── ArticleContainer.js │ ├── RegisterContainer.js │ ├── CategoryContainer.js │ ├── ProductContainer.js │ └── AppMain.js ├── reducers │ ├── myReducer.js │ ├── commonReducer.js │ ├── articleReducer.js │ ├── foodsReducer.js │ ├── productReducer.js │ ├── categoryReducer.js │ ├── rootRudcer.js │ ├── foodInfoReducer.js │ ├── homeReducer.js │ ├── cartReducer.js │ ├── addressReducer.js │ ├── orderReducer.js │ ├── preorderReducer.js │ ├── userReducer.js │ ├── foodsListReducer.js │ ├── foodCompareReducer.js │ └── searchReducer.js ├── root.js ├── store │ └── store.js ├── models │ └── User.js ├── components │ ├── LoadMoreFooter.js │ ├── Loading.js │ ├── SearchInputBar.js │ ├── SearchHeader.js │ ├── FoodCell.js │ └── Header.js ├── common │ ├── UserDefaults.js │ ├── Storage.js │ ├── Buttom.js │ ├── commonStyles.js │ ├── ImageButton.js │ ├── TextButton.js │ ├── constants.js │ ├── constants_url.js │ ├── syncStorage.js │ └── utils.js ├── app.js └── pages │ ├── Splash.js │ ├── FoodAllIngredient.js │ ├── ArticlePage.js │ ├── AddressPage.js │ ├── FunPage.js │ ├── UserPage.js │ └── AddressCreatePage.js ├── screenshoot ├── 01.png ├── 02.jpg ├── 03.jpg ├── 04.jpg ├── 05.png └── 06.jpg ├── ios ├── ShopReactNative │ ├── Images.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── AppIcon29x29@2x.png │ │ │ ├── AppIcon29x29@3x.png │ │ │ ├── AppIcon40x40@2x.png │ │ │ ├── AppIcon40x40@3x.png │ │ │ ├── AppIcon60x60@2x.png │ │ │ ├── AppIcon60x60@3x.png │ │ │ └── Contents.json │ ├── AppDelegate.h │ ├── main.m │ ├── AppDelegate.m │ ├── Info.plist │ └── Base.lproj │ │ └── LaunchScreen.xib ├── ShopReactNativeTests │ ├── Info.plist │ └── ShopReactNativeTests.m └── ShopReactNative.xcodeproj │ └── xcshareddata │ └── xcschemes │ └── ShopReactNative.xcscheme ├── android ├── app │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ └── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── assets │ │ │ └── fonts │ │ │ │ ├── Entypo.ttf │ │ │ │ ├── Ionicons.ttf │ │ │ │ ├── Octicons.ttf │ │ │ │ ├── Zocial.ttf │ │ │ │ ├── EvilIcons.ttf │ │ │ │ ├── Foundation.ttf │ │ │ │ ├── FontAwesome.ttf │ │ │ │ └── MaterialIcons.ttf │ │ │ ├── java │ │ │ └── com │ │ │ │ └── shopreactnative │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── AndroidManifest.xml │ ├── BUCK │ ├── proguard-rules.pro │ └── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── keystores │ ├── debug.keystore.properties │ └── BUCK ├── settings.gradle ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── .buckconfig ├── index.ios.js ├── index.android.js ├── package.json ├── .gitignore ├── README-DOC.txt ├── LICENSE ├── .flowconfig └── README.md /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /app/images/RMB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/RMB.png -------------------------------------------------------------------------------- /app/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/bg.png -------------------------------------------------------------------------------- /app/images/bus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/bus.png -------------------------------------------------------------------------------- /app/images/kf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/kf.png -------------------------------------------------------------------------------- /app/images/ri.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/ri.png -------------------------------------------------------------------------------- /app/images/sc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/sc.png -------------------------------------------------------------------------------- /app/images/wh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/wh.png -------------------------------------------------------------------------------- /app/images/yj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/yj.png -------------------------------------------------------------------------------- /app/images/yjj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/yjj.png -------------------------------------------------------------------------------- /screenshoot/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/screenshoot/01.png -------------------------------------------------------------------------------- /screenshoot/02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/screenshoot/02.jpg -------------------------------------------------------------------------------- /screenshoot/03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/screenshoot/03.jpg -------------------------------------------------------------------------------- /screenshoot/04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/screenshoot/04.jpg -------------------------------------------------------------------------------- /screenshoot/05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/screenshoot/05.png -------------------------------------------------------------------------------- /screenshoot/06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/screenshoot/06.jpg -------------------------------------------------------------------------------- /app/images/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/back.png -------------------------------------------------------------------------------- /app/images/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/left.png -------------------------------------------------------------------------------- /app/images/moneys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/moneys.png -------------------------------------------------------------------------------- /app/images/prompt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/prompt.png -------------------------------------------------------------------------------- /app/images/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/right.png -------------------------------------------------------------------------------- /app/images/side.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/side.png -------------------------------------------------------------------------------- /app/images/tosts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tosts.png -------------------------------------------------------------------------------- /app/images/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/user.png -------------------------------------------------------------------------------- /app/images/complete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/complete.png -------------------------------------------------------------------------------- /app/images/ic_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/ic_back.png -------------------------------------------------------------------------------- /app/images/ic_cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/ic_cart.png -------------------------------------------------------------------------------- /app/images/ic_scan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/ic_scan.jpg -------------------------------------------------------------------------------- /app/images/passicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/passicon.png -------------------------------------------------------------------------------- /app/images/executing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/executing.png -------------------------------------------------------------------------------- /app/images/ic_search.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/ic_search.jpg -------------------------------------------------------------------------------- /app/images/ic_welcome.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/ic_welcome.jpg -------------------------------------------------------------------------------- /app/images/img_my_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/img_my_bg.png -------------------------------------------------------------------------------- /app/images/uncomplete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/uncomplete.png -------------------------------------------------------------------------------- /app/images/ic_cart_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/ic_cart_press.png -------------------------------------------------------------------------------- /app/images/tab/ic_tab_my.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_my.png -------------------------------------------------------------------------------- /app/images/img_default_head.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/img_default_head.png -------------------------------------------------------------------------------- /app/images/tab/ic_tab_cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_cart.png -------------------------------------------------------------------------------- /app/images/tab/ic_tab_fun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_fun.png -------------------------------------------------------------------------------- /app/images/tab/ic_tab_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_home.png -------------------------------------------------------------------------------- /app/images/tab/ic_tab_cart_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_cart_press.png -------------------------------------------------------------------------------- /app/images/tab/ic_tab_category.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_category.png -------------------------------------------------------------------------------- /app/images/tab/ic_tab_fun_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_fun_press.png -------------------------------------------------------------------------------- /app/images/tab/ic_tab_home_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_home_press.png -------------------------------------------------------------------------------- /app/images/tab/ic_tab_my_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_my_press.png -------------------------------------------------------------------------------- /app/images/tab/others/cart_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/cart_focus.png -------------------------------------------------------------------------------- /app/images/tab/others/home_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/home_focus.png -------------------------------------------------------------------------------- /ios/ShopReactNative/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /app/images/tab/others/cart_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/cart_normal.png -------------------------------------------------------------------------------- /app/images/tab/others/faxian_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/faxian_focus.png -------------------------------------------------------------------------------- /app/images/tab/others/home_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/home_normal.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ShopReactNative 5 | 6 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/images/tab/ic_tab_category_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/ic_tab_category_press.png -------------------------------------------------------------------------------- /app/images/tab/others/category_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/category_focus.png -------------------------------------------------------------------------------- /app/images/tab/others/category_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/category_normal.png -------------------------------------------------------------------------------- /app/images/tab/others/faxian_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/faxian_normal.png -------------------------------------------------------------------------------- /app/images/tab/others/personal_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/personal_focus.png -------------------------------------------------------------------------------- /app/images/tab/others/personal_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/app/images/tab/others/personal_normal.png -------------------------------------------------------------------------------- /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Entypo.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/assets/fonts/Entypo.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Ionicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/assets/fonts/Ionicons.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Octicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/assets/fonts/Octicons.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Zocial.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/assets/fonts/Zocial.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/EvilIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/assets/fonts/EvilIcons.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Foundation.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/assets/fonts/Foundation.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/FontAwesome.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/assets/fonts/FontAwesome.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/MaterialIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/assets/fonts/MaterialIcons.ttf -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon29x29@2x.png -------------------------------------------------------------------------------- /ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon29x29@3x.png -------------------------------------------------------------------------------- /ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon40x40@2x.png -------------------------------------------------------------------------------- /ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon40x40@3x.png -------------------------------------------------------------------------------- /ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png -------------------------------------------------------------------------------- /ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleTeam/Shop-React-Native/HEAD/ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/AppIcon60x60@3x.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /index.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | /** 12 | * iOS入口文件 13 | */ 14 | import { AppRegistry } from 'react-native'; 15 | import Root from './app/root'; 16 | 17 | AppRegistry.registerComponent('ShopReactNative', () => Root); 18 | -------------------------------------------------------------------------------- /index.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | /** 12 | * Android入口文件 13 | */ 14 | import { AppRegistry } from 'react-native'; 15 | import Root from './app/root'; 16 | 17 | AppRegistry.registerComponent('ShopReactNative', () => Root); 18 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ShopReactNative' 2 | 3 | include ':app' 4 | include ':react-native-device-info' 5 | project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android') 6 | include ':react-native-vector-icons' 7 | project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') 8 | -------------------------------------------------------------------------------- /app/actions/commonActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-24 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | 13 | /** 14 | * 公共的actions 15 | */ 16 | 17 | export let commonIsToasting = (isToasting) => { 18 | return (dispatch) => { 19 | dispatch({type:types.kCommonIsToasting, isToasting:isToasting}); 20 | } 21 | }; -------------------------------------------------------------------------------- /app/containers/SearchContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ljunb on 16/6/5. 3 | */ 4 | import React from 'react'; 5 | import {connect} from 'react-redux'; 6 | import Search from '../pages/Search'; 7 | 8 | class SearchContainer extends React.Component { 9 | render() { 10 | return ( 11 | 12 | ) 13 | } 14 | } 15 | 16 | export default connect((state) => { 17 | const {Search} = state; 18 | return { 19 | Search 20 | } 21 | })(SearchContainer); -------------------------------------------------------------------------------- /ios/ShopReactNative/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/shopreactnative/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.shopreactnative; 2 | 3 | import com.facebook.react.ReactActivity; 4 | import com.oblador.vectoricons.VectorIconsPackage; 5 | 6 | public class MainActivity extends ReactActivity { 7 | 8 | /** 9 | * Returns the name of the main component registered from JavaScript. 10 | * This is used to schedule rendering of the component. 11 | */ 12 | @Override 13 | protected String getMainComponentName() { 14 | return "ShopReactNative"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/actions/foodCompareActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | 13 | export let clearCompareFood = (position)=> { 14 | return { 15 | type: types.CLEAR_COMPARE_FOOD, 16 | position: position 17 | } 18 | } 19 | 20 | export let resetState = ()=> { 21 | return { type: types.FOOD_COMPARE_RESET_STATE } 22 | } -------------------------------------------------------------------------------- /app/containers/FoodCompareContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ljunb on 16/6/5. 3 | */ 4 | import React from 'react'; 5 | import {connect} from 'react-redux'; 6 | import FoodCompare from '../pages/FoodCompare'; 7 | 8 | class FoodCompareContainer extends React.Component { 9 | render() { 10 | return ( 11 | 12 | ) 13 | } 14 | } 15 | 16 | export default connect((state)=>{ 17 | const {FoodCompare} = state; 18 | return { 19 | FoodCompare, 20 | } 21 | })(FoodCompareContainer); -------------------------------------------------------------------------------- /app/reducers/myReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | isLoggedIn: false, 15 | user: {}, 16 | status: null, 17 | } 18 | 19 | let myReducer = (state=initialState, action) => { 20 | switch (action.type) { 21 | default: 22 | return state; 23 | } 24 | } 25 | 26 | export default myReducer; -------------------------------------------------------------------------------- /ios/ShopReactNative/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/root.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, { Component } from 'react'; 12 | import { Provider } from 'react-redux'; 13 | import store from './store/store'; 14 | 15 | import App from './app'; 16 | 17 | export default class Root extends Component { 18 | render() { 19 | return ( 20 | 21 | 22 | 23 | ) 24 | } 25 | } -------------------------------------------------------------------------------- /app/containers/MyContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import MyPage from '../pages/MyPage'; 14 | 15 | class MyContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | return { userReducer } = state; 25 | })(MyContainer); -------------------------------------------------------------------------------- /app/store/store.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | 'use strict'; 12 | 13 | import { createStore, applyMiddleware } from 'redux'; 14 | import thunk from 'redux-thunk'; 15 | import rootReducer from '../reducers/rootRudcer'; 16 | 17 | let createStoreWithMiddleware = applyMiddleware(thunk)(createStore); 18 | let store = createStoreWithMiddleware(rootReducer); 19 | // let state = store.getState(); 20 | // alert(state.Search.searchText); 21 | export default store; -------------------------------------------------------------------------------- /app/containers/FoodInfoContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React from 'react'; 12 | import { connect } from 'react-redux'; 13 | import FoodInfo from '../pages/FoodInfo'; 14 | 15 | class FoodInfoContainer extends React.Component { 16 | render() { 17 | return 18 | } 19 | } 20 | 21 | export default connect((state)=>{ 22 | const { FoodInfo } = state; 23 | return { FoodInfo }; 24 | })(FoodInfoContainer); -------------------------------------------------------------------------------- /app/containers/FunContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-24 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import FunPage from '../pages/FunPage'; 14 | 15 | class FunContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | return { userReducer } = state; 25 | })(FunContainer); -------------------------------------------------------------------------------- /app/containers/HomeContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import HomePage from '../pages/HomePage'; 14 | 15 | class HomeContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | return { homeReducer, cartReducer, userReducer } = state; 25 | })(HomeContainer); -------------------------------------------------------------------------------- /app/containers/CartContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-11 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import CartPage from '../pages/CartPage'; 14 | 15 | class CartContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | return { cartReducer, userReducer, preorderReducer } = state; 25 | })(CartContainer); -------------------------------------------------------------------------------- /app/containers/AddressContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-24 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import AddressPage from '../pages/AddressPage'; 14 | 15 | class AddressContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | return { addressReducer, userReducer} = state; 25 | })(AddressContainer); -------------------------------------------------------------------------------- /app/containers/OrderContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-27 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import OrderPage from '../pages/OrderPage'; 14 | 15 | class OrderContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | return { orderReducer, userReducer, commonReducer} = state; 25 | })(OrderContainer); -------------------------------------------------------------------------------- /app/containers/UserContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import User from '../pages/UserPage'; 14 | 15 | class UserContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | const { userReducer } = state; 25 | return { 26 | userReducer 27 | } 28 | })(UserContainer); -------------------------------------------------------------------------------- /app/containers/FoodsListContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React from 'react'; 12 | import {connect} from 'react-redux'; 13 | import FoodsList from '../pages/FoodsList'; 14 | 15 | class FoodsListContainer extends React.Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | const {FoodsList} = state; 25 | return { 26 | FoodsList 27 | } 28 | })(FoodsListContainer); -------------------------------------------------------------------------------- /app/containers/LoginContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import LoginPage from '../pages/LoginPage'; 14 | 15 | class LoginContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | const { userReducer } = state; 25 | return { 26 | userReducer 27 | } 28 | })(LoginContainer); -------------------------------------------------------------------------------- /app/containers/AddressCreateContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-25 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import AddressCreatePage from '../pages/AddressCreatePage'; 14 | 15 | class AddressCreateContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | return {addressReducer, userReducer} = state; 25 | })(AddressCreateContainer); -------------------------------------------------------------------------------- /app/containers/PreorderContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-23 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import PreorderPage from '../pages/PreorderPage'; 14 | 15 | class PreorderContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | return { preorderReducer, orderReducer, userReducer, commonReducer} = state; 25 | })(PreorderContainer); -------------------------------------------------------------------------------- /app/containers/ArticleContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import ArticlePage from '../pages/ArticlePage'; 14 | 15 | class ArticleContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | const { articleReducer } = state; 25 | return { 26 | articleReducer 27 | } 28 | })(ArticleContainer); -------------------------------------------------------------------------------- /app/containers/RegisterContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import RegisterPage from '../pages/RegisterPage'; 14 | 15 | class RegisterContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | const { userReducer } = state; 25 | return { 26 | userReducer 27 | } 28 | })(RegisterContainer); -------------------------------------------------------------------------------- /app/containers/CategoryContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import CategoryPage from '../pages/CategoryPage'; 14 | 15 | class CategoryContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | const { categoryReducer } = state; 25 | return { 26 | categoryReducer 27 | } 28 | })(CategoryContainer); -------------------------------------------------------------------------------- /app/reducers/commonReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-27 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | isToasting: false, 15 | }; 16 | 17 | let commonReducer = (state=initialState, action) => { 18 | switch (action.type) { 19 | case types.kCommonIsToasting: 20 | return { 21 | ...state, 22 | isToasting: action.isToasting, 23 | }; 24 | default: 25 | return state; 26 | } 27 | }; 28 | 29 | export default commonReducer; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ShopReactNative", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start" 7 | }, 8 | "dependencies": { 9 | "react": "15.3.1", 10 | "react-native": "0.33.0", 11 | "react-native-device-info": "^0.9.5", 12 | "react-native-root-toast": "^1.0.3", 13 | "react-native-swiper": "^1.4.4", 14 | "react-native-tab-navigator": "^0.3.3", 15 | "react-native-vector-icons": "^2.0.3", 16 | "react-redux": "^4.4.5", 17 | "redux": "^3.5.2", 18 | "redux-persist": "^2.0.1", 19 | "redux-thunk": "^2.1.0" 20 | }, 21 | "devDependencies": { 22 | "redux-devtools": "^3.3.1" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/models/User.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | 'use strict'; 12 | // @property (nonatomic, copy) NSNumber *id; 13 | // @property (nonatomic, copy) NSString *username;// 用户名 14 | // @property (nonatomic, copy) NSString *email; // 邮箱 15 | // @property (nonatomic, copy) NSString *mobile; // 手机 16 | // @property (nonatomic, copy) NSNumber *level; 17 | // @property (nonatomic, copy) NSString *level_label; 18 | // @property (nonatomic, copy) NSNumber *created_at; 19 | // @property (nonatomic, copy) NSNumber *updated_at; 20 | // @property (nonatomic, copy) NSString *access_token; -------------------------------------------------------------------------------- /app/containers/ProductContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import {connect} from 'react-redux'; 13 | import ProductPage from '../pages/ProductPage'; 14 | 15 | class ProductContainer extends Component { 16 | render() { 17 | return ( 18 | 19 | ) 20 | } 21 | } 22 | 23 | export default connect((state) => { 24 | const { productReducer, userReducer, cartReducer } = state; 25 | return { productReducer, userReducer, cartReducer }; 26 | })(ProductContainer); -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IJ 26 | # 27 | *.iml 28 | .idea 29 | .gradle 30 | local.properties 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | 37 | # BUCK 38 | buck-out/ 39 | \.buckd/ 40 | #android/app/libs 41 | #android/keystores/debug.keystore 42 | #.buckconfig 43 | #.flowconfig 44 | #.gitignore 45 | #.watchmanconfig 46 | #android/ 47 | #index.android.js 48 | #index.ios.js 49 | #ios/ 50 | #package.json 51 | -------------------------------------------------------------------------------- /README-DOC.txt: -------------------------------------------------------------------------------- 1 | # 该项目的短链接: 2 | 发布一个电商APP开源项目 Shop-React-Native, 一次开发同时运行在iOS和Android上, 极大地提高开发速度和降低人力成本。 3 | 代码托管在: http://t.cn/Rc4mP0l 4 | 5 | # 参考开源项目 6 | https://github.com/ljunb/react-native-iShiWuPai //初始化项目+redux 7 | react-native-redux-demo //redux登录demo 8 | demoJD 9 | https://github.com/jiangqqlmj/GaGaMall 点餐商城 10 | https://github.com/JasonStu/ReactNative_Shopping 实现电商基础界面和购物车功能 11 | 12 | # 安卓的问题 13 | 1.启动安卓AVD虚拟模拟器 14 | $android avd 15 | 2.选中Emulator, 点击start, 就能启动Emulator 16 | 3. $react-native run-android 17 | 4.查看对应的安卓设备 18 | $ adb devices 19 | 新建安卓AVD虚拟模拟器 20 | http://jingyan.baidu.com/article/a681b0ded7e7573b1943465b.html 21 | 22 | # 需要更改原生文件的组件 23 | react-native-vector-icons https://www.npmjs.com/package/react-native-vector-icons -------------------------------------------------------------------------------- /ios/ShopReactNative/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ios/ShopReactNativeTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/reducers/articleReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | const initialState = { 13 | article: [], 14 | isLoading: true, 15 | }; 16 | 17 | let articleReducer = (state = initialState, action) => { 18 | switch (action.type) { 19 | case types.kArticleView: 20 | return { 21 | ...state, 22 | isLoading: true, 23 | }; 24 | case types.kArticleViewReceived: 25 | return { 26 | ...state, 27 | article: action.article, 28 | isLoading: false, 29 | }; 30 | default: 31 | return state; 32 | } 33 | }; 34 | 35 | export default articleReducer; -------------------------------------------------------------------------------- /app/reducers/foodsReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | categoryList: [], 15 | isLoading: true, 16 | } 17 | 18 | let foodsReducer = (state = initialState, action)=>{ 19 | 20 | switch (action.type) { 21 | case types.FETCH_CATEGORY_LIST: 22 | return Object.assign({}, state, { 23 | ...state, 24 | }) 25 | case types.RECEIVE_CATEGORY_LIST: 26 | return Object.assign({}, state, { 27 | categoryList: action.categoryList, 28 | isLoading: false, 29 | }) 30 | default: 31 | return state 32 | } 33 | } 34 | 35 | export default foodsReducer; -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /app/reducers/productReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | import {Alert} from 'react-native'; 13 | 14 | const initialState = { 15 | categories: [], 16 | product: {}, 17 | isLoading: true, 18 | }; 19 | 20 | let productReducer = (state = initialState, action) => { 21 | switch (action.type) { 22 | case types.kProductView: 23 | // alert(1); 24 | return { 25 | ...state, 26 | isLoading: true, 27 | }; 28 | case types.kProductViewReceived: 29 | return { 30 | ...state, 31 | ...action, 32 | isLoading: false, 33 | }; 34 | default: 35 | return state; 36 | } 37 | }; 38 | 39 | export default productReducer; -------------------------------------------------------------------------------- /app/reducers/categoryReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | import {Alert} from 'react-native'; 13 | 14 | const initialState = { 15 | categories: [], 16 | isLoading: true, 17 | }; 18 | 19 | let categoryReducer = (state = initialState, action) => { 20 | switch (action.type) { 21 | case types.kCategoryListWithProduct: 22 | return { 23 | ...state 24 | }; 25 | case types.kCategoryListWithProductReceived: 26 | // Alert.alert(action.categories); 27 | return { 28 | ...state, 29 | categories: action.categories, 30 | isLoading: false, 31 | }; 32 | default: 33 | return state; 34 | } 35 | }; 36 | 37 | export default categoryReducer; -------------------------------------------------------------------------------- /app/components/LoadMoreFooter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React from 'react'; 12 | import { 13 | ActivityIndicator, 14 | View, 15 | Text, 16 | StyleSheet, 17 | } from 'react-native'; 18 | 19 | export default class LoadMoreFooter extends React.Component { 20 | render() { 21 | return ( 22 | 23 | 24 | 正在加载更多…… 25 | 26 | ) 27 | } 28 | } 29 | 30 | const styles = StyleSheet.create({ 31 | footer: { 32 | flexDirection: 'row', 33 | justifyContent: 'center', 34 | alignItems: 'center', 35 | height: 40, 36 | }, 37 | 38 | footerTitle: { 39 | marginLeft: 10, 40 | fontSize: 15, 41 | color: 'gray' 42 | } 43 | }) -------------------------------------------------------------------------------- /app/common/UserDefaults.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import { AsyncStorage } from 'react-native'; 12 | 13 | let UserDefaults = { 14 | setObject: (key, value) => { 15 | const jsonValue = JSON.stringify(value); 16 | return AsyncStorage.setItem(key, jsonValue, (error) => { 17 | // console.log(key + ' setOrRemoveObject error: ' + error); 18 | }); 19 | }, 20 | 21 | cachedObject: (key) => { 22 | return AsyncStorage.getItem(key) 23 | .then((data, error) => { 24 | if (data) return JSON.parse(data); 25 | 26 | // console.log(key + ' cachedObject error: ' + error); 27 | return null; 28 | }) 29 | }, 30 | 31 | clearCachedObject: (key) => { 32 | return AsyncStorage.removeItem(key); 33 | }, 34 | } 35 | 36 | export default UserDefaults; -------------------------------------------------------------------------------- /app/actions/foodsActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | import Util from '../common/utils'; 13 | 14 | export let fetchCategories = ()=>{ 15 | let URL = 'http://food.boohee.com/fb/v1/categories/list'; 16 | 17 | return dispatch => { 18 | dispatch(fetchCategoryList()); 19 | 20 | Util.get(URL, (response) => { 21 | dispatch(receiveCategoryList(response.group)); 22 | }, (error) => { 23 | console.log('Fetch category list error: ' + error); 24 | dispatch(receiveCategoryList([])); 25 | }); 26 | } 27 | } 28 | 29 | let fetchCategoryList = ()=> { 30 | return { 31 | type: types.FETCH_CATEGORY_LIST, 32 | } 33 | } 34 | 35 | let receiveCategoryList = (categoryList)=> { 36 | return { 37 | type: types.RECEIVE_CATEGORY_LIST, 38 | categoryList: categoryList, 39 | } 40 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 EleTeam 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/actions/articleActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | import Util from '../common/utils'; 13 | import * as urls from '../common/constants_url'; 14 | 15 | export let articleView = (id)=> { 16 | let url = urls.kUrlArticleView + id; 17 | 18 | return dispatch => { 19 | dispatch({type: types.kArticleView}); 20 | return Util.get(url, 21 | (status, code, message, data, share) => { 22 | let article = []; 23 | if (status) { 24 | article = data.article; 25 | } 26 | dispatch({type:types.kArticleViewReceived, status:status, code:code, message:message, share:share, article:article}); 27 | }, 28 | (error) => { 29 | // console.log('Fetch banner list error: ' + error); 30 | dispatch({'type': types.kActionError}); 31 | } 32 | ); 33 | } 34 | }; -------------------------------------------------------------------------------- /app/reducers/rootRudcer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | /** 12 | * 根reducer 13 | */ 14 | import { combineReducers } from 'redux'; 15 | import homeReducer from './homeReducer'; 16 | import categoryReducer from './categoryReducer'; 17 | import productReducer from './productReducer'; 18 | import articleReducer from './articleReducer'; 19 | import cartReducer from './cartReducer'; 20 | import preorderReducer from './preorderReducer'; 21 | import orderReducer from './orderReducer'; 22 | import myReducer from './myReducer'; 23 | import userReducer from './userReducer'; 24 | import addressReducer from './addressReducer'; 25 | import commonReducer from './commonReducer'; 26 | 27 | export default rootReducer = combineReducers({ 28 | homeReducer, 29 | categoryReducer, 30 | productReducer, 31 | articleReducer, 32 | cartReducer, 33 | preorderReducer, 34 | orderReducer, 35 | myReducer, 36 | userReducer, 37 | addressReducer, 38 | commonReducer 39 | }) -------------------------------------------------------------------------------- /app/actions/foodInfoActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | import Util from '../common/utils'; 13 | 14 | export let fetchFoodInfo = (foodCode)=> { 15 | 16 | let URL = `http://food.boohee.com/fb/v1/foods/${foodCode}/mode_show`; 17 | 18 | return dispatch => { 19 | dispatch(fetchFood()); 20 | 21 | Util.get(URL, (response) => { 22 | dispatch(receiveFood(response)); 23 | }, (error) => {alert(error) 24 | console.log(`Fetch food info error: ${error}`); 25 | dispatch(receiveFood({})) 26 | }) 27 | } 28 | } 29 | 30 | let fetchFood = ()=> { 31 | return { type: types.FOOD_INFO_FETCH_FOOD } 32 | } 33 | 34 | let receiveFood = (food)=> { 35 | return { 36 | type: types.FOOD_INFO_RECEIVE_FOOD, 37 | food: food 38 | } 39 | } 40 | 41 | export let changeUnitsStatus = ()=> { 42 | return { type: types.FOOD_INFO_CHANGE_SHOW_UNITS_STATUS } 43 | } -------------------------------------------------------------------------------- /app/reducers/foodInfoReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | food: undefined, 15 | isFetchingFood: true, 16 | isShowAllUnit: false, // 是否展开所有元素 17 | } 18 | 19 | let foodInfoReducer = (state = initialState, action) => { 20 | switch (action.type) { 21 | case types.FOOD_INFO_FETCH_FOOD: 22 | return Object.assign({}, state, { 23 | ...state, 24 | isFetchingFood: true 25 | }) 26 | case types.FOOD_INFO_RECEIVE_FOOD: 27 | return Object.assign({}, state, { 28 | food: action.food, 29 | isFetchingFood: false 30 | }) 31 | case types.FOOD_INFO_CHANGE_SHOW_UNITS_STATUS: 32 | return Object.assign({}, state, { 33 | isShowAllUnit: !state.isShowAllUnit 34 | }) 35 | default: 36 | return state 37 | } 38 | } 39 | 40 | export default foodInfoReducer; -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/shopreactnative/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.shopreactnative; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.learnium.RNDeviceInfo.RNDeviceInfo; 8 | import com.facebook.react.ReactInstanceManager; 9 | import com.facebook.react.ReactNativeHost; 10 | import com.facebook.react.ReactPackage; 11 | import com.facebook.react.shell.MainReactPackage; 12 | import com.oblador.vectoricons.VectorIconsPackage; 13 | 14 | import java.util.Arrays; 15 | import java.util.List; 16 | 17 | public class MainApplication extends Application implements ReactApplication { 18 | 19 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 20 | @Override 21 | protected boolean getUseDeveloperSupport() { 22 | return BuildConfig.DEBUG; 23 | } 24 | 25 | @Override 26 | protected List getPackages() { 27 | return Arrays.asList( 28 | new MainReactPackage(), 29 | new RNDeviceInfo(), 30 | new VectorIconsPackage() 31 | ); 32 | } 33 | }; 34 | 35 | @Override 36 | public ReactNativeHost getReactNativeHost() { 37 | return mReactNativeHost; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/components/Loading.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React from 'react'; 12 | import { 13 | StyleSheet, 14 | View, 15 | Text, 16 | ActivityIndicator, 17 | } from 'react-native'; 18 | 19 | import Common from '../common/constants'; 20 | 21 | export default class Loading extends React.Component { 22 | render() { 23 | return ( 24 | 25 | 26 | 加载中…… 27 | 28 | ) 29 | } 30 | } 31 | 32 | const styles = StyleSheet.create({ 33 | loading: { 34 | backgroundColor: 'gray', 35 | height: 80, 36 | width: 100, 37 | borderRadius: 10, 38 | justifyContent: 'center', 39 | alignItems: 'center', 40 | position: 'absolute', 41 | top: (Common.window.height-80)/2, 42 | left: (Common.window.width-100)/2, 43 | }, 44 | 45 | loadingTitle: { 46 | marginTop: 10, 47 | fontSize: 14, 48 | color: 'white' 49 | } 50 | }) -------------------------------------------------------------------------------- /app/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, { Component } from 'react'; 12 | import { 13 | Navigator, 14 | View, 15 | StatusBar, 16 | Platform 17 | } from 'react-native'; 18 | 19 | import Splash from './pages/Splash'; 20 | 21 | class App extends Component { 22 | render() { 23 | return ( 24 | 25 | 30 | { 33 | return Navigator.SceneConfigs.PushFromRight; 34 | }} 35 | renderScene={(route, navigator) => { 36 | let Component = route.component; 37 | return ( 38 | 39 | ) 40 | }} 41 | /> 42 | 43 | ) 44 | } 45 | } 46 | 47 | export default App; -------------------------------------------------------------------------------- /app/common/Storage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-16 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | 'use strict'; 12 | 13 | import {AsyncStorage} from 'react-native'; 14 | 15 | const kStorageUser = 'kStorageUser'; 16 | const kStorageAppCartCookieId = 'kStorageAppCartCookieId'; 17 | 18 | export const getUser = () => { 19 | return AsyncStorage.getItem(kStorageUser) 20 | .then((user) => { 21 | if (user) { 22 | return JSON.parse(user); 23 | } else { 24 | return {}; 25 | } 26 | }) 27 | .catch(error => { 28 | // console.log(error); 29 | }); 30 | }; 31 | 32 | export const setUser = (user) => { 33 | AsyncStorage.setItem(kStorageUser, JSON.stringify(user)); 34 | }; 35 | 36 | export const getAppCartCookieId = () => { 37 | return AsyncStorage.getItem(kStorageAppCartCookieId) 38 | .then((app_cart_cookie_id) => { 39 | if (app_cart_cookie_id) { 40 | return app_cart_cookie_id; 41 | } else { 42 | return ''; 43 | } 44 | }) 45 | .catch(error => { 46 | // console.log(error); 47 | }); 48 | }; 49 | 50 | export const setAppCartCookieId = (app_cart_cookie_id) => { 51 | AsyncStorage.setItem(kStorageAppCartCookieId, app_cart_cookie_id); 52 | }; 53 | -------------------------------------------------------------------------------- /app/pages/Splash.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | 'use strict'; 12 | 13 | import React, { Component } from 'react'; 14 | import { 15 | Dimensions, 16 | Image, 17 | InteractionManager, 18 | View 19 | } from 'react-native'; 20 | import AppMain from '../containers/AppMain'; 21 | // import syncStorage from '../common/syncStorage'; 22 | 23 | var {height, width} = Dimensions.get('window'); 24 | 25 | class Splash extends Component { 26 | constructor(props) { 27 | super(props); 28 | } 29 | 30 | componentDidMount() { 31 | const {navigator} = this.props; 32 | this.timer = setTimeout(() => { 33 | InteractionManager.runAfterInteractions(() => { 34 | navigator.resetTo({ 35 | component: AppMain, 36 | name: 'AppMain' 37 | }); 38 | }); 39 | }, 2000); 40 | } 41 | 42 | componentWillUnmount() { 43 | this.timer && clearTimeout(this.timer); 44 | } 45 | 46 | render() { 47 | return ( 48 | 49 | 53 | 54 | ); 55 | } 56 | } 57 | 58 | export default Splash; -------------------------------------------------------------------------------- /ios/ShopReactNative/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import "RCTBundleURLProvider.h" 13 | #import "RCTRootView.h" 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"ShopReactNative" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /app/reducers/homeReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | const initialState = { 13 | banners: [], 14 | articles: [], 15 | isLoading: true, 16 | isLoadMore: false, 17 | isRefreshing: false, 18 | }; 19 | 20 | let homeReducer = (state = initialState, action) => { 21 | switch (action.type) { 22 | case types.kBannerList: 23 | return { 24 | ...state, 25 | }; 26 | case types.kBannerListReceived: 27 | return { 28 | ...state, 29 | banners: action.banners, 30 | }; 31 | case types.kHomeListArticles: 32 | 33 | return Object.assign({}, state, { 34 | isLoadMore: action.isLoadMore, 35 | isRefreshing: action.isRefreshing, 36 | isLoading: action.isLoading, 37 | }); 38 | case types.kHomeListArticlesReceived: 39 | return { 40 | ...state, 41 | //articles: action.articles, 42 | articles: action.articles.length > 0 ? state.articles.concat(action.articles) : state.articles, 43 | isLoading: false, 44 | isRefreshing: false, 45 | }; 46 | default: 47 | return state; 48 | } 49 | }; 50 | 51 | export default homeReducer; -------------------------------------------------------------------------------- /app/common/Buttom.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Copyright 2016-present reading 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | import React, { PropTypes } from 'react'; 19 | import { 20 | View, 21 | Text, 22 | TouchableOpacity 23 | } from 'react-native'; 24 | 25 | const propTypes = { 26 | onPress: PropTypes.func, 27 | disabled: PropTypes.bool, 28 | style: Text.propTypes.style, 29 | containerStyle: View.propTypes.style, 30 | text: PropTypes.string 31 | }; 32 | 33 | const Button = ({ onPress, disabled, style, containerStyle, text }) => ( 34 | 40 | 41 | 42 | {text} 43 | 44 | 45 | 46 | ); 47 | 48 | Button.propTypes = propTypes; 49 | 50 | Button.defaultProps = { 51 | onPress() { }, 52 | disabled: false 53 | }; 54 | 55 | export default Button; 56 | -------------------------------------------------------------------------------- /app/common/commonStyles.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import {StyleSheet} from 'react-native'; 12 | 13 | export const colors = { 14 | lightGray:"#F0F0F0", 15 | lineGray: '#F0F0F0', 16 | green: '#80BD01', 17 | backGray: '#E5E5E5', 18 | textGray: '#9A9A9A', 19 | textBlack: '#333333', 20 | purple: '#9966CC', 21 | red: '#f61d4b', 22 | backWhite: '#F2F2F2', 23 | textGold: '#BC7233', 24 | borderColor: '#E2E2E2', 25 | black: '#586872', 26 | blue: '#4078c0', 27 | white: "white", 28 | }; 29 | 30 | const commonStyles = StyleSheet.create({ 31 | container: { 32 | flex: 1, 33 | justifyContent: 'center', 34 | alignItems: 'center', 35 | }, 36 | shadowLine: { 37 | shadowColor: '#999999', 38 | shadowOpacity: 0.8, 39 | shadowRadius: 1, 40 | shadowOffset: { 41 | height: 2, 42 | width: 1 43 | }, 44 | }, 45 | sepLine: { 46 | backgroundColor: colors.backGray, 47 | height: 0.5, 48 | }, 49 | textInput: { 50 | fontSize: 15, 51 | borderWidth: 1, 52 | height: 38, 53 | marginTop: 5, 54 | marginBottom: 10, 55 | borderRadius: 4, 56 | padding: 3, 57 | borderColor: colors.blue, 58 | }, 59 | btn: { 60 | borderWidth: 1, 61 | height: 38, 62 | marginLeft: 20, 63 | marginRight: 20, 64 | justifyContent: "center", 65 | borderColor: colors.blue, 66 | backgroundColor: colors.blue, 67 | borderRadius: 6, 68 | marginTop:20, 69 | } 70 | }); 71 | 72 | export default commonStyles; -------------------------------------------------------------------------------- /app/reducers/cartReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-11 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | const initialState = { 13 | cartItems: [], 14 | cart_num: 0, 15 | app_cart_cookie_id: '', 16 | isLoading: true, 17 | }; 18 | 19 | /** 20 | * 购物车reducer 21 | * @param state 22 | * @param action 23 | * @returns {*} 24 | */ 25 | let cartReducer = (state = initialState, action) => { 26 | switch (action.type) { 27 | case types.kAppCartCookieIdFromSync: 28 | return { 29 | ...state, 30 | ...action, 31 | }; 32 | case types.kCartNumFromSync: 33 | return { 34 | ...state, 35 | ...action, 36 | }; 37 | case types.kCartView: 38 | return { 39 | ...state, 40 | isLoading: true, 41 | }; 42 | case types.kCartViewReceived: 43 | return { 44 | ...state, 45 | ...action, 46 | isLoading: false, 47 | }; 48 | case types.kCartAdd: 49 | return { 50 | ...state, 51 | isLoading: true, 52 | }; 53 | case types.kCartAddReceived: 54 | return { 55 | ...state, 56 | ...action, 57 | isLoading: false, 58 | }; 59 | default: 60 | return state; 61 | } 62 | }; 63 | 64 | export default cartReducer; -------------------------------------------------------------------------------- /app/common/ImageButton.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Copyright 2016-present reading 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | import React, { PropTypes } from 'react'; 19 | import { 20 | View, 21 | Text, 22 | Image, 23 | TouchableOpacity 24 | } from 'react-native'; 25 | 26 | const propTypes = { 27 | onPress: PropTypes.func, 28 | disabled: PropTypes.bool, 29 | style: Text.propTypes.style, 30 | containerStyle: View.propTypes.style, 31 | text: PropTypes.string 32 | }; 33 | 34 | const ImageButton = ({ onPress, disabled, style, text, imageUrl, imageStyle }) => ( 35 | 41 | 45 | 46 | {text} 47 | 48 | 49 | ); 50 | 51 | ImageButton.propTypes = propTypes; 52 | 53 | ImageButton.defaultProps = { 54 | onPress() { }, 55 | disabled: false 56 | }; 57 | 58 | export default ImageButton; 59 | -------------------------------------------------------------------------------- /app/common/TextButton.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Copyright 2016-present reading 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | import React, { PropTypes } from 'react'; 19 | import { 20 | View, 21 | Text, 22 | TouchableOpacity, 23 | ScrollView, 24 | 25 | } from 'react-native'; 26 | 27 | const propTypes = { 28 | onPress: PropTypes.func, 29 | disabled: PropTypes.bool, 30 | style: Text.propTypes.style, 31 | containerStyle: View.propTypes.style, 32 | text: PropTypes.string 33 | }; 34 | 35 | const TextButton = ({ onPress, disabled, style, text, upText, upTextStyle }) => ( 36 | 43 | 44 | {upText} 45 | 46 | 47 | {text} 48 | 49 | 50 | ); 51 | 52 | TextButton.propTypes = propTypes; 53 | 54 | TextButton.defaultProps = { 55 | onPress() { }, 56 | disabled: false 57 | }; 58 | 59 | export default TextButton; 60 | -------------------------------------------------------------------------------- /app/reducers/addressReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-24 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | addresses: [], 15 | address: {}, 16 | isLoading: true, 17 | isToasting: false, 18 | }; 19 | 20 | let addressReducer = (state=initialState, action) => { 21 | switch (action.type) { 22 | case types.kAddressIsToasting: 23 | return { 24 | ...state, 25 | isToasting: action.isToasting, 26 | }; 27 | case types.kAddressList: 28 | return { 29 | ...state, 30 | isLoading: true 31 | }; 32 | case types.kAddressListReceived: 33 | return { 34 | ...state, 35 | ...action, 36 | isLoading: false 37 | }; 38 | case types.kAddressCreate: 39 | return { 40 | ...state, 41 | isLoading: true 42 | }; 43 | case types.kAddressCreateReceived: 44 | return { 45 | ...state, 46 | isLoading: true 47 | }; 48 | case types.kAddressDelete: 49 | return { 50 | ...state, 51 | isLoading: true 52 | }; 53 | case types.kAddressDeleteReceived: 54 | return { 55 | ...state, 56 | isLoading: true 57 | }; 58 | default: 59 | return state; 60 | } 61 | }; 62 | 63 | export default addressReducer; -------------------------------------------------------------------------------- /app/common/constants.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import {Dimensions} from 'react-native'; 12 | 13 | let window = { 14 | width: Dimensions.get('window').width, 15 | height: Dimensions.get('window').height, 16 | }; 17 | 18 | let colors = { 19 | themeColor: 'rgb(217, 51, 58)', 20 | }; 21 | 22 | let storeKeys = { 23 | SEARCH_HISTORY_KEY: 'SEARCH_HISTORY_KEY', 24 | }; 25 | 26 | let mapper = { 27 | 'calory': {name: '热量', unit: ''}, 28 | 'protein': {name: '蛋白质', unit: '克'}, 29 | 'fat': {name: '脂肪', unit: '克'}, 30 | 'carbohydrate': {name: '碳水化合物', unit: '克'}, 31 | 'fiber_dietary': {name: '膳食纤维', unit: '克'}, 32 | 'vitamin_a': {name: '维生素A', unit: 'IU'}, 33 | 'vitamin_c': {name: '维生素C', unit: '毫克'}, 34 | 'vitamin_e': {name: '维生素E', unit: '毫克'}, 35 | 'carotene': {name: '胡萝卜素', unit: '微克'}, 36 | 'thiamine': {name: '维生素B1', unit: '毫克'}, 37 | 'lactoflavin': {name: '维生素B2', unit: '毫克'}, 38 | 'niacin': {name: '烟酸', unit: '毫克'}, 39 | 'cholesterol': {name: '胆固醇', unit: '毫克'}, 40 | 'magnesium': {name: '镁', unit: '毫克'}, 41 | 'calcium': {name: '钙', unit: '毫克'}, 42 | 'iron': {name: '铁', unit: '毫克'}, 43 | 'zinc': {name: '锌', unit: '毫克'}, 44 | 'copper': {name: '铜', unit: '毫克'}, 45 | 'manganese': {name: '锰', unit: '毫克'}, 46 | 'kalium': {name: '钾', unit: '毫克'}, 47 | 'phosphor': {name: '磷', unit: '毫克'}, 48 | 'natrium': {name: '钠', unit: '毫克'}, 49 | 'selenium': {name: '硒', unit: '毫克'} 50 | }; 51 | 52 | export default { 53 | window: window, 54 | colors: colors, 55 | storeKeys: storeKeys, 56 | ingredientMapper: mapper 57 | }; -------------------------------------------------------------------------------- /android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.shopreactnative', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.shopreactnative', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /app/common/constants_url.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | /** 12 | * 服务器地址 13 | * @type {string} 14 | */ 15 | 16 | // const kUrlHost = 'http://local.api.eleteam.com/v1'; //本地服务器 17 | const kUrlHost = 'http://api.eleteam.com/v1'; //在线服务器 18 | 19 | //产品和分类 20 | export const kUrlCategoryListWithProduct = kUrlHost + '/category/list-with-product'; 21 | export const kUrlProductView = kUrlHost + '/product/view?id='; 22 | 23 | //首页 24 | export const kUrlBannerList = kUrlHost + '/banner/list'; 25 | export const kUrlHomeListArticles = kUrlHost + '/home/list-articles'; 26 | 27 | //文章 28 | export const kUrlArticleView = kUrlHost + '/cms-article/view?id='; 29 | 30 | //购物车 31 | export const kUrlCart = kUrlHost + '/cart'; 32 | export const kUrlCartAdd = kUrlHost + '/cart/add'; 33 | 34 | //用户 35 | export const kUrlUserRegister = kUrlHost + '/user/register'; 36 | export const kUrlUserLogin = kUrlHost + '/user/login'; 37 | export const kUrlUserLogout = kUrlHost + '/user/logout'; 38 | 39 | //预订单 40 | export const kUrlPreorderCreate = kUrlHost + '/preorder/create'; 41 | export const kUrlPreorderView = kUrlHost + '/preorder/view?id='; 42 | 43 | //订单 44 | export const kUrlOrderCreate = kUrlHost + '/order/create'; 45 | export const kUrlOrderView = kUrlHost + '/order/view?id='; 46 | export const kUrlOrderIndex = kUrlHost + '/order/index'; 47 | 48 | //地址 49 | export const kUrlAddressList = kUrlHost + '/address/index'; 50 | export const kUrlAddressCreate = kUrlHost + '/address/create'; 51 | export const kUrlAddressDelete = kUrlHost + '/address/delete'; 52 | -------------------------------------------------------------------------------- /app/reducers/orderReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-27 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | order: {}, 15 | address: {}, 16 | isLoading: true, 17 | isOrderCreating: false, //订单是否在创建中 18 | isTurnToOrderView: false, //是否转向订单查看页 19 | }; 20 | 21 | let orderReducer = (state=initialState, action) => { 22 | switch (action.type) { 23 | case types.kOrderCreate: 24 | return { 25 | ...state, 26 | isLoading: true, 27 | isOrderCreating: true, 28 | isTurnToOrderView: false, 29 | }; 30 | case types.kOrderCreateReceived: 31 | return { 32 | ...state, 33 | ...action, 34 | isLoading: false, 35 | isOrderCreating: false, 36 | isTurnToOrderView: true, 37 | }; 38 | case types.kOrderIsTurnedToViewFromSync: 39 | return { 40 | ...state, 41 | isLoading: true, 42 | isOrderCreating: false, 43 | isTurnToOrderView: false, 44 | }; 45 | case types.kOrderView: 46 | return { 47 | ...state, 48 | isLoading: true, 49 | isOrderCreating: false, 50 | isTurnToOrderView: false, 51 | }; 52 | case types.kOrderViewReceived: 53 | return { 54 | ...state, 55 | ...action, 56 | isLoading: false, 57 | isOrderCreating: false, 58 | isTurnToOrderView: false, 59 | }; 60 | default: 61 | return state; 62 | } 63 | }; 64 | 65 | export default orderReducer; -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | # We fork some components by platform. 4 | .*/*.android.js 5 | 6 | # Ignore templates with `@flow` in header 7 | .*/local-cli/generator.* 8 | 9 | # Ignore malformed json 10 | .*/node_modules/y18n/test/.*\.json 11 | 12 | # Ignore the website subdir 13 | /website/.* 14 | 15 | # Ignore BUCK generated dirs 16 | /\.buckd/ 17 | 18 | # Ignore unexpected extra @providesModule 19 | .*/node_modules/commoner/test/source/widget/share.js 20 | 21 | # Ignore duplicate module providers 22 | # For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root 23 | .*/Libraries/react-native/React.js 24 | .*/Libraries/react-native/ReactNative.js 25 | .*/node_modules/jest-runtime/build/__tests__/.* 26 | 27 | [include] 28 | 29 | [libs] 30 | node_modules/react-native/Libraries/react-native/react-native-interface.js 31 | node_modules/react-native/flow 32 | flow/ 33 | 34 | [options] 35 | module.system=haste 36 | 37 | esproposal.class_static_fields=enable 38 | esproposal.class_instance_fields=enable 39 | 40 | experimental.strict_type_args=true 41 | 42 | munge_underscores=true 43 | 44 | module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' 45 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 46 | 47 | suppress_type=$FlowIssue 48 | suppress_type=$FlowFixMe 49 | suppress_type=$FixMe 50 | 51 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-9]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 52 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-9]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 53 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 54 | 55 | unsafe.enable_getters_and_setters=true 56 | 57 | [version] 58 | ^0.29.0 59 | -------------------------------------------------------------------------------- /app/reducers/preorderReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-23 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | preorder: {}, 15 | address: {}, 16 | isLoading: true, 17 | isPreorderCreating: false, //预订单是否在创建中 18 | isTurnToPreorderView: false, //是否转向预订单查看页 19 | }; 20 | 21 | let preorderReducer = (state=initialState, action) => { 22 | switch (action.type) { 23 | case types.kPreorderCreate: 24 | return { 25 | ...state, 26 | isLoading: true, 27 | isPreorderCreating: true, 28 | isTurnToPreorderView: false, 29 | }; 30 | case types.kPreorderCreateReceived: 31 | return { 32 | ...state, 33 | ...action, 34 | isLoading: false, 35 | isPreorderCreating: false, 36 | isTurnToPreorderView: true, 37 | }; 38 | case types.kPreorderIsTurnedToViewFromSync: 39 | return { 40 | ...state, 41 | isLoading: true, 42 | isPreorderCreating: false, 43 | isTurnToPreorderView: false, 44 | }; 45 | case types.kPreorderView: 46 | return { 47 | ...state, 48 | isLoading: true, 49 | isPreorderCreating: false, 50 | isTurnToPreorderView: false, 51 | }; 52 | case types.kPreorderViewReceived: 53 | return { 54 | ...state, 55 | ...action, 56 | isLoading: false, 57 | isPreorderCreating: false, 58 | isTurnToPreorderView: false, 59 | }; 60 | default: 61 | return state; 62 | } 63 | }; 64 | 65 | export default preorderReducer; -------------------------------------------------------------------------------- /app/common/syncStorage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-16 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | /** 12 | * 同步缓存的实现 13 | * It is simple wrapper around AsyncStorage with sync get, set, remove methods and background syncing with AsyncStorage. 14 | * 调用: 应该放在启动页Splash.js里, 使用地方如下: 15 | * import syncStorage from 'react-native-sync-storage' 16 | ... 17 | await syncStorage.init // somewhere where you can wait for loading storage, 首次载入需要,其它地方不用 18 | ... 19 | syncStorage.get('property') 20 | syncStorage.set('property', 2333) 21 | syncStorage.remove('property') 22 | */ 23 | 24 | 'use strict'; 25 | 26 | import { AsyncStorage } from 'react-native' 27 | 28 | const kStorage = 'kStorage'; 29 | const kStorageUser = 'kStorageUser'; 30 | const kStorageAppCartCookieId = 'kStorageAppCartCookieId'; 31 | 32 | let getState = async () => { 33 | let savedState = await AsyncStorage.getItem(kStorage); 34 | if (savedState) { 35 | return JSON.parse(kStorage); 36 | } 37 | 38 | return {}; 39 | }; 40 | 41 | let saveState = (state) => { 42 | return AsyncStorage.setItem(kStorage, JSON.stringify(state)) 43 | }; 44 | 45 | class SyncStorage { 46 | cache = {}; 47 | 48 | init = new Promise(async (resolve, reject) => { 49 | this.cache = await getState(); 50 | resolve(); 51 | }); 52 | 53 | get (property) { 54 | return this.cache[property]; 55 | } 56 | 57 | async set (property, value) { 58 | if (this.cache[property] === value) return; 59 | this.cache[property] = value; 60 | await saveState(this.cache); 61 | return true; 62 | } 63 | 64 | async remove (property) { 65 | delete this.cache[property]; 66 | await saveState(this.cache); 67 | return true; 68 | } 69 | } 70 | 71 | if (!global.syncStorage) 72 | global.syncStorage = new SyncStorage(); 73 | 74 | export default global.syncStorage; 75 | -------------------------------------------------------------------------------- /ios/ShopReactNative/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | NSAllowsArbitraryLoads 44 | 45 | 46 | UIAppFonts 47 | 48 | Entypo.ttf 49 | EvilIcons.ttf 50 | FontAwesome.ttf 51 | Foundation.ttf 52 | Ionicons.ttf 53 | MaterialIcons.ttf 54 | Octicons.ttf 55 | Zocial.ttf 56 | 57 | 58 | -------------------------------------------------------------------------------- /app/components/SearchInputBar.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React from 'react'; 12 | import { 13 | StyleSheet, 14 | View, 15 | TextInput, 16 | TouchableOpacity, 17 | Image, 18 | } from 'react-native'; 19 | 20 | import Icon from 'react-native-vector-icons/FontAwesome'; 21 | import Common from '../common/constants'; 22 | 23 | export default class SearchInputBar extends React.Component { 24 | render() { 25 | return ( 26 | 27 | 32 | 33 | 34 | 39 | 44 | 45 | 46 | 47 | ) 48 | } 49 | } 50 | 51 | const styles = StyleSheet.create({ 52 | searchContainer: { 53 | flexDirection: 'row', 54 | height: 44, 55 | alignItems: 'center', 56 | borderBottomColor: '#ccc', 57 | borderBottomWidth: 0.5, 58 | backgroundColor: 'white', 59 | }, 60 | 61 | textInput: { 62 | width: Common.window.width - 15 - 30 - 20, 63 | height: 30, 64 | marginTop: 9, 65 | paddingLeft: 5, 66 | fontSize: 14, 67 | }, 68 | 69 | searchIcon: { 70 | position: 'absolute', 71 | right: 15, 72 | top: 12 73 | } 74 | }) -------------------------------------------------------------------------------- /app/reducers/userReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | status: false, 15 | code: 0, 16 | message: '', 17 | user: {}, 18 | share: {}, 19 | isLoading: false, 20 | isLoggedIn: false, 21 | }; 22 | 23 | let userReducer = (state=initialState, action) => { 24 | switch (action.type) { 25 | case types.kUserFromSync: 26 | return { 27 | ...state, 28 | ...action, 29 | }; 30 | case types.kUserRegister: 31 | return { 32 | ...state, 33 | isLoading: true, 34 | }; 35 | case types.kUserRegisterReceived: 36 | var isLoggedIn = state.isLoggedIn; 37 | if (action.status) { 38 | isLoggedIn = true; 39 | } 40 | return { 41 | ...state, 42 | ...action, 43 | isLoading: false, 44 | isLoggedIn: isLoggedIn, 45 | }; 46 | case types.kUserLogin: 47 | return { 48 | ...state, 49 | isLoading: true, 50 | }; 51 | case types.kUserLoginReceived: 52 | var isLoggedIn = state.isLoggedIn; 53 | if (action.status) { 54 | isLoggedIn = true; 55 | } 56 | return { 57 | ...state, 58 | ...action, 59 | isLoading: false, 60 | isLoggedIn: isLoggedIn, 61 | }; 62 | case types.kUserLogout: 63 | return { 64 | ...state, 65 | isLoading: true, 66 | }; 67 | case types.kUserLogoutReceived: 68 | var isLoggedIn = state.isLoggedIn; 69 | if (action.status) { 70 | isLoggedIn = false; 71 | } 72 | return { 73 | ...state, 74 | ...action, 75 | isLoading: false, 76 | isLoggedIn: isLoggedIn, 77 | }; 78 | default: 79 | return state; 80 | } 81 | }; 82 | 83 | export default userReducer; -------------------------------------------------------------------------------- /ios/ShopReactNativeTests/ShopReactNativeTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import "RCTLog.h" 14 | #import "RCTRootView.h" 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface ShopReactNativeTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation ShopReactNativeTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /app/actions/homeActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | import Util from '../common/utils'; 13 | import * as urls from '../common/constants_url'; 14 | 15 | export let bannerList = ()=> { 16 | let url = urls.kUrlBannerList; 17 | return dispatch => { 18 | // 请求轮播数据 19 | dispatch({type: types.kBannerList}); 20 | return Util.get(url, 21 | (status, code, message, data, share) => { 22 | let banners = []; 23 | if (status) { 24 | banners = data.banners; 25 | } 26 | dispatch({type:types.kBannerListReceived, status:status, code:code, message:message, share:share, banners:banners}); 27 | }, 28 | (error) => { 29 | // console.log('Fetch banner list error: ' + error); 30 | dispatch({'type': types.kActionError}); 31 | alert('Android要用外网地址'); 32 | } 33 | ); 34 | } 35 | }; 36 | 37 | export let homeListArticles = (page, isLoadMore, isRefreshing, isLoading)=> { 38 | let url = urls.kUrlHomeListArticles + '?page=' + page; 39 | return dispatch => { 40 | dispatch({ 41 | type: types.kHomeListArticles, 42 | isLoadMore: isLoadMore, 43 | isRefreshing: isRefreshing, 44 | isLoading: isLoading, 45 | }); 46 | 47 | return Util.get(url, 48 | (status, code, message, data, share) => { 49 | let articles = []; 50 | if (status) { 51 | articles = data.articles; 52 | } 53 | dispatch({type:types.kHomeListArticlesReceived, status:status, code:code, message:message, share:share, articles:articles}); 54 | }, 55 | (error) => { 56 | dispatch({'type': types.kActionError, 'isLoading':false}); 57 | } 58 | ); 59 | 60 | //模拟网络延迟 61 | // function fetching() { 62 | // Util.get(URL, (response) => { 63 | // dispatch(receiveFeedList(response.feeds)); 64 | // }, (error) => { 65 | // dispatch(receiveFeedList([])); 66 | // }); 67 | // } 68 | // setTimeout(fetching, 3000); 69 | } 70 | }; -------------------------------------------------------------------------------- /app/actions/preorderActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-23 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | import Util from '../common/utils'; 13 | import * as urls from '../common/constants_url'; 14 | 15 | /** 16 | * 预订单actions 17 | */ 18 | 19 | export let preorderCreate = (access_token)=> { 20 | let url = urls.kUrlPreorderCreate; 21 | let data = { 22 | access_token: access_token, 23 | }; 24 | 25 | return dispatch => { 26 | dispatch({type: types.kPreorderCreate}); 27 | return Util.post(url, data, 28 | (status, code, message, data, share) => { 29 | let preorder = {}; 30 | if (status) { 31 | preorder = data.preorder; 32 | } 33 | dispatch({type:types.kPreorderCreateReceived, status:status, code:code, message:message, share:share, 34 | preorder:preorder}); 35 | }, 36 | (error) => { 37 | // console.log('Fetch banner list error: ' + error); 38 | dispatch({'type': types.kActionError}); 39 | } 40 | ); 41 | } 42 | }; 43 | 44 | export let preorderIsTurnedToViewFromSync = () => { 45 | return (dispatch) => { 46 | dispatch({type:types.kPreorderIsTurnedToViewFromSync}); 47 | } 48 | }; 49 | 50 | export let preorderView = (preorder_id, access_token)=> { 51 | let url = urls.kUrlPreorderView + preorder_id; 52 | let data = { 53 | access_token: access_token 54 | }; 55 | 56 | return dispatch => { 57 | dispatch({type: types.kPreorderView}); 58 | return Util.post(url, data, 59 | (status, code, message, data, share) => { 60 | let preorder = {}; 61 | let address = {}; 62 | if (status) { 63 | preorder = data.preorder; 64 | address = data.address; 65 | } 66 | dispatch({type:types.kPreorderViewReceived, status:status, code:code, message:message, share:share, 67 | preorder:preorder, address:address}); 68 | }, 69 | (error) => { 70 | // console.log('Fetch banner list error: ' + error); 71 | dispatch({'type': types.kActionError}); 72 | } 73 | ); 74 | } 75 | }; -------------------------------------------------------------------------------- /app/components/SearchHeader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React from 'react'; 12 | import { 13 | StyleSheet, 14 | View, 15 | Text, 16 | TouchableOpacity, 17 | Image, 18 | } from 'react-native'; 19 | import Common from '../common/constants'; 20 | 21 | export default class SearchHeader extends React.Component { 22 | render() { 23 | return ( 24 | 25 | 30 | 34 | 请输入食物名称 35 | 36 | 40 | 44 | 45 | 46 | ) 47 | } 48 | } 49 | 50 | const styles = StyleSheet.create({ 51 | headerWrap: { 52 | flexDirection: 'row', 53 | alignItems: 'center', 54 | justifyContent: 'center', 55 | backgroundColor: '#ff7419', 56 | borderBottomColor: '#ccc', 57 | borderBottomWidth: 0.5, 58 | height: 44, 59 | }, 60 | 61 | searchInput: { 62 | flexDirection: 'row', 63 | alignItems: 'center', 64 | height: 24, 65 | width: Common.window.width - 30 - 6 * 3, 66 | marginTop: 16, 67 | backgroundColor: '#ff7419', 68 | borderRadius: 2, 69 | }, 70 | 71 | searchIcon: { 72 | width: 20, 73 | height: 20, 74 | }, 75 | 76 | scanIcon: { 77 | marginTop: 16, 78 | width: 20, 79 | height: 20, 80 | }, 81 | 82 | searchPlaceholder: { 83 | marginLeft: 10, 84 | textAlign: 'center', 85 | fontSize: 15, 86 | color: 'gray' 87 | } 88 | }) -------------------------------------------------------------------------------- /app/common/utils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | 'use strict'; 12 | 13 | // import {FormData} from 'react-native'; 14 | 15 | let Util = { 16 | /** 17 | * http get 请求简单封装 18 | * @param url 请求的URL 19 | * @param successCallback 请求成功回调 20 | * @param failCallback 请求失败回调 21 | */ 22 | get: (url, successCallback, failCallback) => { 23 | fetch(url) 24 | .then((response) => response.text()) 25 | .then((responseText) => { 26 | let result = JSON.parse(responseText); 27 | successCallback(result.status, result.code, result.message, result.data, result.share); 28 | }) 29 | .catch((err) => { 30 | failCallback(err); 31 | }); 32 | }, 33 | 34 | /** 35 | * http post 请求简单封装 36 | * @param url 请求的URL 37 | * @param data post的数据 38 | * @param successCallback 请求成功回调 39 | * @param failCallback failCallback 请求失败回调 40 | */ 41 | post: (url, data, successCallback, failCallback) => { 42 | let formData = new FormData(); 43 | Object.keys(data).map(function(key) { 44 | var value = data[key]; 45 | formData.append(key, value); 46 | }); 47 | 48 | let fetchOptions = { 49 | method: 'POST', 50 | headers: { 51 | 'Accept': 'application/json', 52 | // 'Content-Type': 'application/json' 53 | 'Content-Type': 'multipart/form-data', 54 | }, 55 | body: formData 56 | // body: JSON.stringify(data) 57 | }; 58 | 59 | fetch(url, fetchOptions) 60 | .then((response) => response.text()) 61 | .then((responseText) => { 62 | let result = JSON.parse(responseText); 63 | successCallback(result.status, result.code, result.message, result.data, result.share); 64 | }) 65 | .catch((err) => { 66 | failCallback(err); 67 | }); 68 | }, 69 | 70 | /** 71 | * 日志打印 72 | * @param obj 73 | */ 74 | log: (obj) => { 75 | var description = ""; 76 | for(let i in obj){ 77 | let property = obj[i]; 78 | description += i + " = " + property + "\n"; 79 | } 80 | alert(description); 81 | }, 82 | }; 83 | 84 | export default Util; -------------------------------------------------------------------------------- /app/actions/orderActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-27 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | import Util from '../common/utils'; 13 | import * as urls from '../common/constants_url'; 14 | import {commonIsToasting} from './commonActions'; 15 | 16 | /** 17 | * 订单actions 18 | */ 19 | 20 | export let orderCreate = (access_token, preorder_id, address_id, notice)=> { 21 | let url = urls.kUrlOrderCreate; 22 | let data = { 23 | access_token: access_token, 24 | preorder_id: preorder_id, 25 | address_id: address_id, 26 | notice: notice 27 | }; 28 | 29 | return dispatch => { 30 | dispatch({type: types.kOrderCreate}); 31 | return Util.post(url, data, 32 | (status, code, message, data, share) => { 33 | let order = {}; 34 | if (status) { 35 | order = data.order; 36 | }else{ 37 | dispatch(commonIsToasting(true)); 38 | } 39 | dispatch({type:types.kOrderCreateReceived, status:status, code:code, message:message, share:share, 40 | order:order}); 41 | dispatch(commonIsToasting(false)); 42 | }, 43 | (error) => { 44 | // console.log('Fetch banner list error: ' + error); 45 | dispatch({'type': types.kActionError}); 46 | } 47 | ); 48 | } 49 | }; 50 | 51 | export let orderView = (order_id, access_token)=> { 52 | let url = urls.kUrlOrderView + order_id; 53 | let data = { 54 | access_token: access_token 55 | }; 56 | 57 | return dispatch => { 58 | dispatch({type: types.kOrderView}); 59 | return Util.post(url, data, 60 | (status, code, message, data, share) => { 61 | let order = {}; 62 | let address = {}; 63 | if (status) { 64 | order = data.order; 65 | address = data.address; 66 | } 67 | dispatch({type:types.kOrderViewReceived, status:status, code:code, message:message, share:share, 68 | order:order, address:address}); 69 | }, 70 | (error) => { 71 | // console.log('Fetch banner list error: ' + error); 72 | dispatch({'type': types.kActionError}); 73 | } 74 | ); 75 | } 76 | }; -------------------------------------------------------------------------------- /app/actions/productActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | /** 12 | * redux actions - 用户模块 13 | */ 14 | 15 | 'user strict'; 16 | 17 | import * as types from './actionTypes'; 18 | import {cartNumFromSync} from '../actions/cartActions'; 19 | import * as urls from '../common/constants_url'; 20 | import Util from '../common/utils'; 21 | import { Alert } from 'react-native'; 22 | 23 | /** 24 | * 25 | * @param isLoading 26 | * @returns {function(*)} 27 | */ 28 | export let categoryListWithProduct = (isLoading) => { 29 | let url = urls.kUrlCategoryListWithProduct; 30 | return (dispatch) => { 31 | dispatch({'type': types.kCategoryListWithProduct, 'isLoading':isLoading}); 32 | Util.get(url, 33 | (status, code, message, data, share) => { 34 | let categories = []; 35 | if (status) { 36 | categories = data.categories; 37 | } 38 | dispatch({type:types.kCategoryListWithProductReceived, status:status, code:code, message:message, share:share, categories:categories}); 39 | }, 40 | (error) => { 41 | // Alert.alert(error.message); 42 | dispatch({'type': types.kActionError, 'isLoading':false}); 43 | }); 44 | } 45 | }; 46 | 47 | /** 48 | * 49 | * @param isLoading 50 | * @returns {function(*)} 51 | */ 52 | export let productView = (product_id, app_cart_cookie_id, access_token) => { 53 | let url = urls.kUrlProductView + product_id; 54 | let data = { 55 | app_cart_cookie_id: app_cart_cookie_id, 56 | access_token: access_token, 57 | }; 58 | return (dispatch) => { 59 | dispatch({'type': types.kProductView, 'isLoading':true}); 60 | Util.post(url, data, 61 | (status, code, message, data, share) => { 62 | let product = []; 63 | let cart_num = 0; 64 | if (status) { 65 | product = data.product; 66 | cart_num = data.cart_num; 67 | } 68 | dispatch({type:types.kProductViewReceived, status:status, code:code, message:message, share:share, product:product, cart_num:cart_num}); 69 | dispatch(cartNumFromSync(cart_num)); 70 | }, 71 | (error) => { 72 | // Alert.alert(error.message); 73 | dispatch({'type': types.kActionError, 'isLoading':false, 'error':error}); 74 | }); 75 | } 76 | }; 77 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/reducers/foodsListReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | // 食物分类数组 15 | foodsList: [], 16 | // 营养素数组 17 | sortTypesList: [], 18 | // 当前营养素 19 | currentSortType: null, 20 | // 显示营养素视图 21 | showSortTypeView: false, 22 | // 升降序 23 | orderByAsc: false, 24 | // 显示子分类视图 25 | showSubcategoryView: false, 26 | // 当前子分类 27 | currentSubcategory: null, 28 | isLoading: true, 29 | isLoadMore: false, 30 | } 31 | 32 | let foodsListReducer = (state = initialState, action)=> { 33 | 34 | switch (action.type) { 35 | case types.FETCH_FOODS_LIST: 36 | return Object.assign({}, state, { 37 | isLoading: action.isLoading, 38 | isLoadMore: action.isLoadMore, 39 | }) 40 | case types.RECEIVE_FOODS_LIST: 41 | return Object.assign({}, state, { 42 | foodsList: state.isLoadMore ? state.foodsList.concat(action.foodsList) : action.foodsList, 43 | isLoading: false, 44 | }) 45 | case types.FETCH_SORT_TYPES_LIST: 46 | return Object.assign({}, state, { 47 | ...state, 48 | }) 49 | case types.RECEIVE_SORT_TYPES_LIST: 50 | return Object.assign({}, state, { 51 | sortTypesList: action.sortTypesList, 52 | }) 53 | case types.SELECT_SORT_TYPE: 54 | return Object.assign({}, state, { 55 | currentSortType: action.currentSortType, 56 | }) 57 | case types.CHANGE_SORT_VIEW_STATUS: 58 | return Object.assign({}, state, { 59 | showSortTypeView: !state.showSortTypeView 60 | }) 61 | case types.ORDER_ASC_OR_DESC: 62 | return Object.assign({}, state, { 63 | orderByAsc: !state.orderByAsc, 64 | }) 65 | case types.CHANGE_SUBCATEGORY_STATUS: 66 | return Object.assign({}, state, { 67 | showSubcategoryView: !state.showSubcategoryView, 68 | }) 69 | case types.SELECT_SUBCATEGORY: 70 | return Object.assign({}, state, { 71 | currentSubcategory: action.currentSubcategory, 72 | showSubcategoryView: false, 73 | }) 74 | case types.RESET_FOODS_LIST_STATE: 75 | return initialState 76 | default: 77 | return state 78 | } 79 | } 80 | 81 | export default foodsListReducer; -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /app/components/FoodCell.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React from 'react'; 12 | import { 13 | StyleSheet, 14 | TouchableOpacity, 15 | View, 16 | Text, 17 | Image, 18 | } from 'react-native'; 19 | 20 | import Common from '../common/constants'; 21 | 22 | export default class FoodCell extends React.Component { 23 | 24 | constructor(props) { 25 | super(props); 26 | } 27 | 28 | render() { 29 | 30 | let lightStyle = [styles.healthLight]; 31 | if (food.health_light == 2) { 32 | lightStyle.push({backgroundColor: 'orange'}) 33 | } else if (food.health_light == 3) { 34 | lightStyle.push({backgroundColor: 'red'}) 35 | } 36 | 37 | return 38 | 39 | // return ( 40 | // 43 | // 44 | // 45 | // 46 | // {food.name} 47 | // 48 | // {food.calory} 49 | // 千卡/{food.weight}克 50 | // 51 | // 52 | // 53 | // 54 | // 55 | // ) 56 | } 57 | } 58 | 59 | const styles = StyleSheet.create({ 60 | foodsCell: { 61 | flexDirection: 'row', 62 | paddingLeft: 15, 63 | paddingRight: 15, 64 | paddingTop: 10, 65 | paddingBottom: 10, 66 | borderBottomColor: '#ccc', 67 | borderBottomWidth: 0.5, 68 | alignItems: 'center', 69 | justifyContent: 'space-between', 70 | }, 71 | 72 | foodIcon: { 73 | width: 40, 74 | height: 40, 75 | borderRadius: 20, 76 | }, 77 | 78 | titleContainer: { 79 | height: 40, 80 | marginLeft: 15, 81 | justifyContent: 'space-between', 82 | }, 83 | 84 | foodName: { 85 | width: Common.window.width - 15 - 15 - 40 - 15 - 10, 86 | }, 87 | 88 | calory: { 89 | fontSize: 13, 90 | color: 'red', 91 | }, 92 | 93 | unit: { 94 | fontSize: 13, 95 | color: 'black' 96 | }, 97 | 98 | healthLight: { 99 | width: 10, 100 | height: 10, 101 | borderRadius: 5, 102 | backgroundColor: 'green', 103 | marginRight: 0, 104 | }, 105 | }) -------------------------------------------------------------------------------- /app/actions/foodsListActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | import Util from '../common/utils'; 13 | 14 | export let fetchFoods = (kind, value, order_by, page, order_asc, isLoadMore, isLoading, sub_value)=> { 15 | 16 | if (sub_value == undefined) sub_value = ''; 17 | 18 | let URL = 'http://food.boohee.com/fb/v1/foods?kind=' + kind + '&value=' + value + '&order_by=' + order_by + '&page=' + page + '&order_asc=' + order_asc + '&sub_value=' + sub_value; 19 | 20 | return dispatch => { 21 | dispatch(fetchFoodsList(isLoadMore, isLoading)); 22 | 23 | Util.get(URL, (response) => { 24 | dispatch(receiveFoodsList(response.foods)) 25 | }, (error) => { 26 | console.log('Fetch foods list error: ' + error); 27 | dispatch(receiveFoodsList([])) 28 | }) 29 | } 30 | } 31 | 32 | let fetchFoodsList = (isLoadMore, isLoading)=> { 33 | return { 34 | type: types.FETCH_FOODS_LIST, 35 | isLoadMore: isLoadMore, 36 | isLoading: isLoading, 37 | } 38 | } 39 | 40 | let receiveFoodsList = (foods)=> { 41 | return { 42 | type: types.RECEIVE_FOODS_LIST, 43 | foodsList: foods, 44 | } 45 | } 46 | 47 | export let fetchSortTypes = ()=> { 48 | let URL = 'http://food.boohee.com/fb/v1/foods/sort_types'; 49 | 50 | return dispatch => { 51 | dispatch(fetchSortTypesList()); 52 | 53 | Util.get(URL, (response) => { 54 | dispatch(receiveSortTypesList(response.types)); 55 | }, (error) => { 56 | console.log('Fetch sort types error: ' + error); 57 | dispatch(receiveSortTypesList([])) 58 | }) 59 | } 60 | } 61 | 62 | let fetchSortTypesList = ()=> { 63 | return { 64 | type: types.FETCH_SORT_TYPES_LIST, 65 | } 66 | } 67 | 68 | let receiveSortTypesList = (sortTypes)=> { 69 | return { 70 | type: types.RECEIVE_SORT_TYPES_LIST, 71 | sortTypesList: sortTypes, 72 | } 73 | } 74 | 75 | export let selectSortType = (type)=> { 76 | return { 77 | type: types.SELECT_SORT_TYPE, 78 | currentSortType: type 79 | } 80 | } 81 | 82 | export let changeSortViewStatus = ()=> { 83 | return { 84 | type: types.CHANGE_SORT_VIEW_STATUS, 85 | } 86 | } 87 | 88 | export let changeOrderAscStatus = ()=> { 89 | return { 90 | type: types.ORDER_ASC_OR_DESC, 91 | } 92 | } 93 | 94 | export let changeSubcategoryViewStatus = ()=> { 95 | return { 96 | type: types.CHANGE_SUBCATEGORY_STATUS, 97 | } 98 | } 99 | 100 | export let selectSubcategory = (subcategory)=> { 101 | return { 102 | type: types.SELECT_SUBCATEGORY, 103 | currentSubcategory: subcategory, 104 | } 105 | } 106 | 107 | export let resetState = ()=> { 108 | return { 109 | type: types.RESET_FOODS_LIST_STATE, 110 | } 111 | } -------------------------------------------------------------------------------- /app/pages/FoodAllIngredient.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React from 'react'; 12 | import { 13 | StyleSheet, 14 | View, 15 | Text, 16 | ScrollView, 17 | } from 'react-native'; 18 | 19 | import Common from '../common/constants'; 20 | import Header from '../components/Header'; 21 | 22 | export default class FoodAllIngredient extends React.Component { 23 | render() { 24 | const {food} = this.props; 25 | 26 | let ingredientNames = []; 27 | for (let ingredient in Common.ingredientMapper) { 28 | ingredientNames.push(ingredient) 29 | } 30 | 31 | return ( 32 | 33 |
this.props.navigator.pop()} 36 | title="营养信息" 37 | /> 38 | 39 | 营养元素 40 | 每100克 41 | 备注 42 | 43 | 48 | 49 | {ingredientNames.map((ingredient, i) => { 50 | 51 | let itemUnit = `${food.ingredient[ingredient]} ${Common.ingredientMapper[ingredient].unit}`; 52 | if (food.ingredient[ingredient] === '') { 53 | itemUnit = '-' 54 | } 55 | return ( 56 | 57 | {Common.ingredientMapper[ingredient].name} 59 | {itemUnit} 61 | {food.lights[ingredient]} 63 | 64 | ) 65 | })} 66 | 67 | 68 | ) 69 | } 70 | } 71 | 72 | const styles = { 73 | container: { 74 | flex: 1, 75 | backgroundColor: 'white', 76 | }, 77 | 78 | nutritionHeader: { 79 | flexDirection: 'row', 80 | alignItems: 'center', 81 | height: 40, 82 | borderBottomWidth: 0.5, 83 | borderColor: '#ccc', 84 | paddingHorizontal: 15 85 | }, 86 | } -------------------------------------------------------------------------------- /app/actions/cartActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-11 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | import Util from '../common/utils'; 13 | import * as urls from '../common/constants_url'; 14 | import * as Storage from '../common/Storage'; 15 | 16 | /** 17 | * 购物车actions 18 | * @param id 19 | * @returns {function(*)} 20 | */ 21 | 22 | export let appCartCookieIdFromSync = (app_cart_cookie_id) => { 23 | return (dispatch) => { 24 | dispatch({type:types.kAppCartCookieIdFromSync, app_cart_cookie_id:app_cart_cookie_id}); 25 | } 26 | }; 27 | 28 | export let cartNumFromSync = (cart_num) => { 29 | return (dispatch) => { 30 | dispatch({type:types.kCartNumFromSync, cart_num:cart_num}); 31 | } 32 | }; 33 | 34 | export let cartView = (app_cart_cookie_id, access_token)=> { 35 | let url = urls.kUrlCart; 36 | let data = { 37 | app_cart_cookie_id: app_cart_cookie_id, 38 | access_token: access_token 39 | }; 40 | 41 | return dispatch => { 42 | dispatch({type: types.kCartView}); 43 | return Util.post(url, data, 44 | (status, code, message, data, share) => { 45 | let app_cart_cookie_id = ''; 46 | let cartItems = []; 47 | if (status) { 48 | cartItems = data.cartItems; 49 | app_cart_cookie_id = data.app_cart_cookie_id; 50 | } 51 | dispatch({type:types.kCartViewReceived, status:status, code:code, message:message, share:share, cartItems:cartItems, app_cart_cookie_id:app_cart_cookie_id}); 52 | }, 53 | (error) => { 54 | // console.log('Fetch banner list error: ' + error); 55 | dispatch({'type': types.kActionError}); 56 | } 57 | ); 58 | } 59 | }; 60 | 61 | export let cartAdd = (product_id, count, app_cart_cookie_id, access_token)=> { 62 | let url = urls.kUrlCartAdd; 63 | let data = { 64 | product_id: product_id, 65 | count: count, 66 | app_cart_cookie_id: app_cart_cookie_id, 67 | access_token: access_token, 68 | }; 69 | 70 | return dispatch => { 71 | dispatch({type: types.kCartAdd}); 72 | return Util.post(url, data, 73 | (status, code, message, data, share) => { 74 | let cart_num = 0; 75 | let app_cart_cookie_id = app_cart_cookie_id; 76 | if (status) { 77 | cart_num = data.cart_num; 78 | app_cart_cookie_id = data.app_cart_cookie_id; 79 | } 80 | Storage.setAppCartCookieId(app_cart_cookie_id); 81 | dispatch({type:types.kCartAddReceived, status:status, code:code, message:message, share:share, 82 | cart_num:cart_num, app_cart_cookie_id}); 83 | dispatch(cartView(app_cart_cookie_id, access_token)); 84 | }, 85 | (error) => { 86 | // console.log('Fetch banner list error: ' + error); 87 | dispatch({'type': types.kActionError}); 88 | } 89 | ); 90 | } 91 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shop-React-Native 2 | 3 | ### Shop-React-Native 是基于 React Native 和 Redux 实现的电商类APP,同时运行在iOS和Android平台上。持续更新中,欢迎一起讨论学习! 4 | 5 | #### 如果你支持这个项目,请 Star and Fork Me。 6 | 7 | #### 注:有任何问题请在Issues提交,EleTeam会尽快回复。 8 | 9 | #### EleTeam开源项目 - 电商全套解决方案之 React Native 版 - Shop-React-Native。一个类似京东/天猫/淘宝的商城,有对应的服务端支持,由EleTeam团队维护! 10 | #### 服务端是PHP商城,对应项目是 Shop-PHP-Yii2,https://github.com/EleTeam/Shop-PHP-Yii2 11 | 12 | ### 功能如下: 13 | 支持下拉刷新和上拖加载更多 14 | 广告模块 15 | 文章模块 16 | 用户模块 17 | 产品模块 18 | 购物车模块 19 | 订单模块 20 | 地址模块 21 | 分享&收藏 22 | 营销模块 23 | 24 | #### 依赖组件: 25 | "dependencies": { 26 | "react": "15.3.1", //react框架 27 | "react-native": "0.33.0", //react native 28 | "react-native-device-info": "^0.9.5", //获取硬件信息 29 | "react-native-root-toast": "^1.0.3", //纯JS toast, 用于错误提示的小弹窗 30 | "react-native-swiper": "^1.4.4", //滑动查看图片 31 | "react-native-tab-navigator": "^0.3.3", //纯JS底部导航条, 同时适用在iOS和Android上 32 | "react-native-vector-icons": "^2.0.3", //图标库, 需要更改原生文件的组件, 查看: https://www.npmjs.com/package/react-native-vector-icons 33 | "react-redux": "^4.4.5", //将redux跟react应用结合起来 34 | "redux": "^3.5.2", //数据流动的控制 35 | "redux-persist": "^2.0.1", //将store对象存储到本地, 从本地恢复数据到store中 36 | "redux-thunk": "^2.1.0" //redux-thunk 37 | 38 | } 39 | 40 | #### 访问在线服务器: 41 | 取消注释, 在文件: app/common/constants_url.js: 42 | const kUrlHost = 'http://api.eleteam.com/v1'; //在线服务器 43 | 44 | #### 查看服务器是否可用 45 | http://api.eleteam.com/v1/banner/list 46 | 47 | #### 安装出现问题 48 | 1. Application Shop-React-Native has not been registered. This is either due to a require() error during initialization or failure to call AppRegistry.registerComponent 49 | 解决办法: 50 | 造成这种错误有两种情况: 51 | 1. AppRegistry.registerComponent('项目名', () => 项目名); 与./ios/项目名/appDelegate.m中的RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"项目名" initialProperties:nil launchOptions:launchOptions]; 不同 52 | 在Android项目中可能是./android/app/src/main/java/com/项目名/MainActivity.java中的mReactRootView.startReactApplication(mReactInstanceManager, "项目名", null); 没有保持一致,修改方法:编辑成相同的参数即可。 53 | 2. 有可能你同时在运行一个以上的程序。如果你的react-native在运行程序A而你打开了程序B,也会出现相同的问题。解决方法:关闭其它React Native程序, 只运行一个。 54 | 55 | #### react-native 的学习文档: 56 | 入门基础: http://reactnative.cn/docs/0.31/getting-started.html 57 | 组件的生命周期: http://www.race604.com/react-native-component-lifecycle 58 | 59 | ### 部分App界面: 60 | ![](https://github.com/EleTeam/Shop-React-Native/blob/master/screenshoot/01.png) ![](https://github.com/EleTeam/Shop-React-Native/blob/master/screenshoot/02.jpg) ![](https://github.com/EleTeam/Shop-React-Native/blob/master/screenshoot/03.jpg) 61 | 62 | ![](https://github.com/EleTeam/Shop-React-Native/blob/master/screenshoot/04.jpg) ![](https://github.com/EleTeam/Shop-React-Native/blob/master/screenshoot/05.png) ![](https://github.com/EleTeam/Shop-React-Native/blob/master/screenshoot/06.jpg) 63 | 64 | ###### @author Tony Wong 65 | ###### @copyright Copyright © 2016 EleTeam. All rights reserved. 66 | ###### @license The MIT License (MIT) 67 | 68 | ###### 此源码遵守 The MIT License (MIT),可用于商业上,但是因此带来的商业损失EleTeam团队不承担责任。 69 | -------------------------------------------------------------------------------- /app/reducers/foodCompareReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | rightFood: undefined, // 右边食物 15 | rightFoodBrief: undefined, // 右边食物营养元素对象 16 | rightFoodBriefNames: [], // 右边食物营养元素名称数组 17 | 18 | leftFood: undefined, // 左边食物 19 | leftFoodBrief: undefined, // 左边食物营养元素对象 20 | leftFoodBriefNames: [], // 左边食物营养元素名称数组 21 | } 22 | 23 | let foodCompareReducer = (state = initialState, action)=> { 24 | 25 | switch (action.type) { 26 | case types.SELECT_COMPARE_FOOD: 27 | return Object.assign({}, state, { 28 | rightFood: action.rightFood ? action.rightFood : state.rightFood, 29 | leftFood: action.leftFood ? action.leftFood : state.leftFood, 30 | }) 31 | case types.CLEAR_COMPARE_FOOD: 32 | 33 | // 左边食物、营养元素对象、营养元素名称数组 34 | let leftFood = action.position === 'Left' ? undefined : state.leftFood; 35 | let leftBrief = action.position === 'Left' ? undefined : state.leftFoodBrief; 36 | let leftBriefNames = action.position === 'Left' ? [] : state.leftFoodBriefNames; 37 | 38 | // 右边食物、营养元素对象、营养元素名称数组 39 | let rightFood = action.position === 'Right' ? undefined : state.rightFood; 40 | let rightBrief = action.position === 'Right' ? undefined : state.rightFoodBrief; 41 | let rightBriefNames = action.position === 'Right' ? [] : state.rightFoodBriefNames; 42 | 43 | return Object.assign({}, state, { 44 | rightFood: rightFood, 45 | rightFoodBrief: rightBrief, 46 | rightFoodBriefNames: rightBriefNames, 47 | leftFood: leftFood, 48 | leftFoodBrief: leftBrief, 49 | leftFoodBriefNames: leftBriefNames 50 | }) 51 | case types.FETCH_FOOD_BRIEF: 52 | return Object.assign({}, state, { 53 | ...state 54 | }) 55 | case types.RECEIVE_FOOD_BRIEF: 56 | 57 | // 左边食物营养元素对象 58 | let leftFoodBrief = action.position === 'Left' ? action.brief : state.leftFoodBrief; 59 | let leftNames = []; 60 | if (leftFoodBrief) { 61 | leftFoodBrief.nutrition.map(data => { 62 | leftNames.push(data.name) 63 | }) 64 | } 65 | 66 | // 右边食物营养元素对象 67 | let rightFoodBrief = action.position === 'Right' ? action.brief : state.rightFoodBrief; 68 | let rightNames = []; 69 | if (rightFoodBrief) { 70 | rightFoodBrief.nutrition.map(data => { 71 | rightNames.push(data.name) 72 | }) 73 | } 74 | 75 | return Object.assign({}, state, { 76 | leftFoodBrief: leftFoodBrief, 77 | leftFoodBriefNames: leftNames, 78 | rightFoodBrief: rightFoodBrief, 79 | rightFoodBriefNames: rightNames, 80 | }) 81 | case types.FOOD_COMPARE_RESET_STATE: 82 | return initialState 83 | default: 84 | return state 85 | } 86 | } 87 | 88 | export default foodCompareReducer; -------------------------------------------------------------------------------- /app/reducers/searchReducer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from '../actions/actionTypes'; 12 | 13 | const initialState = { 14 | history: [], // 搜索历史 15 | keywordsList: [], // 热搜词 16 | searchText: null, // 搜索文本 17 | tags: [], // 标签数组 18 | searchResultList: [], // 搜索结果 19 | sortTypesList: [], // 营养素数组 20 | currentSortType: null, // 当前营养素 21 | currentTag: null, // 当前tag 22 | showSortTypeView: false, // 显示营养素视图 23 | orderByAsc: false, // 升降序 24 | isHealthLight: false, // 是否推荐食物 25 | isLoading: true, 26 | isLoadMore: false, 27 | } 28 | 29 | let searchReducer = (state = initialState, action)=> { 30 | 31 | switch (action.type) { 32 | case types.FETCH_KEYWORDS_LIST: 33 | return Object.assign({}, state, { 34 | ...state 35 | }) 36 | case types.RECEIVE_KEYWORDS_LIST: 37 | return Object.assign({}, state, { 38 | keywordsList: action.keywordsList, 39 | history: action.history, 40 | }) 41 | case types.FETCH_SEARCH_RESULT_LIST: 42 | return Object.assign({}, state, { 43 | tags: [], 44 | isLoading: action.isLoading, 45 | isLoadMore: action.isLoadMore, 46 | }) 47 | case types.RECEIVE_SEARCH_RESULT_LIST: 48 | return Object.assign({}, state, { 49 | tags: action.tags, 50 | searchResultList: state.isLoadMore ? state.searchResultList.concat(action.searchResultList) : action.searchResultList, 51 | isLoading: false, 52 | }) 53 | case types.SELECT_KEYWORD: 54 | return Object.assign({}, state, { 55 | searchText: action.searchText, 56 | }) 57 | case types.SETUP_SEARCH_TEXT: 58 | return Object.assign({}, state, { 59 | searchText: action.searchText, 60 | }) 61 | case types.CACHE_HISTORY: 62 | return Object.assign({}, state, { 63 | history: action.history, 64 | }) 65 | case types.CLEAR_HISTORY: 66 | return Object.assign({}, state, { 67 | history: [] 68 | }) 69 | case types.CHANGE_SORT_VIEW_STATUS_SEARCH: 70 | return Object.assign({}, state, { 71 | showSortTypeView: !state.showSortTypeView, 72 | }) 73 | case types.RECEIVE_SORT_TYPES_LIST_SEARCH: 74 | return Object.assign({}, state, { 75 | sortTypesList: action.sortTypesList 76 | }) 77 | case types.SELECT_SORT_TYPE_SEARCH: 78 | return Object.assign({}, state, { 79 | currentSortType: action.currentSortType 80 | }) 81 | case types.ORDER_ASC_OR_DESC_SEARCH: 82 | return Object.assign({}, state, { 83 | orderByAsc: !state.orderByAsc 84 | }) 85 | case types.CHANGE_HEALTH_LIGHT_SEARCH: 86 | return Object.assign({}, state, { 87 | isHealthLight: !state.isHealthLight 88 | }) 89 | case types.SELECT_FOOD_TAG: 90 | return Object.assign({}, state, { 91 | currentTag: action.currentTag 92 | }) 93 | case types.RESET_SEARCH_STATE: 94 | return initialState 95 | default: 96 | return state; 97 | } 98 | } 99 | 100 | export default searchReducer; -------------------------------------------------------------------------------- /app/actions/actionTypes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | 'use strict'; 12 | 13 | /** 14 | * action 类型 15 | */ 16 | 17 | //公用类型 18 | export const kActionError = 'kActionError'; 19 | export const kCommonIsToasting = 'kCommonIsToasting'; 20 | 21 | //首页 22 | export const kBannerList = 'kBannerList'; 23 | export const kBannerListReceived = 'kBannerListReceived'; 24 | export const kHomeListArticles = 'kHomeListArticles'; 25 | export const kHomeListArticlesReceived = 'kHomeListArticlesReceived'; 26 | 27 | // 用户 28 | export const kUserFromSync = 'kUserFromSync'; //同步加载用户数据, 一般从缓存加载 29 | export const kUserRegister = 'kUserRegister'; 30 | export const kUserRegisterReceived = 'kUserRegisterReceived'; 31 | export const kUserView = 'kUserView'; 32 | export const kUserLogin = 'kUserLogin'; 33 | export const kUserLoginReceived = 'kUserLoginReceived'; 34 | export const kUserLogout = 'kUserLogout'; 35 | export const kUserLogoutReceived = 'kUserLogoutReceived'; 36 | 37 | //商品、商品目录 38 | export const kCategoryListWithProduct = 'kCategoryListWithProduct'; 39 | export const kCategoryListWithProductReceived = 'kCategoryListWithProductReceived'; 40 | export const kProductView = 'kProductView'; 41 | export const kProductViewReceived = 'kProductViewReceived'; 42 | 43 | //文章 44 | export const kArticleView = 'kArticleView'; 45 | export const kArticleViewReceived = 'kArticleViewReceived'; 46 | 47 | //购物车 48 | export const kAppCartCookieIdFromSync = 'kAppCartCookieIdFromSync'; //同步加载数据, 一般从缓存加载 49 | export const kCartNumFromSync = 'kCartNumFromSync'; //同步加载数据, 一般从商品详情页 50 | export const kCartView = 'kCartView'; 51 | export const kCartViewReceived = 'kCartViewReceived'; 52 | export const kCartAdd = 'kCartAdd'; 53 | export const kCartAddReceived = 'kCartAddReceived'; 54 | 55 | //预订单 56 | export const kPreorderCreate = 'kPreorderCreate'; 57 | export const kPreorderCreateReceived = 'kPreorderCreateReceived'; 58 | export const kPreorderIsTurnedToViewFromSync = 'kPreorderIsTurnedToViewFromSync'; 59 | export const kPreorderView = 'kPreorderView'; 60 | export const kPreorderViewReceived = 'kPreorderViewReceived'; 61 | 62 | //订单 63 | export const kOrderCreate = 'kOrderCreate'; 64 | export const kOrderCreateReceived = 'kOrderCreateReceived'; 65 | export const kOrderIsTurnedToViewFromSync = 'kOrderIsTurnedToViewFromSync'; 66 | export const kOrderView = 'kOrderView'; 67 | export const kOrderViewReceived = 'kOrderViewReceived'; 68 | export const kOrderIndex = 'kOrderIndex'; 69 | export const kOrderIndexReceived = 'kOrderIndexReceived'; 70 | 71 | //地址 72 | export const kAddressIsToasting = 'kAddressIsToasting'; 73 | export const kAddressList = 'kAddressList'; 74 | export const kAddressListReceived = 'kAddressListReceived'; 75 | export const kAddressCreate = 'kAddressCreate'; 76 | export const kAddressCreateReceived = 'kAddressCreateReceived'; 77 | export const kAddressDelete = 'kAddressDelete'; 78 | export const kAddressDeleteReceived = 'kAddressDeleteReceived'; 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /ios/ShopReactNative/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/actions/addressActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-24 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import * as types from './actionTypes'; 12 | import Util from '../common/utils'; 13 | import * as urls from '../common/constants_url'; 14 | 15 | /** 16 | * 地址actions 17 | */ 18 | 19 | // export let addressIsToasting = (isToasting) => { 20 | // return (dispatch) => { 21 | // dispatch({type:types.kAddressIsToasting, isToasting:isToasting}); 22 | // } 23 | // }; 24 | 25 | export let addressList = (access_token)=> { 26 | let url = urls.kUrlAddressList; 27 | let data = { 28 | access_token: access_token 29 | }; 30 | 31 | return dispatch => { 32 | dispatch({type: types.kAddressList}); 33 | return Util.post(url, data, 34 | (status, code, message, data, share) => { 35 | let addresses = []; 36 | if (status) { 37 | addresses = data.addresses; 38 | } else { 39 | dispatch({type:types.kAddressIsToasting, isToasting:true}); 40 | } 41 | dispatch({type:types.kAddressListReceived, status:status, code:code, message:message, share:share, 42 | addresses:addresses}); 43 | dispatch({type:types.kAddressIsToasting, isToasting:false}); 44 | }, 45 | (error) => { 46 | // console.log('Fetch banner list error: ' + error); 47 | dispatch({'type': types.kActionError}); 48 | } 49 | ); 50 | } 51 | }; 52 | 53 | export let addressCreate = (access_token, fullname, telephone, area_id, detail)=> { 54 | let url = urls.kUrlAddressCreate; 55 | let data = { 56 | access_token: access_token, 57 | fullname: fullname, 58 | telephone: telephone, 59 | area_id: area_id, 60 | detail: detail 61 | }; 62 | 63 | return dispatch => { 64 | dispatch({type: types.kAddressCreate}); 65 | return Util.post(url, data, 66 | (status, code, message, data, share) => { 67 | let address = {}; 68 | let addresses = []; 69 | if (status) { 70 | address = data.address; 71 | addresses = data.addresses; 72 | } else { 73 | dispatch({type:types.kAddressIsToasting, isToasting:true}); 74 | } 75 | dispatch({type:types.kAddressCreateReceived, status:status, code:code, message:message, share:share, 76 | address:address, addresses:addresses}); 77 | dispatch({type:types.kAddressIsToasting, isToasting:false}); 78 | }, 79 | (error) => { 80 | // console.log('Fetch banner list error: ' + error); 81 | dispatch({'type': types.kActionError}); 82 | } 83 | ); 84 | } 85 | }; 86 | 87 | export let addressDelete = (access_token, address_id)=> { 88 | let url = urls.kUrlAddressDelete; 89 | let data = { 90 | access_token: access_token, 91 | id: address_id, 92 | }; 93 | 94 | return dispatch => { 95 | dispatch({type: types.kAddressDelete}); 96 | return Util.post(url, data, 97 | (status, code, message, data, share) => { 98 | if (status) { 99 | } 100 | dispatch({type:types.kPreorderViewReceived, status:status, code:code, message:message, share:share}); 101 | }, 102 | (error) => { 103 | // console.log('Fetch banner list error: ' + error); 104 | dispatch({'type': types.kActionError}); 105 | } 106 | ); 107 | } 108 | }; -------------------------------------------------------------------------------- /app/containers/AppMain.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 商城主框架界面 3 | */ 4 | 'use strict'; 5 | import React, {Component} from 'react'; 6 | import { 7 | StyleSheet, 8 | Image 9 | } from 'react-native'; 10 | import TabNavigator from 'react-native-tab-navigator'; 11 | 12 | import HomeContainer from './HomeContainer'; 13 | import CategoryContainer from './CategoryContainer'; 14 | import CartContainer from './CartContainer'; 15 | import FunContainer from './FunContainer'; 16 | import MyContainer from './MyContainer'; 17 | 18 | class AppMain extends Component { 19 | constructor(props) { 20 | super(props); 21 | this.state = { 22 | selectedTab:'home' 23 | }; 24 | } 25 | 26 | render() { 27 | return ( 28 | 29 | } 35 | renderSelectedIcon={() => } 36 | onPress={() => this.setState({ selectedTab: 'home' })}> 37 | 38 | 39 | } 45 | renderSelectedIcon={() => } 46 | onPress={() => this.setState({ selectedTab: 'order' })}> 47 | 48 | 49 | } 55 | renderSelectedIcon={() => } 56 | onPress={() => this.setState({ selectedTab: 'cart' })}> 57 | 58 | 59 | } 65 | renderSelectedIcon={() => } 66 | onPress={() => this.setState({ selectedTab: 'fun' })}> 67 | 68 | 69 | } 75 | renderSelectedIcon={() => } 76 | onPress={() => this.setState({ selectedTab: 'center' })}> 77 | 78 | 79 | 80 | ); 81 | } 82 | } 83 | 84 | const styles=StyleSheet.create({ 85 | iconStyle:{ 86 | width:26, 87 | height:26, 88 | }, 89 | textStyle:{ 90 | color:'#999', 91 | }, 92 | selectedTextStyle:{ 93 | color:'black', 94 | } 95 | }); 96 | 97 | export default AppMain; 98 | 99 | -------------------------------------------------------------------------------- /app/pages/ArticlePage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React from 'react'; 12 | import { 13 | View, 14 | StyleSheet, 15 | WebView, 16 | Image, 17 | Text, 18 | TouchableOpacity, 19 | InteractionManager 20 | } from 'react-native'; 21 | 22 | import Header from '../components/Header'; 23 | import Common from '../common/constants'; 24 | import Icon from 'react-native-vector-icons/FontAwesome'; 25 | import {articleView} from '../actions/articleActions'; 26 | import Loading from '../components/Loading'; 27 | 28 | export default class ArticlePage extends React.Component { 29 | componentDidMount() { 30 | // 交互管理器在任意交互/动画完成之后,允许安排长期的运行工作. 在所有交互都完成之后安排一个函数来运行。 31 | InteractionManager.runAfterInteractions(() => { 32 | const {dispatch, id} = this.props; 33 | dispatch(articleView(id)); 34 | }); 35 | } 36 | 37 | render() { 38 | const {articleReducer} = this.props; 39 | let article = articleReducer.article; 40 | // alert(article.link); 41 | 42 | return ( 43 | 44 |
this.props.navigator.pop()} 47 | title='资讯详情' 48 | /> 49 | {articleReducer.isLoading ? 50 | : 51 | 58 | } 59 | 60 | 61 | ) 62 | } 63 | } 64 | 65 | class ToolBar extends React.Component { 66 | render() { 67 | return ( 68 | 69 | 70 | 75 | 分享 76 | 77 | 78 | 79 | 84 | 收藏 85 | 86 | 87 | ) 88 | } 89 | } 90 | 91 | const styles = StyleSheet.create({ 92 | webView: { 93 | width: Common.window.width, 94 | height: Common.window.height - 64 - 40, 95 | }, 96 | 97 | container: { 98 | height: 40, 99 | flexDirection: 'row', 100 | alignItems: 'center', 101 | borderTopColor: '#ccc', 102 | borderTopWidth: 0.5, 103 | }, 104 | 105 | toolBarItem: { 106 | flex: 1, 107 | flexDirection: 'row', 108 | justifyContent: 'center', 109 | alignItems: 'center', 110 | }, 111 | 112 | itemTitle: { 113 | marginLeft: 5, 114 | fontSize: 12, 115 | color: 'gray' 116 | }, 117 | 118 | centerLine: { 119 | position: 'absolute', 120 | height: 20, 121 | width: 0.5, 122 | top: 10, 123 | right: Common.window.width * 0.5, 124 | backgroundColor: '#ccc' 125 | } 126 | }); 127 | -------------------------------------------------------------------------------- /app/actions/userActions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | /** 12 | * action 创建函数 - 用户模块 13 | */ 14 | 15 | 'user strict'; 16 | 17 | import * as types from './actionTypes'; 18 | import {cartView} from './cartActions'; 19 | import Util from '../common/utils'; 20 | import * as urls from '../common/constants_url'; 21 | import * as Storage from '../common/Storage'; 22 | import { Alert } from 'react-native'; 23 | 24 | export let userFromSync = (user) => { 25 | return (dispatch) => { 26 | dispatch({type: types.kUserFromSync, user: user}); 27 | } 28 | }; 29 | 30 | export let userRegister = (mobile, password, code) => { 31 | let url = urls.kUrlUserRegister; 32 | let data = { 33 | mobile: mobile, 34 | password: password, 35 | code: code 36 | }; 37 | return (dispatch) => { 38 | dispatch({type: types.kUserRegister}); 39 | Util.post(url, data, 40 | (status, code, message, data, share) => { 41 | let user = {}; 42 | let app_cart_cookie_id = ''; 43 | if (status) { 44 | user = data.user; 45 | app_cart_cookie_id = data.app_cart_cookie_id; 46 | Storage.setAppCartCookieId(app_cart_cookie_id); 47 | Storage.setUser(user); 48 | } 49 | dispatch({type:types.kUserRegisterReceived, status:status, code:code, message:message, user:user, share:share}); 50 | dispatch(cartView(app_cart_cookie_id, user.access_token)); 51 | }, 52 | (error) => { 53 | dispatch({'type': types.kActionError}); 54 | }); 55 | } 56 | }; 57 | 58 | export let userView = () => { 59 | let url = 'http://local.eleteamapi.ygcr8.com/v1/user/view?id=2'; 60 | return (dispatch) => { 61 | dispatch({'type':types.kUserView}); 62 | Util.get(url, 63 | () => {}, 64 | () => {}); 65 | } 66 | }; 67 | 68 | export let userLogin = (mobile, password) => { 69 | let url = urls.kUrlUserLogin; 70 | let data = { 71 | mobile: mobile, 72 | password: password 73 | }; 74 | return (dispatch) => { 75 | dispatch({'type': types.kUserLogin}); 76 | Util.post(url, data, 77 | (status, code, message, data, share) => { 78 | let app_cart_cookie_id = ''; 79 | let user = {}; 80 | if (status) { 81 | user = data.user; 82 | app_cart_cookie_id = data.app_cart_cookie_id; 83 | Storage.setAppCartCookieId(app_cart_cookie_id); 84 | Storage.setUser(user); 85 | } 86 | dispatch({type:types.kUserLoginReceived, status:status, code:code, message:message, share:share, user:user, app_cart_cookie_id:app_cart_cookie_id}); 87 | dispatch(cartView(app_cart_cookie_id, user.access_token)); 88 | }, 89 | (error) => { 90 | Alert.alert(error.message); 91 | dispatch({'type': types.kActionError}); 92 | }); 93 | } 94 | }; 95 | 96 | export let userLogout = () => { 97 | let url = urls.kUrlUserLogout; 98 | return (dispatch) => { 99 | dispatch({'type': types.kUserLogout}); 100 | Util.get(url, 101 | (status, code, message, data, share) => { 102 | let app_cart_cookie_id = ''; 103 | if (status) { 104 | app_cart_cookie_id = data.app_cart_cookie_id; 105 | Storage.setAppCartCookieId(app_cart_cookie_id); 106 | Storage.setUser({}); 107 | } 108 | dispatch({type:types.kUserLogoutReceived, status:status, code:code, message:message, share:share, app_cart_cookie_id:app_cart_cookie_id, user:{}}); 109 | dispatch(cartView(app_cart_cookie_id, '')); 110 | }, 111 | (error) => { 112 | Alert.alert(error.message); 113 | dispatch({'type': types.kActionError}); 114 | }); 115 | } 116 | }; 117 | -------------------------------------------------------------------------------- /app/components/Header.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | /** 12 | * 导航栏标题 13 | */ 14 | import React from 'react'; 15 | import { 16 | StyleSheet, 17 | View, 18 | Text, 19 | Image, 20 | TouchableOpacity, 21 | } from 'react-native'; 22 | import Icon from 'react-native-vector-icons/FontAwesome'; 23 | 24 | export default class Header extends React.Component { 25 | render() { 26 | let NavigationBar = []; 27 | 28 | // 左边图片按钮 29 | if (this.props.leftIcon != undefined) { 30 | NavigationBar.push( 31 | 37 | 38 | 39 | ) 40 | } 41 | 42 | // 标题 43 | if (this.props.title != undefined) { 44 | NavigationBar.push( 45 | 46 | {this.props.title} 47 | 48 | ) 49 | } 50 | 51 | // 自定义标题View 52 | if (this.props.titleView != undefined) { 53 | let Component = this.props.titleView; 54 | NavigationBar.push( 55 | 56 | ) 57 | } 58 | 59 | // 右边图片按钮 60 | if (this.props.rightIcon != undefined) { 61 | NavigationBar.push( 62 | 68 | 69 | 70 | ) 71 | } 72 | 73 | // 右边文字按钮 74 | if (this.props.rightButton != undefined) { 75 | NavigationBar.push( 76 | 82 | {this.props.rightButton} 83 | 84 | ) 85 | } 86 | 87 | if (this.props.rightMenu != undefined) { 88 | NavigationBar.push( 89 | 95 | {this.props.rightMenu} 96 | 97 | 98 | ) 99 | } 100 | 101 | 102 | return ( 103 | 104 | {NavigationBar} 105 | 106 | ) 107 | } 108 | } 109 | 110 | const styles = StyleSheet.create({ 111 | navigationBarContainer: { 112 | flexDirection: 'row', 113 | height: 44, 114 | alignItems: 'center', 115 | borderBottomColor: '#ccc', 116 | borderBottomWidth: 0.5, 117 | backgroundColor: 'white' 118 | }, 119 | titleWrap: { 120 | flex:1, 121 | alignItems:'center', 122 | }, 123 | title: { 124 | fontSize: 15, 125 | marginLeft: -40, 126 | }, 127 | leftIcon: { 128 | paddingLeft: 15, 129 | paddingRight: 15, 130 | }, 131 | rightIcon: { 132 | position: 'absolute', 133 | right: 10, 134 | top: 7 135 | }, 136 | rightButton: { 137 | position: 'absolute', 138 | right: 10, 139 | height: 44, 140 | justifyContent: 'center', 141 | flexDirection: 'row', 142 | }, 143 | buttonTitleFont: { 144 | color: 'white', 145 | fontSize: 15, 146 | }, 147 | rightMenu: { 148 | position: 'absolute', 149 | right: 10, 150 | height: 44, 151 | justifyContent: 'center', 152 | flexDirection: 'row', 153 | alignItems: 'center' 154 | }, 155 | }); -------------------------------------------------------------------------------- /ios/ShopReactNative.xcodeproj/xcshareddata/xcschemes/ShopReactNative.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /app/pages/AddressPage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-24 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | 'use strict'; 12 | 13 | import React, {Component} from 'react'; 14 | import { 15 | StyleSheet, 16 | View, 17 | ListView, 18 | Text, 19 | Image, 20 | InteractionManager, 21 | TouchableOpacity, 22 | } from 'react-native'; 23 | import Loading from '../components/Loading'; 24 | import Header from '../components/Header'; 25 | import Common from '../common/constants'; 26 | import {addressList, addressDelete} from '../actions/addressActions'; 27 | import AddressCreateContainer from '../containers/AddressCreateContainer'; 28 | 29 | export default class AddressPage extends Component { 30 | constructor(props) { 31 | super(props); 32 | this.state = { 33 | dataSource: new ListView.DataSource({ 34 | rowHasChanged: (row1, row2) => row1 !== row2 35 | }), 36 | }; 37 | } 38 | 39 | componentDidMount() { 40 | const {dispatch, userReducer} = this.props; 41 | //交互管理器在任意交互/动画完成之后,允许安排长期的运行工作. 在所有交互都完成之后安排一个函数来运行。 42 | InteractionManager.runAfterInteractions(() => { 43 | let user = userReducer.user; 44 | dispatch(addressList(user.access_token)); 45 | }); 46 | } 47 | 48 | render() { 49 | const {addressReducer} = this.props; 50 | let isLoading = addressReducer.isLoading; 51 | let addresses = addressReducer.addresses; 52 | 53 | return ( 54 | 55 |
this.props.navigator.pop()} 58 | title='收货地址' 59 | /> 60 | {isLoading ? 61 | : 62 | 63 | 69 | 70 | 71 | 72 | + 添加收货地址 73 | 74 | 75 | 76 | 77 | } 78 | 79 | ) 80 | } 81 | 82 | _renderRow(address) { 83 | return ( 84 | 85 | 86 | {address.name} 87 | 88 | 89 | ); 90 | } 91 | 92 | _gotoAddressCreatePage(){ 93 | InteractionManager.runAfterInteractions(() => { 94 | this.props.navigator.push({ 95 | name: 'AddressCreateContainer', 96 | component: AddressCreateContainer 97 | }) 98 | }); 99 | }; 100 | } 101 | 102 | const styles = StyleSheet.create({ 103 | container: { 104 | flex: 1, 105 | backgroundColor: 'white', 106 | }, 107 | headerWrap: { 108 | alignItems: 'center', 109 | height: 44, 110 | backgroundColor: '#ff7419', 111 | }, 112 | header: { 113 | color: '#fff', 114 | paddingTop: 22, 115 | fontSize: 17, 116 | }, 117 | 118 | productListWrap: { 119 | height: Common.window.height - 64 - 44 - 40, 120 | }, 121 | productItem: { 122 | height: 80, 123 | flexDirection:'row', 124 | padding: 15, 125 | marginBottom: 1, 126 | backgroundColor:'#fff', 127 | }, 128 | productRight: { 129 | flexDirection:'column', 130 | }, 131 | productImage: { 132 | width: 60, 133 | height: 60, 134 | marginRight: 15, 135 | }, 136 | productPrice: { 137 | fontSize: 24, 138 | color: 'red', 139 | }, 140 | productFeaturedPrice: { 141 | fontSize: 14, 142 | color: '#ddd', 143 | }, 144 | 145 | // 底部栏 146 | toolBarWrap: { 147 | height: 40, 148 | flexDirection: 'row', 149 | alignItems: 'center', 150 | borderTopColor: '#ccc', 151 | borderTopWidth: 0.5, 152 | }, 153 | toolBarItem: { 154 | flex: 1, 155 | flexDirection: 'row', 156 | justifyContent: 'center', 157 | alignItems: 'center', 158 | }, 159 | addToCartWrap: { 160 | flex: 1, 161 | backgroundColor: '#fd6161', 162 | justifyContent: 'center', 163 | alignItems: 'center', 164 | }, 165 | addToCart: { 166 | flex: 1, 167 | color: '#fff', 168 | fontSize: 16, 169 | }, 170 | }); -------------------------------------------------------------------------------- /app/pages/FunPage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-24 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | 'use strict'; 12 | 13 | import React, {Component} from 'react'; 14 | import { 15 | StyleSheet, 16 | View, 17 | ScrollView, 18 | Text, 19 | Image, 20 | InteractionManager, 21 | TouchableOpacity, 22 | } from 'react-native'; 23 | import DeviceInfo from 'react-native-device-info'; 24 | import Common from '../common/constants'; 25 | 26 | export default class FunPage extends Component { 27 | render() { 28 | return ( 29 | 30 | 31 | 好玩集市 32 | 33 | 34 | 35 | 36 | 37 | ) 38 | } 39 | } 40 | 41 | class DeviceComponent extends Component { 42 | render(){ 43 | console.log(DeviceInfo); 44 | // console.log("Device Unique ID", DeviceInfo.getUniqueID()); // e.g. FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9 45 | // * note this is IDFV on iOS so it will change if all apps from the current apps vendor have been previously uninstalled 46 | // console.log("Device Manufacturer", DeviceInfo.getManufacturer()); // e.g. Apple 47 | // console.log("Device Brand", DeviceInfo.getBrand()); // e.g. Apple / htc / Xiaomi 48 | // console.log("Device Model", DeviceInfo.getModel()); // e.g. iPhone 6 49 | // console.log("Device ID", DeviceInfo.getDeviceId()); // e.g. iPhone7,2 / or the board on Android e.g. goldfish 50 | // console.log("System Name", DeviceInfo.getSystemName()); // e.g. iPhone OS 51 | // console.log("System Version", DeviceInfo.getSystemVersion()); // e.g. 9.0 52 | // console.log("Bundle ID", DeviceInfo.getBundleId()); // e.g. com.learnium.mobile 53 | // console.log("Build Number", DeviceInfo.getBuildNumber()); // e.g. 89 54 | // console.log("App Version", DeviceInfo.getVersion()); // e.g. 1.1.0 55 | // console.log("App Version (Readable)", DeviceInfo.getReadableVersion()); // e.g. 1.1.0.89 56 | // console.log("Device Name", DeviceInfo.getDeviceName()); // e.g. Becca's iPhone 6 57 | // console.log("User Agent", DeviceInfo.getUserAgent()); // e.g. Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D) 58 | // console.log("Device Locale", DeviceInfo.getDeviceLocale()); // e.g en-US 59 | // console.log("Device Country", DeviceInfo.getDeviceCountry()); // e.g US 60 | // console.log("App Instance ID", DeviceInfo.getInstanceID()); // ANDROID ONLY - see https://developers.google.com/instance-id/ 61 | 62 | return ( 63 | 64 | 我的设备 65 | 66 | 67 | 型号: 68 | {DeviceInfo.getModel()} 69 | 70 | 71 | 手机版本: 72 | {DeviceInfo.getSystemVersion()} 73 | 74 | 75 | 76 | 77 | 厂家: 78 | {DeviceInfo.getManufacturer()} 79 | 80 | 81 | APP版本: 82 | {DeviceInfo.getVersion()} 83 | 84 | 85 | 86 | ) 87 | } 88 | } 89 | 90 | const styles = StyleSheet.create({ 91 | container: { 92 | flex: 1, 93 | backgroundColor: '#eee', 94 | }, 95 | headerWrap: { 96 | alignItems: 'center', 97 | height: 44, 98 | backgroundColor: '#ff7419', 99 | }, 100 | header: { 101 | color: '#fff', 102 | paddingTop: 22, 103 | fontSize: 16, 104 | }, 105 | mainWrap: { 106 | }, 107 | 108 | //我的设备 109 | deviceInfoWrap: { 110 | padding: 10, 111 | backgroundColor: 'white', 112 | }, 113 | deviceTitle: { 114 | fontSize: 15, 115 | color: '#383838', 116 | }, 117 | deviceRow: { 118 | flexDirection: 'row', 119 | marginTop: 8, 120 | }, 121 | deviceItem: { 122 | flex: 1, 123 | flexDirection: 'row', 124 | width: (Common.width - 20 ) / 2, 125 | }, 126 | deviceName: { 127 | fontSize: 14, 128 | color: '#555', 129 | }, 130 | deviceValue: { 131 | fontSize: 13, 132 | color: '#777', 133 | marginLeft: 2, 134 | }, 135 | }); -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.shopreactnative" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile project(':react-native-device-info') 130 | compile project(':react-native-vector-icons') 131 | compile fileTree(dir: "libs", include: ["*.jar"]) 132 | compile "com.android.support:appcompat-v7:23.0.1" 133 | compile "com.facebook.react:react-native:+" // From node_modules 134 | } 135 | 136 | // Run this once to be able to run the application with BUCK 137 | // puts all compile dependencies into folder libs for BUCK to use 138 | task copyDownloadableDepsToLibs(type: Copy) { 139 | from configurations.compile 140 | into 'libs' 141 | } 142 | -------------------------------------------------------------------------------- /app/pages/UserPage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-08-13 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | 'user strict'; 12 | 13 | import React from 'react'; 14 | import { 15 | StyleSheet, 16 | View, 17 | Text, 18 | Image, 19 | Switch, 20 | TouchableOpacity, 21 | InteractionManager, 22 | } from 'react-native'; 23 | import UserLoginPage from './UserLoginPage'; 24 | 25 | export default class User extends React.Component { 26 | constructor(props) { 27 | super(props); 28 | } 29 | 30 | render() { 31 | let titles = ['清除缓存', '关于我', '将ShopReactNative分享给朋友']; 32 | 33 | return ( 34 | 35 | 36 | 我的 37 | 38 | 39 | 40 | 41 | 42 | 控血糖模式 43 | 开启后食物红绿灯将针对糖尿病人群 44 | 45 | 50 | 51 | { 52 | titles.map((title) => { 53 | return ( 54 | 58 | {title} 59 | 60 | 61 | ) 62 | }) 63 | } 64 | 65 | 66 | ) 67 | } 68 | } 69 | 70 | class HeadView extends React.Component { 71 | constructor(props) { 72 | super(props); 73 | } 74 | 75 | render() { 76 | 77 | return ( 78 | 79 | 80 | 81 | 85 | 点击登录 86 | 87 | 88 | 89 | ) 90 | } 91 | 92 | _onPressFeedItem(feedItem) { 93 | InteractionManager.runAfterInteractions(() => { 94 | this.props.navigator.push({ 95 | name: 'UserLoginPage', 96 | component: UserLoginPage, 97 | passProps: { 98 | feed: feedItem, 99 | } 100 | }) 101 | }); 102 | } 103 | } 104 | 105 | class JurisdictionView extends React.Component { 106 | render() { 107 | let icons = ['ic_my_food', 'ic_my_upload', 'ic_my_collect']; 108 | let titles = ['饮食分析', '上传食物', '我的收藏']; 109 | return ( 110 | 111 | { 112 | icons.map((icon, i) => { 113 | return ( 114 | 119 | 120 | {titles[i]} 121 | 122 | ) 123 | }) 124 | } 125 | 126 | ) 127 | } 128 | } 129 | 130 | const styles = StyleSheet.create({ 131 | headerWrap: { 132 | alignItems: 'center', 133 | height: 44, 134 | backgroundColor: '#ff7419', 135 | }, 136 | header: { 137 | color: '#fff', 138 | paddingTop: 22, 139 | fontSize: 17, 140 | }, 141 | 142 | myBgImage: { 143 | flex: 1, 144 | height: 160, 145 | justifyContent: 'center', 146 | alignItems: 'center', 147 | }, 148 | 149 | headIcon: { 150 | height: 80, 151 | width: 80, 152 | }, 153 | 154 | login: { 155 | justifyContent: 'center', 156 | alignItems: 'center', 157 | borderColor: 'white', 158 | borderWidth: 0.5, 159 | padding: 5, 160 | marginTop: 10, 161 | }, 162 | 163 | jurisdictionView: { 164 | flexDirection: 'row', 165 | height: 100, 166 | borderBottomColor: 'rgb(241, 241, 241)', 167 | borderBottomWidth: 10 168 | }, 169 | 170 | handleView: { 171 | flex: 1, 172 | justifyContent: 'center', 173 | alignItems: 'center', 174 | }, 175 | 176 | switchCell: { 177 | flexDirection: 'row', 178 | padding: 10, 179 | alignItems: 'center', 180 | borderBottomColor: 'rgb(241, 241, 241)', 181 | borderBottomWidth: 10 182 | }, 183 | 184 | switch: { 185 | position: 'absolute', 186 | right: 15, 187 | top: 10, 188 | }, 189 | 190 | cell: { 191 | flexDirection: 'row', 192 | height: 40, 193 | marginLeft: 10, 194 | marginRight: 10, 195 | justifyContent: 'space-between', 196 | borderBottomColor: '#ccc', 197 | borderBottomWidth: 0.5, 198 | alignItems: 'center' 199 | }, 200 | 201 | rightIcon: { 202 | position: 'absolute', 203 | right: -10, 204 | top: 5, 205 | height: 30, 206 | width: 30 207 | } 208 | 209 | }) -------------------------------------------------------------------------------- /app/pages/AddressCreatePage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ShopReactNative 3 | * 4 | * @author Tony Wong 5 | * @date 2016-09-25 6 | * @email 908601756@qq.com 7 | * @copyright Copyright © 2016 EleTeam 8 | * @license The MIT License (MIT) 9 | */ 10 | 11 | import React, {Component} from 'react'; 12 | import { 13 | StyleSheet, 14 | Text, 15 | TextInput, 16 | View, 17 | Image, 18 | 19 | TouchableOpacity, 20 | InteractionManager, 21 | } from 'react-native'; 22 | import Toast from 'react-native-root-toast'; 23 | import Header from '../components/Header'; 24 | import {addressCreate, addressList} from '../actions/addressActions'; 25 | 26 | export default class AddressCreatePage extends Component { 27 | constructor(props){ 28 | super(props); 29 | this.state = { 30 | area_id: 0, 31 | detail: '', 32 | fullname:'', 33 | telephone:'', 34 | }; 35 | } 36 | 37 | componentWillUnmount(){ 38 | // this.unsubscribe(); 39 | } 40 | 41 | componentDidMount(){ 42 | // this.unsubscribe = MemberStore.listen(this.onLogined.bind(this)); 43 | } 44 | 45 | componentWillUpdate(nextProps, nextState){ 46 | InteractionManager.runAfterInteractions(() => { 47 | const {addressReducer} = this.props; 48 | if (addressReducer.isToasting) { 49 | Toast.show(addressReducer.message, {position:Toast.positions.CENTER}); 50 | } 51 | }); 52 | } 53 | 54 | render(){ 55 | return ( 56 | 57 |
this.props.navigator.pop()} 60 | title='添加收货地址' 61 | /> 62 | 63 | 64 | 68 | 69 | 70 | 71 | 75 | 76 | 77 | 78 | 82 | 83 | 84 | 保存 85 | 86 | 87 | ) 88 | } 89 | 90 | _onChangeFullname(text) { 91 | this.state.fullname = text; 92 | // this.setState({'mobile': text}); 93 | } 94 | 95 | _onChangeTelephone(text){ 96 | this.state.telephone = text; 97 | // this.setState({'password': text}); 98 | } 99 | 100 | _onChangeDetail(text){ 101 | this.state.detail = text; 102 | // this.setState({'password': text}); 103 | } 104 | 105 | _addressCreate(){ 106 | let {telephone, fullname, detail, area_id} = this.state; 107 | 108 | if (!fullname.length) { 109 | Toast.show('请输入收货人姓名', {position:Toast.positions.CENTER}); 110 | return; 111 | } 112 | if (!telephone.length) { 113 | Toast.show('请输入收货人电话', {position:Toast.positions.CENTER}); 114 | return; 115 | } 116 | 117 | InteractionManager.runAfterInteractions(() => { 118 | const {dispatch, userReducer} = this.props; 119 | let access_token = userReducer.user.access_token; 120 | dispatch(addressCreate(access_token, fullname, telephone, area_id, detail)); 121 | }); 122 | }; 123 | } 124 | 125 | const styles = StyleSheet.create({ 126 | container: { 127 | flex: 1, 128 | }, 129 | 130 | headerWrap: { 131 | alignItems: 'center', 132 | height: 44, 133 | backgroundColor: '#ff7419', 134 | }, 135 | header: { 136 | color: '#fff', 137 | paddingTop: 22, 138 | fontSize: 17, 139 | }, 140 | 141 | loginWrap: { 142 | backgroundColor: '#FCE9D4', 143 | }, 144 | imgWrap: { 145 | flexDirection: 'row', 146 | flex: 1, 147 | }, 148 | loginMain: { 149 | flex:1, 150 | }, 151 | comCulture: { 152 | width:320, 153 | marginTop:50, 154 | }, 155 | 156 | formInput:{ 157 | flexDirection:'row', 158 | height: 60, 159 | padding: 20, 160 | }, 161 | formInputSplit:{ 162 | borderBottomWidth:1, 163 | borderBottomColor:'#dbdada', 164 | }, 165 | loginInput: { 166 | height: 40, 167 | paddingLeft: 10, 168 | flex: 1, 169 | fontSize: 16, 170 | }, 171 | 172 | verifyCodeBtn: { 173 | backgroundColor: '#c5523f', 174 | paddingTop: 5, 175 | paddingBottom: 5, 176 | alignItems:'center', 177 | width: 80, 178 | height: 30, 179 | borderRadius: 2, 180 | }, 181 | verifyCodeText: { 182 | color: '#ffffff', 183 | }, 184 | 185 | registerBtn:{ 186 | backgroundColor: '#ff6836', 187 | padding: 10, 188 | alignItems: 'center', 189 | marginTop: 20, 190 | marginLeft: 10, 191 | marginRight: 10, 192 | borderRadius: 3, 193 | }, 194 | registerText:{ 195 | color:'#ffffff', 196 | fontSize: 17, 197 | }, 198 | 199 | registerWrap: { 200 | flexDirection: 'row', 201 | marginTop: 20, 202 | marginBottom: 20, 203 | marginLeft: 10, 204 | marginRight: 10, 205 | }, 206 | }); 207 | --------------------------------------------------------------------------------