...
|
...
|
@@ -54,13 +54,28 @@ export function changeFavoriteStatus(favorite) { |
|
|
return (dispatch, getState) => {
|
|
|
let {app, detail} = getState();
|
|
|
let product_id = detail.get('product').get('data').get('product_id');
|
|
|
if (product_id && favorite) {
|
|
|
new DetailService(app.host).cancelFavorite(product_id);
|
|
|
let favRequest = (product_id, favorite) => {
|
|
|
if (product_id && favorite) {
|
|
|
new DetailService(app.host).cancelFavorite(product_id);
|
|
|
}
|
|
|
if (product_id && !favorite) {
|
|
|
new DetailService(app.host).addFavorite(product_id);
|
|
|
}
|
|
|
dispatch(setFavoriteStatus(!favorite));
|
|
|
}
|
|
|
if (product_id && !favorite) {
|
|
|
new DetailService(app.host).addFavorite(product_id);
|
|
|
}
|
|
|
dispatch(setFavoriteStatus(!favorite));
|
|
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
|
|
.then(uid => {
|
|
|
favRequest(product_id, favorite);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
ReactNative.NativeModules.YH_CommonHelper.login()
|
|
|
.then(uid => {
|
|
|
favRequest(product_id, favorite);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|