Authored by 孙凯

添加 奥莱 频道切换 review by zhanglixia

... ... @@ -34,9 +34,12 @@ export default class Outlet extends Component {
let list = categoryList.get('list').toArray();
let isFetching = categoryList.get('isFetching');
let initialPage = categoryList.get('initialPage');
return (
<View style={styles.container}>
{!isFetching?<ScrollableTabView
initialPage={initialPage}
renderTabBar={() => <OutletSrollableBar />}
>
{list.map((item, i) => {
... ...
... ... @@ -5,6 +5,7 @@ export default keyMirror({
SET_PLATFORM: null,
SET_HOST: null,
SET_CHANNEL: null,
SET_YH_CHANNEL: null,
SET_SERVICE_HOST: null,
SET_CATEGORYID: null,
HIDE_TOAST: null,
... ...
... ... @@ -49,6 +49,13 @@ class OutletContainer extends Component {
this._setActivityFliter = this._setActivityFliter.bind(this);
this._showToast = this._showToast.bind(this);
this._hideToastMessage = this._hideToastMessage.bind(this);
this._onSelectChannel = this._onSelectChannel.bind(this);
this.subscription = NativeAppEventEmitter.addListener(
'ChannelDidChangeEvent',
(reminder) => {
this._onSelectChannel(reminder.channel);
}
);
}
componentDidMount() {
... ... @@ -56,7 +63,11 @@ class OutletContainer extends Component {
}
componentWillUnmount() {
this.subscription && this.subscription.remove();
}
_onSelectChannel(channel){
this.props.actions.setChannel(channel);
}
_onEndReached(content_code,categoryNavigationItem) {
... ...
... ... @@ -9,7 +9,7 @@ const {
SET_PLATFORM,
SET_ACTIVITY_FLITER,
SET_YH_CHANNEL,
SET_FLITER,
SHOW_TOAST,
HIDE_TOAST,
... ... @@ -38,6 +38,13 @@ export function onPressCoupon() {
};
}
export function setChannel(channel) {
return {
type: SET_YH_CHANNEL,
payload: channel
};
}
export function getCategoryRequest() {
return {
type: GET_CATEGORY_REQUEST,
... ... @@ -62,10 +69,11 @@ export function getCategory() {
return (dispatch, getState) => {
let {app, outlet} = getState();
let parent_id = app.categoryId;
let channel = outlet.channel;
dispatch(getCategoryRequest());
return new OutletService(app.serviceHost).getCategory(parent_id)
.then(json => {
let params = parseListFromCategory(json);
let params = parseListFromCategory(channel,json);
dispatch(getCategorySuccess(params));
})
.catch(error => {
... ... @@ -74,8 +82,8 @@ export function getCategory() {
};
}
function parseListFromCategory(json) {
function parseListFromCategory(channel,json) {
let initialPage = 0;
json.map((item, i) => {
let url = item.sort_url;
let content_code = GetQueryString(url,'content_code');
... ... @@ -87,8 +95,15 @@ function parseListFromCategory(json) {
item.content_code = content_code;
item.type = type?type:0;
item.yh_channel=yh_channel?yh_channel:0;
if (yh_channel == channel) {
initialPage = i;
}
})
return json;
return {
json,
initialPage,
};
}
export function getOutletHomeResourceRequest(content_code) {
... ...
... ... @@ -7,10 +7,12 @@ let InitialState = Record({
categoryList: new (Record({
isFetching: false,
error: null,
initialPage: 0,
list: List(),
})),
isShowToast: false,
toastMessage: '',
channel: 1, // 1 - boy, 2 - girl, 3 - kid, 4 - lifestyle, 5 - yoho
});
export default InitialState;
... ...
... ... @@ -8,6 +8,7 @@ const {
SET_FLITER,
SHOW_TOAST,
HIDE_TOAST,
SET_YH_CHANNEL,
GET_CATEGORY_REQUEST,
GET_CATEGORY_SUCCESS,
GET_CATEGORY_FAILURE,
... ... @@ -30,13 +31,16 @@ const initialState = new InitialState;
export default function outletReducer(state=initialState, action) {
switch(action.type) {
case SET_YH_CHANNEL: {
return state.set('channel', action.payload);
}
case GET_CATEGORY_REQUEST: {
return state.setIn(['categoryList', 'isFetching'], true);
}
case GET_CATEGORY_SUCCESS: {
return state.setIn(['categoryList', 'list'], Immutable.fromJS(action.payload))
.setIn(['categoryList', 'isFetching'], false);
return state.setIn(['categoryList', 'list'], Immutable.fromJS(action.payload.json))
.setIn(['categoryList', 'isFetching'], false)
.setIn(['categoryList', 'initialPage'], action.payload.initialPage);
}
case GET_CATEGORY_FAILURE: {
return state.setIn(['categoryList', 'isFetching'], false)
... ...