...
|
...
|
@@ -7,6 +7,7 @@ const Platform = require('Platform'); |
|
|
|
|
|
const {
|
|
|
SET_ACTIVITY_ID,
|
|
|
SET_GROUPLIST_PARAMS,
|
|
|
PRODUCT_LIST_REQUEST,
|
|
|
PRODUCT_LIST_SUCCESS,
|
|
|
PRODUCT_LIST_FAILURE,
|
...
|
...
|
@@ -42,6 +43,13 @@ export function setActivityId(activityId) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function setGroupListParams(params) {
|
|
|
return {
|
|
|
type: SET_GROUPLIST_PARAMS,
|
|
|
payload: params,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function productListRequest() {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_REQUEST,
|
...
|
...
|
@@ -97,11 +105,11 @@ export function fetchResourceInfo() { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getProductList(reload=false) {
|
|
|
export function getProductList(reload=false, fromDetail=false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, groupPurchase} = getState();
|
|
|
let {productList,activityId} = groupPurchase;
|
|
|
if (reload) {
|
|
|
let {productList,activityId, groupListParams} = groupPurchase;
|
|
|
if (reload) {
|
|
|
|
|
|
} else {
|
|
|
if (productList.isFetching || productList.endReached || productList.error) {
|
...
|
...
|
@@ -111,25 +119,73 @@ export function getProductList(reload=false) { |
|
|
|
|
|
let page = productList.page + 1;
|
|
|
let limit = productList.pageSize;
|
|
|
let fromPage = Platform.OS === 'android' ? 'aFP_GroupPurchaseList' : 'iFP_GroupPurchaseList';
|
|
|
|
|
|
dispatch(productListRequest());
|
|
|
return new GroupPurchaseService(app.host).fetchProductList(activityId, page, limit,fromPage)
|
|
|
.then(json => {
|
|
|
json.endReached = json.page == json.page_total;
|
|
|
if (json.page > 1) {
|
|
|
let oldList = productList.list.toJS();
|
|
|
let list = [...oldList, ...json.collageProductVoList];
|
|
|
json.collageProductVoList = list;
|
|
|
}
|
|
|
dispatch(productListSuccess(json));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(productListFailure(error));
|
|
|
});
|
|
|
let fromPage = Platform.OS === 'android' ? 'aFP_GroupPurchaseList' : 'iFP_GroupPurchaseList';
|
|
|
|
|
|
dispatch(productListRequest());
|
|
|
|
|
|
if(fromDetail){
|
|
|
return new GroupPurchaseService(app.host).fetchGroupDetailProductList(activityId, page, limit,fromPage)
|
|
|
.then(json => {
|
|
|
json.endReached = json.page == json.page_total;
|
|
|
if (json.page > 1) {
|
|
|
let oldList = productList.list.toJS();
|
|
|
let list = [...oldList, ...json.collageProductVoList];
|
|
|
json.collageProductVoList = list;
|
|
|
}
|
|
|
dispatch(productListSuccess(json));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(productListFailure(error));
|
|
|
});
|
|
|
}else{
|
|
|
//处理拼团列表参数
|
|
|
let listParams = excludeParams(groupListParams);
|
|
|
|
|
|
return new GroupPurchaseService(app.host).fetchGroupProductList(activityId, page, limit,fromPage, listParams)
|
|
|
.then(json => {
|
|
|
json.endReached = json.page == json.page_total;
|
|
|
if (json.page > 1) {
|
|
|
let oldList = productList.list.toJS();
|
|
|
let list = [...oldList, ...json.collageProductVoList];
|
|
|
json.collageProductVoList = list;
|
|
|
}
|
|
|
dispatch(productListSuccess(json));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(productListFailure(error));
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function excludeParams(groupParams){
|
|
|
let newParams = {};
|
|
|
try{
|
|
|
let params = groupParams.toJS();
|
|
|
|
|
|
for(let key in params){
|
|
|
if(params[key]){
|
|
|
newParams[key] = params[key]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//gender 需要进行空处理,防止原生会添加默认值
|
|
|
if(!newParams["gender"]){
|
|
|
newParams["gender"] = "";
|
|
|
}
|
|
|
|
|
|
//size因为字段是关键字,使用了g_size替换
|
|
|
if(newParams["g_size"]){
|
|
|
newParams["size"] = newParams["g_size"];
|
|
|
delete newParams["g_size"]
|
|
|
}
|
|
|
}catch(e){
|
|
|
|
|
|
}
|
|
|
|
|
|
return newParams;
|
|
|
}
|
|
|
|
|
|
export function shareCodeInfoRequest() {
|
|
|
return {
|
|
|
type: SHARECODEINFO_REQUEST,
|
...
|
...
|
|