...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
|
|
|
import ReactNative from 'react-native';
|
|
|
import CategoryService from '../../services/CategoryService';
|
|
|
|
|
|
import Immutable, {Map} from 'immutable';
|
|
|
const {
|
|
|
SET_TYPE,
|
|
|
|
...
|
...
|
@@ -23,7 +23,8 @@ export function getCategory() { |
|
|
dispatch(getCategoryRequest());
|
|
|
return new CategoryService(app.host).getCategoryList('0')
|
|
|
.then(json => {
|
|
|
dispatch(getCategorySuccess(json));
|
|
|
let payload=parseCategoryList(json);
|
|
|
dispatch(getCategorySuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(getCategoryFailure(error));
|
...
|
...
|
@@ -31,6 +32,140 @@ export function getCategory() { |
|
|
};
|
|
|
}
|
|
|
|
|
|
function parseCategoryList(json) {
|
|
|
if(!json){
|
|
|
return;
|
|
|
}
|
|
|
let boy = json && json.boy ? json.boy : [];
|
|
|
let girl = json && json.girl ? json.girl : [];
|
|
|
let kids = json && json.kids ? json.kids : [];
|
|
|
let lifestyle = json && json.lifestyle ? json.lifestyle : [];
|
|
|
|
|
|
let newBoy=[];
|
|
|
let newGirl=[];
|
|
|
let newKids=[];
|
|
|
let newLifestyle=[];
|
|
|
|
|
|
//男
|
|
|
// for (let i in boy)
|
|
|
boy.map((item, i) => {
|
|
|
// let item=boy[i];
|
|
|
let newBoySub=[];
|
|
|
let all={
|
|
|
category_name: '全部'+item.category_name,
|
|
|
category_id: item.category_id,
|
|
|
parent_id: item.parent_id,
|
|
|
relation_parameter:item.relation_parameter,
|
|
|
node_count:item.node_count,
|
|
|
};
|
|
|
if(item.sub){
|
|
|
newBoySub=[all,...item.sub];
|
|
|
}else{
|
|
|
newBoySub.push(all);
|
|
|
}
|
|
|
|
|
|
newBoy.push({
|
|
|
sub:newBoySub,
|
|
|
category_name:item.category_name,
|
|
|
category_id:item.category_id,
|
|
|
parent_id:item.parent_id,
|
|
|
relation_parameter:item.relation_parameter,
|
|
|
sort_ico:item.sort_ico,
|
|
|
node_count:item.node_count,
|
|
|
});
|
|
|
});
|
|
|
//女
|
|
|
girl.map((item, i) => {
|
|
|
let newGirlSub=[];
|
|
|
let all={
|
|
|
category_name: '全部'+item.category_name,
|
|
|
category_id: item.category_id,
|
|
|
parent_id: item.parent_id,
|
|
|
relation_parameter:item.relation_parameter,
|
|
|
node_count:item.node_count,
|
|
|
};
|
|
|
|
|
|
if(item.sub){
|
|
|
newGirlSub=[all,...item.sub];
|
|
|
}else{
|
|
|
newGirlSub.push(all);
|
|
|
}
|
|
|
|
|
|
newGirl.push({
|
|
|
sub:newGirlSub,
|
|
|
category_name:item.category_name,
|
|
|
category_id:item.category_id,
|
|
|
parent_id:item.parent_id,
|
|
|
relation_parameter:item.relation_parameter,
|
|
|
sort_ico:item.sort_ico,
|
|
|
node_count:item.node_count,
|
|
|
});
|
|
|
});
|
|
|
|
|
|
//kid
|
|
|
kids.map((item, i) => {
|
|
|
let newKidsSub=[];
|
|
|
let all={
|
|
|
category_name: '全部'+item.category_name,
|
|
|
category_id: item.category_id,
|
|
|
parent_id: item.parent_id,
|
|
|
relation_parameter:item.relation_parameter,
|
|
|
node_count:item.node_count,
|
|
|
};
|
|
|
|
|
|
if(item.sub){
|
|
|
newKidsSub=[all,...item.sub];
|
|
|
}else{
|
|
|
newKidsSub.push(all);
|
|
|
}
|
|
|
|
|
|
newKids.push({
|
|
|
sub:newKidsSub,
|
|
|
category_name:item.category_name,
|
|
|
category_id:item.category_id,
|
|
|
parent_id:item.parent_id,
|
|
|
relation_parameter:item.relation_parameter,
|
|
|
sort_ico:item.sort_ico,
|
|
|
node_count:item.node_count,
|
|
|
});
|
|
|
});
|
|
|
|
|
|
//家居
|
|
|
lifestyle.map((item, i) => {
|
|
|
let newLifestyleSub=[];
|
|
|
let all={
|
|
|
category_name: '全部'+item.category_name,
|
|
|
category_id: item.category_id,
|
|
|
parent_id: item.parent_id,
|
|
|
relation_parameter:item.relation_parameter,
|
|
|
node_count:item.node_count,
|
|
|
};
|
|
|
if(item.sub){
|
|
|
newLifestyleSub=[all,...item.sub];
|
|
|
|
|
|
}else{
|
|
|
newLifestyleSub.push(all);
|
|
|
}
|
|
|
|
|
|
newLifestyle.push({
|
|
|
sub:newLifestyleSub,
|
|
|
category_name:item.category_name,
|
|
|
category_id:item.category_id,
|
|
|
parent_id:item.parent_id,
|
|
|
relation_parameter:item.relation_parameter,
|
|
|
sort_ico:item.sort_ico,
|
|
|
node_count:item.node_count,
|
|
|
});
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
boy:newBoy,
|
|
|
girl:newGirl,
|
|
|
kids:newKids,
|
|
|
lifestyle:newLifestyle,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getCategoryRequest() {
|
|
|
return {
|
|
|
type: GET_CATEGORY_REQUEST,
|
...
|
...
|
|