Skip to content

Commit

Permalink
修改用户登录注册模块
Browse files Browse the repository at this point in the history
  • Loading branch information
EleTeam committed Sep 16, 2016
1 parent 83cddb9 commit 4ed3f11
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 117 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#### EleTeam开源项目 - 电商全套解决方案之 React Native 版 - Shop-React-Native。一个类似京东/天猫/淘宝的商城,有对应的服务端支持,由EleTeam团队维护!
#### 服务端是PHP商城,对应项目是 Shop-PHP-Yii2,https://github.com/EleTeam/Shop-PHP-Yii2

#### react-native 的学习文档: http://reactnative.cn/docs/0.31/getting-started.html

### 功能如下:
支持下拉刷新和上拖加载更多
广告模块
Expand Down Expand Up @@ -49,7 +47,10 @@
在Android项目中可能是./android/app/src/main/java/com/项目名/MainActivity.java中的mReactRootView.startReactApplication(mReactInstanceManager, "项目名", null); 没有保持一致,修改方法:编辑成相同的参数即可。
2. 有可能你同时在运行一个以上的程序。如果你的react-native在运行程序A而你打开了程序B,也会出现相同的问题。解决方法:关闭其它React Native程序, 只运行一个。

#### react-native 的学习文档:
入门基础: http://reactnative.cn/docs/0.31/getting-started.html
组件的生命周期: http://www.race604.com/react-native-component-lifecycle

### 部分App界面:
![](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)

Expand Down
28 changes: 28 additions & 0 deletions app/actions/userActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ export let userView = () => {
}
};

export let userLogin = (mobile, password) => {
let url = urls.kUrlUserLogin;
let data = {
mobile: mobile,
password: password
};
return (dispatch) => {
dispatch({'type': types.kUserLogin});
Util.post(url, data,
(status, code, message, data, share) => {
let app_cart_cookie_id = '';
let user = {};
if (status) {
user = data.user;
app_cart_cookie_id = data.app_cart_cookie_id;
Storage.setAppCartCookieId(app_cart_cookie_id);
Storage.setUser(user);
}
dispatch({type:types.kUserLoginReceived, status:status, code:code, message:message, share:share, user:user, app_cart_cookie_id:app_cart_cookie_id});
},
(error) => {
Alert.alert(error.message);
dispatch({'type': types.kActionError});
});
}
};

export let userLogout = () => {
let url = urls.kUrlUserLogout;
return (dispatch) => {
Expand All @@ -64,6 +91,7 @@ export let userLogout = () => {
if (status) {
app_cart_cookie_id = data.app_cart_cookie_id;
Storage.setAppCartCookieId(app_cart_cookie_id);
Storage.setUser({});
}
dispatch({type:types.kUserLogoutReceived, status:status, code:code, message:message, share:share, app_cart_cookie_id:app_cart_cookie_id});
},
Expand Down
72 changes: 72 additions & 0 deletions app/common/commonStyles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* ShopReactNative
*
* @author Tony Wong
* @date 2016-08-13
* @email 908601756@qq.com
* @copyright Copyright © 2016 EleTeam
* @license The MIT License (MIT)
*/

import {StyleSheet} from 'react-native';

export const colors = {
lightGray:"#F0F0F0",
lineGray: '#F0F0F0',
green: '#80BD01',
backGray: '#E5E5E5',
textGray: '#9A9A9A',
textBlack: '#333333',
purple: '#9966CC',
red: '#f61d4b',
backWhite: '#F2F2F2',
textGold: '#BC7233',
borderColor: '#E2E2E2',
black: '#586872',
blue: '#4078c0',
white: "white",
};

const commonStyles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
shadowLine: {
shadowColor: '#999999',
shadowOpacity: 0.8,
shadowRadius: 1,
shadowOffset: {
height: 2,
width: 1
},
},
sepLine: {
backgroundColor: colors.backGray,
height: 0.5,
},
textInput: {
fontSize: 15,
borderWidth: 1,
height: 38,
marginTop: 5,
marginBottom: 10,
borderRadius: 4,
padding: 3,
borderColor: colors.blue,
},
btn: {
borderWidth: 1,
height: 38,
marginLeft: 20,
marginRight: 20,
justifyContent: "center",
borderColor: colors.blue,
backgroundColor: colors.blue,
borderRadius: 6,
marginTop:20,
}
});

