...
|
...
|
@@ -2,8 +2,7 @@ |
|
|
|
|
|
import ReactNative from 'react-native';
|
|
|
import DetailService from '../../services/DetailService';
|
|
|
|
|
|
import helper from '../../../common/utils/helper';
|
|
|
import Immutable, {Map} from 'immutable';
|
|
|
|
|
|
const {
|
|
|
SET_PRODUCT_SKN,
|
...
|
...
|
@@ -14,6 +13,7 @@ const { |
|
|
GET_SIMILAR_REQUEST,
|
|
|
GET_SIMILAR_SUCCESS,
|
|
|
GET_SIMILAR_FAILURE,
|
|
|
SET_FAVORITE_STATUS,
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
export function setProductSKN(product_skn) {
|
...
|
...
|
@@ -33,9 +33,16 @@ export function getDetail() { |
|
|
dispatch(getDetailRequest());
|
|
|
return new DetailService(app.host).getDetailWithProductSKN(product_skn)
|
|
|
.then(json => {
|
|
|
console.log(product_skn);
|
|
|
console.log(json);
|
|
|
// console.log(product_skn);
|
|
|
// console.log(json);
|
|
|
dispatch(getDetailSuccess(json));
|
|
|
return new DetailService('http://single.yoho.cn/favorite').getFavoriteStatusWithProductID(json.product_id)
|
|
|
.then(json => {
|
|
|
dispatch(setFavoriteStatus(json));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(setFavoriteStatus(false));
|
|
|
})
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(getDetailFailure(error));
|
...
|
...
|
@@ -43,6 +50,28 @@ export function getDetail() { |
|
|
};
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
}
|
|
|
if (product_id && !favorite) {
|
|
|
new DetailService(app.host).addFavorite(product_id);
|
|
|
}
|
|
|
dispatch(setFavoriteStatus(!favorite));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
export function setFavoriteStatus(favorite) {
|
|
|
return {
|
|
|
type: SET_FAVORITE_STATUS,
|
|
|
payload: favorite
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getDetailRequest() {
|
|
|
return {
|
|
|
type: GET_DETAIL_REQUEST,
|
...
|
...
|
@@ -73,8 +102,8 @@ export function getSimilar() { |
|
|
dispatch(getSimilarRequest());
|
|
|
return new DetailService(app.host).getSimilarListWithSKN(product_skn)
|
|
|
.then(json => {
|
|
|
console.log(product_skn);
|
|
|
console.log(json);
|
|
|
// console.log(product_skn);
|
|
|
// console.log(json);
|
|
|
dispatch(getSimilarSuccess(json.product_list));
|
|
|
})
|
|
|
.catch(error => {
|
...
|
...
|
|