Authored by 于良

Merge branch 'brand_store' of http://git.yoho.cn/mobile/YH_RNComponent into brand_store

... ... @@ -97,6 +97,7 @@ export default class BrandStore extends Component {
switch (rowID) {
case '0': {
return null;
return (
<CouponCell
resource={rowData}
... ... @@ -105,7 +106,6 @@ export default class BrandStore extends Component {
);
}
case '1': {
return null;
return (
<BrandListCell
resource={rowData}
... ... @@ -180,7 +180,7 @@ export default class BrandStore extends Component {
}
render() {
let {info, resource, coupon, productList, storeFilter} = this.props;
let {info, resource, coupon, productList, storeFilter,productListForPerson,productListForNew} = this.props;
let {
shopTopBanner_APP,
... ... @@ -208,12 +208,12 @@ export default class BrandStore extends Component {
} else if (storeFilter == 1) {
dataSource = {
shopTopBanner_APP: [shopTopBanner_APP],
storeFilter: productList.list.toArray(),
storeFilter: productListForNew.list.toArray(),
};
} else if (storeFilter == 2) {
dataSource = {
shopTopBanner_APP: [shopTopBanner_APP],
storeFilter: productList.list.toArray(),
storeFilter: productListForPerson.list.toArray(),
};
}
... ...
... ... @@ -31,6 +31,14 @@ export default keyMirror({
PRODUCT_LIST_SUCCESS: null,
PRODUCT_LIST_FAILURE: null,
PRODUCT_LIST_FORPERSON_REQUEST:null,
PRODUCT_LIST_FORPERSON_SUCCESS:null,
PRODUCT_LIST_FORPERSON_FAILURE:null,
PRODUCT_LIST_FORNEW_REQUEST:null,
PRODUCT_LIST_FORNEW_SUCCESS:null,
PRODUCT_LIST_FORNEW_FAILURE:null,
PRODUCT_FILTER_ACTION: null,
});
... ...
... ... @@ -60,6 +60,8 @@ class BrandStoreContainer extends Component {
this.props.actions.getShopResources();
this.props.actions.getProductList();
this.props.actions.getFavoriteState();
this.props.actions.getProductListForPersopn();
this.props.actions.getProductListForNew();
}
componentWillUnmount() {
... ... @@ -127,13 +129,15 @@ class BrandStoreContainer extends Component {
}
render() {
let {info, resource, coupon,productList,storeFilter} = this.props.brandStore;
let {info, resource, coupon,productList,storeFilter,productListForPerson,productListForNew} = this.props.brandStore;
return (
<BrandStore
info={info}
resource={resource}
coupon={coupon}
productList={productList}
productListForPerson={productListForPerson}
productListForNew={productListForNew}
storeFilter={storeFilter}
onPressCollection={this._onPressCollection}
onPressCoupon={this._onPressCoupon}
... ...
... ... @@ -35,6 +35,14 @@ const {
PRODUCT_LIST_SUCCESS,
PRODUCT_LIST_FAILURE,
PRODUCT_LIST_FORPERSON_REQUEST,
PRODUCT_LIST_FORPERSON_SUCCESS,
PRODUCT_LIST_FORPERSON_FAILURE,
PRODUCT_LIST_FORNEW_REQUEST,
PRODUCT_LIST_FORNEW_SUCCESS,
PRODUCT_LIST_FORNEW_FAILURE,
PRODUCT_FILTER_ACTION,
} = require('../../constants/actionTypes').default;
... ... @@ -594,6 +602,125 @@ function parseProductList(json) {
}
export function productListForPersonRequest() {
return {
type: PRODUCT_LIST_FORPERSON_REQUEST,
};
}
export function productListForPersonSuccess(json) {
return {
type: PRODUCT_LIST_FORPERSON_SUCCESS,
payload: json
}
}
export function productListForPersonFailure(error) {
return {
type: PRODUCT_LIST_FORPERSON_FAILURE,
payload: error
}
}
export function getProductListForPersopn(reload=false) {
return (dispatch, getState) => {
let {app, brandStore} = getState();
let {shopId, productListForPerson} = brandStore;
if (reload) {
} else {
if (productListForPerson.isFetching || productListForPerson.endReached || productListForPerson.error) {
return;
}
}
let order = productListForPerson.order;
let page = productListForPerson.currentPage + 1;
let pageSize = productListForPerson.pageSize;
let channel = 1;
dispatch(productListForPersonRequest());
return new BrandStoreService().productListForPerson(shopId, channel, order, page, pageSize)
.then(json => {
let payload = parseProductList(json);
payload.endReached = payload.currentPage == payload.pageCount;
if (payload.currentPage > 1) {
let oldList = productList.list.toJS();
let list = [...oldList, ...payload.list];
payload.list = list;
}
dispatch(productListForPersonSuccess(payload));
})
.catch(error => {
dispatch(productListForPersonFailure(error));
});
};
}
export function productListForNewRequest() {
return {
type: PRODUCT_LIST_FORNEW_REQUEST,
};
}
export function productListForNewSuccess(json) {
return {
type: PRODUCT_LIST_FORNEW_SUCCESS,
payload: json
}
}
export function productListForNewFailure(error) {
return {
type: PRODUCT_LIST_FORNEW_FAILURE,
payload: error
}
}
export function getProductListForNew(reload=false) {
return (dispatch, getState) => {
let {app, brandStore} = getState();
let {shopId, productListForNew} = brandStore;
if (reload) {
} else {
if (productListForNew.isFetching || productListForNew.endReached || productListForNew.error) {
return;
}
}
let order = productListForNew.order;
let page = productListForNew.currentPage + 1;
let pageSize = productListForNew.pageSize;
let channel = 1;
dispatch(productListForNewRequest());
return new BrandStoreService().productListForNew(shopId, channel, order, page, pageSize)
.then(json => {
let payload = parseProductList(json);
payload.endReached = payload.currentPage == payload.pageCount;
if (payload.currentPage > 1) {
let oldList = productListForNew.list.toJS();
let list = [...oldList, ...payload.list];
payload.list = list;
}
dispatch(productListForNewSuccess(payload));
})
.catch(error => {
dispatch(productListForNewFailure(error));
});
};
}
export function addFavorite() {
return (dispatch, getState) => {
let {app, brandStore} = getState();
... ...
... ... @@ -61,6 +61,33 @@ let InitialState = Record({
endReached: false,
sourceType: 0, // 0 - 默认,1 - 购,全球2 - 奥莱
})),
productListForPerson: new (Record({
isFetching: false,
error: null,
list: List(),
filter: null,
order: 's_n_asc',
currentPage: 0,
pageCount: 0,
pageSize: 6,//60,
total: 0,
endReached: false,
sourceType: 0, // 0 - 默认,1 - 购,全球2 - 奥莱
})),
productListForNew: new (Record({
isFetching: false,
error: null,
list: List(),
filter: null,
order: 's_t_desc',
currentPage: 0,
pageCount: 0,
pageSize: 6,//60,
total: 0,
endReached: false,
sourceType: 0, // 0 - 默认,1 - 购,全球2 - 奥莱
})),
storeFilter: 0,
filterFactors: new (Record({
gender: '', //性别
... ...
... ... @@ -34,6 +34,14 @@ const {
PRODUCT_LIST_SUCCESS,
PRODUCT_LIST_FAILURE,
PRODUCT_LIST_FORPERSON_REQUEST,
PRODUCT_LIST_FORPERSON_SUCCESS,
PRODUCT_LIST_FORPERSON_FAILURE,
PRODUCT_LIST_FORNEW_REQUEST,
PRODUCT_LIST_FORNEW_SUCCESS,
PRODUCT_LIST_FORNEW_FAILURE,
PRODUCT_FILTER_ACTION,
} = require('../../constants/actionTypes').default;
... ... @@ -215,6 +223,72 @@ export default function brandStoreReducer(state=initialState, action) {
.set('filterCategoryDetailFilterList', filterCategoryDetailFilterList);
}
case PRODUCT_LIST_FORPERSON_REQUEST:{
return state.setIn(['productListForPerson', 'isFetching'], true)
.setIn(['productListForPerson', 'error'], null);
}
case PRODUCT_LIST_FORPERSON_SUCCESS: {
let {
list,
filter,
currentPage,
pageCount,
total,
endReached,
} = action.payload;
let newState = state.setIn(['productListForPerson', 'isFetching'], false)
.setIn(['productListForPerson', 'error'], null)
.setIn(['productListForPerson', 'list'], Immutable.fromJS(list))
.setIn(['productListForPerson', 'currentPage'], currentPage)
.setIn(['productListForPerson', 'pageCount'], pageCount)
.setIn(['productListForPerson', 'total'], total)
.setIn(['productListForPerson', 'endReached'], endReached)
if (currentPage == 1) {
newState = newState.setIn(['productListForPerson', 'filter'], Immutable.fromJS(filter));
}
return newState;
}
case PRODUCT_LIST_FORPERSON_FAILURE: {
return state.setIn(['productListForPerson', 'isFetching'], false)
.setIn(['productListForPerson', 'error'], action.payload);
}
case PRODUCT_LIST_FORNEW_REQUEST:{
return state.setIn(['productListForNew', 'isFetching'], true)
.setIn(['productListForNew', 'error'], null);
}
case PRODUCT_LIST_FORNEW_SUCCESS: {
let {
list,
filter,
currentPage,
pageCount,
total,
endReached,
} = action.payload;
let newState = state.setIn(['productListForNew', 'isFetching'], false)
.setIn(['productListForNew', 'error'], null)
.setIn(['productListForNew', 'list'], Immutable.fromJS(list))
.setIn(['productListForNew', 'currentPage'], currentPage)
.setIn(['productListForNew', 'pageCount'], pageCount)
.setIn(['productListForNew', 'total'], total)
.setIn(['productListForNew', 'endReached'], endReached)
if (currentPage == 1) {
newState = newState.setIn(['productListForNew', 'filter'], Immutable.fromJS(filter));
}
return newState;
}
case PRODUCT_LIST_FORNEW_FAILURE: {
return state.setIn(['productListForNew', 'isFetching'], false)
.setIn(['productListForNew', 'error'], action.payload);
}
}
return state;
... ...
... ... @@ -162,4 +162,50 @@ export default class BrandStoreService {
});
}
async productListForPerson(shop_id, yh_channel=1, order='s_n_asc', page=1, limit=60, v=7) {
return await this.api.get({
url: '',
body: {
method: 'app.search.brand',
shop_id,
yh_channel,
order,
status: 1,
sales: 'Y',
stocknumber: 1,
attribute_not: 2,
v,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async productListForNew(shop_id, yh_channel=1, order='s_t_desc', page=1, limit=60, v=7) {
return await this.api.get({
url: '',
body: {
method: 'app.search.brand',
shop_id,
yh_channel,
order,
status: 1,
sales: 'Y',
stocknumber: 1,
attribute_not: 2,
v,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...