export default commonStyles;
10 changes: 5 additions & 5 deletions app/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import {Dimensions} from 'react-native';
let window = {
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
}
};

let colors = {
themeColor: 'rgb(217, 51, 58)',
}
};

let storeKeys = {
SEARCH_HISTORY_KEY: 'SEARCH_HISTORY_KEY',
}
};

let mapper = {
'calory': {name: '热量', unit: ''},
Expand All @@ -47,11 +47,11 @@ let mapper = {
'phosphor': {name: '磷', unit: '毫克'},
'natrium': {name: '钠', unit: '毫克'},
'selenium': {name: '硒', unit: '毫克'}
}
};

export default {
window: window,
colors: colors,
storeKeys: storeKeys,
ingredientMapper: mapper
}
};
5 changes: 3 additions & 2 deletions app/common/constants_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* @type {string}
*/

// const kUrlHost = 'http://local.eleteamapi.ygcr8.com/v1'; //本地服务器
const kUrlHost = 'http://eleteamapi.ygcr8.com/v1'; //在线服务器
const kUrlHost = 'http://local.eleteamapi.ygcr8.com/v1'; //本地服务器
// const kUrlHost = 'http://eleteamapi.ygcr8.com/v1'; //在线服务器

//产品和分类
export const kUrlCategoryListWithProduct = kUrlHost + '/category/list-with-product';
Expand All @@ -32,4 +32,5 @@ export const kUrlCart = kUrlHost + '/cart';

//用户
export const kUrlUserRegister = kUrlHost + '/user/register';
export const kUrlUserLogin = kUrlHost + '/user/login';
export const kUrlUserLogout = kUrlHost + '/user/logout';
26 changes: 11 additions & 15 deletions app/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import {
import Icon from 'react-native-vector-icons/FontAwesome';

export default class Header extends React.Component {

render() {

let NavigationBar = [];

// 左边图片按钮
Expand All @@ -44,22 +42,22 @@ export default class Header extends React.Component {
// 标题
if (this.props.title != undefined) {
NavigationBar.push(
<Text key={'title'} style={styles.title}>{this.props.title}</Text>
<View key={'title'} style={styles.titleWrap}>
<Text style={styles.title}>{this.props.title}</Text>
</View>
)
}

// 自定义标题View
if (this.props.titleView != undefined) {
let Component = this.props.titleView;

NavigationBar.push(
<Component key={'titleView'}/>
)
}

// 右边图片按钮
if (this.props.rightIcon != undefined) {

NavigationBar.push(
<TouchableOpacity
key={'rightIcon'}
Expand Down Expand Up @@ -110,7 +108,6 @@ export default class Header extends React.Component {
}

const styles = StyleSheet.create({

navigationBarContainer: {
flexDirection: 'row',
height: 44,
Expand All @@ -119,35 +116,34 @@ const styles = StyleSheet.create({
borderBottomWidth: 0.5,
backgroundColor: 'white'
},

titleWrap: {
flex:1,
alignItems:'center',
},
title: {
fontSize: 15,
marginLeft: 15,
marginLeft: -40,
},

leftIcon: {
marginLeft: 15,
paddingLeft: 15,
paddingRight: 15,
},

rightIcon: {
position: 'absolute',
right: 10,
top: 7
},

rightButton: {
position: 'absolute',
right: 10,
height: 44,
justifyContent: 'center',
flexDirection: 'row',
},

buttonTitleFont: {
color: 'white',
fontSize: 15,
},

rightMenu: {
position: 'absolute',
right: 10,
Expand All @@ -156,4 +152,4 @@ const styles = StyleSheet.create({
flexDirection: 'row',
alignItems: 'center'
},
})
});
4 changes: 2 additions & 2 deletions app/containers/MyContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class MyContainer extends Component {
}

export default connect((state) => {
const { myReducer } = state;
const { userReducer } = state;
return {
myReducer
userReducer
}
})(MyContainer);
Loading

0 comments on commit 4ed3f11

Please sign in to comment.