Authored by chenl

更改了品牌B版接口调用地址。review by yuliang。

... ... @@ -32,6 +32,7 @@ import {
setPlatform,
setHost,
setServiceHost,
setABVersion,
} from './reducers/app/appActions';
import {
... ... @@ -81,6 +82,7 @@ export default function native(platform) {
store.dispatch(setPlatform(platform));
store.dispatch(setHost(this.props.host));
store.dispatch(setServiceHost(this.props.serviceHost));
store.dispatch(setABVersion(this.props.abversion));
if (this.props.type == 0) {
if (this.props.channelId == '1') {
... ...
... ... @@ -5,6 +5,7 @@ export default keyMirror({
SET_PLATFORM: null,
SET_HOST: null,
SET_SERVICE_HOST: null,
SET_AB_VERSION: null,
SET_CHANNEL: null,
SET_TYPE: null,
SET_INITIALLISTSIZE: null,
... ...
... ... @@ -7,6 +7,7 @@ const {
SET_CHANNEL,
SET_HOST,
SET_SERVICE_HOST,
SET_AB_VERSION,
} = require('../../constants/actionTypes').default;
export function setPlatform(platform) {
... ... @@ -35,4 +36,11 @@ export function setServiceHost(host) {
type: SET_SERVICE_HOST,
payload: host
};
}
export function setABVersion(version) {
return {
type: SET_AB_VERSION,
payload: version
};
}
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@ let InitialState = Record({
channel: 1, // 1 - boy, 2 - girl, 3 - kid, 4 - lifestyle, 5 - yoho
host: 'http://api.yoho.cn',
serviceHost: 'http://service.yoho.cn',
abversion: 'A', //A,B
});
export default InitialState;
... ...
... ... @@ -7,6 +7,7 @@ const {
SET_CHANNEL,
SET_HOST,
SET_SERVICE_HOST,
SET_AB_VERSION,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -23,6 +24,8 @@ export default function appReducer(state = initialState, action) {
return state.set('host', action.payload);
case SET_SERVICE_HOST:
return state.set('serviceHost', action.payload);
case SET_AB_VERSION:
return state.set('abversion', action.payload);
}
return state;
... ...
... ... @@ -344,32 +344,64 @@ export function getBrandResource(channel) {
content_code = 'f1aa914fd23cbcda71a87de6f5416c75';
}
return new BrandService(app.serviceHost).getBrandResource(channel, content_code)
.then(json => {
let payload = parseResourceResources(json);
if (channel == 1) {
dispatch(getBrandResourceForBoySuccess(payload));
}else if (channel == 2) {
dispatch(getBrandResourceForGirlSuccess(payload));
}else if (channel == 3) {
dispatch(getBrandResourceForKidSuccess(payload));
}else if (channel == 4) {
dispatch(getBrandResourceForLifeStyleSuccess(payload));
}
//区分ab版本
let abversion = app.abversion;
if(abversion == "B"){
return new BrandService(app.host).getBrandResourceB(channel, content_code)
.then(json => {
let payload = parseResourceResources(json);
if (channel == 1) {
dispatch(getBrandResourceForBoySuccess(payload));
}else if (channel == 2) {
dispatch(getBrandResourceForGirlSuccess(payload));
}else if (channel == 3) {
dispatch(getBrandResourceForKidSuccess(payload));
}else if (channel == 4) {
dispatch(getBrandResourceForLifeStyleSuccess(payload));
}
dispatch(resourceDataExposure(json));
})
.catch(error => {
if (channel == 1) {
dispatch(getBrandResourceForBoyFailure(error));
}else if (channel == 2) {
dispatch(getBrandResourceForGirlFailure(error));
}else if (channel == 3) {
dispatch(getBrandResourceForKidFailure(error));
}else if (channel == 4) {
dispatch(getBrandResourceForLifeStyleFailure(error));
}
});
dispatch(resourceDataExposure(json));
})
.catch(error => {
if (channel == 1) {
dispatch(getBrandResourceForBoyFailure(error));
}else if (channel == 2) {
dispatch(getBrandResourceForGirlFailure(error));
}else if (channel == 3) {
dispatch(getBrandResourceForKidFailure(error));
}else if (channel == 4) {
dispatch(getBrandResourceForLifeStyleFailure(error));
}
});
}
else{
return new BrandService(app.serviceHost).getBrandResource(channel, content_code)
.then(json => {
let payload = parseResourceResources(json);
if (channel == 1) {
dispatch(getBrandResourceForBoySuccess(payload));
}else if (channel == 2) {
dispatch(getBrandResourceForGirlSuccess(payload));
}else if (channel == 3) {
dispatch(getBrandResourceForKidSuccess(payload));
}else if (channel == 4) {
dispatch(getBrandResourceForLifeStyleSuccess(payload));
}
dispatch(resourceDataExposure(json));
})
.catch(error => {
if (channel == 1) {
dispatch(getBrandResourceForBoyFailure(error));
}else if (channel == 2) {
dispatch(getBrandResourceForGirlFailure(error));
}else if (channel == 3) {
dispatch(getBrandResourceForKidFailure(error));
}else if (channel == 4) {
dispatch(getBrandResourceForLifeStyleFailure(error));
}
});
}
};
}
... ...
... ... @@ -91,8 +91,6 @@ export function pressCategoryBMore(category_id){
node_count: category ? category.get('node_count') : 0,
};
console.log("chenlin", JSON.stringify(all));
//设置当前的类别信息
dispatch(setCurrentCateB(category_id, category.get('category_name')));
dispatch(jumpToCategory(all, 0, categoryB.currentChannelId));
... ...
... ... @@ -29,7 +29,26 @@ export default class BrandService {
});
}
async getBrandResource(channel_id, content_code,fromPage='iFP_Brand'){
async getBrandResourceB(channel_id, content_code, fromPage='iFP_Brand'){
return await this.api.get({
url: '',
body: {
method: 'app.brand.fromBigData',
channel_id,
content_code,
fromPage,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async getBrandResource(channel_id, content_code, fromPage='iFP_Brand'){
return await this.api.get({
url: '/operations/api/v5/resource/get',
body: {
... ...