Authored by 张丽霞

秒杀列表,review by redding

... ... @@ -10,6 +10,8 @@ import ReactNative, {
Dimensions,
TouchableOpacity,
} from 'react-native';
import SlicedImage from '../../../common/components/SlicedImage';
import DeleteLineText from '../../../common/components/DeleteLineText';
export default class ProductListView extends Component {
... ... @@ -20,6 +22,7 @@ export default class ProductListView extends Component {
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1.key != r2.key,
});
this._renderSeparator = this._renderSeparator.bind(this);
this.state = {
selectedIndex: 0,
... ... @@ -28,34 +31,90 @@ export default class ProductListView extends Component {
_renderRow(rowData, sectionID, rowID) {
rowData = rowData.toJS();
let brandIconUrl = SlicedImage.getSlicedUrl(rowData.defaultImages, 152, 203, 2);
let tipState='';
if (rowData.over) {
tipState = '已抢光';
} else if (rowData.wait) {
if (!rowData.remindFlag) {
tipState = '提醒我';
}else {
tipState = '取消提醒';
}
} else {
tipState = '去抢购';
}
return (
<TouchableOpacity onPress={() => {
if (true) {
return;
}
this.props.onPressProductItem && this.props.onPressProductItem(rowData);
}}>
<View key={'row' + rowID} style={styles.rowContainer}>
<Text>{rowData.productName}</Text>
<Image style={styles.leftImage} source={{uri: brandIconUrl}} />
<View style={styles.rowRight}>
<View style={styles.productTitlePrice}>
<Text style={styles.productTitle}>{rowData.productName}</Text>
{rowData.wait?
<View style={styles.secKillMarketPriceContainer}>
<Text style={styles.secKillPrice}>¥{rowData.secKillPrice}</Text>
<DeleteLineText style={{top:3, left:8}} text={rowData.marketPrice} />
</View>
:null
}
</View>
<View style={styles.priceClickTipView}>
<View style={styles.priceClickTipViewLeft}>
{rowData.wait?
<View style={styles.secKillMarketPriceContainer}>
<Image style={{top:1.5,marginRight:2}} source={require('../../images/time_icon.png')}/>
<Text style={styles.seckillBeginTimeTip}>{rowData.readableTime}开始</Text>
</View>
:<View style={styles.secKillMarketPriceContainer}>
<Text style={styles.secKillPrice}>¥{rowData.secKillPrice}</Text>
<DeleteLineText style={{top:3, left:8}} text={rowData.marketPrice} />
</View>
}
</View>
<TouchableOpacity onPress={() => {
this.props.onPressRemindBtn && this.props.onPressRemindBtn(rowData);
}}>
<View style={styles.priceClickTipViewRight}>
<Text style={{color:'white'}}>{tipState}</Text>
</View>
</TouchableOpacity>
</View>
</View>
</View>
</TouchableOpacity>
);
}
_renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
return (
<View key={'sep' + rowID} style={styles.separator}>
</View>
);
}
render() {
let {
resource,
} = this.props;
let backgroundWidth = width;
let backgroundHeight = 64 + 20 + Math.ceil(resource.length / 2) * rowHeight;
let backgroundHeight = 64 + 20 + resource.length * rowHeight;
return (
<View style={{width: backgroundWidth, height: backgroundHeight, backgroundColor: 'white'}}>
<View style={{width: backgroundWidth, height: backgroundHeight, backgroundColor: '#f0f0f0'}}>
<ListView
contentContainerStyle={[styles.contentContainer]}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(resource)}
renderRow={this._renderRow}
renderSeparator={this._renderSeparator}
scrollEnabled={false}
scrollsToTop={false}
/>
... ... @@ -66,9 +125,10 @@ export default class ProductListView extends Component {
let {width, height} = Dimensions.get('window');
let backgroundWidth= width;
let backgroundHeight = Math.ceil((120 / 640) * width);
let rowHeight = Math.ceil((120 / 640) * width);
let backgroundHeight = 121;
let rowHeight = backgroundHeight;
let imageWidth= 76;
let imageHeight = 101;
let styles = StyleSheet.create({
container: {
marginLeft: -1,
... ... @@ -84,10 +144,49 @@ let styles = StyleSheet.create({
},
rowContainer: {
flexDirection: 'row',
height: rowHeight,
backgroundColor:'white',
},
leftImage: {
width: imageWidth,
height: imageHeight,
marginLeft: 15,
marginRight: 15,
marginTop: 10,
resizeMode: 'contain',
},
rowRight: {
flexDirection: 'column',
justifyContent: 'space-between',
},
priceClickTipView: {
flexDirection: 'row',
justifyContent: 'space-between',
width: width - imageWidth - 35,
height: 50,
backgroundColor: 'white',
},
priceClickTipViewLeft: {
top: 25,
},
priceClickTipViewRight: {
width: 80,
height: 30,
marginRight: 10,
marginTop: 10,
alignItems: 'center',
justifyContent: 'center',
height: backgroundHeight,
backgroundColor:'blue',
borderRadius: 3,
backgroundColor: '#d0021b',
},
productTitlePrice: {
top: 15,
width: width - imageWidth - 30,
flexDirection: 'column',
},
secKillMarketPriceContainer: {
flexDirection: 'row',
},
bottomToolBar: {
top: 200,
... ... @@ -101,9 +200,24 @@ let styles = StyleSheet.create({
top: 10,
},
separator: {
width: 0.5,
top: 37 / 4,
height: 37 / 2,
width: width,
height: 1.5,
backgroundColor: '#e5e5e5',
},
productTitle: {
fontSize: 14,
color: '#444444',
},
marketPrice: {
fontSize: 11,
color: '#d0021b',
},
seckillPrice: {
fontSize: 10,
color: '#b0b0b0',
},
seckillBeginTimeTip: {
fontSize: 11,
color: '#b0b0b0',
}
});
... ...
... ... @@ -16,7 +16,7 @@ import {Map} from 'immutable';
import ProductListView from './ProductListView';
import TimeListView from './TimeListView';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import Toast from 'react-native-smart-toast'
export default class Seckill extends Component {
constructor(props) {
... ... @@ -38,9 +38,48 @@ export default class Seckill extends Component {
}
componentWillReceiveProps(nextProps) {
if (nextProps.addCancelUserReminderTip && nextProps.addCancelUserReminderTip !== '') {
this._showToast && this._showToast(nextProps.addCancelUserReminderTip);
}
}
_showToast(message){
this._toast && this._toast.show({
position: Toast.constants.gravity.center,
duration: 255,
children: message,
animationEnd : () => {
this._toast._toastAnimationToggle = setTimeout(
() => {
this._toast.hide({
duration: 0,
animationEnd: () => {
}
})
},
1000
);
}
})
}
renderRow(rowData, sectionID, rowID, highlightRow) {
console.log('rowData');
console.log(rowData);
if (Array.isArray(rowData) && rowData.length == 0) {
switch (rowID) {
case 'ActivityTimeList':
return (
<View style={styles.seckillEndView}>
<Text style={{fontSize:16}}>来晚啦~秒杀已结束</Text>
</View>
);
case 'ActivityProductList':
return null;
default:
}
}
if (rowID == 'ActivityTimeList') {
return (
<TimeListView
... ... @@ -54,9 +93,8 @@ export default class Seckill extends Component {
<ProductListView
resource={rowData}
onPressProductItem={this.props.onPressProductItem}
onPressRemindBtn={this.props.onPressRemindBtn}
/>
// <View>
// </View>
);
}
... ... @@ -70,6 +108,7 @@ export default class Seckill extends Component {
error,
queryActivityInfo,
queryProductList,
addCancelUserReminderTip,
} = this.props;
diff = Math.round((queryActivityInfo.currentTime - Date.now()) / 1000);
let dataSource = {
... ... @@ -84,6 +123,15 @@ export default class Seckill extends Component {
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(dataSource)}
renderRow={this.renderRow}
enablePullToRefresh={true}
isOnPullToRefresh={isFetching}
onRefreshData={() => {
//强制刷新数据
if (isFetching) {
return;
}
this.props.onRefresh && this.props.onRefresh();
}}
renderFooter={()=>{
return <View style={styles.descriptionContainer}>
<Text style={styles.descriptionText}>秒杀活动说明</Text>
... ... @@ -98,6 +146,12 @@ export default class Seckill extends Component {
<LoadingIndicator
isVisible={isFetching}
/>
<Toast
ref={ component => this._toast = component }
marginTop={64}>
</Toast>
</View>
);
}
... ... @@ -114,11 +168,19 @@ let diff = 0;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f0f0f0',
},
contentContainer:{
flexDirection: 'row',
flexWrap: 'wrap',
},
seckillEndView: {
height: 200,
width: width,
alignItems: 'center',
justifyContent: 'center',
},
listContainer: {
width: width / 2,
},
... ...
... ... @@ -10,6 +10,7 @@ import ReactNative, {
Dimensions,
TouchableOpacity,
} from 'react-native';
import Immutable, {Map} from 'immutable';
let diff;
... ... @@ -23,7 +24,7 @@ export default class SeckillTimeListView extends Component {
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1.key != r2.key,
});
this.curFocusActivity = {};
this.curFocusActivity = Immutable.fromJS({});
this.state = {
selectedIndex: 0,
tickHour: '00',
... ... @@ -35,11 +36,11 @@ export default class SeckillTimeListView extends Component {
componentDidMount() {
this.timer = setInterval(function () {
if (!this.curFocusActivity && this.curFocusActivity.size > 0 && !this.curFocusActivity.get('over')) {
if (!this.curFocusActivity && this.curFocusActivity.size > 0 && !this.curFocusActivity.has('over')) {
return;
}
let nowTime = Date.parse(new Date()) / 1000 + diffTime;
let time = this.curFocusActivity.get('now') ? this.curFocusActivity.get('endTime'): this.curFocusActivity.get('startTime') / 1000;
let time = this.curFocusActivity.has('now') ? this.curFocusActivity.get('endTime'): this.curFocusActivity.get('startTime') / 1000;
let offsetTime = time - nowTime;
let hour = parseInt(offsetTime / (60 * 60), 10);
let minute = parseInt(offsetTime % (60 * 60) / 60, 10);
... ...
... ... @@ -18,5 +18,14 @@ export default keyMirror({
QUERY_PRODUCT_LIST_SUCCESS: null,
QUERY_PRODUCT_LIST_FAILURE: null,
QUERY_REMIND_LIST_REQUEST: null,
QUERY_REMIND_LIST_SUCCESS: null,
QUERY_REMIND_LIST_FAILURE: null,
ADD_CANCEL_USER_REMINDER_REQUEST: null,
ADD_CANCEL_USER_REMINDER_SUCCESS: null,
ADD_CANCEL_USER_REMINDER_FAILURE: null,
UPDATE_SECKILL_PRODUCT_VO_LIST: null,
UPDATE_SECKILL_PRODUCT_LIST: null,
});
... ...
... ... @@ -43,21 +43,30 @@ class SeckillContainer extends Component {
super(props);
this._onPressTimeItem = this._onPressTimeItem.bind(this);
this._onPressProductItem = this._onPressProductItem.bind(this);
this._onPressRemindBtn = this._onPressRemindBtn.bind(this);
this._onRefresh = this._onRefresh.bind(this);
}
componentDidMount() {
this.props.actions.getSeckillQueryActivity();
}
_onPressTimeItem(activity){
_onPressTimeItem(activity) {
this.props.actions.clickActivityTimeItem(activity);
console.log('PressTimeItem');
}
_onPressProductItem(value){
console.log('onPressProductItem');
_onPressProductItem(product) {
this.props.actions.clickProductItem(product);
}
_onPressRemindBtn(product) {
this.props.actions.clickRemindBtn(product);
}
_onRefresh() {
this.props.actions.refreshList();
}
render() {
... ... @@ -66,6 +75,8 @@ class SeckillContainer extends Component {
error,
queryActivityInfo,
queryProductList,
queryRemindList,
addCancelUserReminderTip,
} = this.props.seckill;
return (
... ... @@ -74,8 +85,12 @@ class SeckillContainer extends Component {
error = {error}
queryActivityInfo = {queryActivityInfo}
queryProductList = {queryProductList}
queryRemindList = {queryRemindList}
addCancelUserReminderTip = {addCancelUserReminderTip}
onPressTimeItem={this._onPressTimeItem}
onPressProductItem={this._onPressProductItem}
onPressRemindBtn={this._onPressRemindBtn}
onRefresh={this._onRefresh}
/>
);
}
... ...
... ... @@ -3,6 +3,7 @@
import ReactNative from 'react-native';
import SeckillService from '../../services/SeckillService';
const Platform = require('Platform');
const moment = require('moment');
const {
SET_HOST,
... ... @@ -14,9 +15,19 @@ const {
QUERY_PRODUCT_LIST_SUCCESS,
QUERY_PRODUCT_LIST_FAILURE,
QUERY_REMIND_LIST_REQUEST,
QUERY_REMIND_LIST_SUCCESS,
QUERY_REMIND_LIST_FAILURE,
ADD_CANCEL_USER_REMINDER_REQUEST,
ADD_CANCEL_USER_REMINDER_SUCCESS,
ADD_CANCEL_USER_REMINDER_FAILURE,
UPDATE_SECKILL_PRODUCT_VO_LIST,
UPDATE_SECKILL_PRODUCT_LIST,
} = require('../../constants/actionTypes').default;
let curActivityId = 0;
/**
* [时间缺0补0]
*/
... ... @@ -38,7 +49,6 @@ export function queryActivityRequest() {
}
export function queryActivitySuccess(json) {
console.log('cccccc');
return {
type: QUERY_ACTIVITY_SUCCESS,
payload: json
... ... @@ -72,12 +82,59 @@ export function queryProductListFailure(error) {
}
}
export function queryRemindListRequest() {
return {
type: QUERY_REMIND_LIST_REQUEST
}
}
export function queryRemindListSuccess(json) {
return {
type: QUERY_REMIND_LIST_SUCCESS,
payload: json
}
}
export function queryRemindListFailure(error) {
return {
type: QUERY_REMIND_LIST_FAILURE,
payload: error
}
}
export function addCancelUserReminderRequest() {
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,
payload: message
}
}
export function updateSecKillProductVoList(json) {
return {
type: UPDATE_SECKILL_PRODUCT_VO_LIST,
payload: json
}
}
export function updateSecKillProductList(json) {
return {
type: UPDATE_SECKILL_PRODUCT_LIST,
payload: json
}
}
/*
* 秒杀时间栏
*/
... ... @@ -92,13 +149,17 @@ export function getSeckillQueryActivity() {
let processedTimeInfo = parseActivityTimeLsit(json);
dispatch(queryActivitySuccess(processedTimeInfo.newQueryActivityInfo));
let focusActivity = processedTimeInfo.focusActivity;
dispatch(getSeckillProductList(focusActivity.activityId));
curActivityId = focusActivity.activityId;
if (Date.now() < focusActivity.startTime) {
dispatch(getSeckillRemindList(curActivityId));
} else {
dispatch(getSeckillProductList(curActivityId));
}
} else {
dispatch(queryActivityFailure({error:'来晚啦~秒杀已结束'}));
}
})
.catch(error => {
console.log('bbbb');
dispatch(queryActivityFailure(error));
});
};
... ... @@ -107,40 +168,287 @@ export function getSeckillQueryActivity() {
/*
* 秒杀商品列表
*/
export function getSeckillProductList(activityId = 1) {
export function getSeckillProductList(activityId = curActivityId) {
curActivityId = activityId;
return (dispatch, getState) => {
let {app, seckill} = getState();
dispatch(queryProductListRequest());
return new SeckillService(app.host).fetchQueryProductList(activityId)
let queryProductList = (activityId) => {
let {app, seckill} = getState();
let {queryRemindList} = seckill;
queryRemindList = queryRemindList.toJS();
return new SeckillService(app.host).fetchQueryProductList(activityId)
.then(json => {
let productList = productAddFlag(json, queryRemindList);
dispatch(queryProductListSuccess(productList, queryRemindList));
})
.catch(error => {
dispatch(queryProductListFailure(error));
});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
queryProductList(activityId);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
queryProductList(activityId);
})
.catch(error => {
});
});
};
}
export function getSeckillRemindList(activityId = curActivityId) {
curActivityId = activityId;
return (dispatch, getState) => {
dispatch(queryRemindListRequest());
let queryRemindList = (activityId, uid) => {
let {app} = getState();
return new SeckillService(app.host).fetchQueryRemindList(activityId, uid)
.then(json => {
dispatch(queryRemindListSuccess(json));
dispatch(getSeckillProductList(activityId));
})
.catch(error => {
dispatch(queryRemindListFailure(error));
dispatch(getSeckillProductList(activityId));
});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
queryRemindList(activityId, uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
queryRemindList(activityId, uid);
})
.catch(error => {
});
});
};
}
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());
return new SeckillService(app.host).addCancelUserReminder(method,activityId,productSkn,uid,secKillId)
.then(json => {
console.log('22222222222222');
console.log(json);
dispatch(queryProductListSuccess(json));
//更新提醒状态
let remindFlag;
if (method === 'app.seckill.addUserReminder') {
remindFlag = true;
} else {
remindFlag = false;
}
queryProductList = queryProductList.toJS();
let curActivity = {};
console.log('99999999');
console.log(queryProductList);
queryProductList.forEach((productItem, i) => {
if (productItem.id === secKillId) {
productItem.remindFlag = remindFlag;
}
});
console.log('5555555');
console.log(queryProductList);
dispatch(updateSecKillProductList(queryProductList));
dispatch(addCancelUserReminderSuccess(okTip));
})
.catch(error => {
dispatch(queryProductListFailure(error));
console.log('error');
console.log(error);
dispatch(addCancelUserReminderFailure(failTip));
});
};
}
export function clickActivityTimeItem(activity) {
curActivityId = activity.activityId;
return (dispatch, getState) => {
let {app, seckill} = getState();
let {queryActivityInfo} = seckill;
queryActivityInfo = queryActivityInfo.toJS();
let curActivity = {};
queryActivityInfo.secKillProductVoList.forEach((activityTimeItem, i) => {
if (activityTimeItem.activityId === activity.activityId) {
curActivity = activityTimeItem;
activityTimeItem.focus = true;
} else {
activityTimeItem.focus = false;
}
});
dispatch(updateSecKillProductVoList(queryActivityInfo.secKillProductVoList));
dispatch(getSeckillProductList(activity.activityId));
if (Date.now() < curActivity.startTime) {
dispatch(getSeckillRemindList(curActivityId));
} else {
dispatch(getSeckillProductList(curActivityId));
}
};
}
export function clickProductItem(product) {
return (dispatch, getState) => {
if (!product.secKillSku || product.secKillSku.length == 0) {
return;
}
let skn = product.secKillSku[0].productSkn;
//
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${skn}", "is_seckill": "Y","tags_filter":""}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
}
export function clickRemindBtn(product) {
return (dispatch, getState) => {
if (!product.secKillSku || product.secKillSku.length == 0) {
return;
}
console.log('333333');
let skn = product.secKillSku[0].productSkn;
let actionName,
action,
params,
on_off,
method;
let okTip,
failTip,
result;
// default
on_off = true;
action = 'go.addSecKill';
method = 'app.seckill.addUserReminder';
params = {
skn: skn,
startTime: product.startTime,
productName: product.productName,
};
okTip = '设置提醒成功,将在开抢3分钟前提醒';
failTip = '设置提醒失败';
if (product.remindFlag) {
on_off = false;
action = 'go.delSecKill';
okTip = '取消提醒成功';
failTip = '取消提醒失败';
method = 'app.seckill.cancelUserReminder';
}
let queryRemindList = (uid) => {
ReactNative.NativeModules.YH_SeckillHelper.remindTip({
method: action,
arguments: params,
})
.then(flag => {
})
.then(flag => { //成功
console.log('method');
console.log(method);
dispatch(addCancelUserReminder(method, product.activityId, skn,uid, product.id, okTip, failTip));
})
.catch(error => {
});
};
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
console.log('1111');
queryRemindList(uid);
})
.catch(error => {
console.log('22222');
console.log(error);
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
queryRemindList(uid);
})
.catch(error => {
});
});
}
}
export function refreshList() {
return (dispatch, getState) => {
let {app, seckill} = getState();
let {queryActivityInfo,queryProductList} = seckill;
if (curActivityId !== 0) {
dispatch(getSeckillRemindList(curActivityId));
} else {
dispatch(getSeckillQueryActivity());
}
};
}
/**
* 秒杀商品 添加 自定义属性
* ----------------------------------------
* 已开抢
* product.over [APP,H5: 1.已抢光 2.过了endTime]
* product.isSeckill [APP,H5 秒杀中, 与over互斥]
* 抢购中:
* product.over
* product.isSeckill
* 即将开抢:
* product.wait = true
* product.remindFlag = true [APP: 已添加提醒]
* product.remindFalg = false [APP: 默认提醒状态]
* Product.hideRemind = true [APP: queryRemindList接口失败的情况下]
*/
function productAddFlag(productList, remindList) {
let now = Date.now();
productList
.sort((a, b) => b.orderBy - a.orderBy)
.forEach(product => {
let startTime = product.startTime * 1000; // s to ms
let endTime = product.endTime * 1000;
product.remindFlag = false;
product.readableTime = moment.unix(product.startTime).format('MM月DD日 HH:mm');
if (now < startTime) { // 未开抢
product.wait = true;
product.isSeckill = true;
if (!remindList) {
product.hideRemind = true;
} else if (remindList.length) {
for (let i = 0, j = remindList.length; i < j; i++) {
if (remindList[i].productSkn === product.productSkn) { // remind on;
product.remindFlag = true;
remindList.splice(i, 1);
break;
}
}
}
} else if (product.secKillStatus === 0 || (now > endTime)) { // 确实已抢光, 过了秒杀时间
product.over = true;
}
});
return productList;
}
function parseActivityTimeLsit(json, focusTime=0) {
let currentTime = json && json.currentTime ? json.currentTime * 1000 : Date.new();
let secKillProductVoList = json && json.secKillProductVoList ? json.secKillProductVoList : [];
... ... @@ -200,7 +508,6 @@ function parseActivityTimeLsit(json, focusTime=0) {
activityTimeItem.focus = true;
break;
}
i = i - 1;
}
... ...
... ... @@ -12,7 +12,9 @@ let InitialState = Record({
secKillProductVoList: List(),
})),
queryProductList: List(),
queryRemindList: List(),
addCancelUserReminderTip: '',
});
export default InitialState;
... ...
... ... @@ -13,7 +13,16 @@ const {
QUERY_PRODUCT_LIST_SUCCESS,
QUERY_PRODUCT_LIST_FAILURE,
QUERY_REMIND_LIST_REQUEST,
QUERY_REMIND_LIST_SUCCESS,
QUERY_REMIND_LIST_FAILURE,
ADD_CANCEL_USER_REMINDER_REQUEST,
ADD_CANCEL_USER_REMINDER_SUCCESS,
ADD_CANCEL_USER_REMINDER_FAILURE,
UPDATE_SECKILL_PRODUCT_VO_LIST,
UPDATE_SECKILL_PRODUCT_LIST,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -53,11 +62,38 @@ export default function seckillReducer(state=initialState, action) {
return state.set('isFetching', false)
.set('error', action.payload);
}
case QUERY_REMIND_LIST_REQUEST: {
return state.set('isFetching', true)
.set('error', null);
}
case QUERY_REMIND_LIST_SUCCESS: {
return state.set('isFetching', false)
.set('queryRemindList', Immutable.fromJS(action.payload))
.set('error', null);
}
case QUERY_REMIND_LIST_FAILURE: {
return state.set('isFetching', false)
.set('error', action.payload);
}
case ADD_CANCEL_USER_REMINDER_REQUEST: {
return state.set('addCancelUserReminderTip', '');
}
case ADD_CANCEL_USER_REMINDER_SUCCESS: {
return state.set('addCancelUserReminderTip', Immutable.fromJS(action.payload));
}
case ADD_CANCEL_USER_REMINDER_FAILURE: {
return state.set('addCancelUserReminderTip', Immutable.fromJS(action.payload));
}
case UPDATE_SECKILL_PRODUCT_VO_LIST: {
return state.setIn(['queryActivityInfo', 'secKillProductVoList'], Immutable.fromJS(action.payload))
.set('error', null);
}
case UPDATE_SECKILL_PRODUCT_LIST: {
return state.set('queryProductList', Immutable.fromJS(action.payload))
.set('error', null);
}
}
return state;
... ...
... ... @@ -42,4 +42,39 @@ export default class SeckillService {
throw(error);
});
}
async fetchQueryRemindList(activityId ,uid) {
return await this.api.get({
url: '',
body: {
method: 'app.seckill.queryRemindList',
activityId,
uid,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async addCancelUserReminder(method, activity_id, product_skn, uid, sec_kill_id) {
return await this.api.get({
url: '',
body: {
method: method,
activity_id,
product_skn,
uid,
sec_kill_id,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...