...
|
...
|
@@ -6,7 +6,6 @@ import * as _ from 'lodash'; |
|
|
import {parseShopResources} from '../../utils/ResourceParser';
|
|
|
|
|
|
const {
|
|
|
SET_COLLECTION,
|
|
|
SET_STOREFILTER,
|
|
|
JUMP_WITH_URL,
|
|
|
SET_SCANTYPE,
|
...
|
...
|
@@ -45,10 +44,17 @@ const { |
|
|
|
|
|
PRODUCT_FILTER_ACTION,
|
|
|
|
|
|
ADD_FAVORITE_REQUEST,
|
|
|
ADD_FAVORITE_SUCCESS,
|
|
|
ADD_FAVORITE_FAILURE,
|
|
|
|
|
|
CANCEL_FAVORITE_REQUEST,
|
|
|
CANCEL_FAVORITE_SUCCESS,
|
|
|
CANCEL_FAVORITE_FAILURE,
|
|
|
|
|
|
SET_PRODUCT_LIST_FILTER,
|
|
|
RESET_LIST_PAGE_INFO,
|
|
|
|
|
|
|
|
|
FILTER_LIST_VIEW,
|
|
|
|
|
|
} = require('../../constants/actionTypes').default;
|
...
|
...
|
@@ -73,32 +79,42 @@ export function resetListPageInfo() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function addFavoriteRequest() {
|
|
|
return {
|
|
|
type: ADD_FAVORITE_REQUEST,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function addFavoriteSuccess() {
|
|
|
return {
|
|
|
type: SET_COLLECTION,
|
|
|
type: ADD_FAVORITE_SUCCESS,
|
|
|
payload: true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function addFavoriteFailure(error) {
|
|
|
if (error.code == 413) {
|
|
|
return {
|
|
|
type: SET_COLLECTION,
|
|
|
payload: true,
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
type: ADD_FAVORITE_FAILURE,
|
|
|
payload: error,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function cancelFavoriteRequest() {
|
|
|
return {
|
|
|
type: CANCEL_FAVORITE_REQUEST,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function cancelFavoriteSuccess() {
|
|
|
return {
|
|
|
type: SET_COLLECTION,
|
|
|
type: CANCEL_FAVORITE_SUCCESS,
|
|
|
payload: false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function cancelFavoriteFailure(error) {
|
|
|
return {
|
|
|
type: SET_COLLECTION,
|
|
|
type: CANCEL_FAVORITE_FAILURE,
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -791,6 +807,7 @@ export function addFavorite() { |
|
|
let {app, brandStore} = getState();
|
|
|
let {shopId} = brandStore;
|
|
|
|
|
|
dispatch(addFavoriteRequest());
|
|
|
let favoriteRequest = (shopId, favId, uid) => {
|
|
|
return new BrandStoreService(app.host).addFavorite(shopId, favId, uid)
|
|
|
.then(json => {
|
...
|
...
|
@@ -822,6 +839,7 @@ export function cancelFavorite() { |
|
|
let {app, brandStore} = getState();
|
|
|
let {shopId} = brandStore;
|
|
|
|
|
|
dispatch(cancelFavoriteRequest());
|
|
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
|
|
.then(uid => {
|
|
|
return new BrandStoreService(app.host).cancelFavorite(shopId, shopId, uid)
|
...
|
...
|
|