Authored by 孙凯

修改 收藏 bug review by hongmo

... ... @@ -830,10 +830,10 @@ export function addFavoriteRequest() {
}
}
export function addFavoriteSuccess() {
export function addFavoriteSuccess(isAdd) {
return {
type: ADD_FAVORITE_SUCCESS,
payload: true
payload: isAdd
}
}
... ... @@ -870,7 +870,7 @@ export function addFavorite() {
let favoriteRequest = (shopId, favId, uid) => {
dispatch(addFavoriteRequest());
dispatch(addFavoriteSuccess());
dispatch(addFavoriteSuccess(true));
return new RedBrandService(app.host).addFavorite(shopId, favId, uid)
.then(json => {
})
... ... @@ -927,7 +927,7 @@ export function getFavoriteState() {
return new RedBrandService(app.host).isFavorite(shopId, uid)
.then(json => {
if (json) {
dispatch(addFavoriteSuccess());
dispatch(addFavoriteSuccess(false));
}
})
.catch(error => {
... ...
... ... @@ -155,8 +155,13 @@ export default function redBrandReducer(state=initialState, action) {
.setIn(['receiveCouponResult', 'isNeedShow'], false);
}
case ADD_FAVORITE_SUCCESS: {
if (action.payload) {
return state.setIn(['shopIntro', 'is_addFav'], action.payload)
.setIn(['shopIntro', 'favoriteCount'],parseInt(state.shopIntro.favoriteCount) +1);
}else {
return state.setIn(['shopIntro', 'is_addFav'], action.payload);
}
}
case ADD_FAVORITE_FAILURE: {
if (action.payload.code == 413) {
return state.setIn(['shopIntro', 'is_addFav'], true);
... ... @@ -164,7 +169,8 @@ export default function redBrandReducer(state=initialState, action) {
return state.setIn(['shopIntro', 'is_addFav'], false);
}
case CANCEL_FAVORITE_SUCCESS: {
return state.setIn(['shopIntro', 'is_addFav'], action.payload);
return state.setIn(['shopIntro', 'is_addFav'], action.payload)
.setIn(['shopIntro', 'favoriteCount'],(parseInt(state.shopIntro.favoriteCount) -1)>0?(parseInt(state.shopIntro.favoriteCount) -1):0);
}
case GET_FAVORITE_COUNT_SUCCESS: {
return state.setIn(['shopIntro', 'favoriteCount'], action.payload);
... ...