...
|
...
|
@@ -22,16 +22,13 @@ const { |
|
|
QUERY_PRODUCT_AND_REMIND_LIST_SUCCESS,
|
|
|
QUERY_PRODUCT_AND_REMIND_LIST_FAILURE,
|
|
|
|
|
|
ADD_CANCEL_USER_REMINDER_REQUEST,
|
|
|
ADD_CANCEL_USER_REMINDER_SUCCESS,
|
|
|
ADD_CANCEL_USER_REMINDER_FAILURE,
|
|
|
ADD_CANCEL_USER_REMINDER_CLEAR_TIP,
|
|
|
SHOW_TIP_MESSAGE,
|
|
|
CLEAR_TIP_MESSAGE,
|
|
|
|
|
|
UPDATE_SECKILL_PRODUCT_VO_LIST,
|
|
|
UPDATE_SECKILL_PRODUCT_LIST,
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
let curActivityId = 0;
|
|
|
/**
|
|
|
* [时间缺0补0]
|
|
|
*/
|
...
|
...
|
@@ -66,9 +63,10 @@ export function queryActivityFailure(error) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function queryProductListRequest() {
|
|
|
export function queryProductListRequest(activityId) {
|
|
|
return {
|
|
|
type: QUERY_PRODUCT_LIST_REQUEST
|
|
|
type: QUERY_PRODUCT_LIST_REQUEST,
|
|
|
payload: activityId
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -86,9 +84,10 @@ export function queryProductListFailure(error) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function queryProductAndRemindListRequest() {
|
|
|
export function queryProductAndRemindListRequest(activityId) {
|
|
|
return {
|
|
|
type: QUERY_PRODUCT_AND_REMIND_LIST_REQUEST
|
|
|
type: QUERY_PRODUCT_AND_REMIND_LIST_REQUEST,
|
|
|
payload: activityId
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -106,29 +105,16 @@ export function queryProductAndRemindListFailure(error) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function addCancelUserReminderRequest() {
|
|
|
export function showTipMessage(message) {
|
|
|
return {
|
|
|
type: ADD_CANCEL_USER_REMINDER_REQUEST
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function addCancelUserReminderSuccess(message) {
|
|
|
return {
|
|
|
type: ADD_CANCEL_USER_REMINDER_SUCCESS,
|
|
|
payload: message
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function addCancelUserReminderFailure(message) {
|
|
|
return {
|
|
|
type: ADD_CANCEL_USER_REMINDER_FAILURE,
|
|
|
type: SHOW_TIP_MESSAGE,
|
|
|
payload: message
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function addCancelUserReminderClearTip() {
|
|
|
export function clearTipMessage() {
|
|
|
return {
|
|
|
type:ADD_CANCEL_USER_REMINDER_CLEAR_TIP,
|
|
|
type:CLEAR_TIP_MESSAGE,
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -147,7 +133,10 @@ export function updateSecKillProductList(json) { |
|
|
}
|
|
|
|
|
|
export function setStartTime(startTime) {
|
|
|
console.log('---startTime----');
|
|
|
console.log(startTime);
|
|
|
startTime = moment(startTime, 'YYYYMMDDHHmmss').unix();
|
|
|
console.log(startTime);
|
|
|
return {
|
|
|
type: SET_START_TIME,
|
|
|
payload: startTime,
|
...
|
...
|
@@ -157,8 +146,15 @@ export function setStartTime(startTime) { |
|
|
* 秒杀时间栏
|
|
|
*/
|
|
|
export function getSeckillQueryActivity(inStartTime = 0) {
|
|
|
console.log('00000000');
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, seckill, startTime} = getState();
|
|
|
let {app, seckill} = getState();
|
|
|
let {startTime} = seckill;
|
|
|
console.log('aaaaa----aaaaa');
|
|
|
if (seckill.isFetching || seckill.tipMessage) {
|
|
|
return;
|
|
|
}
|
|
|
console.log('kkk---kkkk');
|
|
|
if (inStartTime) {
|
|
|
startTime = inStartTime;
|
|
|
}
|
...
|
...
|
@@ -169,18 +165,19 @@ export function getSeckillQueryActivity(inStartTime = 0) { |
|
|
let processedTimeInfo = parseActivityTimeLsit(json, startTime);
|
|
|
dispatch(queryActivitySuccess(processedTimeInfo.newQueryActivityInfo));
|
|
|
let focusActivity = processedTimeInfo.focusActivity;
|
|
|
curActivityId = focusActivity.activityId;
|
|
|
if (Date.now() < focusActivity.startTime) {
|
|
|
dispatch(getSeckillProductRemindList(curActivityId));
|
|
|
dispatch(getSeckillProductRemindList(focusActivity.activityId));
|
|
|
} else {
|
|
|
dispatch(getSeckillProductList(curActivityId));
|
|
|
dispatch(getSeckillProductList(focusActivity.activityId));
|
|
|
}
|
|
|
} else {
|
|
|
dispatch(queryActivityFailure({error:'来晚啦~秒杀已结束'}));
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.log('queryActivityFailure');
|
|
|
dispatch(queryActivityFailure(error));
|
|
|
dispatch(showTipMessage(error.message));
|
|
|
});
|
|
|
};
|
|
|
}
|
...
|
...
|
@@ -188,12 +185,14 @@ export function getSeckillQueryActivity(inStartTime = 0) { |
|
|
/*
|
|
|
* 秒杀商品列表
|
|
|
*/
|
|
|
export function getSeckillProductList(activityId = curActivityId) {
|
|
|
curActivityId = activityId;
|
|
|
export function getSeckillProductList(activityId = 0) {
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch(queryProductListRequest());
|
|
|
let {app, seckill} = getState();
|
|
|
let {queryRemindList} = seckill;
|
|
|
let {queryRemindList, queryProductList, curActivityId} = seckill;
|
|
|
if (!activityId) {
|
|
|
activityId = curActivityId;
|
|
|
}
|
|
|
dispatch(queryProductListRequest(activityId));
|
|
|
queryRemindList = queryRemindList.toJS();
|
|
|
return new SeckillService(app.host).fetchQueryProductList(activityId)
|
|
|
.then(json => {
|
...
|
...
|
@@ -203,7 +202,13 @@ export function getSeckillProductList(activityId = curActivityId) { |
|
|
} else {
|
|
|
productList = productAddFlag(json);
|
|
|
}
|
|
|
dispatch(queryProductListSuccess(productList));
|
|
|
queryProductList = queryProductList.toJS();
|
|
|
console.log(queryProductList);
|
|
|
queryProductList[activityId] = productList;
|
|
|
console.log('-----------');
|
|
|
console.log(productList);
|
|
|
console.log(queryProductList);
|
|
|
dispatch(queryProductListSuccess(queryProductList));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(queryProductListFailure(error));
|
...
|
...
|
@@ -214,11 +219,10 @@ export function getSeckillProductList(activityId = curActivityId) { |
|
|
/*
|
|
|
* 秒杀商品列表
|
|
|
*/
|
|
|
export function getSeckillProductRemindList(activityId = curActivityId) {
|
|
|
curActivityId = activityId;
|
|
|
export function getSeckillProductRemindList(activityId = 0) {
|
|
|
return (dispatch, getState) => {
|
|
|
let queryProductRemindList = (activityId, uid) => {
|
|
|
dispatch(queryProductAndRemindListRequest());
|
|
|
dispatch(queryProductAndRemindListRequest(activityId));
|
|
|
let {app, seckill} = getState();
|
|
|
let {queryProductList} = seckill;
|
|
|
Promise.all([
|
...
|
...
|
@@ -228,7 +232,16 @@ export function getSeckillProductRemindList(activityId = curActivityId) { |
|
|
let productList = result[0];
|
|
|
let remindList = result[1];
|
|
|
productList = productAddFlag(productList, remindList);
|
|
|
dispatch(queryProductAndRemindListSuccess({productList,remindList}));
|
|
|
console.log('1111111111111');
|
|
|
console.log(queryProductList);
|
|
|
console.log(activityId);
|
|
|
console.log(productList);
|
|
|
queryProductList = queryProductList.toJS();
|
|
|
|
|
|
queryProductList[activityId] = productList;
|
|
|
console.log('7777777777');
|
|
|
console.log(queryProductList);
|
|
|
dispatch(queryProductAndRemindListSuccess({queryProductList,remindList}));
|
|
|
|
|
|
})
|
|
|
.catch(error => {
|
...
|
...
|
@@ -249,8 +262,8 @@ export function getSeckillProductRemindList(activityId = curActivityId) { |
|
|
export function addCancelUserReminder(method='app.seckill.addUserReminder', activityId=0, productSkn=0, uid=0, secKillId=0, okTip='', failTip='') {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, seckill} = getState();
|
|
|
let {queryProductList} = seckill;
|
|
|
dispatch(addCancelUserReminderRequest());
|
|
|
let {queryProductList, curActivityId} = seckill;
|
|
|
dispatch(clearTipMessage());
|
|
|
return new SeckillService(app.host).addCancelUserReminder(method,activityId,productSkn,uid,secKillId)
|
|
|
.then(json => {
|
|
|
//更新提醒状态
|
...
|
...
|
@@ -262,23 +275,25 @@ export function addCancelUserReminder(method='app.seckill.addUserReminder', acti |
|
|
}
|
|
|
queryProductList = queryProductList.toJS();
|
|
|
let curActivity = {};
|
|
|
queryProductList.forEach((productItem, i) => {
|
|
|
queryProductList[curActivityId].forEach((productItem, i) => {
|
|
|
if (productItem.id === secKillId) {
|
|
|
productItem.remindFlag = remindFlag;
|
|
|
}
|
|
|
});
|
|
|
dispatch(addCancelUserReminderSuccess(okTip));
|
|
|
dispatch(showTipMessage(okTip));
|
|
|
dispatch(updateSecKillProductList(queryProductList));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(addCancelUserReminderFailure(failTip));
|
|
|
dispatch(showTipMessage(failTip));
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
export function clickActivityTimeItem(activity) {
|
|
|
curActivityId = activity.activityId;
|
|
|
console.log('----5');
|
|
|
console.log(activity);
|
|
|
let curActivityId = activity.activityId;
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, seckill} = getState();
|
|
|
let {queryActivityInfo} = seckill;
|
...
|
...
|
@@ -292,7 +307,8 @@ export function clickActivityTimeItem(activity) { |
|
|
activityTimeItem.focus = false;
|
|
|
}
|
|
|
});
|
|
|
dispatch(updateSecKillProductVoList(queryActivityInfo.secKillProductVoList));
|
|
|
let secKillProductVoList = queryActivityInfo.secKillProductVoList;
|
|
|
dispatch(updateSecKillProductVoList({secKillProductVoList, curActivityId}));
|
|
|
if (Date.now() < curActivity.startTime) {
|
|
|
dispatch(getSeckillProductRemindList(curActivityId));
|
|
|
} else {
|
...
|
...
|
@@ -376,7 +392,7 @@ export function clickRemindBtn(product) { |
|
|
dispatch(addCancelUserReminder(method, product.activityId, skn,uid, product.id, okTip, failTip));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(addCancelUserReminderFailure(error));
|
|
|
dispatch(showTipMessage(error));
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
@@ -386,8 +402,10 @@ export function clickRemindBtn(product) { |
|
|
export function refreshList() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, seckill} = getState();
|
|
|
let {queryActivityInfo,queryProductList} = seckill;
|
|
|
|
|
|
let {queryActivityInfo,queryProductList,curActivityId} = seckill;
|
|
|
console.log('------refreshList');
|
|
|
console.log('------55');
|
|
|
console.log(curActivityId);
|
|
|
if (curActivityId !== 0 && queryActivityInfo.secKillProductVoList) {
|
|
|
queryActivityInfo.secKillProductVoList.forEach((activityInfo, i) => {
|
|
|
if (activityInfo.get('activityId') === curActivityId) {
|
...
|
...
|
|