Authored by 孙凯

add app.search.category 和 app.outlets.activityGet 接口 review by zhanglixia

... ... @@ -45,6 +45,7 @@ export default class Outlet extends Component {
key={'OutletPageListView' + i}
resource = {list[i]}
getOutletHomeResource = {this.props.getOutletHomeResource}
getOutletActivityList = {this.props.getOutletActivityList}
onPressProduct = {this.props.onPressProduct}
onPressFilter = {this.props.onPressFilter}
/>
... ...
... ... @@ -46,10 +46,19 @@ export default class OutletPageListView extends Component {
} = this.props;
this.props.getOutletHomeResource && this.props.getOutletHomeResource(resource.get('content_code'),ptr);
this.props.getOutletActivityList && this.props.getOutletActivityList(resource.get('content_code'));
}
renderSectionHeader(sectionData, sectionID) {
if (sectionID == 'categoryNavigationList') {
let {
resource,
} = this.props;
if (!resource) {
return null;
}
let categoryNavigationList = resource.get('categoryNavigationList');
return (
<ProductFliter
resource={categoryNavigationList}
... ... @@ -78,8 +87,10 @@ export default class OutletPageListView extends Component {
}else if (rowData.get('template_name') == '文字广告') {
// return(<TripleImage resource={rowData} onPressProduct={this.props.onPressProduct}/>);
}
}else if (sectionID == 'categoryNavigationList') {
}else if (sectionID == 'activityList') {
}else if (sectionID == 'categoryNavigationList') {
console.log(rowData.toJS());
}
return null;
}
... ... @@ -96,6 +107,9 @@ 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 categoryNavigationList = resource.get('categoryNavigationList');
let error = resource.get('error');
let ptr = resource.get('ptr')==true ? true : false;
... ... @@ -104,17 +118,9 @@ export default class OutletPageListView extends Component {
list = honeResource.get('list');
}
if (list) {
list.map((item, i) => {
let template_name = item.get('template_name');
if (template_name == 'categoryNavigation') {
categoryNavigationList = item.get('data');
}
})
}
let dataSource = {
outletHomeReource: list?list.toArray():[],
activityList: activityList?activityList.toArray():[],
categoryNavigationList: categoryNavigationList?categoryNavigationList.toArray():[],
};
... ... @@ -142,7 +148,6 @@ export default class OutletPageListView extends Component {
}
let {width, height} = Dimensions.get('window');
let categoryNavigationList;
let styles = StyleSheet.create({
container: {
flex: 1,
... ...
... ... @@ -16,4 +16,13 @@ export default keyMirror({
GET_OUTLETHOMERESOURCE_REQUEST: null,
GET_OUTLETHOMERESOURCE_SUCCESS: null,
GET_OUTLETHOMERESOURCE_FAILURE: null,
GET_PRODUCT_REQUEST: null,
GET_PRODUCT_SUCCESS: null,
GET_PRODUCT_FAILURE: null,
GET_OUTLET_ACTIVITY_LIST_REQUEST: null,
GET_OUTLET_ACTIVITY_LIST_SUCCESS: null,
GET_OUTLET_ACTIVITY_LIST_FAILURE: null,
});
... ...
... ... @@ -43,6 +43,7 @@ class OutletContainer extends Component {
this._getOutletHomeResource = this._getOutletHomeResource.bind(this);
this._onPressProduct = this._onPressProduct.bind(this);
this._onPressFilter = this._onPressFilter.bind(this);
this._getOutletActivityList = this._getOutletActivityList.bind(this);
}
componentDidMount() {
... ... @@ -57,6 +58,11 @@ class OutletContainer extends Component {
this.props.actions.getOutletHomeResource(content_code,ptr);
}
_getOutletActivityList(content_code){
this.props.actions.getOutletActivityList(content_code);
}
_onPressProduct(url){
console.log('_onPressProduct = '+url);
}
... ... @@ -76,6 +82,7 @@ class OutletContainer extends Component {
<Outlet
categoryList = {categoryList}
getOutletHomeResource = {this._getOutletHomeResource}
getOutletActivityList = {this._getOutletActivityList}
onPressProduct = {this._onPressProduct}
onPressFilter = {this._onPressFilter}
/>
... ...
... ... @@ -15,6 +15,15 @@ const {
GET_OUTLETHOMERESOURCE_REQUEST,
GET_OUTLETHOMERESOURCE_SUCCESS,
GET_OUTLETHOMERESOURCE_FAILURE,
GET_PRODUCT_REQUEST,
GET_PRODUCT_SUCCESS,
GET_PRODUCT_FAILURE,
GET_OUTLET_ACTIVITY_LIST_REQUEST,
GET_OUTLET_ACTIVITY_LIST_SUCCESS,
GET_OUTLET_ACTIVITY_LIST_FAILURE,
} = require('../../constants/actionTypes').default;
export function onPressCoupon() {
... ... @@ -99,9 +108,107 @@ export function getOutletHomeResource(content_code,ptr) {
return new OutletService(app.serviceHost).getOutletHomeResource(content_code)
.then(json => {
dispatch(getOutletHomeResourceSuccess({'json':json,'content_code':content_code}));
let categoryNavigationItem;
if (json.list) {
json.list.map((item, i) => {
let template_name = item.template_name;
if (template_name == 'categoryNavigation') {
categoryNavigationItem = item.data[0];
}
});
}
dispatch(getProductList(content_code,categoryNavigationItem));
})
.catch(error => {
dispatch(getOutletHomeResourceFailure(content_code,error));
});
};
}
export function getProductListRequest(json) {
return {
type: GET_PRODUCT_REQUEST,
payload: json
};
}
export function getProductListSuccess(json) {
return {
type: GET_PRODUCT_SUCCESS,
payload: json
}
}
export function getProductListFailure(content_code,error) {
return {
type: GET_PRODUCT_FAILURE,
payload: {'error':error,'content_code':content_code,'categoryNavigationItem':categoryNavigationItem}
}
}
export function getProductList(content_code,categoryNavigationItem) {
return (dispatch, getState) => {
let {app, outlet} = getState();
let {categoryList} = outlet;
//limit,page,uid,firstProductSkn='',"http://list.m.yohobuy.com/?outlets=1&gender=1,3&openby:yohobuy={"action":"go.list","params":{"actiontype":1,"gender":"1,3","outlets":"1"}}"
// if (productList.isFetching || productList.endReached || productList.error) {
// return;
// }
let param = parseUrlForparam(categoryNavigationItem.url);
let page = 1;//productList.currentPage + 1;
let pageSize = 60;//productList.pageSize;
dispatch(getProductListRequest({'content_code':content_code,'categoryNavigationItem':categoryNavigationItem}));
return new OutletService(app.host).getProductList(pageSize,page,param)
.then(json => {
dispatch(getProductListSuccess({'json':json,'content_code':content_code,'categoryNavigationItem':categoryNavigationItem}));
})
.catch(error => {
dispatch(getProductListFailure(content_code,error,categoryNavigationItem));
});
};
}
function parseUrlForparam(url) {
let part = GetQueryString(url,'openby:yohobuy');
let param = JSON.parse(part).params;
return param;
}
export function getOutletActivityListRequest(content_code) {
return {
type: GET_OUTLET_ACTIVITY_LIST_REQUEST,
payload: content_code
};
}
export function getOutletActivityListSuccess(json) {
return {
type: GET_OUTLET_ACTIVITY_LIST_SUCCESS,
payload: json
}
}
export function getOutletActivityListFailure(content_code,error) {
return {
type: GET_OUTLET_ACTIVITY_LIST_FAILURE,
payload: {'error':error,'content_code':content_code}
}
}
export function getOutletActivityList(content_code) {
return (dispatch, getState) => {
let {app, outlet} = getState();
let {categoryList} = outlet;
dispatch(getOutletActivityListRequest(content_code));
return new OutletService(app.host).getOutletActivityList(app.yh_channel)
.then(json => {
dispatch(getOutletActivityListSuccess({'json':json,'content_code':content_code}));
})
.catch(error => {
dispatch(getOutletActivityListFailure(content_code,error));
});
};
}
... ...
... ... @@ -13,6 +13,14 @@ const {
GET_OUTLETHOMERESOURCE_SUCCESS,
GET_OUTLETHOMERESOURCE_FAILURE,
GET_PRODUCT_REQUEST,
GET_PRODUCT_SUCCESS,
GET_PRODUCT_FAILURE,
GET_OUTLET_ACTIVITY_LIST_REQUEST,
GET_OUTLET_ACTIVITY_LIST_SUCCESS,
GET_OUTLET_ACTIVITY_LIST_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -46,12 +54,24 @@ export default function outletReducer(state=initialState, action) {
return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
}
case GET_OUTLETHOMERESOURCE_SUCCESS: {
let categoryNavigationList;
if (action.payload.json.list) {
action.payload.json.list.map((item, i) => {
let template_name = item.template_name;
if (template_name == 'categoryNavigation') {
categoryNavigationList = item.data;
}
});
}
let categoryList = state.categoryList.toJS();
let content_code1 = action.payload.json.content_code?action.payload.json.content_code:action.payload.content_code;
let content_code1 = action.payload.content_code;
categoryList.list.map((item, i) => {
let content_code0 = item.content_code;
if (content_code1 == content_code0) {
item.honeResource = action.payload.json;
item.categoryNavigationList = categoryNavigationList;
item.isFetching = false;
item.error = '';
item.ptr = false;
... ... @@ -73,6 +93,84 @@ export default function outletReducer(state=initialState, action) {
})
return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
}
case GET_PRODUCT_REQUEST: {
let categoryList = state.categoryList.toJS();
let content_code1 = action.payload.content_code;
let categoryNavigationItem = action.payload.categoryNavigationItem;
categoryList.list.map((item, i) => {
let content_code0 = item.content_code;
if (content_code1 == content_code0) {
item.categoryNavigationList.map((item0, i) => {
let categoryName = item0.categoryName;
if (categoryNavigationItem.categoryName == categoryName) {
item0.isFetching = true;
item0.error = null;
}
});
}
});
return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
}
case GET_PRODUCT_SUCCESS: {
let categoryList = state.categoryList.toJS();
let content_code1 = action.payload.content_code;
let categoryNavigationItem = action.payload.categoryNavigationItem;
categoryList.list.map((item, i) => {
let content_code0 = item.content_code;
if (content_code1 == content_code0) {
item.categoryNavigationList.map((item0, i) => {
let categoryName = item0.categoryName;
if (categoryNavigationItem.categoryName == categoryName) {
item0.list = action.payload.json;
item0.isFetching = false;
}
});
}
});
return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
}
case GET_PRODUCT_FAILURE: {
let categoryList = state.categoryList.toJS();
let content_code1 = action.payload.content_code;
let categoryNavigationItem = action.payload.categoryNavigationItem;
let error = action.payload.error;
categoryList.list.map((item, i) => {
let content_code0 = item.content_code;
if (content_code1 == content_code0) {
item.categoryNavigationList.map((item0, i) => {
let categoryName = item0.categoryName;
if (categoryNavigationItem.categoryName == categoryName) {
item0.isFetching = false;
item0.error = error;
}
});
}
});
return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
}
case GET_OUTLET_ACTIVITY_LIST_REQUEST: {
}
case GET_OUTLET_ACTIVITY_LIST_SUCCESS: {
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.activityList = action.payload.json;
}
})
return state.setIn(['categoryList', 'list'], Immutable.fromJS(categoryList.list))
}
case GET_OUTLET_ACTIVITY_LIST_FAILURE: {
}
}
return state;
... ...
... ... @@ -46,4 +46,44 @@ export default class OutletService {
throw(error);
});
}
async getProductList(limit,page,param,uid,firstProductSkn='',fromPage='iFP_CategoryProList'){
return await this.api.get({
url: '',
body: {
method: 'app.search.category',
limit,
page,
...param,
uid,
fromPage,
firstProductSkn,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async getOutletActivityList(yh_channel='',platform='2',size=0, type=0){
return await this.api.get({
url: '',
body: {
method: 'app.outlets.activityGet',
yh_channel,
platform,
size,
type,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...