Authored by 孙凯

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

@@ -47,6 +47,7 @@ export default class Outlet extends Component { @@ -47,6 +47,7 @@ export default class Outlet extends Component {
47 getOutletHomeResource = {this.props.getOutletHomeResource} 47 getOutletHomeResource = {this.props.getOutletHomeResource}
48 getOutletActivityList = {this.props.getOutletActivityList} 48 getOutletActivityList = {this.props.getOutletActivityList}
49 onPressProduct = {this.props.onPressProduct} 49 onPressProduct = {this.props.onPressProduct}
  50 + setActivityFliter = {this.props.setActivityFliter}
50 onPressFilter = {this.props.onPressFilter} 51 onPressFilter = {this.props.onPressFilter}
51 /> 52 />
52 ); 53 );
@@ -33,6 +33,7 @@ export default class OutletPageListView extends Component { @@ -33,6 +33,7 @@ export default class OutletPageListView extends Component {
33 this.renderSectionHeader = this.renderSectionHeader.bind(this); 33 this.renderSectionHeader = this.renderSectionHeader.bind(this);
34 this.renderRow = this.renderRow.bind(this); 34 this.renderRow = this.renderRow.bind(this);
35 this._onRefresh = this._onRefresh.bind(this); 35 this._onRefresh = this._onRefresh.bind(this);
  36 + this.setActivityFliter = this.setActivityFliter.bind(this);
36 } 37 }
37 38
38 componentDidMount() { 39 componentDidMount() {
@@ -49,6 +50,14 @@ export default class OutletPageListView extends Component { @@ -49,6 +50,14 @@ export default class OutletPageListView extends Component {
49 this.props.getOutletActivityList && this.props.getOutletActivityList(resource.get('content_code')); 50 this.props.getOutletActivityList && this.props.getOutletActivityList(resource.get('content_code'));
50 } 51 }
51 52
  53 + setActivityFliter() {
  54 + let {
  55 + resource,
  56 + } = this.props;
  57 +
  58 + this.props.setActivityFliter && this.props.setActivityFliter(resource.get('content_code'),true);
  59 + }
  60 +
52 renderSectionHeader(sectionData, sectionID) { 61 renderSectionHeader(sectionData, sectionID) {
53 if (sectionID == 'categoryNavigationList') { 62 if (sectionID == 'categoryNavigationList') {
54 let { 63 let {
@@ -89,6 +98,16 @@ export default class OutletPageListView extends Component { @@ -89,6 +98,16 @@ export default class OutletPageListView extends Component {
89 } 98 }
90 }else if (sectionID == 'activityList') { 99 }else if (sectionID == 'activityList') {
91 return(<ActivityCell resource={rowData} onPressProduct={this.props.onPressProduct}/>); 100 return(<ActivityCell resource={rowData} onPressProduct={this.props.onPressProduct}/>);
  101 + }else if (sectionID == 'activityMore') {
  102 + if (rowData == 'more') {
  103 + return(
  104 + <TouchableOpacity activeOpacity={1} style={{width: width,height: 50,backgroundColor: 'red'}} onPress={() => {this.setActivityFliter && this.setActivityFliter();}}>
  105 + <View style={{width: width,height: 50,backgroundColor: 'red'}}>
  106 + <Text>more</Text>
  107 + </View>
  108 + </TouchableOpacity>
  109 + );
  110 + }
92 }else if (sectionID == 'categoryNavigationList') { 111 }else if (sectionID == 'categoryNavigationList') {
93 112
94 let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal; 113 let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
@@ -117,17 +136,23 @@ export default class OutletPageListView extends Component { @@ -117,17 +136,23 @@ export default class OutletPageListView extends Component {
117 136
118 let isFetching = resource.get('isFetching')?resource.get('isFetching'):false; 137 let isFetching = resource.get('isFetching')?resource.get('isFetching'):false;
119 let honeResource = resource.get('honeResource'); 138 let honeResource = resource.get('honeResource');
120 - let activityList = resource.get('activityList'); 139 + let activityList = resource.get('activityList')?resource.get('activityList').toArray():null;
  140 + let activityMore = resource.get('activityMore');
121 let categoryNavigationList = resource.get('categoryNavigationList')?resource.get('categoryNavigationList').toArray():null; 141 let categoryNavigationList = resource.get('categoryNavigationList')?resource.get('categoryNavigationList').toArray():null;
122 let productObj = categoryNavigationList?categoryNavigationList[0].get('list'):null; 142 let productObj = categoryNavigationList?categoryNavigationList[0].get('list'):null;
123 let productList = productObj?productObj.get('product_list'):null; 143 let productList = productObj?productObj.get('product_list'):null;
124 let error = resource.get('error'); 144 let error = resource.get('error');
125 let ptr = resource.get('ptr')==true ? true : false; 145 let ptr = resource.get('ptr')==true ? true : false;
126 let list = list = honeResource?honeResource.get('list'):null; 146 let list = list = honeResource?honeResource.get('list'):null;
  147 + let activityListNum = activityList?activityList.length:0;
  148 + if (!activityMore) {
  149 + activityList = activityList?activityList.slice(0,10):null;
  150 + }
127 151
128 let dataSource = { 152 let dataSource = {
129 outletHomeReource: list?list.toArray():[], 153 outletHomeReource: list?list.toArray():[],
130 - activityList: activityList?activityList.toArray():[], 154 + activityList: activityList?activityList:[],
  155 + activityMore: (!activityMore && activityListNum>10)?['more']:[],
131 categoryNavigationList: productList?productList.toArray():[], 156 categoryNavigationList: productList?productList.toArray():[],
132 }; 157 };
133 158
@@ -8,6 +8,8 @@ export default keyMirror({ @@ -8,6 +8,8 @@ export default keyMirror({
8 SET_SERVICE_HOST: null, 8 SET_SERVICE_HOST: null,
9 SET_CATEGORYID: null, 9 SET_CATEGORYID: null,
10 10
  11 + SET_ACTIVITY_FLITER: null,
  12 +
11 GET_CATEGORY_REQUEST: null, 13 GET_CATEGORY_REQUEST: null,
12 GET_CATEGORY_SUCCESS: null, 14 GET_CATEGORY_SUCCESS: null,
13 GET_CATEGORY_FAILURE: null, 15 GET_CATEGORY_FAILURE: null,
@@ -44,6 +44,7 @@ class OutletContainer extends Component { @@ -44,6 +44,7 @@ class OutletContainer extends Component {
44 this._onPressProduct = this._onPressProduct.bind(this); 44 this._onPressProduct = this._onPressProduct.bind(this);
45 this._onPressFilter = this._onPressFilter.bind(this); 45 this._onPressFilter = this._onPressFilter.bind(this);
46 this._getOutletActivityList = this._getOutletActivityList.bind(this); 46 this._getOutletActivityList = this._getOutletActivityList.bind(this);
  47 + this._setActivityFliter = this._setActivityFliter.bind(this);
47 } 48 }
48 49
49 componentDidMount() { 50 componentDidMount() {
@@ -62,6 +63,9 @@ class OutletContainer extends Component { @@ -62,6 +63,9 @@ class OutletContainer extends Component {
62 this.props.actions.getOutletActivityList(content_code); 63 this.props.actions.getOutletActivityList(content_code);
63 } 64 }
64 65
  66 + _setActivityFliter(content_code,activityMore) {
  67 + this.props.actions.setActivityFliter(content_code,activityMore);
  68 + }
65 69
66 _onPressProduct(url){ 70 _onPressProduct(url){
67 console.log('_onPressProduct = '+url); 71 console.log('_onPressProduct = '+url);
@@ -82,6 +86,7 @@ class OutletContainer extends Component { @@ -82,6 +86,7 @@ class OutletContainer extends Component {
82 <Outlet 86 <Outlet
83 categoryList = {categoryList} 87 categoryList = {categoryList}
84 getOutletHomeResource = {this._getOutletHomeResource} 88 getOutletHomeResource = {this._getOutletHomeResource}
  89 + setActivityFliter = {this._setActivityFliter}
85 getOutletActivityList = {this._getOutletActivityList} 90 getOutletActivityList = {this._getOutletActivityList}
86 onPressProduct = {this._onPressProduct} 91 onPressProduct = {this._onPressProduct}
87 onPressFilter = {this._onPressFilter} 92 onPressFilter = {this._onPressFilter}
@@ -8,6 +8,8 @@ import {GetQueryString} from '../../utils/ResourceParser'; @@ -8,6 +8,8 @@ import {GetQueryString} from '../../utils/ResourceParser';
8 const { 8 const {
9 SET_PLATFORM, 9 SET_PLATFORM,
10 10
  11 + SET_ACTIVITY_FLITER,
  12 +
11 GET_CATEGORY_REQUEST, 13 GET_CATEGORY_REQUEST,
12 GET_CATEGORY_SUCCESS, 14 GET_CATEGORY_SUCCESS,
13 GET_CATEGORY_FAILURE, 15 GET_CATEGORY_FAILURE,
@@ -212,3 +214,11 @@ export function getOutletActivityList(content_code) { @@ -212,3 +214,11 @@ export function getOutletActivityList(content_code) {
212 }); 214 });
213 }; 215 };
214 } 216 }
  217 +
  218 +
  219 +export function setActivityFliter(content_code,activityMore) {
  220 + return {
  221 + type: SET_ACTIVITY_FLITER,
  222 + payload: {'activityMore':activityMore,'content_code':content_code}
  223 + };
  224 +}
@@ -4,6 +4,7 @@ import InitialState from './outletInitialState'; @@ -4,6 +4,7 @@ import InitialState from './outletInitialState';
4 import Immutable, {Map} from 'immutable'; 4 import Immutable, {Map} from 'immutable';
5 5
6 const { 6 const {
  7 + SET_ACTIVITY_FLITER,
7 8
8 GET_CATEGORY_REQUEST, 9 GET_CATEGORY_REQUEST,
9 GET_CATEGORY_SUCCESS, 10 GET_CATEGORY_SUCCESS,
@@ -164,6 +165,7 @@ export default function outletReducer(state=initialState, action) { @@ -164,6 +165,7 @@ export default function outletReducer(state=initialState, action) {
164 let content_code0 = item.content_code; 165 let content_code0 = item.content_code;
165 if (content_code1 == content_code0) { 166 if (content_code1 == content_code0) {
166 item.activityList = action.payload.json; 167 item.activityList = action.payload.json;
  168 + item.activityMore = false;
167 } 169 }
168 }) 170 })
169 return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list)) 171 return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
@@ -171,6 +173,17 @@ export default function outletReducer(state=initialState, action) { @@ -171,6 +173,17 @@ export default function outletReducer(state=initialState, action) {
171 case GET_OUTLET_ACTIVITY_LIST_FAILURE: { 173 case GET_OUTLET_ACTIVITY_LIST_FAILURE: {
172 174
173 } 175 }
  176 + case SET_ACTIVITY_FLITER: {
  177 + let categoryList = state.categoryList.toJS();
  178 + let content_code1 = action.payload.content_code;
  179 + categoryList.list.map((item, i) => {
  180 + let content_code0 = item.content_code;
  181 + if (content_code1 == content_code0) {
  182 + item.activityMore = action.payload.activityMore;
  183 + }
  184 + })
  185 + return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
  186 + }
174 } 187 }
175 188
176 return state; 189 return state;