秒杀细节优化 review by chenlin
Showing
3 changed files
with
34 additions
and
18 deletions
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | import React, {Component} from "react"; | 3 | import React, {Component} from "react"; |
4 | import {View, Text, Image, ListView, StyleSheet, Dimensions, TouchableOpacity} from "react-native"; | 4 | import {View, Text, Image, ListView, StyleSheet, Dimensions, TouchableOpacity} from "react-native"; |
5 | import SlicedImage from "../../../common/components/SlicedImage"; | 5 | import SlicedImage from "../../../common/components/SlicedImage"; |
6 | - | 6 | +import YH_Image from '../../../common/components/YH_Image'; |
7 | 7 | ||
8 | export default class ProductListView extends Component { | 8 | export default class ProductListView extends Component { |
9 | 9 | ||
@@ -47,8 +47,7 @@ export default class ProductListView extends Component { | @@ -47,8 +47,7 @@ export default class ProductListView extends Component { | ||
47 | }}> | 47 | }}> |
48 | <View style={styles.rowContainer}> | 48 | <View style={styles.rowContainer}> |
49 | <View style={styles.leftImage}> | 49 | <View style={styles.leftImage}> |
50 | - <Image style={{flex: 1,}} | ||
51 | - source={{uri: brandIconUrl}}/> | 50 | + <YH_Image style={{flex:1}} url={brandIconUrl} /> |
52 | {tipState == '已抢光' ? | 51 | {tipState == '已抢光' ? |
53 | <View style={styles.soldOutContainer}> | 52 | <View style={styles.soldOutContainer}> |
54 | <Image source={require('../../images/yqg.png')}/> | 53 | <Image source={require('../../images/yqg.png')}/> |
@@ -74,7 +73,7 @@ export default class ProductListView extends Component { | @@ -74,7 +73,7 @@ export default class ProductListView extends Component { | ||
74 | <Text style={styles.originPrice}> | 73 | <Text style={styles.originPrice}> |
75 | {'¥' + parseFloat(rowData.marketPrice + '').toFixed(2)}</Text> | 74 | {'¥' + parseFloat(rowData.marketPrice + '').toFixed(2)}</Text> |
76 | </View> | 75 | </View> |
77 | - <View style={{justifyContent: 'center'}}> | 76 | + <View style={{justifyContent: 'center', alignItems: 'flex-end'}}> |
78 | {tipState == '已抢光' && url && url.length ? | 77 | {tipState == '已抢光' && url && url.length ? |
79 | <TouchableOpacity onPress={()=> { | 78 | <TouchableOpacity onPress={()=> { |
80 | this.props.onPressGuangShopWithURL && this.props.onPressGuangShopWithURL(url); | 79 | this.props.onPressGuangShopWithURL && this.props.onPressGuangShopWithURL(url); |
@@ -180,7 +179,6 @@ let styles = StyleSheet.create({ | @@ -180,7 +179,6 @@ let styles = StyleSheet.create({ | ||
180 | priceClickTipViewRight: { | 179 | priceClickTipViewRight: { |
181 | width: 80, | 180 | width: 80, |
182 | height: 30, | 181 | height: 30, |
183 | - marginRight: 10, | ||
184 | marginTop: 10, | 182 | marginTop: 10, |
185 | alignItems: 'center', | 183 | alignItems: 'center', |
186 | justifyContent: 'center', | 184 | justifyContent: 'center', |
@@ -228,7 +226,7 @@ let styles = StyleSheet.create({ | @@ -228,7 +226,7 @@ let styles = StyleSheet.create({ | ||
228 | }, | 226 | }, |
229 | separator: { | 227 | separator: { |
230 | position: 'absolute', | 228 | position: 'absolute', |
231 | - left: 0, | 229 | + left: 15, |
232 | right: 0, | 230 | right: 0, |
233 | bottom: 0, | 231 | bottom: 0, |
234 | height: 0.5, | 232 | height: 0.5, |
@@ -92,8 +92,11 @@ export default class Seckill extends Component { | @@ -92,8 +92,11 @@ export default class Seckill extends Component { | ||
92 | renderSectionHeader({section: {type, title}}) { | 92 | renderSectionHeader({section: {type, title}}) { |
93 | if (type == SECTION_TYPE_DISCOUNT) { | 93 | if (type == SECTION_TYPE_DISCOUNT) { |
94 | return <View style={styles.sectionHeaderContainer}> | 94 | return <View style={styles.sectionHeaderContainer}> |
95 | + <View style={styles.sectionLine}/> | ||
95 | <Text style={styles.sectionHeaderText}>{title}</Text> | 96 | <Text style={styles.sectionHeaderText}>{title}</Text> |
97 | + <View style={{position:'absolute',left:0,right:0,bottom:0,height:0.5,backgroundColor:'#E0E0E0'}}/> | ||
96 | </View> | 98 | </View> |
99 | + | ||
97 | } | 100 | } |
98 | return null | 101 | return null |
99 | } | 102 | } |
@@ -182,7 +185,7 @@ export default class Seckill extends Component { | @@ -182,7 +185,7 @@ export default class Seckill extends Component { | ||
182 | ]; | 185 | ]; |
183 | if (discountProduct.list && discountProduct.list.length > 0) { | 186 | if (discountProduct.list && discountProduct.list.length > 0) { |
184 | sections.push({ | 187 | sections.push({ |
185 | - title: '限时热促', | 188 | + title: '限时促销', |
186 | type: SECTION_TYPE_DISCOUNT, | 189 | type: SECTION_TYPE_DISCOUNT, |
187 | data: discountProduct.list ? [discountProduct.list] : [[]], | 190 | data: discountProduct.list ? [discountProduct.list] : [[]], |
188 | renderItem: this.renderDiscountSection | 191 | renderItem: this.renderDiscountSection |
@@ -257,21 +260,25 @@ let styles = StyleSheet.create({ | @@ -257,21 +260,25 @@ let styles = StyleSheet.create({ | ||
257 | paddingBottom: 10, | 260 | paddingBottom: 10, |
258 | paddingLeft: 15, | 261 | paddingLeft: 15, |
259 | paddingRight: 15, | 262 | paddingRight: 15, |
260 | - backgroundColor: 'white' | ||
261 | }, | 263 | }, |
262 | descriptionText: { | 264 | descriptionText: { |
263 | - color: 'black', | 265 | + color: '#b0b0b0', |
264 | fontSize: 12, | 266 | fontSize: 12, |
265 | }, | 267 | }, |
266 | sectionHeaderContainer: { | 268 | sectionHeaderContainer: { |
267 | width: width, | 269 | width: width, |
268 | - paddingTop: 15, | ||
269 | - paddingBottom: 15, | 270 | + paddingTop: 10, |
271 | + paddingBottom: 10, | ||
272 | + paddingLeft:15, | ||
273 | + backgroundColor: 'white', | ||
270 | alignItems: 'center', | 274 | alignItems: 'center', |
271 | - justifyContent: 'center', | 275 | + flexDirection:'row' |
272 | }, | 276 | }, |
273 | sectionHeaderText: { | 277 | sectionHeaderText: { |
274 | - color: 'black', | ||
275 | - fontWeight: 'bold' | ||
276 | - } | 278 | + fontSize: 14, |
279 | + marginLeft:10, | ||
280 | + color: '#444444', | ||
281 | + fontFamily: 'PingFang-SC-Medium' | ||
282 | + }, | ||
283 | + sectionLine: {width: 2, height: 15, backgroundColor: '#444444', marginLeft: 2} | ||
277 | }); | 284 | }); |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | import React, {Component} from "react"; | 3 | import React, {Component} from "react"; |
4 | -import {View, Text, Image, ListView, StyleSheet, Dimensions, TouchableOpacity} from "react-native"; | 4 | +import {View, Text, Image, ListView, StyleSheet, Dimensions, TouchableOpacity, Platform} from "react-native"; |
5 | import Immutable from "immutable"; | 5 | import Immutable from "immutable"; |
6 | import TimeForFocus from "./TimeForFocus"; | 6 | import TimeForFocus from "./TimeForFocus"; |
7 | import TimeForLostFocus from "./TimeForLostFocus"; | 7 | import TimeForLostFocus from "./TimeForLostFocus"; |
@@ -41,11 +41,18 @@ export default class SeckillTimeListView extends Component { | @@ -41,11 +41,18 @@ export default class SeckillTimeListView extends Component { | ||
41 | let scrollX; | 41 | let scrollX; |
42 | let currentScrollX = this.listView ? this.listView.scrollProperties.offset : 0; | 42 | let currentScrollX = this.listView ? this.listView.scrollProperties.offset : 0; |
43 | scrollX = (this.curFocusActivity.get('index') - 1) * (rowContainerWidth + separatorWidth); | 43 | scrollX = (this.curFocusActivity.get('index') - 1) * (rowContainerWidth + separatorWidth); |
44 | + if (Platform.OS == 'ios') { | ||
45 | + if (scrollX < 0) { | ||
46 | + scrollX = 0 | ||
47 | + } else if (this.listView && (scrollX > this.listView.scrollProperties.contentLength - this.listView.scrollProperties.visibleLength)) { | ||
48 | + scrollX = this.listView.scrollProperties.contentLength - this.listView.scrollProperties.visibleLength | ||
49 | + } | ||
50 | + } | ||
44 | if (this.scrollX == scrollX && ((Math.floor(scrollX) == Math.floor(currentScrollX)) || scrollX != 0)) { | 51 | if (this.scrollX == scrollX && ((Math.floor(scrollX) == Math.floor(currentScrollX)) || scrollX != 0)) { |
45 | return; | 52 | return; |
46 | } | 53 | } |
47 | - this.scrollX = scrollX; | ||
48 | 54 | ||
55 | + this.scrollX = scrollX; | ||
49 | this.listView && this.listView.scrollTo({x: scrollX, y: 0, animated: true}); | 56 | this.listView && this.listView.scrollTo({x: scrollX, y: 0, animated: true}); |
50 | } | 57 | } |
51 | } | 58 | } |
@@ -178,6 +185,10 @@ export default class SeckillTimeListView extends Component { | @@ -178,6 +185,10 @@ export default class SeckillTimeListView extends Component { | ||
178 | } | 185 | } |
179 | 186 | ||
180 | _renderSeparator(sectionID, rowID, adjacentRowHighlighted) { | 187 | _renderSeparator(sectionID, rowID, adjacentRowHighlighted) { |
188 | + let listLength = this.secKillProductVoList.length; | ||
189 | + if (listLength - 1 == rowID) { | ||
190 | + return null; | ||
191 | + } | ||
181 | return ( | 192 | return ( |
182 | <View key={'sep' + rowID} style={styles.separator}> | 193 | <View key={'sep' + rowID} style={styles.separator}> |
183 | </View> | 194 | </View> |
@@ -224,7 +235,7 @@ let backgroundHeight = 61; | @@ -224,7 +235,7 @@ let backgroundHeight = 61; | ||
224 | let diffTime; | 235 | let diffTime; |
225 | let rowContainerWidth = Math.ceil((223 * width) / 750); | 236 | let rowContainerWidth = Math.ceil((223 * width) / 750); |
226 | let rowContainerFocusWidth = Math.ceil((294 * width) / 750); | 237 | let rowContainerFocusWidth = Math.ceil((294 * width) / 750); |
227 | -let separatorWidth = 1.5; | 238 | +let separatorWidth = 1; |
228 | 239 | ||
229 | let styles = StyleSheet.create({ | 240 | let styles = StyleSheet.create({ |
230 | container: { | 241 | container: { |
-
Please register or login to post a comment