actions.js
15.1 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
/**
* Created by shipfi on 2016/5/28.
*/
import api from '../api/index';
import {cacheType, cacheManager} from '../utils/cacheManager';
import * as types from './mutationTypes';
//import {saveCookie,signOut} from '../utils/AuthService';
/**
*获取首页结构
* @param store
*/
export const getweiIndext = (store, pageId) => {
let promise = new Promise(function (resolve, reject) {
api.getweiIndext(pageId).then((response) => {
if (response.code != 20000) { // 获取数据失败
reject(1);
} else {
store.dispatch(types.WEI_INDEX, {weiIndex: response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
//获取个人信息
export const getpersonData = (store) => {
let promise = new Promise(function (resolve, reject) {
api.getpersonData().then((response) => {
if (response.code != 20000) { // 获取数据失败
reject(1);
} else {
store.dispatch(types.PERSON_DATA, {personData: response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
//获取个人信息订单数
export const getorderNum = (store) => {
let promise = new Promise(function (resolve, reject) {
api.getorderNum().then((response) => {
if (response.code != 20000) { // 获取数据失败
reject(1);
} else {
store.dispatch(types.ORDER_NUM, {orderNum: response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
//获取浏览记录
export const getbrowseRecordList = (store,page,pageNum) => {
let promise = new Promise(function (resolve, reject) {
// store.dispatch(types.BROWSE_RECORD_LIST, {page: page});
api.getbrowseRecordList(page, pageNum).then((response) => {
console.log("调浏览记录数据page:"+page)
// if (response.code != 20000) { // 获取数据失败
// reject(1);
if(response.content.length>=pageNum) {
resolve("continue");
}else {
resolve("stop");
}
store.dispatch(types.BROWSE_RECORD_LIST, {browseRecordList: response.content});
// }
}, (response) => {
reject(1)
showMsg(store, response.message);
});
});
return promise;
};
//清除浏览记录
export const clearbrowseRecordList = (store) => {
let promise = new Promise(function (resolve, reject) {
store.dispatch(types.BROWSE_RECORD_LIST_CLEAR,{browseRecordList:{}});
resolve(1)
}, (response) => {
reject(1);
showMsg(store, response.message);
});
return promise;
};
//获取我的收藏记录
export const getmyCollectionList = (store,page) => {
let promise = new Promise(function (resolve, reject) {
// store.dispatch(types.MY_COLLECTION_LIST, {page: page});
api.getmyCollectionList(page, 10).then((response) => {
console.log("调浏览记录数据page:"+page)
// if (response.code != 20000) { // 获取数据失败
// reject(1);
if(response.content.length>=10) {
resolve("continue");
}else {
resolve("stop");
}
store.dispatch(types.MY_COLLECTION_LIST, {myCollectionList: response.content});
// }
}, (response) => {
reject(1);
showMsg(store, response.message);
});
});
return promise;
};
//清除收藏记录
export const clearmyCollectionList = (store) => {
let promise = new Promise(function (resolve, reject) {
store.dispatch(types.MY_COLLECTION_LIST_CLEAR,{myCollectionList:{}});
resolve(1)
}, (response) => {
reject(1);
showMsg(store, response.message);
});
return promise;
};
/*添加/取消收藏*/
export const addCancelCollection = (store,id,type) => {
let promise = new Promise(function (resolve, reject) {
api.addCancelCollection(id,type).then((response) => {
if (response.code == 20000) { // 获取数据失败
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
//获取我的优惠券列表
export const getmyCouponList = (store,page,pageNum) => {
let promise = new Promise(function (resolve, reject) {
// store.dispatch(types.MY_COUPON_LIST, {page: page});
api.getmyCouponList(page, pageNum).then((response) => {
console.log("调浏览记录数据page:"+page)
// if (response.code != 20000) { // 获取数据失败
// reject(1);
if(response.content.length>=pageNum) {
resolve("continue");
}else {
resolve("stop");
}
store.dispatch(types.MY_COUPON_LIST, {myCouponList: response.content});
// }
}, (response) => {
reject(1)
showMsg(store, response.message);
});
});
return promise;
};
//清除我的优惠券列表
export const clearmyCouponList = (store) => {
let promise = new Promise(function (resolve, reject) {
store.dispatch(types.MY_COUPON_LIST_CLEAR,{myCouponList:{}});
resolve(1)
}, (response) => {
reject(1);
showMsg(store, response.message);
});
return promise;
};
//获取我的优惠券详情
export const getmyCouponDetail = (store) => {
let promise = new Promise(function (resolve, reject) {
api.getmyCouponDetail().then((response) => {
if (response.code != 20000) { // 获取数据失败
reject(1);
} else {
store.dispatch(types.MY_COUPON_DETAIL, {myCouponDetail: response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
//获取优惠券中心列表
export const getcouponCenterList = (store,cplType,page,pageNum) => {
let promise = new Promise(function (resolve, reject) {
api.getmyCouponList(cplType,page, pageNum).then((response) => {
console.log("调浏览记录数据page:"+page);
if(response.content.length>=pageNum) {
resolve("continue");
}else {
resolve("stop");
}
store.dispatch(types.COUPON_CENTER_LIST, {couponCenterList: response.content});
}, (response) => {
reject(1);
showMsg(store, response.message);
});
});
return promise;
};
//获取优惠券中心标题背景
export const getcouponTab = (store) => {
let promise = new Promise(function (resolve, reject) {
api.getcouponTab().then((response) => {
if (response.code != 20000) { // 获取数据失败
reject(1);
} else {
store.dispatch(types.COUPON_TAB, {couponTab: response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
//清除优惠券中心列表
export const clearcouponCenterList = (store) => {
let promise = new Promise(function (resolve, reject) {
store.dispatch(types.COUPON_CENTER_LIST_CLEAR,{couponCenterList:{}});
resolve(1)
}, (response) => {
reject(1);
showMsg(store, response.message);
});
return promise;
};
/**
* 获取底部导航
*
*/
export const getgroupNav = (store) => {
let promise = new Promise(function (resolve, reject) {
api.getgroupNav().then((response) => {
if (response.code != 20000) { // 获取数据失败
reject(1);
} else {
console.log(response.content);
store.dispatch(types.GROUP_NAV, {groupNav: response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/**
* 获取我的地址列表
*/
export const getmyAddressList = (store,page,pageNum) => {
let promise = new Promise(function (resolve, reject) {
api.getmyAddressList(page,pageNum).then((response) => {
console.log("page:"+page)
if(response.content.list.length>=pageNum) {
resolve("continue");
}else {
resolve("stop");
}
store.dispatch(types.MY_ADDRESS_LIST, {myAddressList: response.content});
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*清除地址列表*/
export const ClearAddresslist = (store) => {
let promise = new Promise(function (resolve, reject) {
store.dispatch(types.MY_ADDRESS_LIST_ClEAR,{myAddressList:[]});
resolve(1)
}, (response) => {
reject(1)
showMsg(store, response.message);
});
return promise;
};
/*设置默认地址*/
export const setDefaultAddress = (store,id) => {
let promise = new Promise(function (resolve, reject) {
api.setDefaultAddress(id).then((response) => {
if (response.code == 20000) { // 获取数据失败
resolve(1);
store.dispatch(types.SET_DEFAULT_ADDRESS,{buyerAddressId:id});
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*删除地址*/
export const deleteAddress = (store,id) => {
let promise = new Promise(function (resolve, reject) {
api.deleteAddress(id).then((response) => {
if (response.code == 20000) { // 获取数据失败
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*获取指定地址信息*/
export const getselectAddress = (store,id) => {
let promise = new Promise(function (resolve, reject) {
api.selectAddress(id).then((response) => {
if (response.code == 20000) { // 获取数据失败
resolve(1);
store.dispatch(types.SELECT_ADDRESS,{selectAddress:response.content});
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*保存编辑地址信息*/
export const posteditAddress = (store,data) => {
let promise = new Promise(function (resolve, reject) {
api.posteditAddress(data).then((response) => {
if (response.code == 20000) { // 提交成功
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*保存新增地址信息*/
export const postaddAddress= (store,data) => {
let promise = new Promise(function (resolve, reject) {
api.postaddAddress(data).then((response) => {
if (response.code == 20000) { // 提交成功
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*确认订单(结算)*/
export const postcheckOrder= (store,data) => {
console.log(data);
let promise = new Promise(function (resolve, reject) {
api.postcheckOrder(data).then((response) => {
if (response.code == 20000) { // 提交成功
store.dispatch(types.CHECK_ORDER,{checkOrder:response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*获取符合需求的优惠券列表*/
export const postmatchCouponList=(store,data) => {
console.log(data);
let promise = new Promise(function (resolve, reject) {
api.postmatchCouponList(data).then((response) => {
if (response.code == 20000) { // 提交成功
console.log(response.content);
store.dispatch(types.MATCH_COUPON_LIST,{matchCouponList:response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*确认下单*/
export const postconfirmOrder= (store,data) => {
console.log(data);
let promise = new Promise(function (resolve, reject) {
api.postconfirmOrder(data).then((response) => {
if (response.code == 20000) { // 提交成功
store.dispatch(types.CONFIRM_ORDER,{confirmOrder:response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*支付页面数据取得*/
export const getpushOrder= (store,orderId) => {
let promise = new Promise(function (resolve, reject) {
api.getpushOrder(orderId).then((response) => {
if (response.code == 20000) { // 提交成功
store.dispatch(types.PUSH_ORDER,{pushOrder:response.content});
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*支付订单*/
export const postpayOrder= (store,data) => {
let promise = new Promise(function (resolve, reject) {
api.postpayOrder(data).then((response) => {
if (response.code == 20000) { // 提交成功
resolve(1);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*获取订单列表*/
export const getOrderList = (store,orderState,evaluationState,page,pageNum) => {
let promise = new Promise(function (resolve, reject) {
api.getOrderList(orderState,evaluationState,page,pageNum).then((response) => {
if(response.content.list.length>=pageNum) {
resolve("continue");
}else {
resolve("stop");
}
store.dispatch(types.ORDER_LIST, {orderList: response.content});
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*获取订单列表数量*/
export const getOrderCount=(store) => {
let promise = new Promise(function (resolve, reject) {
api.getOrderCount().then((response) => {
if (response.code == 20000) { // 提交成功
resolve(response.content);
}
}, (response) => {
showMsg(store, response.message);
});
});
return promise;
};
/*清除订单列表*/
export const ClearOrderList=(store) => {
let promise = new Promise(function (resolve, reject) {
store.dispatch(types.ORDER_LIST_ClEAR,{orderList:[]});
resolve(1)
}, (response) => {
reject(1)
showMsg(store, response.message);
});
return promise;
};