...
|
...
|
@@ -84,9 +84,10 @@ function parseProductList(json) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getGlobalProductListRequest() {
|
|
|
export function getGlobalProductListRequest(json) {
|
|
|
return {
|
|
|
type: GET_GLOBAL_PRODUCT_LIST_REQUEST,
|
|
|
payload: json,
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -103,13 +104,27 @@ export function getGlobalProductListFailure(error) { |
|
|
payload: error
|
|
|
}
|
|
|
}
|
|
|
export function getGlobalProductList(index,json) {
|
|
|
export function getGlobalProductList(index,json,reload=false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, home} = getState();
|
|
|
let page = 1;
|
|
|
|
|
|
if (json.isFetching || json.endReached) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let page_0 = json.page?json.page:1;
|
|
|
let page = reload?parseInt(page_0)+1:parseInt(page_0);
|
|
|
let order = json.order;
|
|
|
let sort = json.msort?json.msort:'';
|
|
|
dispatch(getGlobalProductListRequest());
|
|
|
console.log(page);
|
|
|
if (json) {
|
|
|
json.page = page;
|
|
|
json.isFetching = true;
|
|
|
json.filter = index;
|
|
|
json.endReached = false;
|
|
|
}
|
|
|
|
|
|
dispatch(getGlobalProductListRequest(json));
|
|
|
return new HomeService(app.host).getGlobalProductList(page,order,sort)
|
|
|
.then(json => {
|
|
|
let data = parseDetailProductList(index,home,json);
|
...
|
...
|
@@ -127,13 +142,26 @@ function parseDetailProductList(index,home,json) { |
|
|
let total = json.total;
|
|
|
let product_list = json.product_list;
|
|
|
let page_total = json.page_total;
|
|
|
let isFetching = false;
|
|
|
let error = '';
|
|
|
let filter = index;
|
|
|
let obj = {page,total,product_list,page_total,filter};
|
|
|
|
|
|
let list = home.groupInfo.list.toJS();
|
|
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
if (i == filter) {
|
|
|
list[i].product = obj
|
|
|
if (page > 1) {
|
|
|
let oldList =list[i].product;
|
|
|
product_list = [...oldList, ...product_list];
|
|
|
}
|
|
|
list[i].product = product_list;
|
|
|
list[i].page = page;
|
|
|
list[i].isFetching = isFetching;
|
|
|
list[i].error = error;
|
|
|
list[i].total = total;
|
|
|
list[i].page_total = page_total;
|
|
|
list[i].filter = parseInt(filter);
|
|
|
list[i].endReached = page == page_total;
|
|
|
}
|
|
|
}
|
|
|
return list;
|
...
|
...
|
|