Authored by 孙凯

add 我的优惠劵 bug review by hongmo

... ... @@ -44,8 +44,10 @@ export default class Coupon extends Component {
}
_renderRow(rowData, sectionID, rowID) {
let {resource} = this.props;
let fliter = resource.get('fliter');
return(
<CouponCell resource={rowData} onPressUseNow={this.props.onPressUseNow}/>
<CouponCell usedType={fliter} index={rowID} resource={rowData} showCouponDetail={this.props.showCouponDetail} onPressUseNow={this.props.onPressUseNow}/>
);
}
... ...
... ... @@ -19,16 +19,20 @@ export default class CouponCell extends React.Component {
constructor(props) {
super (props);
}
this.state = {
showDetail: false,
};
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
render() {
let resource = this.props.resource?this.props.resource.toJS():null;
let showDetail = this.state.showDetail;
let tipImage = showDetail?require('../../image/up_tip_ic.png'):require('../../image/down_tip_ic.png');
let usedType = this.props.usedType;
let index = this.props.index;
let couponDetailInfomation = resource.couponDetailInfomation;
let couponValidity = resource.couponValidity;
let rule4ShortName = resource.rule4ShortName;
... ... @@ -37,6 +41,9 @@ export default class CouponCell extends React.Component {
let isNoLimit = resource.isNoLimit;
let brandNameLimit = resource.brandNameLimit;
let sortNameLimit = resource.sortNameLimit;
let showDetail = resource.showDetail?resource.showDetail:false;
let tipImage = showDetail?require('../../image/up_tip_ic.png'):require('../../image/down_tip_ic.png');
let bottomText = brandNameLimit.length > 0 ? '限品牌:'+brandNameLimit[0] :'';
bottomText = sortNameLimit.length > 0 ? bottomText + '限品类:'+sortNameLimit[0] : bottomText;
bottomText = isNoLimit=='true' ? '全场通用' : bottomText;
... ... @@ -44,6 +51,7 @@ export default class CouponCell extends React.Component {
let backgroundHeigth = showDetail ? topBackgroundHeigth + detailBackgroundHeigth + 20 : topBackgroundHeigth + 20;
return (
<View style={{width: width, height: backgroundHeigth}}>
<View style={{width: width,height: 20,backgroundColor: 'white',}}/>
<Image source={require('../../image/coupon1_tip_bg.png')} style={styles.couponBackgroundImage}></Image>
<View style={styles.topContent}>
<View style={styles.topTitleView}>
... ... @@ -59,24 +67,26 @@ export default class CouponCell extends React.Component {
<View style={styles.rigthDetail}>
<View style={styles.timeDetailTopView}>
<Text style={styles.timeDetailTop} numberOfLines={1}>{couponValidity}</Text>
{overState ? <Text style={styles.timeDetail2} numberOfLines={1}>({overState})</Text>:null}
{usedType == 0 && overState ? <Text style={styles.timeDetail2} numberOfLines={1}>({overState})</Text>:null}
</View>
<View style={styles.timeDetailBottomView}>
<TouchableOpacity activeOpacity={1} style={styles.timeDetailBottomView}
onPress={() => {
this.setState({showDetail: !showDetail});
this.props.showCouponDetail && this.props.showCouponDetail(usedType,index,!showDetail)
}}
>
<Text style={styles.timeDetailSwitch} numberOfLines={1}>详细信息</Text>
<Image source={tipImage} style={styles.timeDetailSwitchIcon}></Image>
</TouchableOpacity>
<TouchableOpacity activeOpacity={1} style={styles.button}
onPress={() => {
this.props.onPressUseNow && this.props.onPressUseNow(resource)
}}
>
<Image source={require('../../image/ljsy_tip_an.png')} style={styles.button}></Image>
</TouchableOpacity>
{usedType == 0 ? <TouchableOpacity activeOpacity={1} style={styles.button}
onPress={() => {
this.props.onPressUseNow && this.props.onPressUseNow(resource)
}}
>
<Image source={require('../../image/ljsy_tip_an.png')} style={styles.button}></Image>
</TouchableOpacity> :
<Image source={require('../../image/coupon_mark_used.png')} style={styles.usedIcon}></Image>
}
</View>
</View>
</View>
... ... @@ -90,8 +100,6 @@ export default class CouponCell extends React.Component {
</View>
</View>
</View> : null}
<View style={{width: width,height: 20,backgroundColor: 'white',}}/>
</View>
);
}
... ... @@ -107,6 +115,7 @@ let topBackgroundWidth = width - 50;
let sc2 = 182/1035;//背景宽高比
let detailBackgroundHeigth = sc2*(width - 50);
let detailBackgroundWidth = width - 50;
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
... ... @@ -204,7 +213,13 @@ let styles = StyleSheet.create({
right: 15,
top: 5,
},
usedIcon: {
width: detailBackgroundHeigth + 8,
height: detailBackgroundHeigth + 8,
position: 'absolute',
right: 10,
bottom: -5,
},
bottom: {
width: detailBackgroundWidth,
... ...
... ... @@ -40,8 +40,11 @@ export default keyMirror({
UNUSE_COUPON_LIST_SUCCESS: null,
UNUSE_COUPON_LIST_FAILURE: null,
RESET_DATA: null,
SHOW_USED_COUPON_DETAIL: null,
SHOW_UNUSED_COUPON_DETAIL: null,
RESET_DATA: null,
USED_COUPON_LIST_REQUEST: null,
USED_COUPON_LIST_SUCCESS: null,
USED_COUPON_LIST_FAILURE: null,
... ...
... ... @@ -48,6 +48,7 @@ class CouponContainer extends Component {
this._onPressMore = this._onPressMore.bind(this);
this._onEndReached = this._onEndReached.bind(this);
this._onPressUseNow = this._onPressUseNow.bind(this);
this._showCouponDetail = this._showCouponDetail.bind(this);
this.subscription = NativeAppEventEmitter.addListener(
'needUpdateCoupon',
(reminder) => {
... ... @@ -59,6 +60,7 @@ class CouponContainer extends Component {
componentDidMount() {
this.props.actions.getUnuseCouponsList();
this.props.actions.getUsedCouponsList();
}
componentWillUnmount() {
... ... @@ -70,7 +72,18 @@ class CouponContainer extends Component {
}
_onEndReached() {
this.props.actions.getUnuseCouponsList();
let {coupon} = this.props;
let fliter = coupon.get('fliter');
if (fliter == 0) {
this.props.actions.getUnuseCouponsList();
}else if (fliter == 1) {
this.props.actions.getUsedCouponsList();
}
}
_showCouponDetail(fliter,index,isShow){
this.props.actions.showCouponDetail(fliter,index,isShow)
}
_onPressFilter(fliter){
... ... @@ -91,6 +104,7 @@ class CouponContainer extends Component {
onPressMore={this._onPressMore}
onEndReached={this._onEndReached}
onPressUseNow={this._onPressUseNow}
showCouponDetail={this._showCouponDetail}
/>
</View>
);
... ...
... ... @@ -14,6 +14,9 @@ const {
USED_COUPON_LIST_SUCCESS,
USED_COUPON_LIST_FAILURE,
SHOW_USED_COUPON_DETAIL,
SHOW_UNUSED_COUPON_DETAIL,
RESET_DATA,
} = require('../../constants/actionTypes').default;
... ... @@ -107,6 +110,45 @@ export function usedCouponListFailure(error) {
}
}
export function showUsedCouponDetail(list) {
return {
type: SHOW_USED_COUPON_DETAIL,
payload: list
}
}
export function showUnusedCouponDetail(list) {
return {
type: SHOW_UNUSED_COUPON_DETAIL,
payload: list
}
}
export function showCouponDetail(fliter,index,isShow) {
return (dispatch, getState) => {
let {app, coupon} = getState();
let couponDic = coupon?coupon.toJS():null;
let couponLists = couponDic.usedCoupon.couponList;
if (fliter == 0) {
couponLists = couponDic.unuseCoupon.couponList;
}
let items = couponLists&&couponLists.length>index?couponLists[index]:null;
if (items) {
items.showDetail = isShow;
}
if (fliter == 0) {
dispatch(showUnusedCouponDetail(couponLists));
}else if (fliter == 1) {
dispatch(showUsedCouponDetail(couponLists));
}
};
}
export function getUsedCouponsList() {
return (dispatch, getState) => {
... ...
... ... @@ -13,6 +13,10 @@ const {
USED_COUPON_LIST_REQUEST,
USED_COUPON_LIST_SUCCESS,
USED_COUPON_LIST_FAILURE,
SHOW_USED_COUPON_DETAIL,
SHOW_UNUSED_COUPON_DETAIL,
RESET_DATA,
} = require('../../constants/actionTypes').default;
... ... @@ -66,6 +70,13 @@ export default function detailReducer(state=initialState, action) {
.setIn(['unuseCoupon', 'couponList'], Immutable.fromJS([]))
.setIn(['unuseCoupon', 'error'], null);
}
case SHOW_USED_COUPON_DETAIL: {
return state.setIn(['usedCoupon', 'couponList'], Immutable.fromJS(action.payload))
}
case SHOW_UNUSED_COUPON_DETAIL: {
return state.setIn(['unuseCoupon', 'couponList'], Immutable.fromJS(action.payload))
}
break;
}
return state;
... ...