Authored by 于良

修改获取默认品牌信息的时机 review by yewanwan

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
... ...
... ... @@ -5,6 +5,7 @@ import Button from "apsl-react-native-button";
import {Actions} from "react-native-router-flux";
import Immutable, {List} from 'immutable';
import ImmutablePropTypes from 'react-immutable-proptypes';
let {
Component,
... ... @@ -19,7 +20,12 @@ let {
export default class SideMenu extends React.Component {
static propTypes = {
items: React.PropTypes.instanceOf(List),
items: ImmutablePropTypes.listOf(
ImmutablePropTypes.contains({
shopName:React.PropTypes.string,
shopsId: React.PropTypes.number,
})
),
onPressItem: React.PropTypes.func,
};
... ... @@ -118,6 +124,7 @@ let styles = StyleSheet.create({
right: 15,
height: 28,
alignSelf: 'flex-end',
backgroundColor: 'transparent',
},
separator: {
height: 1,
... ...
... ... @@ -74,7 +74,7 @@ export default keyMirror({
GO_TO_REQUEST_STATS: null,
GO_TO_ACCOUNT_SETTLEMENT: null,
SWITCH_BRAND: null,
SETUP_CURRENT_BRAND: null,
STOCK_STATS_REQUEST: null,
STOCK_STATS_SUCCESS: null,
... ...
... ... @@ -56,7 +56,7 @@ class DrawerContainer extends Component {
_onPressItem(brand) {
//选择店铺
this.drawer.close();
this.props.actions.switchBrand(brand.get('shopsId'), brand.get('shopName'));
this.props.actions.setupDefaultBrand(brand.get('shopsId'), brand.get('shopName'));
this.props.actions.overview(brand.get('shopsId'));
this.props.actions.brandRank(brand.get('shopsId'));
this.props.actions.requestUnreadMsgNum(brand.get('shopsId'), 'N');
... ...
... ... @@ -102,14 +102,9 @@ class HomeContainer extends Component {
componentDidMount() {
let brands = this.props.user.get('brands');
if (!this.props.home.brandId) {
this.props.actions.switchBrand(brands.get(0).get('shopsId'), brands.get(0).get('shopName'));
}
this.props.actions.overview(this.props.home.brandId);
this.props.actions.brandRank(this.props.home.brandId);
this.props.actions.requestUnreadMsgNum(!this.props.home.brandId ? brands.get(0).get('shopsId') : this.props.home.brandId, 'N');
this.props.actions.requestUnreadMsgNum(this.props.home.brandId, 'N');
// this.props.actions.overview(1200);
// this.props.actions.brandRank(1200);
... ...
... ... @@ -27,7 +27,7 @@ const {
GO_TO_REQUEST_STATS,
GO_TO_ACCOUNT_SETTLEMENT,
SWITCH_BRAND,
SETUP_CURRENT_BRAND,
} = require('../../constants/actionTypes').default;
... ... @@ -135,12 +135,12 @@ export function goToStatsPage(type) {
}
}
export function switchBrand(brandId, brandName) {
export function setupDefaultBrand(brandId, brandName) {
Actions.Home();
return {
type: SWITCH_BRAND,
type: SETUP_CURRENT_BRAND,
payload: {
brandId,
brandName
... ...
... ... @@ -28,7 +28,7 @@ const {
GO_TO_REQUEST_STATS,
GO_TO_ACCOUNT_SETTLEMENT,
SWITCH_BRAND,
SETUP_CURRENT_BRAND,
} = require('../../constants/actionTypes').default;
... ... @@ -44,7 +44,7 @@ export default function userReducer(state = initialState, action) {
switch (action.type) {
case SWITCH_BRAND: {
case SETUP_CURRENT_BRAND: {
let nextState = state.set('brandId', action.payload.brandId)
.set('brandName', action.payload.brandName);
return nextState;
... ...
... ... @@ -50,6 +50,8 @@ const {
CHECK_UPDATE_FAILURE,
UPDATE_VERSION,
SETUP_CURRENT_BRAND,
} = require('../../constants/actionTypes').default;
export function userItemsPressed(item) {
... ... @@ -203,7 +205,7 @@ export function pwdModifySubmit(pid, oldPwd, newPwd) {
]
);
dispatch(modifySubmitDone());
})
.catch((error) => {
Alert.alert(
... ... @@ -256,6 +258,7 @@ export function getStoredUserInfo() {
.then(userInfo => {
if (userInfo) {
dispatch(storedUserInfo(userInfo));
dispatch(setupHomeDefaultBrand(userInfo.shops[0].shopsId, userInfo.shops[0].shopsName))
}
});
... ... @@ -268,3 +271,13 @@ export function storedUserInfo(userInfo) {
payload: userInfo
}
}
export function setupHomeDefaultBrand(brandId, brandName) {
return {
type: SETUP_CURRENT_BRAND,
payload: {
brandId,
brandName
}
}
}
... ...