Authored by 于良

bug fix YH-4949 review by qiangbing

... ... @@ -108,7 +108,7 @@ export default class CouponCenter extends Component {
render() {
let data = this.props.floors.toArray();
return (
<View style={styles.container}>
<ListView
... ... @@ -126,6 +126,12 @@ export default class CouponCenter extends Component {
onPromptHidden={this.props.onPromptHidden}
/> : null}
{this.props.showNetErrorTip ? <Prompt
text={'网络异常!'}
duration={3000}
onPromptHidden={this.props.onNetPromptHidden}
/> : null}
</View>
);
}
... ...
... ... @@ -93,6 +93,7 @@ export default class Prompt extends Component {
color: this.props.textColor,
fontSize: this.props.textFontSize,
maxWidth: width - 30 - 30,
marginTop: 15,
marginLeft: 15,
marginRight: 15,
marginBottom: 15,
... ... @@ -102,7 +103,7 @@ export default class Prompt extends Component {
return (
<Animated.View style={[styles.container, {opacity: this.state.fadeAnim,}]}>
<View style={customStyles.overlay}>
<Image source={this.props.icon} style={customStyles.title}/>
{this.props.icon ? <Image source={this.props.icon} style={customStyles.title}/> : null}
<Text style={customStyles.text}>{this.props.text}</Text>
</View>
</Animated.View>
... ...
... ... @@ -17,5 +17,6 @@ export default keyMirror({
JUMP_WITH_URL: null,
HIDE_SUCCESS_PROMPT: null,
HIDE_NET_ERROR_PROMPT: null,
});
... ...
... ... @@ -49,6 +49,7 @@ class CouponCenterContainer extends Component {
this._onPressCoupon = this._onPressCoupon.bind(this);
this._onGetCoupon = this._onGetCoupon.bind(this);
this._onPromptHidden = this._onPromptHidden.bind(this);
this._onNetPromptHidden = this._onNetPromptHidden.bind(this);
this.subscription = NativeAppEventEmitter.addListener(
'UserDidLoginEvent',
... ... @@ -86,8 +87,13 @@ class CouponCenterContainer extends Component {
this.props.actions.promptHidden();
}
_onNetPromptHidden() {
this.props.actions.netPromptHidden();
}
render() {
let {isFetching, floors, showSuccessTip} = this.props.coupon;
let {isFetching, floors, showSuccessTip, showNetErrorTip} = this.props.coupon;
return (
<CouponCenter
isFetching={isFetching}
... ... @@ -98,6 +104,8 @@ class CouponCenterContainer extends Component {
onGetCoupon={this._onGetCoupon}
showSuccessTip={showSuccessTip}
onPromptHidden={this._onPromptHidden}
showNetErrorTip={showNetErrorTip}
onNetPromptHidden={this._onNetPromptHidden}
/>
);
}
... ...
... ... @@ -13,6 +13,7 @@ const {
GET_COUPON_FAILURE,
JUMP_WITH_URL,
HIDE_SUCCESS_PROMPT,
HIDE_NET_ERROR_PROMPT,
} = require('../../constants/actionTypes').default;
export function setContentCode(code) {
... ... @@ -43,7 +44,6 @@ export function couponCenterFailure(error) {
}
/*
* index number 请求数据的index
* reload bool 是否需要强制重新请求数据,
*/
export function couponCenter(reload = false) {
... ... @@ -68,7 +68,7 @@ export function couponCenter(reload = false) {
dispatch(couponCenterSuccess(payload));
})
.catch(error => {
dispatch(couponCenterFailure(error));
dispatch(couponCenterFailure(error.message));
});
}
... ... @@ -201,7 +201,7 @@ export function getCoupon(couponID) {
dispatch(getCouponSuccess(floors));
})
.catch(error => {
dispatch(getCouponFailure(error));
dispatch(getCouponFailure(error.message));
});
}
... ... @@ -241,3 +241,9 @@ export function promptHidden() {
type: HIDE_SUCCESS_PROMPT,
};
}
export function netPromptHidden() {
return {
type: HIDE_NET_ERROR_PROMPT,
};
}
... ...
... ... @@ -8,6 +8,7 @@ let InitialState = Record({
error: null,
floors: List(),
showSuccessTip: false,
showNetErrorTip: false,
});
export default InitialState;
... ...
... ... @@ -13,6 +13,7 @@ const {
GET_COUPON_FAILURE,
JUMP_WITH_URL,
HIDE_SUCCESS_PROMPT,
HIDE_NET_ERROR_PROMPT,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -35,8 +36,11 @@ export default function couponReducer(state=initialState, action) {
}
case COUPON_CENTER_FAILURE: {
let showNetErrorTip = action.payload && (action.payload.indexOf('Network request failed') != -1 || action.payload.indexOf('Request timeout') != -1);
return state.set('isFetching', false)
.set('error', action.payload);
.set('error', action.payload)
.set('showNetErrorTip', showNetErrorTip);
}
case GET_COUPON_REQUEST: {
... ... @@ -53,14 +57,21 @@ export default function couponReducer(state=initialState, action) {
}
case GET_COUPON_FAILURE: {
let showNetErrorTip = action.payload && (action.payload.indexOf('Network request failed') != -1 || action.payload.indexOf('Request timeout') != -1);
return state.set('isFetching', false)
.set('error', action.payload)
.set('showSuccessTip', false);
.set('showSuccessTip', false)
.set('showNetErrorTip', showNetErrorTip);
}
case HIDE_SUCCESS_PROMPT: {
return state.set('showSuccessTip', false);
}
case HIDE_NET_ERROR_PROMPT: {
return state.set('showNetErrorTip', false);
}
}
return state;
... ...