根据修改意见修改部分好货推荐详情。reviewed by redding.
Showing
8 changed files
with
120 additions
and
60 deletions
@@ -25,6 +25,7 @@ import { | @@ -25,6 +25,7 @@ import { | ||
25 | setPlatform, | 25 | setPlatform, |
26 | setHost, | 26 | setHost, |
27 | setServiceHost, | 27 | setServiceHost, |
28 | + setSingleHost, | ||
28 | } from './reducers/app/appActions'; | 29 | } from './reducers/app/appActions'; |
29 | 30 | ||
30 | import { | 31 | import { |
@@ -49,7 +50,8 @@ export default function native(platform) { | @@ -49,7 +50,8 @@ export default function native(platform) { | ||
49 | store.dispatch(setPlatform(platform)); | 50 | store.dispatch(setPlatform(platform)); |
50 | store.dispatch(setHost(this.props.host)); | 51 | store.dispatch(setHost(this.props.host)); |
51 | store.dispatch(setServiceHost(this.props.serviceHost)); | 52 | store.dispatch(setServiceHost(this.props.serviceHost)); |
52 | - | 53 | + store.dispatch(setSingleHost(this.props.singleHost)); |
54 | + | ||
53 | let type = this.props.type; | 55 | let type = this.props.type; |
54 | if (type == 'list') { | 56 | if (type == 'list') { |
55 | return ( | 57 | return ( |
@@ -6,6 +6,7 @@ import LoadingIndicator from '../../../common/components/LoadingIndicator'; | @@ -6,6 +6,7 @@ import LoadingIndicator from '../../../common/components/LoadingIndicator'; | ||
6 | import GoodGoodsImagesView from './GoodGoodsImagesView' | 6 | import GoodGoodsImagesView from './GoodGoodsImagesView' |
7 | import ContentCell from './ContentCell' | 7 | import ContentCell from './ContentCell' |
8 | import BrandProductListCell from '../../../common/components/ListCell/ProductListCell'; | 8 | import BrandProductListCell from '../../../common/components/ListCell/ProductListCell'; |
9 | +import Footer from './Footer' | ||
9 | 10 | ||
10 | import ReactNative, { | 11 | import ReactNative, { |
11 | View, | 12 | View, |
@@ -109,8 +110,7 @@ export default class Detail extends Component { | @@ -109,8 +110,7 @@ export default class Detail extends Component { | ||
109 | // //Test | 110 | // //Test |
110 | // product_skn = '51148345'; | 111 | // product_skn = '51148345'; |
111 | // // | 112 | // // |
112 | - let fav_image = favorite?require('../../image/love_tab_ic_h.png'):require('../../image/love_tab_ic.png'); | ||
113 | - let fav_title = favorite?'已收藏':'收藏'; | 113 | + |
114 | return ( | 114 | return ( |
115 | <View style={styles.container}> | 115 | <View style={styles.container}> |
116 | {!isFetching? | 116 | {!isFetching? |
@@ -122,20 +122,12 @@ export default class Detail extends Component { | @@ -122,20 +122,12 @@ export default class Detail extends Component { | ||
122 | dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} | 122 | dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} |
123 | renderRow={this.renderRow} | 123 | renderRow={this.renderRow} |
124 | /> | 124 | /> |
125 | - <View style={styles.footer}> | ||
126 | - <TouchableOpacity style={styles.favoriteButton} onPress={() => {this.props.onPressFavorite&&this.props.onPressFavorite(favorite)}}> | ||
127 | - <View style={{flex: 1, flexDirection: 'row', alignItems: 'center'}}> | ||
128 | - <Image style={styles.favIcon} source={fav_image}/> | ||
129 | - <Text style={styles.favText}>{fav_title}</Text> | ||
130 | - </View> | ||
131 | - </TouchableOpacity> | ||
132 | - <View style={styles.detailButton}> | ||
133 | - <Text | ||
134 | - style={styles.detailButtonText} | ||
135 | - onPress={() => {this.props.onPressProduct&& this.props.onPressProduct(Immutable.fromJS({product_skn}))}} | ||
136 | - >查看详情</Text> | ||
137 | - </View> | ||
138 | - </View> | 125 | + <Footer |
126 | + favorite={favorite} | ||
127 | + onPressFavorite={this.props.onPressFavorite} | ||
128 | + onPressProduct={this.props.onPressProduct} | ||
129 | + product_skn={product_skn} | ||
130 | + /> | ||
139 | </View> | 131 | </View> |
140 | :<LoadingIndicator | 132 | :<LoadingIndicator |
141 | isVisible={isFetching} | 133 | isVisible={isFetching} |
@@ -166,45 +158,4 @@ let styles = StyleSheet.create({ | @@ -166,45 +158,4 @@ let styles = StyleSheet.create({ | ||
166 | listContainer: { | 158 | listContainer: { |
167 | width: width / 2, | 159 | width: width / 2, |
168 | }, | 160 | }, |
169 | - footer: { | ||
170 | - width: width, | ||
171 | - height: 59, | ||
172 | - borderColor: '#ededed', | ||
173 | - borderTopWidth: 1, | ||
174 | - flexDirection: 'row', | ||
175 | - alignItems: 'center', | ||
176 | - }, | ||
177 | - detailButton: { | ||
178 | - position: 'absolute', | ||
179 | - width: 100, | ||
180 | - height: 44, | ||
181 | - top: 7, | ||
182 | - left: width - 15 - 100, | ||
183 | - backgroundColor: '#d0021b', | ||
184 | - borderRadius: 4, | ||
185 | - alignItems: 'center', | ||
186 | - }, | ||
187 | - detailButtonText: { | ||
188 | - marginTop: 4, | ||
189 | - height: 36, | ||
190 | - color: 'white', | ||
191 | - paddingTop: 10, | ||
192 | - textAlign: 'center', | ||
193 | - fontSize: 15, | ||
194 | - }, | ||
195 | - favoriteButton: { | ||
196 | - width: 100, | ||
197 | - height: 40, | ||
198 | - }, | ||
199 | - favIcon: { | ||
200 | - width: 17, | ||
201 | - height: 16, | ||
202 | - marginLeft: 20, | ||
203 | - marginRight: 0, | ||
204 | - }, | ||
205 | - favText: { | ||
206 | - fontSize: 13, | ||
207 | - color: '#b0b0b0', | ||
208 | - marginLeft: 5, | ||
209 | - }, | ||
210 | }); | 161 | }); |
1 | +'use strict'; | ||
2 | + | ||
3 | +import React, {Component} from 'react'; | ||
4 | +import Immutable, {Map} from 'immutable'; | ||
5 | + | ||
6 | +import ReactNative, { | ||
7 | + View, | ||
8 | + Text, | ||
9 | + Image, | ||
10 | + ListView, | ||
11 | + StyleSheet, | ||
12 | + Dimensions, | ||
13 | + TouchableOpacity, | ||
14 | + InteractionManager, | ||
15 | + Platform, | ||
16 | +} from 'react-native'; | ||
17 | + | ||
18 | + | ||
19 | + | ||
20 | +export default class Detail extends Component { | ||
21 | + | ||
22 | + constructor(props) { | ||
23 | + super(props); | ||
24 | + | ||
25 | + } | ||
26 | + | ||
27 | + render() { | ||
28 | + | ||
29 | + let fav_image = this.props.favorite?require('../../image/love_tab_ic_h.png'):require('../../image/love_tab_ic.png'); | ||
30 | + let fav_title = this.props.favorite?'已收藏':'收藏'; | ||
31 | + return ( | ||
32 | + <View style={styles.footer}> | ||
33 | + <TouchableOpacity style={styles.favoriteButton} onPress={() => {this.props.onPressFavorite&&this.props.onPressFavorite(this.props.favorite)}}> | ||
34 | + <View style={{flex: 1, flexDirection: 'row', alignItems: 'center'}}> | ||
35 | + <Image style={styles.favIcon} source={fav_image}/> | ||
36 | + <Text style={styles.favText}>{fav_title}</Text> | ||
37 | + </View> | ||
38 | + </TouchableOpacity> | ||
39 | + <View style={styles.detailButton}> | ||
40 | + <Text | ||
41 | + style={styles.detailButtonText} | ||
42 | + onPress={() => {this.props.onPressProduct&& this.props.onPressProduct(Immutable.fromJS({this.props.product_skn}))}} | ||
43 | + >查看详情</Text> | ||
44 | + </View> | ||
45 | + </View> | ||
46 | + ); | ||
47 | + } | ||
48 | +} | ||
49 | + | ||
50 | +let {width, height} = Dimensions.get('window'); | ||
51 | + | ||
52 | +let styles = StyleSheet.create({ | ||
53 | + footer: { | ||
54 | + width: width, | ||
55 | + height: 59, | ||
56 | + borderColor: '#ededed', | ||
57 | + borderTopWidth: 1, | ||
58 | + flexDirection: 'row', | ||
59 | + alignItems: 'center', | ||
60 | + }, | ||
61 | + detailButton: { | ||
62 | + position: 'absolute', | ||
63 | + width: 100, | ||
64 | + height: 44, | ||
65 | + top: 7, | ||
66 | + left: width - 15 - 100, | ||
67 | + backgroundColor: '#d0021b', | ||
68 | + borderRadius: 4, | ||
69 | + alignItems: 'center', | ||
70 | + }, | ||
71 | + detailButtonText: { | ||
72 | + marginTop: 4, | ||
73 | + height: 36, | ||
74 | + color: 'white', | ||
75 | + paddingTop: 10, | ||
76 | + textAlign: 'center', | ||
77 | + fontSize: 15, | ||
78 | + }, | ||
79 | + favoriteButton: { | ||
80 | + width: 100, | ||
81 | + height: 40, | ||
82 | + }, | ||
83 | + favIcon: { | ||
84 | + width: 17, | ||
85 | + height: 16, | ||
86 | + marginLeft: 20, | ||
87 | + marginRight: 0, | ||
88 | + }, | ||
89 | + favText: { | ||
90 | + fontSize: 13, | ||
91 | + color: '#b0b0b0', | ||
92 | + marginLeft: 5, | ||
93 | + }, | ||
94 | +}); |
@@ -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_SINGLE_HOST: null, | ||
9 | 10 | ||
10 | SET_PRODUCT_SKN: null, | 11 | SET_PRODUCT_SKN: null, |
11 | GET_DETAIL_REQUEST: null, | 12 | GET_DETAIL_REQUEST: null, |
@@ -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_SINGLE_HOST, | ||
10 | } = require('../../constants/actionTypes').default; | 11 | } = require('../../constants/actionTypes').default; |
11 | 12 | ||
12 | export function setPlatform(platform) { | 13 | export function setPlatform(platform) { |
@@ -30,9 +31,16 @@ export function setHost(host) { | @@ -30,9 +31,16 @@ export function setHost(host) { | ||
30 | }; | 31 | }; |
31 | } | 32 | } |
32 | 33 | ||
34 | +export function setSingleHost(host) { | ||
35 | + return { | ||
36 | + type: SET_SINGLE_HOST, | ||
37 | + payload: host | ||
38 | + }; | ||
39 | +} | ||
40 | + | ||
33 | export function setServiceHost(host) { | 41 | export function setServiceHost(host) { |
34 | return { | 42 | return { |
35 | type: SET_SERVICE_HOST, | 43 | type: SET_SERVICE_HOST, |
36 | payload: host | 44 | payload: host |
37 | }; | 45 | }; |
38 | -} | ||
46 | +} |
@@ -7,6 +7,7 @@ let InitialState = Record({ | @@ -7,6 +7,7 @@ let InitialState = Record({ | ||
7 | channel: 1, // 1 - boy, 2 - girl, 3 - kid, 4 - lifestyle, 5 - yoho | 7 | channel: 1, // 1 - boy, 2 - girl, 3 - kid, 4 - lifestyle, 5 - yoho |
8 | host: 'http://api.yoho.cn', | 8 | host: 'http://api.yoho.cn', |
9 | serviceHost: 'http://service.yoho.cn', | 9 | serviceHost: 'http://service.yoho.cn', |
10 | + singleHost: 'http://single.yoho.cn/favorite', | ||
10 | }); | 11 | }); |
11 | 12 | ||
12 | export default InitialState; | 13 | 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_SINGLE_HOST, | ||
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_SINGLE_HOST: | ||
28 | + return state.set('singleHost', action.payload); | ||
26 | } | 29 | } |
27 | 30 | ||
28 | return state; | 31 | return state; |
@@ -36,7 +36,7 @@ export function getDetail() { | @@ -36,7 +36,7 @@ export function getDetail() { | ||
36 | // console.log(product_skn); | 36 | // console.log(product_skn); |
37 | // console.log(json); | 37 | // console.log(json); |
38 | dispatch(getDetailSuccess(json)); | 38 | dispatch(getDetailSuccess(json)); |
39 | - return new DetailService('http://single.yoho.cn/favorite').getFavoriteStatusWithProductID(json.product_id) | 39 | + return new DetailService(app.singleHost).getFavoriteStatusWithProductID(json.product_id) |
40 | .then(json => { | 40 | .then(json => { |
41 | dispatch(setFavoriteStatus(json)); | 41 | dispatch(setFavoriteStatus(json)); |
42 | }) | 42 | }) |
-
Please register or login to post a comment