...
|
...
|
@@ -43,11 +43,33 @@ export function onPressCoupon() { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function onPressCollection() {
|
|
|
return {
|
|
|
type: SET_COLLECTION,
|
|
|
payload: true
|
|
|
};
|
|
|
export function addFavoriteSuccess() {
|
|
|
return {
|
|
|
type: SET_COLLECTION,
|
|
|
payload: true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function addFavoriteFailure(error) {
|
|
|
if (error.code == 413) {
|
|
|
return {
|
|
|
type: SET_COLLECTION,
|
|
|
payload: true,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function cancelFavoriteSuccess() {
|
|
|
return {
|
|
|
type: SET_COLLECTION,
|
|
|
payload: false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function cancelFavoriteFailure(error) {
|
|
|
return {
|
|
|
type: SET_COLLECTION,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function setStoreFilter(filter) {
|
...
|
...
|
@@ -386,3 +408,74 @@ function parseProductList(json) { |
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
export function addFavorite() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, brandStore} = getState();
|
|
|
let {shopId} = brandStore;
|
|
|
|
|
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
|
|
.then(uid => {
|
|
|
return new BrandStoreService().addFavorite(shopId, shopId, uid)
|
|
|
.then(json => {
|
|
|
console.log('收藏成功');
|
|
|
dispatch(addFavoriteSuccess());
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.log(error);
|
|
|
dispatch(addFavoriteFailure(error));
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
ReactNative.NativeModules.YH_CommonHelper.login()
|
|
|
.then(uid => {
|
|
|
return new BrandStoreService().addFavorite(shopId, shopId, uid)
|
|
|
.then(json => {
|
|
|
console.log('收藏成功');
|
|
|
dispatch(addFavoriteSuccess());
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(addFavoriteFailure(error));
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function cancelFavorite() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, brandStore} = getState();
|
|
|
let {shopId} = brandStore;
|
|
|
|
|
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
|
|
.then(uid => {
|
|
|
return new BrandStoreService().cancelFavorite(shopId, shopId, uid)
|
|
|
.then(json => {
|
|
|
console.log('取消收藏成功');
|
|
|
dispatch(cancelFavoriteSuccess());
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.log(error);
|
|
|
dispatch(cancelFavoriteFailure(error));
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
ReactNative.NativeModules.YH_CommonHelper.login()
|
|
|
.then(uid => {
|
|
|
return new BrandStoreService().cancelFavorite(shopId, shopId, uid)
|
|
|
.then(json => {
|
|
|
console.log('取消收藏成功');
|
|
|
dispatch(cancelFavoriteSuccess());
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.log(error);
|
|
|
dispatch(cancelFavoriteFailure(error));
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
} |
...
|
...
|
|