新品到着配置资源位 reviewd by 朱傲哲
Showing
6 changed files
with
21 additions
and
5 deletions
@@ -26,6 +26,7 @@ import { | @@ -26,6 +26,7 @@ import { | ||
26 | setHost, | 26 | setHost, |
27 | setServiceHost, | 27 | setServiceHost, |
28 | setChannel, | 28 | setChannel, |
29 | + setContentCode, | ||
29 | } from './reducers/app/appActions'; | 30 | } from './reducers/app/appActions'; |
30 | 31 | ||
31 | 32 | ||
@@ -43,11 +44,12 @@ export default function native(platform) { | @@ -43,11 +44,12 @@ export default function native(platform) { | ||
43 | 44 | ||
44 | render() { | 45 | render() { |
45 | let type = this.props.type; | 46 | let type = this.props.type; |
46 | - const store = configureStore(getInitialState()); | 47 | + const store = configureStore(getInitialState()); |
47 | store.dispatch(setPlatform(platform)); | 48 | store.dispatch(setPlatform(platform)); |
48 | store.dispatch(setHost(this.props.host)); | 49 | store.dispatch(setHost(this.props.host)); |
49 | store.dispatch(setChannel(this.props.channelId)); | 50 | store.dispatch(setChannel(this.props.channelId)); |
50 | store.dispatch(setServiceHost(this.props.serviceHost)); | 51 | store.dispatch(setServiceHost(this.props.serviceHost)); |
52 | + store.dispatch(setContentCode(this.props.contentCode)); | ||
51 | if (type == 'recForYou' ) { | 53 | if (type == 'recForYou' ) { |
52 | return ( | 54 | return ( |
53 | <Provider store={store}> | 55 | <Provider store={store}> |
@@ -6,6 +6,7 @@ export default keyMirror({ | @@ -6,6 +6,7 @@ export default keyMirror({ | ||
6 | SET_HOST: null, | 6 | SET_HOST: null, |
7 | SET_SERVICE_HOST: null, | 7 | SET_SERVICE_HOST: null, |
8 | SET_CHANNEL: null, | 8 | SET_CHANNEL: null, |
9 | + SET_CONTENT_CODE: null, | ||
9 | 10 | ||
10 | RECOMMEND_SHOP_REQUEST: null, | 11 | RECOMMEND_SHOP_REQUEST: null, |
11 | RECOMMEND_SHOP_SUCCESS: null, | 12 | RECOMMEND_SHOP_SUCCESS: null, |
@@ -5,8 +5,9 @@ import ReactNative from 'react-native'; | @@ -5,8 +5,9 @@ import ReactNative from 'react-native'; | ||
5 | const { | 5 | const { |
6 | SET_PLATFORM, | 6 | SET_PLATFORM, |
7 | SET_CHANNEL, | 7 | SET_CHANNEL, |
8 | - SET_HOST, | ||
9 | - SET_SERVICE_HOST, | 8 | + SET_HOST, |
9 | + SET_SERVICE_HOST, | ||
10 | + SET_CONTENT_CODE, | ||
10 | } = require('../../constants/actionTypes').default; | 11 | } = require('../../constants/actionTypes').default; |
11 | 12 | ||
12 | export function setPlatform(platform) { | 13 | export function setPlatform(platform) { |
@@ -35,4 +36,11 @@ export function setServiceHost(host) { | @@ -35,4 +36,11 @@ export function setServiceHost(host) { | ||
35 | type: SET_SERVICE_HOST, | 36 | type: SET_SERVICE_HOST, |
36 | payload: host | 37 | payload: host |
37 | }; | 38 | }; |
38 | -} | ||
39 | +} | ||
40 | + | ||
41 | +export function setContentCode(contentCode) { | ||
42 | + return { | ||
43 | + type: SET_CONTENT_CODE, | ||
44 | + payload: contentCode | ||
45 | + }; | ||
46 | +} |
@@ -8,6 +8,7 @@ let InitialState = Record({ | @@ -8,6 +8,7 @@ let InitialState = Record({ | ||
8 | host: 'http://api.yoho.cn', | 8 | host: 'http://api.yoho.cn', |
9 | serviceHost: 'http://api.yoho.cn', | 9 | serviceHost: 'http://api.yoho.cn', |
10 | globalHost: 'http://api-global.yohobuy.com', | 10 | globalHost: 'http://api-global.yohobuy.com', |
11 | + contentCode: '', | ||
11 | }); | 12 | }); |
12 | 13 | ||
13 | export default InitialState; | 14 | export default InitialState; |
@@ -7,6 +7,7 @@ const { | @@ -7,6 +7,7 @@ const { | ||
7 | SET_CHANNEL, | 7 | SET_CHANNEL, |
8 | SET_HOST, | 8 | SET_HOST, |
9 | SET_SERVICE_HOST, | 9 | SET_SERVICE_HOST, |
10 | + SET_CONTENT_CODE, | ||
10 | } = require('../../constants/actionTypes').default; | 11 | } = require('../../constants/actionTypes').default; |
11 | 12 | ||
12 | const initialState = new InitialState; | 13 | const initialState = new InitialState; |
@@ -23,6 +24,8 @@ export default function appReducer(state = initialState, action) { | @@ -23,6 +24,8 @@ export default function appReducer(state = initialState, action) { | ||
23 | return state.set('host', action.payload); | 24 | return state.set('host', action.payload); |
24 | case SET_SERVICE_HOST: | 25 | case SET_SERVICE_HOST: |
25 | return state.set('serviceHost', action.payload); | 26 | return state.set('serviceHost', action.payload); |
27 | + case SET_CONTENT_CODE: | ||
28 | + return state.set('contentCode', action.payload); | ||
26 | } | 29 | } |
27 | 30 | ||
28 | return state; | 31 | return state; |
@@ -110,8 +110,9 @@ export function getResourceInfoFailure(error) { | @@ -110,8 +110,9 @@ export function getResourceInfoFailure(error) { | ||
110 | export function getResourceInfo(callback) { | 110 | export function getResourceInfo(callback) { |
111 | return (dispatch, getState) => { | 111 | return (dispatch, getState) => { |
112 | let {app} = getState(); | 112 | let {app} = getState(); |
113 | + let contentCode = app.contentCode ? app.contentCode : '1f2e07cb63811680154ba693c954dd62'; | ||
113 | dispatch(getResourceInfoRequest()); | 114 | dispatch(getResourceInfoRequest()); |
114 | - return new NewArrivalService(app.host).fetchResourceInfo('1f2e07cb63811680154ba693c954dd62') | 115 | + return new NewArrivalService(app.host).fetchResourceInfo(contentCode) |
115 | .then(json => { | 116 | .then(json => { |
116 | let newJson = exposeResourceInfoData(json); | 117 | let newJson = exposeResourceInfoData(json); |
117 | 118 |
-
Please register or login to post a comment