Skip to content

Commit

Permalink
添加订单模块
Browse files Browse the repository at this point in the history
  • Loading branch information
EleTeam committed Sep 27, 2016
1 parent cd95471 commit ce15005
Show file tree
Hide file tree
Showing 12 changed files with 495 additions and 9 deletions.
10 changes: 10 additions & 0 deletions app/actions/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//公用类型
export const kActionError = 'kActionError';
export const kCommonIsToasting = 'kCommonIsToasting';

//首页
export const kBannerList = 'kBannerList';
Expand Down Expand Up @@ -58,6 +59,15 @@ export const kPreorderIsTurnedToViewFromSync = 'kPreorderIsTurnedToViewFromSy
export const kPreorderView = 'kPreorderView';
export const kPreorderViewReceived = 'kPreorderViewReceived';

//订单
export const kOrderCreate = 'kOrderCreate';
export const kOrderCreateReceived = 'kOrderCreateReceived';
export const kOrderIsTurnedToViewFromSync = 'kOrderIsTurnedToViewFromSync';
export const kOrderView = 'kOrderView';
export const kOrderViewReceived = 'kOrderViewReceived';
export const kOrderIndex = 'kOrderIndex';
export const kOrderIndexReceived = 'kOrderIndexReceived';

//地址
export const kAddressIsToasting = 'kAddressIsToasting';
export const kAddressList = 'kAddressList';
Expand Down
21 changes: 21 additions & 0 deletions app/actions/commonActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* ShopReactNative
*
* @author Tony Wong
* @date 2016-09-24
* @email 908601756@qq.com
* @copyright Copyright © 2016 EleTeam
* @license The MIT License (MIT)
*/

import * as types from './actionTypes';

/**
* 公共的actions
*/

export let commonIsToasting = (isToasting) => {
return (dispatch) => {
dispatch({type:types.kCommonIsToasting, isToasting:isToasting});
}
};
76 changes: 76 additions & 0 deletions app/actions/orderActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* ShopReactNative
*
* @author Tony Wong
* @date 2016-09-27
* @email 908601756@qq.com
* @copyright Copyright © 2016 EleTeam
* @license The MIT License (MIT)
*/

import * as types from './actionTypes';
import Util from '../common/utils';
import * as urls from '../common/constants_url';
import {commonIsToasting} from './commonActions';

/**
* 订单actions
*/

export let orderCreate = (access_token, preorder_id, address_id, notice)=> {
let url = urls.kUrlOrderCreate;
let data = {
access_token: access_token,
preorder_id: preorder_id,
address_id: address_id,
notice: notice
};

return dispatch => {
dispatch({type: types.kOrderCreate});
return Util.post(url, data,
(status, code, message, data, share) => {
let order = {};
if (status) {
order = data.order;
}else{
dispatch(commonIsToasting(true));
}
dispatch({type:types.kOrderCreateReceived, status:status, code:code, message:message, share:share,
order:order});
dispatch(commonIsToasting(false));
},
(error) => {
// console.log('Fetch banner list error: ' + error);
dispatch({'type': types.kActionError});
}
);
}
};

export let orderView = (order_id, access_token)=> {
let url = urls.kUrlOrderView + order_id;
let data = {
access_token: access_token
};

return dispatch => {
dispatch({type: types.kOrderView});
return Util.post(url, data,
(status, code, message, data, share) => {
let order = {};
let address = {};
if (status) {
order = data.order;
address = data.address;
}
dispatch({type:types.kOrderViewReceived, status:status, code:code, message:message, share:share,
order:order, address:address});
},
(error) => {
// console.log('Fetch banner list error: ' + error);
dispatch({'type': types.kActionError});
}
);
}
};
9 changes: 7 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 @@ -40,6 +40,11 @@ export const kUrlUserLogout = kUrlHost + '/user/logout';
export const kUrlPreorderCreate = kUrlHost + '/preorder/create';
export const kUrlPreorderView = kUrlHost + '/preorder/view?id=';

//订单
export const kUrlOrderCreate = kUrlHost + '/order/create';
export const kUrlOrderView = kUrlHost + '/order/view?id=';
export const kUrlOrderIndex = kUrlHost + '/order/index';

//地址
export const kUrlAddressList = kUrlHost + '/address/index';
export const kUrlAddressCreate = kUrlHost + '/address/create';
Expand Down
25 changes: 25 additions & 0 deletions app/containers/OrderContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* ShopReactNative
*
* @author Tony Wong
* @date 2016-09-27
* @email 908601756@qq.com
* @copyright Copyright © 2016 EleTeam
* @license The MIT License (MIT)
*/

import React, {Component} from 'react';
import {connect} from 'react-redux';
import OrderPage from '../pages/OrderPage';

class OrderContainer extends Component {
render() {
return (
<OrderPage {...this.props} />
)
}
}

export default connect((state) => {
return { orderReducer, userReducer, commonReducer} = state;
})(OrderContainer);
2 changes: 1 addition & 1 deletion app/containers/PreorderContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ class PreorderContainer extends Component {
}

export default connect((state) => {
return { preorderReducer, userReducer} = state;
return { preorderReducer, orderReducer, userReducer, commonReducer} = state;
})(PreorderContainer);
1 change: 1 addition & 0 deletions app/pages/AddressCreatePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
TextInput,
View,
Image,

TouchableOpacity,
InteractionManager,
} from 'react-native';
Expand Down
Loading

0 comments on commit ce15005

Please sign in to comment.