Authored by 孙凯

add 活动楼层多余10个 显示more按钮 review by hongmo

... ... @@ -47,6 +47,7 @@ export default class Outlet extends Component {
getOutletHomeResource = {this.props.getOutletHomeResource}
getOutletActivityList = {this.props.getOutletActivityList}
onPressProduct = {this.props.onPressProduct}
setActivityFliter = {this.props.setActivityFliter}
onPressFilter = {this.props.onPressFilter}
/>
);
... ...
... ... @@ -33,6 +33,7 @@ export default class OutletPageListView extends Component {
this.renderSectionHeader = this.renderSectionHeader.bind(this);
this.renderRow = this.renderRow.bind(this);
this._onRefresh = this._onRefresh.bind(this);
this.setActivityFliter = this.setActivityFliter.bind(this);
}
componentDidMount() {
... ... @@ -49,6 +50,14 @@ export default class OutletPageListView extends Component {
this.props.getOutletActivityList && this.props.getOutletActivityList(resource.get('content_code'));
}
setActivityFliter() {
let {
resource,
} = this.props;
this.props.setActivityFliter && this.props.setActivityFliter(resource.get('content_code'),true);
}
renderSectionHeader(sectionData, sectionID) {
if (sectionID == 'categoryNavigationList') {
let {
... ... @@ -89,6 +98,16 @@ export default class OutletPageListView extends Component {
}
}else if (sectionID == 'activityList') {
return(<ActivityCell resource={rowData} onPressProduct={this.props.onPressProduct}/>);
}else if (sectionID == 'activityMore') {
if (rowData == 'more') {
return(
<TouchableOpacity activeOpacity={1} style={{width: width,height: 50,backgroundColor: 'red'}} onPress={() => {this.setActivityFliter && this.setActivityFliter();}}>
<View style={{width: width,height: 50,backgroundColor: 'red'}}>
<Text>more</Text>
</View>
</TouchableOpacity>
);
}
}else if (sectionID == 'categoryNavigationList') {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
... ... @@ -117,17 +136,23 @@ export default class OutletPageListView extends Component {
let isFetching = resource.get('isFetching')?resource.get('isFetching'):false;
let honeResource = resource.get('honeResource');
let activityList = resource.get('activityList');
let activityList = resource.get('activityList')?resource.get('activityList').toArray():null;
let activityMore = resource.get('activityMore');
let categoryNavigationList = resource.get('categoryNavigationList')?resource.get('categoryNavigationList').toArray():null;
let productObj = categoryNavigationList?categoryNavigationList[0].get('list'):null;
let productList = productObj?productObj.get('product_list'):null;
let error = resource.get('error');
let ptr = resource.get('ptr')==true ? true : false;
let list = list = honeResource?honeResource.get('list'):null;
let activityListNum = activityList?activityList.length:0;
if (!activityMore) {
activityList = activityList?activityList.slice(0,10):null;
}
let dataSource = {
outletHomeReource: list?list.toArray():[],
activityList: activityList?activityList.toArray():[],
activityList: activityList?activityList:[],
activityMore: (!activityMore && activityListNum>10)?['more']:[],
categoryNavigationList: productList?productList.toArray():[],
};
... ...
... ... @@ -8,6 +8,8 @@ export default keyMirror({
SET_SERVICE_HOST: null,
SET_CATEGORYID: null,
SET_ACTIVITY_FLITER: null,
GET_CATEGORY_REQUEST: null,
GET_CATEGORY_SUCCESS: null,
GET_CATEGORY_FAILURE: null,
... ...
... ... @@ -44,6 +44,7 @@ class OutletContainer extends Component {
this._onPressProduct = this._onPressProduct.bind(this);
this._onPressFilter = this._onPressFilter.bind(this);
this._getOutletActivityList = this._getOutletActivityList.bind(this);
this._setActivityFliter = this._setActivityFliter.bind(this);
}
componentDidMount() {
... ... @@ -62,6 +63,9 @@ class OutletContainer extends Component {
this.props.actions.getOutletActivityList(content_code);
}
_setActivityFliter(content_code,activityMore) {
this.props.actions.setActivityFliter(content_code,activityMore);
}
_onPressProduct(url){
console.log('_onPressProduct = '+url);
... ... @@ -82,6 +86,7 @@ class OutletContainer extends Component {
<Outlet
categoryList = {categoryList}
getOutletHomeResource = {this._getOutletHomeResource}
setActivityFliter = {this._setActivityFliter}
getOutletActivityList = {this._getOutletActivityList}
onPressProduct = {this._onPressProduct}
onPressFilter = {this._onPressFilter}
... ...
... ... @@ -8,6 +8,8 @@ import {GetQueryString} from '../../utils/ResourceParser';
const {
SET_PLATFORM,
SET_ACTIVITY_FLITER,
GET_CATEGORY_REQUEST,
GET_CATEGORY_SUCCESS,
GET_CATEGORY_FAILURE,
... ... @@ -212,3 +214,11 @@ export function getOutletActivityList(content_code) {
});
};
}
export function setActivityFliter(content_code,activityMore) {
return {
type: SET_ACTIVITY_FLITER,
payload: {'activityMore':activityMore,'content_code':content_code}
};
}
... ...
... ... @@ -4,6 +4,7 @@ import InitialState from './outletInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_ACTIVITY_FLITER,
GET_CATEGORY_REQUEST,
GET_CATEGORY_SUCCESS,
... ... @@ -164,6 +165,7 @@ export default function outletReducer(state=initialState, action) {
let content_code0 = item.content_code;
if (content_code1 == content_code0) {
item.activityList = action.payload.json;
item.activityMore = false;
}
})
return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
... ... @@ -171,6 +173,17 @@ export default function outletReducer(state=initialState, action) {
case GET_OUTLET_ACTIVITY_LIST_FAILURE: {
}
case SET_ACTIVITY_FLITER: {
let categoryList = state.categoryList.toJS();
let content_code1 = action.payload.content_code;
categoryList.list.map((item, i) => {
let content_code0 = item.content_code;
if (content_code1 == content_code0) {
item.activityMore = action.payload.activityMore;
}
})
return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
}
}
return state;
... ...