Merge branch 'classify' of http://git.yoho.cn/mobile/YH_RNComponent into classify
Showing
11 changed files
with
213 additions
and
71 deletions
@@ -22,8 +22,9 @@ export default class AllBrandListCell extends React.Component { | @@ -22,8 +22,9 @@ export default class AllBrandListCell extends React.Component { | ||
22 | let name = this.props.rowData.brand_name; | 22 | let name = this.props.rowData.brand_name; |
23 | let is_hot = this.props.rowData.is_hot; | 23 | let is_hot = this.props.rowData.is_hot; |
24 | let is_show_new = this.props.rowData.is_show_new; | 24 | let is_show_new = this.props.rowData.is_show_new; |
25 | - let brand_id = this.props.rowData.id; | ||
26 | - let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.brand","params":{"brand_id":"${brand_id}"}}`; | 25 | + let shop_id = this.props.rowData.shop_id; |
26 | + let shop_template_type = this.props.rowData.shop_template_type; | ||
27 | + let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.shop","params":{"shop_id":"${shop_id}","shop_template_type":"${shop_template_type}","name":"${name}"}}`; | ||
27 | return( | 28 | return( |
28 | <TouchableOpacity activeOpacity={0.5} onPress={() => { | 29 | <TouchableOpacity activeOpacity={0.5} onPress={() => { |
29 | this.props.onPressSlideItem && this.props.onPressSlideItem(url); | 30 | this.props.onPressSlideItem && this.props.onPressSlideItem(url); |
@@ -87,7 +87,7 @@ let styles = StyleSheet.create({ | @@ -87,7 +87,7 @@ let styles = StyleSheet.create({ | ||
87 | cellList:{ | 87 | cellList:{ |
88 | justifyContent: 'center', | 88 | justifyContent: 'center', |
89 | width: Dimensions.get('window').width, | 89 | width: Dimensions.get('window').width, |
90 | - height: 180, | 90 | + height: itemHeight + 120, |
91 | backgroundColor: 'white', | 91 | backgroundColor: 'white', |
92 | }, | 92 | }, |
93 | titleStyle:{ | 93 | titleStyle:{ |
@@ -34,7 +34,9 @@ export default class BrandFliter extends React.Component { | @@ -34,7 +34,9 @@ export default class BrandFliter extends React.Component { | ||
34 | let colorStyle = rowID == this.state.selectedIndex ? {color: '#444444'} : {color: '#b0b0b0'}; | 34 | let colorStyle = rowID == this.state.selectedIndex ? {color: '#444444'} : {color: '#b0b0b0'}; |
35 | 35 | ||
36 | return ( | 36 | return ( |
37 | - <TouchableOpacity onPress={() => { | 37 | + <TouchableOpacity |
38 | + activeOpacity={1} | ||
39 | + onPress={() => { | ||
38 | 40 | ||
39 | if (this.state.selectedIndex == rowID) { | 41 | if (this.state.selectedIndex == rowID) { |
40 | return; | 42 | return; |
@@ -52,7 +52,7 @@ export default class ChannelFliter extends React.Component { | @@ -52,7 +52,7 @@ export default class ChannelFliter extends React.Component { | ||
52 | let colorStyle = rowID == this.props.selectID-1 ? {color: '#444444',fontFamily: 'HelveticaNeue',fontSize: 17} : {color: '#b0b0b0',fontFamily: 'HelveticaNeue-Bold',fontSize: 14,}; | 52 | let colorStyle = rowID == this.props.selectID-1 ? {color: '#444444',fontFamily: 'HelveticaNeue',fontSize: 17} : {color: '#b0b0b0',fontFamily: 'HelveticaNeue-Bold',fontSize: 14,}; |
53 | 53 | ||
54 | return ( | 54 | return ( |
55 | - <TouchableOpacity onPress={() => { | 55 | + <TouchableOpacity activeOpacity={1} onPress={() => { |
56 | let filters = this.state.filters; | 56 | let filters = this.state.filters; |
57 | let filter = this.state.filters[rowID]; | 57 | let filter = this.state.filters[rowID]; |
58 | if (this.props.selectID-1 == rowID) { | 58 | if (this.props.selectID-1 == rowID) { |
@@ -22,8 +22,10 @@ export default class NewHotBannerListCell extends React.Component { | @@ -22,8 +22,10 @@ export default class NewHotBannerListCell extends React.Component { | ||
22 | render() { | 22 | render() { |
23 | let rowData = this.props.rowData; | 23 | let rowData = this.props.rowData; |
24 | let newSrc = getSlicedUrl(rowData.brand_ico, width, height, 2); | 24 | let newSrc = getSlicedUrl(rowData.brand_ico, width, height, 2); |
25 | - let brand_id = rowData.id; | ||
26 | - let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.brand","params":{"brand_id":"${brand_id}"}}`; | 25 | + let name = rowData.brand_name; |
26 | + let shop_id = rowData.shop_id; | ||
27 | + let shop_template_type = rowData.shop_template_type; | ||
28 | + let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.shop","params":{"shop_id":"${shop_id}","shop_template_type":"${shop_template_type}","name":"${name}"}}`; | ||
27 | 29 | ||
28 | return ( | 30 | return ( |
29 | <TouchableOpacity activeOpacity={0.5} onPress={() => { | 31 | <TouchableOpacity activeOpacity={0.5} onPress={() => { |
@@ -10,6 +10,8 @@ import ReactNative, { | @@ -10,6 +10,8 @@ import ReactNative, { | ||
10 | Dimensions, | 10 | Dimensions, |
11 | TouchableOpacity, | 11 | TouchableOpacity, |
12 | InteractionManager, | 12 | InteractionManager, |
13 | + Platform, | ||
14 | + RefreshControl, | ||
13 | } from 'react-native'; | 15 | } from 'react-native'; |
14 | 16 | ||
15 | import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator'; | 17 | import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator'; |
@@ -30,9 +32,13 @@ export default class Interest extends Component { | @@ -30,9 +32,13 @@ export default class Interest extends Component { | ||
30 | } | 32 | } |
31 | 33 | ||
32 | componentDidMount() { | 34 | componentDidMount() { |
33 | - InteractionManager.runAfterInteractions(() => { | ||
34 | - this.listView && this.listView.getScrollResponder().startPullToRefresh(); | ||
35 | - }); | 35 | + if (Platform.OS === 'ios') { |
36 | + InteractionManager.runAfterInteractions(() => { | ||
37 | + this.listView && this.listView.getScrollResponder().startPullToRefresh(); | ||
38 | + }); | ||
39 | + }else{ | ||
40 | + this.props.onRefresh && this.props.onRefresh(); | ||
41 | + } | ||
36 | } | 42 | } |
37 | 43 | ||
38 | componentWillReceiveProps(nextProps) { | 44 | componentWillReceiveProps(nextProps) { |
@@ -78,39 +84,77 @@ export default class Interest extends Component { | @@ -78,39 +84,77 @@ export default class Interest extends Component { | ||
78 | return ( | 84 | return ( |
79 | <View style={styles.container}> | 85 | <View style={styles.container}> |
80 | {showLoginTip ? <LoginTip onInterestLogin={this.props.onInterestLogin} /> : null} | 86 | {showLoginTip ? <LoginTip onInterestLogin={this.props.onInterestLogin} /> : null} |
81 | - | ||
82 | - <ListView | ||
83 | - ref={(c) => { | ||
84 | - this.listView = c; | ||
85 | - }} | ||
86 | - contentContainerStyle={styles.contentContainer} | ||
87 | - dataSource={this.dataSource.cloneWithRows(dataSource)} | ||
88 | - renderRow={this._renderRow} | ||
89 | - enableEmptySections={true} | ||
90 | - enablePullToRefresh={true} | ||
91 | - isOnPullToRefresh={isPullToRefresh} | ||
92 | - onRefreshData={() => { | ||
93 | - this.props.onRefresh && this.props.onRefresh(); | ||
94 | - }} | ||
95 | - onEndReached={() => { | ||
96 | - if (list.size != 0) { | ||
97 | - this.props.onEndReached && this.props.onEndReached(); | 87 | + { |
88 | + Platform.OS === 'ios'?<ListView | ||
89 | + ref={(c) => { | ||
90 | + this.listView = c; | ||
91 | + }} | ||
92 | + contentContainerStyle={styles.contentContainer} | ||
93 | + dataSource={this.dataSource.cloneWithRows(dataSource)} | ||
94 | + renderRow={this._renderRow} | ||
95 | + enableEmptySections={true} | ||
96 | + enablePullToRefresh={true} | ||
97 | + isOnPullToRefresh={isPullToRefresh} | ||
98 | + onRefreshData={() => { | ||
99 | + this.props.onRefresh && this.props.onRefresh(); | ||
100 | + }} | ||
101 | + onEndReached={() => { | ||
102 | + if (list.size != 0) { | ||
103 | + this.props.onEndReached && this.props.onEndReached(); | ||
104 | + } | ||
105 | + }} | ||
106 | + renderFooter={() => { | ||
107 | + if (endReached) { | ||
108 | + return <LoadMoreIndicator | ||
109 | + isVisible={true} | ||
110 | + text={'暂无更多'} | ||
111 | + /> | ||
112 | + } else { | ||
113 | + return <LoadMoreIndicator | ||
114 | + isVisible={isLoadingMore} | ||
115 | + animating={isFetching} | ||
116 | + /> | ||
117 | + } | ||
118 | + }} | ||
119 | + />:<ListView | ||
120 | + ref={(c) => { | ||
121 | + this.listView = c; | ||
122 | + }} | ||
123 | + refreshControl={ | ||
124 | + <RefreshControl | ||
125 | + refreshing={false} | ||
126 | + onRefresh={() => { | ||
127 | + this.props.onRefresh && this.props.onRefresh(); | ||
128 | + }} | ||
129 | + colors={['#000000', '#ff0000']} | ||
130 | + progressBackgroundColor="#ffffff" | ||
131 | + /> | ||
98 | } | 132 | } |
99 | - }} | ||
100 | - renderFooter={() => { | ||
101 | - if (endReached) { | ||
102 | - return <LoadMoreIndicator | ||
103 | - isVisible={true} | ||
104 | - text={'暂无更多'} | ||
105 | - /> | ||
106 | - } else { | ||
107 | - return <LoadMoreIndicator | ||
108 | - isVisible={isLoadingMore} | ||
109 | - animating={isFetching} | ||
110 | - /> | ||
111 | - } | ||
112 | - }} | ||
113 | - /> | 133 | + contentContainerStyle={styles.contentContainer} |
134 | + dataSource={this.dataSource.cloneWithRows(dataSource)} | ||
135 | + renderRow={this._renderRow} | ||
136 | + enableEmptySections={true} | ||
137 | + onEndReached={() => { | ||
138 | + if (list.size != 0) { | ||
139 | + this.props.onEndReached && this.props.onEndReached(); | ||
140 | + } | ||
141 | + }} | ||
142 | + renderFooter={() => { | ||
143 | + if (endReached) { | ||
144 | + return <LoadMoreIndicator | ||
145 | + isVisible={true} | ||
146 | + text={'暂无更多'} | ||
147 | + /> | ||
148 | + } else { | ||
149 | + return <LoadMoreIndicator | ||
150 | + isVisible={isLoadingMore} | ||
151 | + animating={isFetching} | ||
152 | + /> | ||
153 | + } | ||
154 | + }} | ||
155 | + /> | ||
156 | + } | ||
157 | + | ||
114 | </View> | 158 | </View> |
115 | ); | 159 | ); |
116 | } | 160 | } |
@@ -85,9 +85,16 @@ export default class ProductListView extends Component { | @@ -85,9 +85,16 @@ export default class ProductListView extends Component { | ||
85 | <TouchableOpacity onPress={() => { | 85 | <TouchableOpacity onPress={() => { |
86 | this.props.onPressRemindBtn && this.props.onPressRemindBtn(rowData); | 86 | this.props.onPressRemindBtn && this.props.onPressRemindBtn(rowData); |
87 | }}> | 87 | }}> |
88 | - <View style={[styles.priceClickTipViewRight,{backgroundColor: btnBgColor}]}> | ||
89 | - <Text style={{color:btnTextcolor}}>{tipState}</Text> | ||
90 | - </View> | 88 | + { |
89 | + (tipState=='取消提醒')? | ||
90 | + <View style={[styles.priceClickTipViewRight,{backgroundColor: btnBgColor,borderWidth:1.0}]}> | ||
91 | + <Text style={{color:btnTextcolor}}>{tipState}</Text> | ||
92 | + </View> | ||
93 | + :<View style={[styles.priceClickTipViewRight,{backgroundColor: btnBgColor}]}> | ||
94 | + <Text style={{color:btnTextcolor}}>{tipState}</Text> | ||
95 | + </View> | ||
96 | + } | ||
97 | + | ||
91 | </TouchableOpacity> | 98 | </TouchableOpacity> |
92 | 99 | ||
93 | </View> | 100 | </View> |
@@ -10,6 +10,7 @@ import { | @@ -10,6 +10,7 @@ import { | ||
10 | Image, | 10 | Image, |
11 | ListView, | 11 | ListView, |
12 | TouchableOpacity, | 12 | TouchableOpacity, |
13 | + RefreshControl, | ||
13 | } from 'react-native'; | 14 | } from 'react-native'; |
14 | 15 | ||
15 | import Immutable, {Map} from 'immutable'; | 16 | import Immutable, {Map} from 'immutable'; |
@@ -74,6 +75,7 @@ export default class Seckill extends Component { | @@ -74,6 +75,7 @@ export default class Seckill extends Component { | ||
74 | <TimeListView | 75 | <TimeListView |
75 | resource={this.queryActivityInfo.secKillProductVoList.toArray()} | 76 | resource={this.queryActivityInfo.secKillProductVoList.toArray()} |
76 | onPressTimeItem={this.props.onPressTimeItem} | 77 | onPressTimeItem={this.props.onPressTimeItem} |
78 | + onFocusToCurStartedActivity={this.props.onFocusToCurStartedActivity} | ||
77 | diff={diff} | 79 | diff={diff} |
78 | /> | 80 | /> |
79 | ); | 81 | ); |
@@ -127,7 +129,8 @@ export default class Seckill extends Component { | @@ -127,7 +129,8 @@ export default class Seckill extends Component { | ||
127 | 129 | ||
128 | return ( | 130 | return ( |
129 | <View style={styles.container}> | 131 | <View style={styles.container}> |
130 | - <ListView | 132 | + { |
133 | + Platform.OS === 'ios'?<ListView | ||
131 | contentContainerStyle={styles.contentContainer} | 134 | contentContainerStyle={styles.contentContainer} |
132 | enableEmptySections={true} | 135 | enableEmptySections={true} |
133 | dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} | 136 | dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} |
@@ -151,7 +154,45 @@ export default class Seckill extends Component { | @@ -151,7 +154,45 @@ export default class Seckill extends Component { | ||
151 | <Text style={styles.descriptionText}>4. 活动最终解释权归YOHO!BUY有货所有.</Text> | 154 | <Text style={styles.descriptionText}>4. 活动最终解释权归YOHO!BUY有货所有.</Text> |
152 | </View> | 155 | </View> |
153 | }} | 156 | }} |
157 | + />:<ListView | ||
158 | + refreshControl={ | ||
159 | + <RefreshControl | ||
160 | + refreshing={false} | ||
161 | + onRefresh={() => { | ||
162 | + //强制刷新数据 | ||
163 | + if (isFetching) { | ||
164 | + return; | ||
165 | + } | ||
166 | + this.props.onRefresh && this.props.onRefresh(); | ||
167 | + }} | ||
168 | + colors={['#000000', '#ff0000']} | ||
169 | + progressBackgroundColor="#ffffff" | ||
170 | + /> | ||
171 | + } | ||
172 | + contentContainerStyle={styles.contentContainer} | ||
173 | + enableEmptySections={true} | ||
174 | + dataSource={this.dataSource.cloneWithRows(dataSource)} | ||
175 | + renderRow={this.renderRow} | ||
176 | + enablePullToRefresh={true} | ||
177 | + isOnPullToRefresh={isFetching} | ||
178 | + onRefreshData={() => { | ||
179 | + //强制刷新数据 | ||
180 | + if (isFetching) { | ||
181 | + return; | ||
182 | + } | ||
183 | + this.props.onRefresh && this.props.onRefresh(); | ||
184 | + }} | ||
185 | + renderFooter={()=>{ | ||
186 | + return <View style={styles.descriptionContainer}> | ||
187 | + <Text style={styles.descriptionText}>秒杀活动说明</Text> | ||
188 | + <Text style={styles.descriptionText}>1. 秒杀商品限活动开始后,在详情页抢购,提前加入购物车无效;</Text> | ||
189 | + <Text style={styles.descriptionText}>2. 秒杀数量有限,抢完即止;</Text> | ||
190 | + <Text style={styles.descriptionText}>3. 秒杀商品限购1件, 不能使用优惠券或优惠码;</Text> | ||
191 | + <Text style={styles.descriptionText}>4. 活动最终解释权归YOHO!BUY有货所有.</Text> | ||
192 | + </View> | ||
193 | + }} | ||
154 | /> | 194 | /> |
195 | + } | ||
155 | 196 | ||
156 | <LoadingIndicator | 197 | <LoadingIndicator |
157 | isVisible={isFetching} | 198 | isVisible={isFetching} |
@@ -20,6 +20,7 @@ export default class SeckillTimeListView extends Component { | @@ -20,6 +20,7 @@ export default class SeckillTimeListView extends Component { | ||
20 | super(props); | 20 | super(props); |
21 | this._renderRow = this._renderRow.bind(this); | 21 | this._renderRow = this._renderRow.bind(this); |
22 | this._renderSeparator = this._renderSeparator.bind(this); | 22 | this._renderSeparator = this._renderSeparator.bind(this); |
23 | + this._scrollToFocusActivity = this._scrollToFocusActivity.bind(this); | ||
23 | 24 | ||
24 | this.dataSource = new ListView.DataSource({ | 25 | this.dataSource = new ListView.DataSource({ |
25 | rowHasChanged: (r1, r2) => r1.key != r2.key, | 26 | rowHasChanged: (r1, r2) => r1.key != r2.key, |
@@ -35,11 +36,43 @@ export default class SeckillTimeListView extends Component { | @@ -35,11 +36,43 @@ export default class SeckillTimeListView extends Component { | ||
35 | }; | 36 | }; |
36 | } | 37 | } |
37 | 38 | ||
39 | + _scrollToFocusActivity = () => { | ||
40 | + //focus | ||
41 | + if (this.secKillProductVoList.length >= 1) { | ||
42 | + let listLength = this.secKillProductVoList.length; | ||
43 | + let curFocusIndex = 0; | ||
44 | + let scrollX = 0; | ||
45 | + this.secKillProductVoList.forEach((activityItem, i) => { | ||
46 | + if (activityItem.get('activityId') === this.curFocusActivity.get('activityId')) { | ||
47 | + curFocusIndex = i; | ||
48 | + } | ||
49 | + }); | ||
50 | + // if (curFocusIndex > 1 && curFocusIndex < listLength-2) { | ||
51 | + scrollX = (curFocusIndex - 1) * rowContainerWidth; | ||
52 | + this.listView && this.listView.scrollTo({x: scrollX, y: 0, animated: false}); | ||
53 | + | ||
54 | + // } | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
38 | componentDidMount() { | 58 | componentDidMount() { |
59 | + | ||
60 | + let jumpToTimeoutActivity = () => { | ||
61 | + this.secKillProductVoList.forEach((activityItem, i) => { | ||
62 | + let nowTime = Date.parse(new Date()) / 1000 + diffTime; | ||
63 | + let startTime = activityItem.get('startTime') / 1000; | ||
64 | + let offsetTime = nowTime - startTime; | ||
65 | + if (activityItem.get('focus') == false && Math.abs(offsetTime) <= 2) { | ||
66 | + this.props.onFocusToCurStartedActivity && this.props.onFocusToCurStartedActivity(activityItem.toJS()); | ||
67 | + } | ||
68 | + }); | ||
69 | + }; | ||
70 | + | ||
39 | this.timer = setInterval(function () { | 71 | this.timer = setInterval(function () { |
40 | if (!this.curFocusActivity && this.curFocusActivity.size > 0 && !this.curFocusActivity.has('over')) { | 72 | if (!this.curFocusActivity && this.curFocusActivity.size > 0 && !this.curFocusActivity.has('over')) { |
41 | return; | 73 | return; |
42 | } | 74 | } |
75 | + jumpToTimeoutActivity(); | ||
43 | let nowTime = Date.parse(new Date()) / 1000 + diffTime; | 76 | let nowTime = Date.parse(new Date()) / 1000 + diffTime; |
44 | let time = this.curFocusActivity.has('now') ? this.curFocusActivity.get('endTime'): this.curFocusActivity.get('startTime') / 1000; | 77 | let time = this.curFocusActivity.has('now') ? this.curFocusActivity.get('endTime'): this.curFocusActivity.get('startTime') / 1000; |
45 | let offsetTime = time - nowTime; | 78 | let offsetTime = time - nowTime; |
@@ -48,13 +81,15 @@ export default class SeckillTimeListView extends Component { | @@ -48,13 +81,15 @@ export default class SeckillTimeListView extends Component { | ||
48 | let second = offsetTime % 60; | 81 | let second = offsetTime % 60; |
49 | 82 | ||
50 | if (offsetTime <= 0) { | 83 | if (offsetTime <= 0) { |
84 | + if (!this.state.tickTimeOut) { | ||
85 | + this.props.onFocusToCurStartedActivity && this.props.onFocusToCurStartedActivity(this.curFocusActivity.toJS()); | ||
86 | + } | ||
51 | this.setState({ | 87 | this.setState({ |
52 | tickHour: '00', | 88 | tickHour: '00', |
53 | tickMinute: '00', | 89 | tickMinute: '00', |
54 | tickSecond: '00', | 90 | tickSecond: '00', |
55 | tickTimeOut: true, | 91 | tickTimeOut: true, |
56 | }); | 92 | }); |
57 | - this.props.onPressTimeItem && this.props.onPressTimeItem(this.curFocusActivity.toJS()); | ||
58 | } else { | 93 | } else { |
59 | this.setState({ | 94 | this.setState({ |
60 | tickHour: hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour), | 95 | tickHour: hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour), |
@@ -65,23 +100,7 @@ export default class SeckillTimeListView extends Component { | @@ -65,23 +100,7 @@ export default class SeckillTimeListView extends Component { | ||
65 | } | 100 | } |
66 | 101 | ||
67 | }.bind(this), 1000); | 102 | }.bind(this), 1000); |
68 | - | ||
69 | - //focus | ||
70 | - if (this.secKillProductVoList.length >= 1) { | ||
71 | - let listLength = this.secKillProductVoList.length; | ||
72 | - let curFocusIndex = 0; | ||
73 | - let scrollX = 0; | ||
74 | - this.secKillProductVoList.forEach((activityItem, i) => { | ||
75 | - if (activityItem.get('activityId') === this.curFocusActivity.get('activityId')) { | ||
76 | - curFocusIndex = i; | ||
77 | - } | ||
78 | - }); | ||
79 | - if (curFocusIndex > 1 && curFocusIndex < listLength-2) { | ||
80 | - scrollX = (curFocusIndex - 1) * rowContainerWidth; | ||
81 | - this.listView.scrollTo({x: scrollX, y: 0, animated: false}); | ||
82 | - | ||
83 | - } | ||
84 | - } | 103 | + this._scrollToFocusActivity(); |
85 | 104 | ||
86 | } | 105 | } |
87 | 106 | ||
@@ -89,6 +108,15 @@ export default class SeckillTimeListView extends Component { | @@ -89,6 +108,15 @@ export default class SeckillTimeListView extends Component { | ||
89 | this.timer && clearInterval(this.timer); | 108 | this.timer && clearInterval(this.timer); |
90 | } | 109 | } |
91 | 110 | ||
111 | + componentWillReceiveProps(nextProps) { | ||
112 | + if (nextProps.resource && nextProps.resource.length > 0) { | ||
113 | + let focusActivity = nextProps.resource.find(activityTimeItem => activityTimeItem.get('focus')); | ||
114 | + this.curFocusActivity = focusActivity; | ||
115 | + } | ||
116 | + this._scrollToFocusActivity(); | ||
117 | + | ||
118 | + } | ||
119 | + | ||
92 | _renderRow(rowData, sectionID, rowID) { | 120 | _renderRow(rowData, sectionID, rowID) { |
93 | rowData = rowData.toJS(); | 121 | rowData = rowData.toJS(); |
94 | let colorStyle = rowData.focus ? {color: '#d30018'} : {color: '#3e3e3e'}; | 122 | let colorStyle = rowData.focus ? {color: '#d30018'} : {color: '#3e3e3e'}; |
@@ -176,15 +204,19 @@ export default class SeckillTimeListView extends Component { | @@ -176,15 +204,19 @@ export default class SeckillTimeListView extends Component { | ||
176 | } | 204 | } |
177 | diffTime = diff; | 205 | diffTime = diff; |
178 | this.secKillProductVoList = resource; | 206 | this.secKillProductVoList = resource; |
207 | + backgroundWidth = Math.max(rowContainerWidth * (resource.length - 1) + rowContainerFocusWidth, width); | ||
208 | + | ||
179 | return ( | 209 | return ( |
180 | <View style={[styles.container]}> | 210 | <View style={[styles.container]}> |
181 | <ListView | 211 | <ListView |
182 | - contentContainerStyle={[styles.contentContainer]} | 212 | + ref={(ref)=>this.listView=ref} |
213 | + contentContainerStyle={[styles.contentContainer,{width:backgroundWidth}]} | ||
183 | enableEmptySections={true} | 214 | enableEmptySections={true} |
184 | dataSource={this.dataSource.cloneWithRows(resource)} | 215 | dataSource={this.dataSource.cloneWithRows(resource)} |
185 | renderSeparator={this._renderSeparator} | 216 | renderSeparator={this._renderSeparator} |
186 | renderRow={this._renderRow} | 217 | renderRow={this._renderRow} |
187 | - scrollEnabled={false} | 218 | + scrollEnabled={true} |
219 | + horizontal={true} | ||
188 | scrollsToTop={false} | 220 | scrollsToTop={false} |
189 | /> | 221 | /> |
190 | </View> | 222 | </View> |
@@ -202,7 +234,7 @@ let rowContainerFocusWidth = Math.ceil((294 * width) / 750); | @@ -202,7 +234,7 @@ let rowContainerFocusWidth = Math.ceil((294 * width) / 750); | ||
202 | let styles = StyleSheet.create({ | 234 | let styles = StyleSheet.create({ |
203 | container: { | 235 | container: { |
204 | marginLeft: -1, | 236 | marginLeft: -1, |
205 | - width: width + 2, | 237 | + width: backgroundWidth + 2, |
206 | height: backgroundHeight, | 238 | height: backgroundHeight, |
207 | borderTopColor: 'transparent', | 239 | borderTopColor: 'transparent', |
208 | borderBottomColor: '#e5e5e5', | 240 | borderBottomColor: '#e5e5e5', |
@@ -46,6 +46,7 @@ class SeckillContainer extends Component { | @@ -46,6 +46,7 @@ class SeckillContainer extends Component { | ||
46 | this._onPressRemindBtn = this._onPressRemindBtn.bind(this); | 46 | this._onPressRemindBtn = this._onPressRemindBtn.bind(this); |
47 | this._onRefresh = this._onRefresh.bind(this); | 47 | this._onRefresh = this._onRefresh.bind(this); |
48 | this._onClearRemindTip = this._onClearRemindTip.bind(this); | 48 | this._onClearRemindTip = this._onClearRemindTip.bind(this); |
49 | + this._onFocusToCurStartedActivity = this._onFocusToCurStartedActivity.bind(this); | ||
49 | } | 50 | } |
50 | 51 | ||
51 | componentDidMount() { | 52 | componentDidMount() { |
@@ -72,6 +73,10 @@ class SeckillContainer extends Component { | @@ -72,6 +73,10 @@ class SeckillContainer extends Component { | ||
72 | this.props.actions.addCancelUserReminderClearTip(); | 73 | this.props.actions.addCancelUserReminderClearTip(); |
73 | } | 74 | } |
74 | 75 | ||
76 | + _onFocusToCurStartedActivity(activity) { | ||
77 | + this.props.actions.getSeckillQueryActivity(activity.startTime); | ||
78 | + } | ||
79 | + | ||
75 | render() { | 80 | render() { |
76 | 81 | ||
77 | let { | 82 | let { |
@@ -96,6 +101,7 @@ class SeckillContainer extends Component { | @@ -96,6 +101,7 @@ class SeckillContainer extends Component { | ||
96 | onPressRemindBtn={this._onPressRemindBtn} | 101 | onPressRemindBtn={this._onPressRemindBtn} |
97 | onRefresh={this._onRefresh} | 102 | onRefresh={this._onRefresh} |
98 | onClearRemindTip={this._onClearRemindTip} | 103 | onClearRemindTip={this._onClearRemindTip} |
104 | + onFocusToCurStartedActivity={this._onFocusToCurStartedActivity} | ||
99 | /> | 105 | /> |
100 | ); | 106 | ); |
101 | } | 107 | } |
@@ -153,10 +153,12 @@ export function setStartTime(startTime) { | @@ -153,10 +153,12 @@ export function setStartTime(startTime) { | ||
153 | /* | 153 | /* |
154 | * 秒杀时间栏 | 154 | * 秒杀时间栏 |
155 | */ | 155 | */ |
156 | -export function getSeckillQueryActivity() { | 156 | +export function getSeckillQueryActivity(inStartTime = 0) { |
157 | return (dispatch, getState) => { | 157 | return (dispatch, getState) => { |
158 | let {app, seckill, startTime} = getState(); | 158 | let {app, seckill, startTime} = getState(); |
159 | - | 159 | + if (inStartTime) { |
160 | + startTime = inStartTime; | ||
161 | + } | ||
160 | dispatch(queryActivityRequest()); | 162 | dispatch(queryActivityRequest()); |
161 | return new SeckillService(app.host).fetchQueryActivity() | 163 | return new SeckillService(app.host).fetchQueryActivity() |
162 | .then(json => { | 164 | .then(json => { |
@@ -391,8 +393,13 @@ export function refreshList() { | @@ -391,8 +393,13 @@ export function refreshList() { | ||
391 | return (dispatch, getState) => { | 393 | return (dispatch, getState) => { |
392 | let {app, seckill} = getState(); | 394 | let {app, seckill} = getState(); |
393 | let {queryActivityInfo,queryProductList} = seckill; | 395 | let {queryActivityInfo,queryProductList} = seckill; |
394 | - if (curActivityId !== 0) { | ||
395 | - dispatch(getSeckillRemindList(curActivityId)); | 396 | + |
397 | + if (curActivityId !== 0 && queryActivityInfo.secKillProductVoList) { | ||
398 | + queryActivityInfo.secKillProductVoList.forEach((activityInfo, i) => { | ||
399 | + if (activityInfo.get('activityId') === curActivityId) { | ||
400 | + dispatch(getSeckillQueryActivity(activityInfo.get('startTime'))); | ||
401 | + } | ||
402 | + }); | ||
396 | } else { | 403 | } else { |
397 | dispatch(getSeckillQueryActivity()); | 404 | dispatch(getSeckillQueryActivity()); |
398 | } | 405 | } |
-
Please register or login to post a comment