...
|
...
|
@@ -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,10 +105,10 @@ 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;
|
|
|
let {productList,activityId, groupListParams} = groupPurchase;
|
|
|
if (reload) {
|
|
|
|
|
|
} else {
|
...
|
...
|
@@ -114,7 +122,9 @@ export function getProductList(reload=false) { |
|
|
let fromPage = Platform.OS === 'android' ? 'aFP_GroupPurchaseList' : 'iFP_GroupPurchaseList';
|
|
|
|
|
|
dispatch(productListRequest());
|
|
|
return new GroupPurchaseService(app.host).fetchProductList(activityId, page, limit,fromPage)
|
|
|
|
|
|
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) {
|
...
|
...
|
@@ -127,9 +137,55 @@ export function getProductList(reload=false) { |
|
|
.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,
|
...
|
...
|
|