秒杀商品列表页接口调整,review by redding
Showing
3 changed files
with
34 additions
and
77 deletions
@@ -18,18 +18,18 @@ export default class ProductListView extends Component { | @@ -18,18 +18,18 @@ export default class ProductListView extends Component { | ||
18 | 18 | ||
19 | constructor(props) { | 19 | constructor(props) { |
20 | super(props); | 20 | super(props); |
21 | - this._renderRow = this._renderRow.bind(this); | ||
22 | - this.dataSource = new ListView.DataSource({ | ||
23 | - rowHasChanged: (r1, r2) => r1.key != r2.key, | ||
24 | - }); | ||
25 | - this._renderSeparator = this._renderSeparator.bind(this); | ||
26 | this.tipMessage = ''; | 21 | this.tipMessage = ''; |
27 | this.state = { | 22 | this.state = { |
28 | selectedIndex: 0, | 23 | selectedIndex: 0, |
29 | }; | 24 | }; |
30 | } | 25 | } |
31 | 26 | ||
32 | - _renderRow(rowData, sectionID, rowID) { | 27 | + render() { |
28 | + let { | ||
29 | + rowData, | ||
30 | + tipMessage, | ||
31 | + } = this.props; | ||
32 | + this.tipMessage = tipMessage; | ||
33 | let brandIconUrl = SlicedImage.getSlicedUrl(rowData.defaultImages, 152, 203, 2); | 33 | let brandIconUrl = SlicedImage.getSlicedUrl(rowData.defaultImages, 152, 203, 2); |
34 | let tipState=''; | 34 | let tipState=''; |
35 | let btnBgColor = '#d30018'; | 35 | let btnBgColor = '#d30018'; |
@@ -53,7 +53,7 @@ export default class ProductListView extends Component { | @@ -53,7 +53,7 @@ export default class ProductListView extends Component { | ||
53 | <TouchableOpacity activeOpacity={1.0} onPress={() => { | 53 | <TouchableOpacity activeOpacity={1.0} onPress={() => { |
54 | this.props.onPressProductItem && this.props.onPressProductItem(rowData); | 54 | this.props.onPressProductItem && this.props.onPressProductItem(rowData); |
55 | }}> | 55 | }}> |
56 | - <View key={'row' + rowID} style={styles.rowContainer}> | 56 | + <View style={styles.rowContainer}> |
57 | <Image style={styles.leftImage} source={{uri: brandIconUrl}} /> | 57 | <Image style={styles.leftImage} source={{uri: brandIconUrl}} /> |
58 | 58 | ||
59 | <View style={styles.rowRight}> | 59 | <View style={styles.rowRight}> |
@@ -110,37 +110,6 @@ export default class ProductListView extends Component { | @@ -110,37 +110,6 @@ export default class ProductListView extends Component { | ||
110 | </TouchableOpacity> | 110 | </TouchableOpacity> |
111 | ); | 111 | ); |
112 | } | 112 | } |
113 | - | ||
114 | - _renderSeparator(sectionID, rowID, adjacentRowHighlighted) { | ||
115 | - return ( | ||
116 | - <View key={'sep' + rowID} style={styles.separator}> | ||
117 | - </View> | ||
118 | - ); | ||
119 | - } | ||
120 | - | ||
121 | - render() { | ||
122 | - let { | ||
123 | - resource, | ||
124 | - tipMessage, | ||
125 | - } = this.props; | ||
126 | - this.tipMessage = tipMessage; | ||
127 | - let backgroundWidth = width; | ||
128 | - let backgroundHeight = 64 + 20 + resource.length * rowHeight; | ||
129 | - | ||
130 | - return ( | ||
131 | - <View style={{width: backgroundWidth, height: backgroundHeight, backgroundColor: '#f0f0f0'}}> | ||
132 | - <ListView | ||
133 | - contentContainerStyle={[styles.contentContainer]} | ||
134 | - enableEmptySections={true} | ||
135 | - dataSource={this.dataSource.cloneWithRows(resource)} | ||
136 | - renderRow={this._renderRow} | ||
137 | - renderSeparator={this._renderSeparator} | ||
138 | - scrollEnabled={false} | ||
139 | - scrollsToTop={false} | ||
140 | - /> | ||
141 | - </View> | ||
142 | - ); | ||
143 | - } | ||
144 | } | 113 | } |
145 | 114 | ||
146 | let {width, height} = Dimensions.get('window'); | 115 | let {width, height} = Dimensions.get('window'); |
@@ -150,21 +119,9 @@ let rowHeight = backgroundHeight; | @@ -150,21 +119,9 @@ let rowHeight = backgroundHeight; | ||
150 | let imageWidth= 76; | 119 | let imageWidth= 76; |
151 | let imageHeight = 101; | 120 | let imageHeight = 101; |
152 | let styles = StyleSheet.create({ | 121 | let styles = StyleSheet.create({ |
153 | - container: { | ||
154 | - marginLeft: -1, | ||
155 | - width: width + 2, | ||
156 | - height: backgroundHeight, | ||
157 | - borderTopColor: 'transparent', | ||
158 | - borderBottomColor: '#e5e5e5', | ||
159 | - borderWidth: 0.5, | ||
160 | - backgroundColor:'white', | ||
161 | - }, | ||
162 | - contentContainer: { | ||
163 | - flexDirection: 'column', | ||
164 | - }, | ||
165 | rowContainer: { | 122 | rowContainer: { |
166 | flexDirection: 'row', | 123 | flexDirection: 'row', |
167 | - height: rowHeight, | 124 | + height: 121, |
168 | backgroundColor:'white', | 125 | backgroundColor:'white', |
169 | }, | 126 | }, |
170 | leftImage: { | 127 | leftImage: { |
@@ -219,11 +176,6 @@ let styles = StyleSheet.create({ | @@ -219,11 +176,6 @@ let styles = StyleSheet.create({ | ||
219 | height: 25, | 176 | height: 25, |
220 | top: 10, | 177 | top: 10, |
221 | }, | 178 | }, |
222 | - separator: { | ||
223 | - width: width, | ||
224 | - height: 1.5, | ||
225 | - backgroundColor: '#e5e5e5', | ||
226 | - }, | ||
227 | productTitle: { | 179 | productTitle: { |
228 | fontSize: 14, | 180 | fontSize: 14, |
229 | color: '#444444', | 181 | color: '#444444', |
@@ -26,6 +26,7 @@ export default class Seckill extends Component { | @@ -26,6 +26,7 @@ export default class Seckill extends Component { | ||
26 | 26 | ||
27 | this.renderRow = this.renderRow.bind(this); | 27 | this.renderRow = this.renderRow.bind(this); |
28 | this.renderSectionHeader = this.renderSectionHeader.bind(this); | 28 | this.renderSectionHeader = this.renderSectionHeader.bind(this); |
29 | + this._renderSeparator = this._renderSeparator.bind(this); | ||
29 | this.dataSource = new ListView.DataSource({ | 30 | this.dataSource = new ListView.DataSource({ |
30 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | 31 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), |
31 | sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2), | 32 | sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2), |
@@ -53,10 +54,9 @@ export default class Seckill extends Component { | @@ -53,10 +54,9 @@ export default class Seckill extends Component { | ||
53 | componentWillReceiveProps(nextProps) { | 54 | componentWillReceiveProps(nextProps) { |
54 | if (nextProps.tipMessage && nextProps.tipMessage !== '') { | 55 | if (nextProps.tipMessage && nextProps.tipMessage !== '') { |
55 | this._showToast && this._showToast(nextProps.tipMessage); | 56 | this._showToast && this._showToast(nextProps.tipMessage); |
56 | - console.log(nextProps.tipMessage); | ||
57 | } | 57 | } |
58 | } | 58 | } |
59 | - | 59 | + |
60 | _showToast = (message) => { | 60 | _showToast = (message) => { |
61 | if (this.toast) { | 61 | if (this.toast) { |
62 | return; | 62 | return; |
@@ -93,24 +93,25 @@ export default class Seckill extends Component { | @@ -93,24 +93,25 @@ export default class Seckill extends Component { | ||
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | - renderRow(rowData, sectionID, rowID, highlightRow) { | ||
97 | - if (Array.isArray(rowData) && rowData.length == 0 && !this.isFetching) { | ||
98 | - switch (rowID) { | ||
99 | - case 'ActivityProductList': | ||
100 | - return ( | ||
101 | - <View style={styles.seckillEndView}> | ||
102 | - <Text style={{fontSize:16}}>来晚啦~秒杀已结束</Text> | ||
103 | - </View> | ||
104 | - ); | ||
105 | - default: | ||
106 | - | ||
107 | - } | 96 | + _renderSeparator(sectionID, rowID, adjacentRowHighlighted) { |
97 | + return ( | ||
98 | + <View key={'sep' + rowID} style={styles.separator}> | ||
99 | + </View> | ||
100 | + ); | ||
101 | + } | ||
108 | 102 | ||
103 | + renderRow(rowData, sectionID, rowID, highlightRow) { | ||
104 | + if (this.queryActivityInfo.secKillProductVoList.size == 0 && !this.isFetching) { | ||
105 | + return ( | ||
106 | + <View style={styles.seckillEndView}> | ||
107 | + <Text style={{fontSize:16}}>来晚啦~秒杀已结束</Text> | ||
108 | + </View> | ||
109 | + ); | ||
109 | } | 110 | } |
110 | if (sectionID == 'ActivityProductList') { | 111 | if (sectionID == 'ActivityProductList') { |
111 | return( | 112 | return( |
112 | <ProductListView | 113 | <ProductListView |
113 | - resource={rowData} | 114 | + rowData={rowData} |
114 | onPressProductItem={this.props.onPressProductItem} | 115 | onPressProductItem={this.props.onPressProductItem} |
115 | onPressRemindBtn={this.props.onPressRemindBtn} | 116 | onPressRemindBtn={this.props.onPressRemindBtn} |
116 | tipMessage={this.tipMessage} | 117 | tipMessage={this.tipMessage} |
@@ -138,7 +139,7 @@ export default class Seckill extends Component { | @@ -138,7 +139,7 @@ export default class Seckill extends Component { | ||
138 | this.tipMessage = tipMessage; | 139 | this.tipMessage = tipMessage; |
139 | diff = localServerTimeDiff; | 140 | diff = localServerTimeDiff; |
140 | let dataSource = { | 141 | let dataSource = { |
141 | - ActivityProductList: [queryProductList ? queryProductList : []], | 142 | + ActivityProductList: queryProductList ? queryProductList : [], |
142 | }; | 143 | }; |
143 | let isPullToRefresh = ptr && isFetching; | 144 | let isPullToRefresh = ptr && isFetching; |
144 | return ( | 145 | return ( |
@@ -159,6 +160,7 @@ export default class Seckill extends Component { | @@ -159,6 +160,7 @@ export default class Seckill extends Component { | ||
159 | this.props.onRefresh && this.props.onRefresh(); | 160 | this.props.onRefresh && this.props.onRefresh(); |
160 | }} | 161 | }} |
161 | renderSectionHeader={this.renderSectionHeader} | 162 | renderSectionHeader={this.renderSectionHeader} |
163 | + renderSeparator={this._renderSeparator} | ||
162 | renderFooter={()=>{ | 164 | renderFooter={()=>{ |
163 | return <View style={styles.descriptionContainer}> | 165 | return <View style={styles.descriptionContainer}> |
164 | <Text style={styles.descriptionText}>秒杀活动说明</Text> | 166 | <Text style={styles.descriptionText}>秒杀活动说明</Text> |
@@ -188,6 +190,7 @@ export default class Seckill extends Component { | @@ -188,6 +190,7 @@ export default class Seckill extends Component { | ||
188 | dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} | 190 | dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} |
189 | renderRow={this.renderRow} | 191 | renderRow={this.renderRow} |
190 | enablePullToRefresh={true} | 192 | enablePullToRefresh={true} |
193 | + renderSeparator={this._renderSeparator} | ||
191 | isOnPullToRefresh={isPullToRefresh} | 194 | isOnPullToRefresh={isPullToRefresh} |
192 | onRefreshData={() => { | 195 | onRefreshData={() => { |
193 | //强制刷新数据 | 196 | //强制刷新数据 |
@@ -230,7 +233,7 @@ let styles = StyleSheet.create({ | @@ -230,7 +233,7 @@ let styles = StyleSheet.create({ | ||
230 | 233 | ||
231 | }, | 234 | }, |
232 | contentContainer:{ | 235 | contentContainer:{ |
233 | - flexDirection: 'row', | 236 | + flexDirection: 'column', |
234 | flexWrap: 'wrap', | 237 | flexWrap: 'wrap', |
235 | }, | 238 | }, |
236 | seckillEndView: { | 239 | seckillEndView: { |
@@ -251,7 +254,7 @@ let styles = StyleSheet.create({ | @@ -251,7 +254,7 @@ let styles = StyleSheet.create({ | ||
251 | borderWidth: 0.5, | 254 | borderWidth: 0.5, |
252 | }, | 255 | }, |
253 | descriptionContainer: { | 256 | descriptionContainer: { |
254 | - marginTop: -40, | 257 | + marginTop: 10, |
255 | marginBottom: 50, | 258 | marginBottom: 50, |
256 | marginLeft: 15, | 259 | marginLeft: 15, |
257 | }, | 260 | }, |
@@ -261,4 +264,9 @@ let styles = StyleSheet.create({ | @@ -261,4 +264,9 @@ let styles = StyleSheet.create({ | ||
261 | width: width - 20, | 264 | width: width - 20, |
262 | 265 | ||
263 | }, | 266 | }, |
267 | + separator: { | ||
268 | + width: width, | ||
269 | + height: 1.5, | ||
270 | + backgroundColor: '#e5e5e5', | ||
271 | + }, | ||
264 | }); | 272 | }); |
@@ -41,13 +41,10 @@ export default class SeckillTimeListView extends Component { | @@ -41,13 +41,10 @@ export default class SeckillTimeListView extends Component { | ||
41 | _scrollToFocusActivity = () => { | 41 | _scrollToFocusActivity = () => { |
42 | //focus | 42 | //focus |
43 | if (this.secKillProductVoList.length >= 1) { | 43 | if (this.secKillProductVoList.length >= 1) { |
44 | - console.log('------>_scrollToFocusActivity'); | ||
45 | let listLength = this.secKillProductVoList.length; | 44 | let listLength = this.secKillProductVoList.length; |
46 | let scrollX = 0; | 45 | let scrollX = 0; |
47 | scrollX = (this.curFocusActivity.get('index') - 1) * (rowContainerWidth + separatorWidth); | 46 | scrollX = (this.curFocusActivity.get('index') - 1) * (rowContainerWidth + separatorWidth); |
48 | this.listView && this.listView.scrollTo({x: scrollX, y: 0, animated: true}); | 47 | this.listView && this.listView.scrollTo({x: scrollX, y: 0, animated: true}); |
49 | - console.log('<<<<<<<<<_scrollToFocusActivity'); | ||
50 | - console.log(scrollX); | ||
51 | } | 48 | } |
52 | } | 49 | } |
53 | 50 |
-
Please register or login to post a comment