Authored by 孙凯

add channel 接口 review by zhanglixia

... ... @@ -47,6 +47,7 @@ export default class Brand extends Component {
renderHeader(){
let data = this.props.reourceForBoy;
let brandFliter = this.props.brandFliter;
let bannerForBoy = data.get('bannerForBoy');
let custom_brandsForBoy = data.get('custom_brandsForBoy');
let brandsTextForBoy = data.get('brandsTextForBoy');
... ... @@ -55,7 +56,7 @@ export default class Brand extends Component {
<View style={styles.header}>
{bannerForBoy?<BrandSwiper resource={bannerForBoy} onPressSlideItem={this.props.onPressSlideItem}/>:null}
{custom_brandsForBoy?<BannerReourceList resource={custom_brandsForBoy} onPressSlideItem={this.props.onPressSlideItem}/>:null}
<BrandFliter dataSource={brandsTextForBoy} selectID={0} onPressFilter={this.props.onPressFilter}/>
<BrandFliter dataSource={brandsTextForBoy} selectID={brandFliter} onPressFilter={this.props.onPressFilter}/>
</View>
);
}
... ... @@ -84,28 +85,43 @@ export default class Brand extends Component {
let {
brandFliter,
channelFliter,
brandListForBoy,
brandListForGirl,
brandListForKid,
brandListForLifeStyle,
reourceForBoy,
} = this.props;
let data = brandListForBoy.toJS();
let data;
console.log('a');
if (channelFliter == 0) {
data = brandListForBoy?brandListForBoy.toJS():null;
}else if (channelFliter == 1) {
data = brandListForGirl?brandListForGirl.toJS():null;
}else if (channelFliter == 2) {
data = brandListForKid?brandListForKid.toJS():null;
}else if (channelFliter == 3) {
data = brandListForLifeStyle?brandListForLifeStyle.toJS():null;
}
let list;
let listDataSource;
let contentContainerStyle;
let renderSectionHeader = null;
if (brandFliter == 0) {
list = data.all_list;
listDataSource = this.dataSource.cloneWithRowsAndSections(list);
list = data?data.all_list:null;
listDataSource = list?this.dataSource.cloneWithRowsAndSections(list):null;
contentContainerStyle = styles.contentContainerOne;
renderSectionHeader = this.renderSectionHeader;
}else if (brandFliter == 1) {
list = data.new_list;
listDataSource = this.dataSource.cloneWithRows(list);
list = data?data.new_list:null;
listDataSource = list?this.dataSource.cloneWithRows(list):null;
contentContainerStyle = styles.contentContainerTwo;
}else if (brandFliter == 2) {
list = data.hot_list;
listDataSource = this.dataSource.cloneWithRows(list);
list = data?data.hot_list:null;
listDataSource = list?this.dataSource.cloneWithRows(list):null;
contentContainerStyle = styles.contentContainerTwo;
}
... ... @@ -115,7 +131,7 @@ export default class Brand extends Component {
return (
<View style={styles.container}>
<ChannelFliter selectID={0} onChannelPressFliter={this.props.onChannelPressFliter}/>
<ChannelFliter selectID={channelFliter} onChannelPressFliter={this.props.onChannelPressFliter}/>
<ListView
contentContainerStyle={contentContainerStyle}
enableEmptySections={true}
... ...
... ... @@ -31,6 +31,18 @@ export default keyMirror({
GETBRANDLIST_FOR_BOY_SUCCESS: null,
GETBRANDLIST_FOR_BOY_FAILURE: null,
GETBRANDLIST_FOR_GIRL_REQUEST: null,
GETBRANDLIST_FOR_GIRL_SUCCESS: null,
GETBRANDLIST_FOR_GIRL_FAILURE: null,
GETBRANDLIST_FOR_KID_REQUEST: null,
GETBRANDLIST_FOR_KID_SUCCESS: null,
GETBRANDLIST_FOR_KID_FAILURE: null,
GETBRANDLIST_FOR_LIFESTYLE_REQUEST: null,
GETBRANDLIST_FOR_LIFESTYLE_SUCCESS: null,
GETBRANDLIST_FOR_LIFESTYLE_FAILURE: null,
GETBRANDRESOURCE_FOR_BOY_REQUEST: null,
GETBRANDRESOURCE_FOR_BOY_SUCCESS: null,
GETBRANDRESOURCE_FOR_BOY_FAILURE: null,
... ...
... ... @@ -54,8 +54,8 @@ class BrandContainer extends Component {
}
componentDidMount() {
this.props.actions.getBrandListForBoy();
this.props.actions.getBrandResourceForBoy();
this.props.actions.getBrandList(0);
this.props.actions.getBrandResource(0);
}
componentWillUnmount() {
... ... @@ -71,6 +71,7 @@ class BrandContainer extends Component {
}
_onChannelPressFliter(value){
this.props.actions.getBrandList(value);
this.props.actions.setChannelFilter(value);
}
... ... @@ -79,6 +80,9 @@ class BrandContainer extends Component {
channelFliter,
brandFliter,
brandListForBoy,
brandListForGirl,
brandListForKid,
brandListForLifeStyle,
reourceForBoy,
} = this.props.brand;
return (
... ... @@ -87,6 +91,9 @@ class BrandContainer extends Component {
channelFliter= {channelFliter}
brandFliter= {brandFliter}
brandListForBoy= {brandListForBoy}
brandListForGirl= {brandListForGirl}
brandListForKid= {brandListForKid}
brandListForLifeStyle= {brandListForLifeStyle}
reourceForBoy= {reourceForBoy}
onPressFilter= {this._onPressFilter}
onPressSlideItem= {this._onPressSlideItem}
... ...
... ... @@ -13,6 +13,18 @@ const {
GETBRANDLIST_FOR_BOY_SUCCESS,
GETBRANDLIST_FOR_BOY_FAILURE,
GETBRANDLIST_FOR_GIRL_REQUEST,
GETBRANDLIST_FOR_GIRL_SUCCESS,
GETBRANDLIST_FOR_GIRL_FAILURE,
GETBRANDLIST_FOR_KID_REQUEST,
GETBRANDLIST_FOR_KID_SUCCESS,
GETBRANDLIST_FOR_KID_FAILURE,
GETBRANDLIST_FOR_LIFESTYLE_REQUEST,
GETBRANDLIST_FOR_LIFESTYLE_SUCCESS,
GETBRANDLIST_FOR_LIFESTYLE_FAILURE,
GETBRANDRESOURCE_FOR_BOY_REQUEST,
GETBRANDRESOURCE_FOR_BOY_SUCCESS,
GETBRANDRESOURCE_FOR_BOY_FAILURE,
... ... @@ -54,16 +66,100 @@ export function getBrandListForBoyFailure(error) {
}
}
export function getBrandListForBoy() {
export function getBrandListForGirlRequest() {
return {
type: GETBRANDLIST_FOR_GIRL_REQUEST,
};
}
export function getBrandListForGirlSuccess(json) {
return {
type: GETBRANDLIST_FOR_GIRL_SUCCESS,
payload: json
}
}
export function getBrandListForGirlFailure(error) {
return {
type: GETBRANDLIST_FOR_GIRL_FAILURE,
payload: error
}
}
export function getBrandListForKidRequest() {
return {
type: GETBRANDLIST_FOR_KID_REQUEST,
};
}
export function getBrandListForKidSuccess(json) {
return {
type: GETBRANDLIST_FOR_KID_SUCCESS,
payload: json
}
}
export function getBrandListForKidFailure(error) {
return {
type: GETBRANDLIST_FOR_KID_FAILURE,
payload: error
}
}
export function getBrandListForLifeStyleRequest() {
return {
type: GETBRANDLIST_FOR_LIFESTYLE_REQUEST,
};
}
export function getBrandListForLifeStyleSuccess(json) {
return {
type: GETBRANDLIST_FOR_LIFESTYLE_SUCCESS,
payload: json
}
}
export function getBrandListForLifeStyleFailure(error) {
return {
type: GETBRANDLIST_FOR_LIFESTYLE_FAILURE,
payload: error
}
}
export function getBrandList(channel) {
return (dispatch, getState) => {
let {app, classify} = getState();
dispatch(getBrandListForBoyRequest());
return new BrandService(app.host).getBrandList()
if (channel == 0) {
dispatch(getBrandListForBoyRequest());
}else if (channel == 1) {
dispatch(getBrandListForGirlRequest());
}else if (channel == 2) {
dispatch(getBrandListForKidRequest());
}else if (channel == 3) {
dispatch(getBrandListForLifeStyleRequest());
}
return new BrandService(app.host).getBrandList(channel)
.then(json => {
dispatch(getBrandListForBoySuccess(json));
if (channel == 0) {
dispatch(getBrandListForBoySuccess(json));
}else if (channel == 1) {
dispatch(getBrandListForGirlSuccess(json));
}else if (channel == 2) {
dispatch(getBrandListForKidSuccess(json));
}else if (channel == 3) {
dispatch(getBrandListForLifeStyleSuccess(json));
}
})
.catch(error => {
dispatch(getBrandListForBoyFailure(error));
if (channel == 0) {
dispatch(getBrandListForBoyFailure(error));
}else if (channel == 1) {
dispatch(getBrandListForGirlFailure(error));
}else if (channel == 2) {
dispatch(getBrandListForKidFailure(error));
}else if (channel == 3) {
dispatch(getBrandListForLifeStyleFailure(error));
}
});
};
}
... ... @@ -88,7 +184,7 @@ export function getBrandResourceForBoyFailure(error) {
}
}
export function getBrandResourceForBoy() {
export function getBrandResource(channel) {
return (dispatch, getState) => {
let {app, classify} = getState();
dispatch(getBrandResourceForBoyRequest());
... ...
... ... @@ -10,6 +10,21 @@ let InitialState = Record({
hot_list: List(),
new_list: List(),
})),
brandListForGirl: new (Record({
all_list: Map(),
hot_list: List(),
new_list: List(),
})),
brandListForKid: new (Record({
all_list: Map(),
hot_list: List(),
new_list: List(),
})),
brandListForLifeStyle: new (Record({
all_list: Map(),
hot_list: List(),
new_list: List(),
})),
reourceForBoy: new (Record({
bannerForBoy: Map(),
custom_brandsForBoy: Map(),
... ...
... ... @@ -13,6 +13,18 @@ const {
GETBRANDLIST_FOR_BOY_SUCCESS,
GETBRANDLIST_FOR_BOY_FAILURE,
GETBRANDLIST_FOR_GIRL_REQUEST,
GETBRANDLIST_FOR_GIRL_SUCCESS,
GETBRANDLIST_FOR_GIRL_FAILURE,
GETBRANDLIST_FOR_KID_REQUEST,
GETBRANDLIST_FOR_KID_SUCCESS,
GETBRANDLIST_FOR_KID_FAILURE,
GETBRANDLIST_FOR_LIFESTYLE_REQUEST,
GETBRANDLIST_FOR_LIFESTYLE_SUCCESS,
GETBRANDLIST_FOR_LIFESTYLE_FAILURE,
GETBRANDRESOURCE_FOR_BOY_REQUEST,
GETBRANDRESOURCE_FOR_BOY_SUCCESS,
GETBRANDRESOURCE_FOR_BOY_FAILURE,
... ... @@ -55,6 +67,66 @@ export default function brandReducer(state=initialState, action) {
{
return state;
}
case GETBRANDLIST_FOR_GIRL_REQUEST:
{
return state;
}
case GETBRANDLIST_FOR_GIRL_SUCCESS:
{
let {
all_list,
hot_list,
new_list,
} = action.payload;
return state.setIn(['brandListForGirl', 'all_list'], Immutable.fromJS(all_list))
.setIn(['brandListForGirl', 'hot_list'], Immutable.fromJS(hot_list))
.setIn(['brandListForGirl', 'new_list'], Immutable.fromJS(new_list));
}
case GETBRANDLIST_FOR_GIRL_FAILURE:
{
return state;
}
case GETBRANDLIST_FOR_KID_REQUEST:
{
return state;
}
case GETBRANDLIST_FOR_KID_SUCCESS:
{
let {
all_list,
hot_list,
new_list,
} = action.payload;
return state.setIn(['brandListForKid', 'all_list'], Immutable.fromJS(all_list))
.setIn(['brandListForKid', 'hot_list'], Immutable.fromJS(hot_list))
.setIn(['brandListForKid', 'new_list'], Immutable.fromJS(new_list));
}
case GETBRANDLIST_FOR_KID_FAILURE:
{
return state;
}
case GETBRANDLIST_FOR_LIFESTYLE_REQUEST:
{
return state;
}
case GETBRANDLIST_FOR_LIFESTYLE_SUCCESS:
{
let {
all_list,
hot_list,
new_list,
} = action.payload;
return state.setIn(['brandListForLifeStyle', 'all_list'], Immutable.fromJS(all_list))
.setIn(['brandListForLifeStyle', 'hot_list'], Immutable.fromJS(hot_list))
.setIn(['brandListForLifeStyle', 'new_list'], Immutable.fromJS(new_list));
}
case GETBRANDLIST_FOR_LIFESTYLE_FAILURE:
{
return state;
}
case GETBRANDRESOURCE_FOR_BOY_REQUEST:
{
return state;
... ...
... ... @@ -12,7 +12,7 @@ export default class BrandService {
this.api = new Request(baseURL);
}
async getBrandList(yh_channel=0, fromPage='iFP_Brand'){
async getBrandList(yh_channel, fromPage='iFP_Brand'){
return await this.api.post({
url: '',
body: {
... ...