groupPurchaseDetailActions.js
4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
'use strict';
import ReactNative from 'react-native';
import GroupPurchaseService from '../../services/GroupPurchaseService';
const Platform = require('Platform');
const {
SET_GROUP_NO,
SET_ACTIVITY_ID,
PRODUCT_LIST_REQUEST,
PRODUCT_LIST_SUCCESS,
PRODUCT_LIST_FAILURE,
RESOURCEINFO_REQUEST,
RESOURCEINFO_SUCCESS,
RESOURCEINFO_FAILURE,
ACTIVITY_GROUP_DETAIL_REQUEST,
ACTIVITY_GROUP_DETAIL_SUCCESS,
ACTIVITY_GROUP_DETAIL_FAILURE,
UPDATE_LEFTTIME,
SHOWSHARVIEW,
SHOWSNAPSHOOTSHARE,
} = require('../../constants/actionTypes').default;
export function showShareView(show) {
return {
type: SHOWSHARVIEW,
payload: show,
}
}
export function showSnapshootShare(show) {
return {
type: SHOWSNAPSHOOTSHARE,
payload: show,
}
}
export function setGroupNo(groupNo) {
return {
type: SET_GROUP_NO,
payload: groupNo,
}
}
export function setDetailActivityId(activityId) {
return {
type: SET_ACTIVITY_ID,
payload: activityId,
}
}
export function productListRequest() {
return {
type: PRODUCT_LIST_REQUEST,
};
}
export function productListSuccess(json) {
return {
type: PRODUCT_LIST_SUCCESS,
payload: json
}
}
export function productListFailure(error) {
return {
type: PRODUCT_LIST_FAILURE,
payload: error
}
}
export function resourceInfoRequest() {
return {
type: RESOURCEINFO_REQUEST,
};
}
export function resourceInfoSuccess(json) {
return {
type: RESOURCEINFO_SUCCESS,
payload: json
}
}
export function resourceInfoFailure(error) {
return {
type: RESOURCEINFO_FAILURE,
payload: error
}
}
export function activityGroupDetailRequest() {
return {
type: ACTIVITY_GROUP_DETAIL_REQUEST,
};
}
export function activityGroupDetailSuccess(json) {
return {
type: ACTIVITY_GROUP_DETAIL_SUCCESS,
payload: json
}
}
export function activityGroupDetailFailure(error) {
return {
type: ACTIVITY_GROUP_DETAIL_FAILURE,
payload: error
}
}
export function fetchActivityGroupDetail(FP_NAME, FP_PARAM) {
return (dispatch, getState) => {
let {app,groupPurchaseDetail} = getState();
let {groupNo} = groupPurchaseDetail;
let getActivityGroupDetail = (groupNo ,uid) => {
dispatch(activityGroupDetailRequest());
return new GroupPurchaseService(app.host).fetchActivityGroupDetail(groupNo ,uid)
.then(json => {
// 注释上报事件
// try {
// let event_params = {
// FP_NAME,
// FP_PARAM,
// PRD_ID: '',
// PRD_SKN: json.membershipItems[0].productSkn,
// PRD_TYPE: 1,
// }
// YH_CommonHelper.logEvent('YB_GDS_DT_INFO', event_params);
// } catch (e) {
// console.log(e);
// }
dispatch(activityGroupDetailSuccess(json));
})
.catch(error => {
dispatch(activityGroupDetailFailure(error));
});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
getActivityGroupDetail( groupNo ,uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
getActivityGroupDetail( groupNo ,uid);
})
.catch(error => {
});
});
};
}
export function getProductList(reload=false) {
return (dispatch, getState) => {
let {app, groupPurchaseDetail} = getState();
let {productList,activityId} = groupPurchaseDetail;
if (reload) {
} else {
if (productList.isFetching || productList.endReached || productList.error) {
return;
}
}
let page = productList.page + 1;
let limit = productList.pageSize;
let fromPage = Platform.OS === 'android' ? 'aFP_GroupPurchaseDetail' : 'iFP_GroupPurchaseDetail';
dispatch(productListRequest());
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));
});
};
}
export function updateTime(leftTime) {
return {
type: UPDATE_LEFTTIME,
payload: leftTime
}
}
export function fetchResourceInfo() {
return (dispatch, getState) => {
let {app} = getState();
dispatch(resourceInfoRequest());
let content_code = '3c3a94fd6c6e19508b6921acd7f6cbad';
return new GroupPurchaseService(app.host).fetchDetailResourceInfo(content_code)
.then(json => {
dispatch(resourceInfoSuccess(json));
})
.catch(error => {
dispatch(resourceInfoFailure(error));
});
};
}