Authored by 孙凯

add 优惠券提示 review by zhanglixia

... ... @@ -27,7 +27,7 @@ import ProductCategoryList from '../brandStore/brandStoreSubView/Cells/ProductCa
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
import BrandProductListCell from '../../../common/components/ListCell/ProductListCell';
import Toast from 'react-native-smart-toast'
export default class BrandStore extends Component {
constructor(props) {
... ... @@ -43,15 +43,13 @@ export default class BrandStore extends Component {
});
}
componentDidMount() {
}
componentWillUnmount() {
componentDidUpdate() {
let needShowToast = this.props.receiveCouponResult.isNeedShow;
let showToastMessage = this.props.receiveCouponResult.showMessage;
if (needShowToast) {
this._showToast && this._showToast(showToastMessage);
}
}
_onPressProductFilter(value){
if(value === 'filter'){
... ... @@ -65,6 +63,27 @@ export default class BrandStore extends Component {
}
_showToast(message){
this.props.resetReceiveCouponResult && this.props.resetReceiveCouponResult();
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
);
}
})
}
renderSectionHeader(sectionData, sectionID) {
switch(sectionID) {
case 'brandReource': {
... ... @@ -213,6 +232,7 @@ export default class BrandStore extends Component {
categoryFilterList,
filterCategoryDetailFilterList,
filterNameFactors,
receiveCouponResult,
} = this.props;
let {
... ... @@ -288,7 +308,7 @@ export default class BrandStore extends Component {
}}
/>
{productList.isFilter ?
{productList.isFilter ?
<ProductCategoryList
categoryFilterList={categoryFilterList}
filterCategoryDetailFilterList={filterCategoryDetailFilterList}
... ... @@ -296,7 +316,7 @@ export default class BrandStore extends Component {
filterNameFactors={filterNameFactors}
onPressProductFilterRightItem={this.props.onPressProductFilterRightItem}/> : null}
{productList.isMoreFilter ?
{productList.isMoreFilter ?
<BrandProductMoreFilter
productList={productList}
onPressCloseMoreFilter={this.props.onPressCloseMoreFilter}
... ... @@ -305,10 +325,14 @@ export default class BrandStore extends Component {
<LoadingIndicator
isVisible={isFetching}
/>
<Toast
ref={ component => this._toast = component }
marginTop={64}>
Unable to connect to apple store
</Toast>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let rowWidth = Math.ceil(137.5 * width / 320);
... ...
... ... @@ -55,7 +55,7 @@ export default keyMirror({
SET_PRODUCT_LIST_FILTER: null,
RESET_LIST_PAGE_INFO: null,
RESETRECEIVECOUPONRES:null,
FILTER_LIST_VIEW:null,
... ...
... ... @@ -58,6 +58,8 @@ class BrandStoreContainer extends Component {
this._onPressProductFilterRightItem=this._onPressProductFilterRightItem.bind(this);
this._onPressMoreFilter=this._onPressMoreFilter.bind(this);
this._onPressCloseMoreFilter=this._onPressCloseMoreFilter.bind(this);
this.resetReceiveCouponResult=this.resetReceiveCouponResult.bind(this);
}
componentDidMount() {
... ... @@ -72,6 +74,10 @@ class BrandStoreContainer extends Component {
}
resetReceiveCouponResult(){
this.props.actions.resetReceiveCouponResult();
}
_onPressCollection(isCollected) {
if (isCollected) {
this.props.actions.addFavorite();
... ... @@ -83,6 +89,8 @@ class BrandStoreContainer extends Component {
_onPressCoupon(rowData) {
if (rowData.status) {
this.props.actions.getCoupon(rowData.id);
}else {
this.props.actions.couponHasRecived();
}
}
... ... @@ -176,6 +184,7 @@ class BrandStoreContainer extends Component {
let {
info,
receiveCouponResult,
resource,
coupon,
productList,
... ... @@ -196,6 +205,7 @@ class BrandStoreContainer extends Component {
<BrandStore
isFetching={isFetching}
info={info}
receiveCouponResult={receiveCouponResult}
resource={resource}
coupon={coupon}
productList={productList}
... ... @@ -220,6 +230,7 @@ class BrandStoreContainer extends Component {
onPressProductFilterRightItem={this._onPressProductFilterRightItem}
onPressMoreFilter={this._onPressMoreFilter}
onPressCloseMoreFilter={this._onPressCloseMoreFilter}
resetReceiveCouponResult={this.resetReceiveCouponResult}
/>
);
}
... ...
... ... @@ -55,6 +55,7 @@ const {
ADD_COUPON_REQUEST,
ADD_COUPON_SUCCESS,
ADD_COUPON_FAILURE,
RESETRECEIVECOUPONRES,
SET_PRODUCT_LIST_FILTER,
RESET_LIST_PAGE_INFO,
... ... @@ -895,6 +896,12 @@ export function getFavoriteState() {
};
}
export function resetReceiveCouponResult() {
return {
type: RESETRECEIVECOUPONRES,
}
}
export function getCouponRequest() {
return {
type: ADD_COUPON_REQUEST,
... ... @@ -908,9 +915,18 @@ export function getCouponSuccess(list) {
}
}
export function couponHasRecived() {
return {
type: ADD_COUPON_FAILURE,
payload: ' 优惠券已领取 '
}
}
export function getCouponFailure(error) {
return {
type: ADD_COUPON_FAILURE,
payload: error.message,
}
}
... ...
... ... @@ -7,6 +7,10 @@ let InitialState = Record({
storeFilter: 0,
categoryFilterList: List(),
filterCategoryDetailFilterList: List(),
receiveCouponResult: new (Record({
showMessage: '',
isNeedShow: false,
})),
info: new (Record({
isFetching: false,
... ...
... ... @@ -52,7 +52,7 @@ const {
SET_PRODUCT_LIST_FILTER,
RESET_LIST_PAGE_INFO,
RESETRECEIVECOUPONRES,
FILTER_LIST_VIEW,
FILTER_MORE_VIEW,
... ... @@ -328,8 +328,20 @@ export default function brandStoreReducer(state=initialState, action) {
return state.setIn(['productList', 'isMoreFilter'], action.payload);
}
case ADD_COUPON_SUCCESS: {
return state.setIn(['coupon', 'list'], Immutable.fromJS(action.payload));
return state.setIn(['coupon', 'list'], Immutable.fromJS(action.payload))
.setIn(['receiveCouponResult', 'showMessage'], ' 领取成功 ')
.setIn(['receiveCouponResult', 'isNeedShow'], true);
}
case ADD_COUPON_FAILURE: {
return state.setIn(['receiveCouponResult', 'showMessage'], Immutable.fromJS(action.payload))
.setIn(['receiveCouponResult', 'isNeedShow'], true);
}
case RESETRECEIVECOUPONRES:
{
return state.setIn(['receiveCouponResult', 'showMessage'], '')
.setIn(['receiveCouponResult', 'isNeedShow'], false);
}
break;
}
return state;
... ...
... ... @@ -32,6 +32,7 @@
"redux-thunk": "^2.0.1",
"stacktrace-js": "^1.3.0",
"timeago.js": "^1.0.5",
"yh_rncamera": "0.1.0"
"yh_rncamera": "0.1.0",
"react-native-smart-toast": "^1.1.1"
}
}
... ...