...
|
...
|
@@ -29,6 +29,19 @@ const { |
|
|
GETBRANDRESOURCE_FOR_BOY_SUCCESS,
|
|
|
GETBRANDRESOURCE_FOR_BOY_FAILURE,
|
|
|
|
|
|
GETBRANDRESOURCE_FOR_GIRL_REQUEST,
|
|
|
GETBRANDRESOURCE_FOR_GIRL_SUCCESS,
|
|
|
GETBRANDRESOURCE_FOR_GIRL_FAILURE,
|
|
|
|
|
|
GETBRANDRESOURCE_FOR_KID_REQUEST,
|
|
|
GETBRANDRESOURCE_FOR_KID_SUCCESS,
|
|
|
GETBRANDRESOURCE_FOR_KID_FAILURE,
|
|
|
|
|
|
GETBRANDRESOURCE_FOR_LIFESTYLE_REQUEST,
|
|
|
GETBRANDRESOURCE_FOR_LIFESTYLE_SUCCESS,
|
|
|
GETBRANDRESOURCE_FOR_LIFESTYLE_FAILURE,
|
|
|
|
|
|
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
|
...
|
...
|
@@ -184,47 +197,137 @@ export function getBrandResourceForBoyFailure(error) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function getBrandResourceForGirlRequest() {
|
|
|
return {
|
|
|
type: GETBRANDRESOURCE_FOR_GIRL_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getBrandResourceForGirlSuccess(json) {
|
|
|
return {
|
|
|
type: GETBRANDRESOURCE_FOR_GIRL_SUCCESS,
|
|
|
payload: json
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function getBrandResourceForGirlFailure(error) {
|
|
|
return {
|
|
|
type: GETBRANDRESOURCE_FOR_GIRL_FAILURE,
|
|
|
payload: error
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function getBrandResourceForKidRequest() {
|
|
|
return {
|
|
|
type: GETBRANDRESOURCE_FOR_KID_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getBrandResourceForKidSuccess(json) {
|
|
|
return {
|
|
|
type: GETBRANDRESOURCE_FOR_KID_SUCCESS,
|
|
|
payload: json
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function getBrandResourceForKidFailure(error) {
|
|
|
return {
|
|
|
type: GETBRANDRESOURCE_FOR_KID_FAILURE,
|
|
|
payload: error
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function getBrandResourceForLifeStyleRequest() {
|
|
|
return {
|
|
|
type: GETBRANDRESOURCE_FOR_LIFESTYLE_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getBrandResourceForLifeStyleSuccess(json) {
|
|
|
return {
|
|
|
type: GETBRANDRESOURCE_FOR_LIFESTYLE_SUCCESS,
|
|
|
payload: json
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function getBrandResourceForLifeStyleFailure(error) {
|
|
|
return {
|
|
|
type: GETBRANDRESOURCE_FOR_LIFESTYLE_FAILURE,
|
|
|
payload: error
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function getBrandResource(channel) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, classify} = getState();
|
|
|
dispatch(getBrandResourceForBoyRequest());
|
|
|
return new BrandService(app.serviceHost).getBrandResource()
|
|
|
let content_code;
|
|
|
if (channel == 0) {
|
|
|
dispatch(getBrandResourceForBoyRequest());
|
|
|
content_code = 'ce6ac059493ec26241a8cbe0bfa1b17a';
|
|
|
}else if (channel == 1) {
|
|
|
dispatch(getBrandResourceForGirlRequest());
|
|
|
content_code = 'dac99cdedc1f948e84c145aca561f7d2';
|
|
|
}else if (channel == 2) {
|
|
|
dispatch(getBrandResourceForKidRequest());
|
|
|
content_code = '713784f93f52bb1a7b93916b2bb15510';
|
|
|
}else if (channel == 3) {
|
|
|
dispatch(getBrandResourceForLifeStyleRequest());
|
|
|
content_code = 'f1aa914fd23cbcda71a87de6f5416c75';
|
|
|
}
|
|
|
|
|
|
return new BrandService(app.serviceHost).getBrandResource(content_code)
|
|
|
.then(json => {
|
|
|
let payload = parseResourceResources(json);
|
|
|
dispatch(getBrandResourceForBoySuccess(payload));
|
|
|
if (channel == 0) {
|
|
|
dispatch(getBrandResourceForBoySuccess(payload));
|
|
|
}else if (channel == 1) {
|
|
|
dispatch(getBrandResourceForGirlSuccess(payload));
|
|
|
}else if (channel == 2) {
|
|
|
dispatch(getBrandResourceForKidSuccess(payload));
|
|
|
}else if (channel == 3) {
|
|
|
dispatch(getBrandResourceForLifeStyleSuccess(payload));
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(getBrandResourceForBoyFailure(error));
|
|
|
if (channel == 0) {
|
|
|
dispatch(getBrandResourceForBoyFailure(error));
|
|
|
}else if (channel == 1) {
|
|
|
dispatch(getBrandResourceForGirlFailure(error));
|
|
|
}else if (channel == 2) {
|
|
|
dispatch(getBrandResourceForKidFailure(error));
|
|
|
}else if (channel == 3) {
|
|
|
dispatch(getBrandResourceForLifeStyleFailure(error));
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function parseResourceResources(json) {
|
|
|
|
|
|
let bannerForBoy = [];
|
|
|
let custom_brandsForBoy = [];
|
|
|
let brandsTextForBoy = [];
|
|
|
let banner = [];
|
|
|
let custom_brands = [];
|
|
|
let brandsText = [];
|
|
|
|
|
|
brandsTextForBoy.push({key: 'default',name: '全部品牌'});
|
|
|
brandsText.push({key: 'default',name: '全部品牌'});
|
|
|
|
|
|
for (var i = 0; i < json.length; i++) {
|
|
|
if (json[i].template_name == 'focus') {
|
|
|
bannerForBoy = json[i];
|
|
|
banner = json[i];
|
|
|
}
|
|
|
if (json[i].template_name == 'custom_brands') {
|
|
|
custom_brandsForBoy = json[i];
|
|
|
custom_brands = json[i];
|
|
|
}
|
|
|
if (json[i].template_name == 'text') {
|
|
|
let data = json[i].data;
|
|
|
let template_id = json[i].template_id;
|
|
|
let text = data.text;
|
|
|
brandsTextForBoy.push({key: template_id,name: text});
|
|
|
brandsText.push({key: template_id,name: text});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
bannerForBoy,
|
|
|
custom_brandsForBoy,
|
|
|
brandsTextForBoy,
|
|
|
banner,
|
|
|
custom_brands,
|
|
|
brandsText,
|
|
|
};
|
|
|
} |
...
|
...
|
|