...
|
...
|
@@ -32,6 +32,9 @@ const { |
|
|
HOT_PRODUCT_SUCCESS,
|
|
|
HOT_PRODUCT_FAILURE,
|
|
|
|
|
|
PRODUCT_LIST_REQUEST,
|
|
|
PRODUCT_LIST_SUCCESS,
|
|
|
PRODUCT_LIST_FAILURE,
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
export function onPressBrandItem() {
|
...
|
...
|
@@ -288,7 +291,10 @@ export function getHotProduct() { |
|
|
dispatch(hotProductRequest());
|
|
|
return new BrandStoreService().searchProductBySkn(productSkn)
|
|
|
.then(json => {
|
|
|
let payload = json;
|
|
|
_.forEach(json.product_list, (value, key) => {
|
|
|
json.product_list[key].is_soon_sold_out = 'N';
|
|
|
});
|
|
|
let payload = json.product_list;
|
|
|
dispatch(hotProductSuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
...
|
...
|
@@ -296,3 +302,81 @@ export function getHotProduct() { |
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
export function productListRequest() {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function productListSuccess(json) {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_SUCCESS,
|
|
|
payload: json
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function productListFailure(error) {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_FAILURE,
|
|
|
payload: error
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 底部产品列表
|
|
|
*/
|
|
|
export function getProductList(reload=false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, brandStore} = getState();
|
|
|
let {shopId, productList} = brandStore;
|
|
|
|
|
|
if (reload) {
|
|
|
|
|
|
} else {
|
|
|
if (productList.isFetching || productList.endReached || productList.error) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let order = productList.order;
|
|
|
let page = productList.currentPage + 1;
|
|
|
let pageSize = productList.pageSize;
|
|
|
let channel = 1;
|
|
|
|
|
|
dispatch(productListRequest());
|
|
|
return new BrandStoreService().productList(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(productListSuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(productListFailure(error));
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function parseProductList(json) {
|
|
|
let currentPage = json && json.page ? json.page : 1;
|
|
|
let pageCount = json && json.page_total ? json.page_total : 0;
|
|
|
let total = json && json.total ? json.total : 0;
|
|
|
|
|
|
let filter = json && json.filter ? json.filter : {};
|
|
|
let list = json && json.product_list ? json.product_list : [];
|
|
|
|
|
|
return {
|
|
|
list,
|
|
|
filter,
|
|
|
currentPage,
|
|
|
pageCount,
|
|
|
total,
|
|
|
};
|
|
|
} |
...
|
...
|
|