...
|
...
|
@@ -15,6 +15,9 @@ const { |
|
|
PRODUCT_LIST_REQUEST,
|
|
|
PRODUCT_LIST_SUCCESS,
|
|
|
PRODUCT_LIST_FAILURE,
|
|
|
PRODUCT_LIST_FOR_NEW_REQUEST,
|
|
|
PRODUCT_LIST_FOR_NEW_SUCCESS,
|
|
|
PRODUCT_LIST_FOR_NEW_FAILURE,
|
|
|
PRODUCT_FILTER_ACTION,
|
|
|
FILTER_LIST_VIEW,
|
|
|
FILTER_MORE_VIEW,
|
...
|
...
|
@@ -153,6 +156,26 @@ export function productListFailure(error) { |
|
|
payload: error
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function productListForNewRequest() {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_FOR_NEW_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function productListForNewSuccess(json) {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_FOR_NEW_SUCCESS,
|
|
|
payload: json
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function productListForNewFailure(error) {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_FOR_NEW_FAILURE,
|
|
|
payload: error
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
|
* 筛选
|
|
|
*/
|
...
|
...
|
@@ -248,6 +271,41 @@ export function getProductList(reload=false) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getProductListForNew(reload=false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, redBrand} = getState();
|
|
|
let {shopId, productListForNew} = redBrand;
|
|
|
|
|
|
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 = app.channel;
|
|
|
|
|
|
dispatch(productListForNewRequest());
|
|
|
return new RedBrandService(app.host).productList(shopId, channel, order, page, pageSize)
|
|
|
.then(json => {
|
|
|
let payload = parseProductList(json);
|
|
|
payload.endReached = payload.currentPage == payload.pageCount || payload.list.length < pageSize;
|
|
|
if (payload.currentPage > 1) {
|
|
|
let oldList = productList.list.toJS();
|
|
|
let list = [...oldList, ...payload.list];
|
|
|
payload.list = list;
|
|
|
}
|
|
|
dispatch(productListForNewSuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(productListForNewFailure(error));
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function parseProductList(json) {
|
|
|
let currentPage = json && json.page ? json.page : 1;
|
|
|
let pageCount = json && json.page_total ? json.page_total : 0;
|
...
|
...
|
@@ -568,7 +626,10 @@ export function getRedBrandDecorator() { |
|
|
if (rooms) {
|
|
|
dispatch(getVideoLiveCount(rooms));
|
|
|
}
|
|
|
console.log('---->>>>>floor');
|
|
|
console.log(payload);
|
|
|
dispatch(getProduct(payload));
|
|
|
|
|
|
dispatch(getRedBrandDecoratorSuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
...
|
...
|
@@ -626,6 +687,60 @@ export function productFailure(error) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function appRecommendProduct(dataSource) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, redBrand} = getState();
|
|
|
|
|
|
let {shopId} = redBrand;
|
|
|
let channel = app.channel;
|
|
|
let {shopBanner,json} = dataSource;
|
|
|
let originJson = json;
|
|
|
let list = originJson.modules;
|
|
|
let moduleData = [];
|
|
|
list.map((item, i) => {
|
|
|
if (item.module_type == 'AppRecommendProduct') {
|
|
|
moduleData = item.module_data.data[0];
|
|
|
if (item.module_data.properties.displayType == 1) {
|
|
|
let sknList = moduleData.sknList;
|
|
|
let SKNs = '';
|
|
|
sknList.map((item, i) => {
|
|
|
if (i == 0) {
|
|
|
SKNs = item;
|
|
|
}else {
|
|
|
SKNs = SKNs + ',' + item;
|
|
|
}
|
|
|
});
|
|
|
return new RedBrandService(app.host).searchProductBySkn(SKNs)
|
|
|
.then(json => {
|
|
|
let product_list = json.product_list;
|
|
|
console.log('----<<<<<<<<product_list');
|
|
|
console.log(product_list);
|
|
|
item.list = product_list;
|
|
|
dispatch(productSuccess(dataSource));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
});
|
|
|
}else if (item.module_data.properties.displayType == 0) {
|
|
|
let pageSize = 2 * moduleData.lineNumber;
|
|
|
let order = moduleData.order;
|
|
|
|
|
|
return new RedBrandService(app.host).productList(shopId, channel, order, 1, pageSize)
|
|
|
.then(json => {
|
|
|
let product_list = json.product_list;
|
|
|
console.log('----------111111');
|
|
|
console.log(product_list);
|
|
|
item.list = product_list;
|
|
|
dispatch(productSuccess(dataSource));
|
|
|
|
|
|
})
|
|
|
.catch(error => {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getProduct(dataSource) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, redBrand} = getState();
|
...
|
...
|
@@ -633,6 +748,10 @@ export function getProduct(dataSource) { |
|
|
let originJson = json;
|
|
|
let list = originJson.modules;
|
|
|
let sknList = [];
|
|
|
|
|
|
console.log('----originJson');
|
|
|
console.log(originJson);
|
|
|
|
|
|
list.map((item, i) => {
|
|
|
if (item.module_type == 'SknList') {
|
|
|
sknList = item.module_data.data;
|
...
|
...
|
@@ -646,11 +765,17 @@ export function getProduct(dataSource) { |
|
|
SKNs = SKNs + ',' + item;
|
|
|
}
|
|
|
});
|
|
|
console.log(SKNs);
|
|
|
console.log('SKNs');
|
|
|
|
|
|
dispatch(productRequest());
|
|
|
return new RedBrandService(app.host).searchProductBySkn(SKNs)
|
|
|
.then(json => {
|
|
|
let product_list = json.product_list;
|
|
|
console.log(json);
|
|
|
console.log('json');
|
|
|
console.log(list);
|
|
|
|
|
|
list.map((item, i) => {
|
|
|
let data = item.module_data.data;
|
|
|
data.map((m, i) => {
|
...
|
...
|
@@ -665,9 +790,13 @@ export function getProduct(dataSource) { |
|
|
});
|
|
|
let payload = parseRource(originJson);
|
|
|
dispatch(productSuccess(payload));
|
|
|
dispatch(appRecommendProduct(payload));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(productFailure(error));
|
|
|
let payload = parseRource(originJson);
|
|
|
dispatch(appRecommendProduct(payload));
|
|
|
|
|
|
});
|
|
|
};
|
|
|
}
|
...
|
...
|
|