Authored by 陈林

增加拼团列表跳转参数调整和拼团详情页商品列表接口调整。review by 孙凯。

@@ -8,7 +8,7 @@ import appInitialState from './reducers/app/appInitialState'; @@ -8,7 +8,7 @@ import appInitialState from './reducers/app/appInitialState';
8 import groupPurchaseInitialState from './reducers/groupPurchase/groupPurchaseInitialState'; 8 import groupPurchaseInitialState from './reducers/groupPurchase/groupPurchaseInitialState';
9 import GroupPurchaseContainer from './containers/GroupPurchaseContainer'; 9 import GroupPurchaseContainer from './containers/GroupPurchaseContainer';
10 import {setHost, setPlatform, setServiceHost, getUid, getUnionType} from './reducers/app/appActions'; 10 import {setHost, setPlatform, setServiceHost, getUid, getUnionType} from './reducers/app/appActions';
11 -import {setActivityId} from './reducers/groupPurchase/groupPurchaseActions'; 11 +import {setActivityId, setGroupListParams} from './reducers/groupPurchase/groupPurchaseActions';
12 import createReactClass from 'create-react-class'; 12 import createReactClass from 'create-react-class';
13 import GroupPurchaseDetailContainer from './containers/GroupPurchaseDetailContainer'; 13 import GroupPurchaseDetailContainer from './containers/GroupPurchaseDetailContainer';
14 import {setDetailActivityId,setGroupNo} from './reducers/groupPurchaseDetail/groupPurchaseDetailActions'; 14 import {setDetailActivityId,setGroupNo} from './reducers/groupPurchaseDetail/groupPurchaseDetailActions';
@@ -30,14 +30,21 @@ export default function native(platform) { @@ -30,14 +30,21 @@ export default function native(platform) {
30 30
31 render() { 31 render() {
32 const store = configureStore(getInitialState()); 32 const store = configureStore(getInitialState());
  33 +
33 store.dispatch(setPlatform(platform)); 34 store.dispatch(setPlatform(platform));
34 store.dispatch(setHost(this.props.host)); 35 store.dispatch(setHost(this.props.host));
35 store.dispatch(setServiceHost(this.props.serviceHost)); 36 store.dispatch(setServiceHost(this.props.serviceHost));
36 - store.dispatch(setActivityId(this.props.activityId)); 37 + // 将activityId的判断逻辑从原生移至RN处理
  38 + let activityId = this.props.activityId;
  39 + if(!activityId && this.props.template_id){
  40 + activityId = this.props.template_id
  41 + }
  42 + store.dispatch(setActivityId(activityId));
37 store.dispatch(setGroupNo(this.props.groupNo)); 43 store.dispatch(setGroupNo(this.props.groupNo));
38 - store.dispatch(setDetailActivityId(this.props.activityId)); 44 + store.dispatch(setDetailActivityId(activityId));
39 store.dispatch(getUid()); 45 store.dispatch(getUid());
40 store.dispatch(getUnionType()); 46 store.dispatch(getUnionType());
  47 + store.dispatch(setGroupListParams(this.props))
41 48
42 let type = this.props.type; 49 let type = this.props.type;
43 if (type === 'List') { 50 if (type === 'List') {
@@ -6,6 +6,7 @@ export default keyMirror({ @@ -6,6 +6,7 @@ export default keyMirror({
6 SET_HOST: null, 6 SET_HOST: null,
7 SET_SERVICE_HOST: null, 7 SET_SERVICE_HOST: null,
8 SET_ACTIVITY_ID: null, 8 SET_ACTIVITY_ID: null,
  9 + SET_GROUPLIST_PARAMS: null,
9 PRODUCT_LIST_REQUEST: null, 10 PRODUCT_LIST_REQUEST: null,
10 PRODUCT_LIST_SUCCESS: null, 11 PRODUCT_LIST_SUCCESS: null,
11 PRODUCT_LIST_FAILURE: null, 12 PRODUCT_LIST_FAILURE: null,
@@ -61,7 +61,7 @@ class GroupPurchaseDetailContainer extends Component { @@ -61,7 +61,7 @@ class GroupPurchaseDetailContainer extends Component {
61 } 61 }
62 62
63 async componentDidMount() { 63 async componentDidMount() {
64 - this.props.actions.getProductList(); 64 + this.props.actions.getProductList(false, true);
65 this.props.actions.fetchActivityGroupDetail(this.props.FP_NAME, this.props.FP_PARAM); 65 this.props.actions.fetchActivityGroupDetail(this.props.FP_NAME, this.props.FP_PARAM);
66 // this.props.actions.fetchResourceInfo(); 66 // this.props.actions.fetchResourceInfo();
67 } 67 }
@@ -190,7 +190,7 @@ class GroupPurchaseDetailContainer extends Component { @@ -190,7 +190,7 @@ class GroupPurchaseDetailContainer extends Component {
190 } 190 }
191 191
192 _onEndReached() { 192 _onEndReached() {
193 - this.props.actions.getProductList(); 193 + this.props.actions.getProductList(false, true);
194 } 194 }
195 195
196 render() { 196 render() {
@@ -7,6 +7,7 @@ const Platform = require('Platform'); @@ -7,6 +7,7 @@ const Platform = require('Platform');
7 7
8 const { 8 const {
9 SET_ACTIVITY_ID, 9 SET_ACTIVITY_ID,
  10 + SET_GROUPLIST_PARAMS,
10 PRODUCT_LIST_REQUEST, 11 PRODUCT_LIST_REQUEST,
11 PRODUCT_LIST_SUCCESS, 12 PRODUCT_LIST_SUCCESS,
12 PRODUCT_LIST_FAILURE, 13 PRODUCT_LIST_FAILURE,
@@ -42,6 +43,13 @@ export function setActivityId(activityId) { @@ -42,6 +43,13 @@ export function setActivityId(activityId) {
42 } 43 }
43 } 44 }
44 45
  46 +export function setGroupListParams(params) {
  47 + return {
  48 + type: SET_GROUPLIST_PARAMS,
  49 + payload: params,
  50 + }
  51 +}
  52 +
45 export function productListRequest() { 53 export function productListRequest() {
46 return { 54 return {
47 type: PRODUCT_LIST_REQUEST, 55 type: PRODUCT_LIST_REQUEST,
@@ -97,10 +105,10 @@ export function fetchResourceInfo() { @@ -97,10 +105,10 @@ export function fetchResourceInfo() {
97 }; 105 };
98 } 106 }
99 107
100 -export function getProductList(reload=false) { 108 +export function getProductList(reload=false, fromDetail=false) {
101 return (dispatch, getState) => { 109 return (dispatch, getState) => {
102 let {app, groupPurchase} = getState(); 110 let {app, groupPurchase} = getState();
103 - let {productList,activityId} = groupPurchase; 111 + let {productList,activityId, groupListParams} = groupPurchase;
104 if (reload) { 112 if (reload) {
105 113
106 } else { 114 } else {
@@ -114,7 +122,9 @@ export function getProductList(reload=false) { @@ -114,7 +122,9 @@ export function getProductList(reload=false) {
114 let fromPage = Platform.OS === 'android' ? 'aFP_GroupPurchaseList' : 'iFP_GroupPurchaseList'; 122 let fromPage = Platform.OS === 'android' ? 'aFP_GroupPurchaseList' : 'iFP_GroupPurchaseList';
115 123
116 dispatch(productListRequest()); 124 dispatch(productListRequest());
117 - return new GroupPurchaseService(app.host).fetchProductList(activityId, page, limit,fromPage) 125 +
  126 + if(fromDetail){
  127 + return new GroupPurchaseService(app.host).fetchGroupDetailProductList(activityId, page, limit,fromPage)
118 .then(json => { 128 .then(json => {
119 json.endReached = json.page == json.page_total; 129 json.endReached = json.page == json.page_total;
120 if (json.page > 1) { 130 if (json.page > 1) {
@@ -127,9 +137,55 @@ export function getProductList(reload=false) { @@ -127,9 +137,55 @@ export function getProductList(reload=false) {
127 .catch(error => { 137 .catch(error => {
128 dispatch(productListFailure(error)); 138 dispatch(productListFailure(error));
129 }); 139 });
  140 + }else{
  141 + //处理拼团列表参数
  142 + let listParams = excludeParams(groupListParams);
  143 +
  144 + return new GroupPurchaseService(app.host).fetchGroupProductList(activityId, page, limit,fromPage, listParams)
  145 + .then(json => {
  146 + json.endReached = json.page == json.page_total;
  147 + if (json.page > 1) {
  148 + let oldList = productList.list.toJS();
  149 + let list = [...oldList, ...json.collageProductVoList];
  150 + json.collageProductVoList = list;
  151 + }
  152 + dispatch(productListSuccess(json));
  153 + })
  154 + .catch(error => {
  155 + dispatch(productListFailure(error));
  156 + });
  157 + }
130 }; 158 };
131 } 159 }
132 160
  161 +function excludeParams(groupParams){
  162 + let newParams = {};
  163 + try{
  164 + let params = groupParams.toJS();
  165 +
  166 + for(let key in params){
  167 + if(params[key]){
  168 + newParams[key] = params[key]
  169 + }
  170 + }
  171 +
  172 + //gender 需要进行空处理,防止原生会添加默认值
  173 + if(!newParams["gender"]){
  174 + newParams["gender"] = "";
  175 + }
  176 +
  177 + //size因为字段是关键字,使用了g_size替换
  178 + if(newParams["g_size"]){
  179 + newParams["size"] = newParams["g_size"];
  180 + delete newParams["g_size"]
  181 + }
  182 + }catch(e){
  183 +
  184 + }
  185 +
  186 + return newParams;
  187 +}
  188 +
133 export function shareCodeInfoRequest() { 189 export function shareCodeInfoRequest() {
134 return { 190 return {
135 type: SHARECODEINFO_REQUEST, 191 type: SHARECODEINFO_REQUEST,
@@ -6,6 +6,24 @@ let InitialState = Record({ @@ -6,6 +6,24 @@ let InitialState = Record({
6 activityId: 0, 6 activityId: 0,
7 showShareView: false, 7 showShareView: false,
8 showSnapshootShare: false, 8 showSnapshootShare: false,
  9 + groupListParams: new (Record({
  10 + collageTopSkn: '',
  11 + sort: '',
  12 + gender: '',
  13 + order: '',
  14 + p_d: '',
  15 + color: '',
  16 + brand: '',
  17 + price: '',
  18 + g_size: '',
  19 + msort: '',
  20 + misort: '',
  21 + age_level: '',
  22 + style: '',
  23 + from: '',
  24 + showType: '',
  25 + })),
  26 +
9 productList: new (Record({ 27 productList: new (Record({
10 isFetching: false, 28 isFetching: false,
11 error: null, 29 error: null,
@@ -5,6 +5,7 @@ import Immutable from 'immutable'; @@ -5,6 +5,7 @@ import Immutable from 'immutable';
5 5
6 const { 6 const {
7 SET_ACTIVITY_ID, 7 SET_ACTIVITY_ID,
  8 + SET_GROUPLIST_PARAMS,
8 PRODUCT_LIST_REQUEST, 9 PRODUCT_LIST_REQUEST,
9 PRODUCT_LIST_SUCCESS, 10 PRODUCT_LIST_SUCCESS,
10 PRODUCT_LIST_FAILURE, 11 PRODUCT_LIST_FAILURE,
@@ -36,6 +37,24 @@ export default function couponReducer(state = initialState, action) { @@ -36,6 +37,24 @@ export default function couponReducer(state = initialState, action) {
36 case SET_ACTIVITY_ID: { 37 case SET_ACTIVITY_ID: {
37 return state.set('activityId', action.payload); 38 return state.set('activityId', action.payload);
38 } 39 }
  40 + case SET_GROUPLIST_PARAMS: {
  41 + let params = action.payload;
  42 + return state.setIn(['groupListParams', 'collageTopSkn'], params.collageTopSkn ? params.collageTopSkn : "")
  43 + .setIn(['groupListParams', 'sort'], params.sort ? params.sort : '')
  44 + .setIn(['groupListParams', 'gender'], params.gender ? params.gender : '')
  45 + .setIn(['groupListParams', 'order'], params.order ? params.order : '')
  46 + .setIn(['groupListParams', 'p_d'], params.p_d ? params.p_d : '')
  47 + .setIn(['groupListParams', 'color'], params.color ? params.color : '')
  48 + .setIn(['groupListParams', 'brand'], params.brand ? params.brand : '')
  49 + .setIn(['groupListParams', 'price'], params.price ? params.price : '')
  50 + .setIn(['groupListParams', 'g_size'], params.size ? params.size : '')
  51 + .setIn(['groupListParams', 'msort'], params.msort ? params.msort : '')
  52 + .setIn(['groupListParams', 'misort'], params.misort ? params.misort : '')
  53 + .setIn(['groupListParams', 'age_level'], params.age_level ? params.age_level : '')
  54 + .setIn(['groupListParams', 'style'], params.style ? params.style : '')
  55 + .setIn(['groupListParams', 'from'], params.from ? params.from : '')
  56 + .setIn(['groupListParams', 'showType'], params.showType ? params.showType : '');
  57 + }
39 case PRODUCT_LIST_REQUEST: { 58 case PRODUCT_LIST_REQUEST: {
40 return state.setIn(['productList', 'isFetching'], true) 59 return state.setIn(['productList', 'isFetching'], true)
41 .setIn(['productList', 'error'], null); 60 .setIn(['productList', 'error'], null);
@@ -13,11 +13,33 @@ export default class groupPurchaseService { @@ -13,11 +13,33 @@ export default class groupPurchaseService {
13 this.api = new Request(baseURL); 13 this.api = new Request(baseURL);
14 } 14 }
15 15
16 - async fetchProductList(activityId,page=1, limit=20,fromPage) { 16 + async fetchGroupProductList(activityId, page=1, limit=20, fromPage, listParams) {
  17 +
17 return await this.api.get({ 18 return await this.api.get({
18 url: '', 19 url: '',
19 body: { 20 body: {
20 method: 'app.collage.productList.page', 21 method: 'app.collage.productList.page',
  22 + ...listParams,
  23 + page,
  24 + limit,
  25 + activityId,
  26 + fromPage,
  27 + }
  28 + })
  29 + .then((json) => {
  30 + return json;
  31 + })
  32 + .catch((error) => {
  33 + throw(error);
  34 + });
  35 + }
  36 +
  37 +
  38 + async fetchGroupDetailProductList(activityId,page=1, limit=20,fromPage) {
  39 + return await this.api.get({
  40 + url: '',
  41 + body: {
  42 + method: 'app.collage.productList.detail',
21 page, 43 page,
22 limit, 44 limit,
23 activityId, 45 activityId,