Authored by 于良

Merge branch 'brand_store' of http://git.yoho.cn/mobile/YH_RNComponent into brand_store

Conflicts:
	js/brandStore/reducers/brandStore/brandStoreReducer.js
... ... @@ -67,7 +67,7 @@ export default class ShopTopBanner extends React.Component {
let {width, height} = Dimensions.get('window');
let backgroundWidth= width;
let backgroundHeight= 100;
let backgroundHeight = Math.ceil((200 / 640) * width);
let buttonWidth= 64;
let buttonHeight= 25;
... ...
... ... @@ -41,6 +41,13 @@ export default keyMirror({
PRODUCT_FILTER_ACTION: null,
ADD_FAVORITE_REQUEST: null,
ADD_FAVORITE_SUCCESS: null,
ADD_FAVORITE_FAILURE: null,
CANCEL_FAVORITE_REQUEST: null,
CANCEL_FAVORITE_SUCCESS: null,
CANCEL_FAVORITE_FAILURE: null,
SET_PRODUCT_LIST_FILTER: null,
RESET_LIST_PAGE_INFO: null,
... ...
... ... @@ -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)
... ...
... ... @@ -38,6 +38,13 @@ 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,
... ... @@ -51,7 +58,18 @@ const initialState = new InitialState;
export default function brandStoreReducer(state=initialState, action) {
switch(action.type) {
case SET_COLLECTION: {
case ADD_FAVORITE_SUCCESS: {
return state.setIn(['info', 'is_addFav'], action.payload);
}
case ADD_FAVORITE_FAILURE: {
if (action.payload.code == 413) {
return state.setIn(['info', 'is_addFav'], true);
}
return state.setIn(['info', 'is_addFav'], false);
}
case CANCEL_FAVORITE_SUCCESS: {
return state.setIn(['info', 'is_addFav'], action.payload);
}
... ... @@ -187,10 +205,11 @@ export default function brandStoreReducer(state=initialState, action) {
return state.setIn(['resource', 'hotProducts_APP'], newHotProducts);
}
case PRODUCT_LIST_REQUEST:{
case PRODUCT_LIST_REQUEST: {
return state.setIn(['productList', 'isFetching'], true)
.setIn(['productList', 'error'], null);
}
case PRODUCT_LIST_SUCCESS: {
let {
list,
... ... @@ -296,6 +315,7 @@ export default function brandStoreReducer(state=initialState, action) {
.setIn(['productListForNew', 'error'], action.payload);
}
case FILTER_LIST_VIEW: {
return state.setIn(['productList', 'isFilter'], !state.productList.isFilter);
... ...
... ... @@ -104,7 +104,7 @@ export default class BrandStoreService {
});
}
async addFavorite(id, fav_id, uid, type='brand', gender=1, v=7) {
async addFavorite(id, fav_id, uid, type='shop', gender=1, v=7) {
return await this.api.get({
url: '',
body: {
... ... @@ -125,7 +125,7 @@ export default class BrandStoreService {
});
}
async cancelFavorite(id, fav_id, uid, type='brand', gender=1, v=7) {
async cancelFavorite(id, fav_id, uid, type='shop', gender=1, v=7) {
return await this.api.get({
url: '',
body: {
... ... @@ -146,7 +146,7 @@ export default class BrandStoreService {
});
}
async isFavorite(id, uid, type='brand') {
async isFavorite(id, uid, type='shop') {
return await this.api.get({
url: '',
body: {
... ...