砍价列表分区展示&&增加资源位请求 review by孙凯
Showing
14 changed files
with
705 additions
and
104 deletions
1 | /* | 1 | /* |
2 | - * @Author: QC.L | ||
3 | - * @Date: 2018-09-11 16:07:56 | 2 | + * @Author: QC.L |
3 | + * @Date: 2018-09-11 16:07:56 | ||
4 | * @Last Modified by: QC.L | 4 | * @Last Modified by: QC.L |
5 | * @Last Modified time: 2018-09-11 16:14:40 | 5 | * @Last Modified time: 2018-09-11 16:14:40 |
6 | * @Description 弹框 Alert 效果 | 6 | * @Description 弹框 Alert 效果 |
@@ -4,73 +4,107 @@ import React, { Component } from 'react'; | @@ -4,73 +4,107 @@ import React, { Component } from 'react'; | ||
4 | import { Dimensions, ListView, Image, StyleSheet, View ,Text, TouchableOpacity} from 'react-native'; | 4 | import { Dimensions, ListView, Image, StyleSheet, View ,Text, TouchableOpacity} from 'react-native'; |
5 | import { Immutable } from 'immutable'; | 5 | import { Immutable } from 'immutable'; |
6 | import ProductCell from './cell/productCell'; | 6 | import ProductCell from './cell/productCell'; |
7 | +import Focus from './floor/Focus'; | ||
7 | 8 | ||
8 | const DEVICE_WIDTH_RATIO = Dimensions.get('window').width / 375; | 9 | const DEVICE_WIDTH_RATIO = Dimensions.get('window').width / 375; |
9 | 10 | ||
10 | export default class HaggleList extends Component { | 11 | export default class HaggleList extends Component { |
11 | constructor(props) { | 12 | constructor(props) { |
12 | super(props); | 13 | super(props); |
13 | - this.state = {categoryType:0}; | ||
14 | this._renderRow = this._renderRow.bind(this); | 14 | this._renderRow = this._renderRow.bind(this); |
15 | this._changeCategory = this._changeCategory.bind(this); | 15 | this._changeCategory = this._changeCategory.bind(this); |
16 | this.dataSource = new ListView.DataSource({ | 16 | this.dataSource = new ListView.DataSource({ |
17 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | 17 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), |
18 | + sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2), | ||
18 | }); | 19 | }); |
19 | } | 20 | } |
20 | 21 | ||
21 | -_renderRow(rowData, sectionID, rowID) { | 22 | + _renderResourceInfoListRow(item) { |
23 | + if (item.get('template_name') === 'focus' && item.get('data')) { | ||
22 | return ( | 24 | return ( |
23 | - <ProductCell | ||
24 | - key={'row' + rowID} | ||
25 | - rowID={rowID} | ||
26 | - data={rowData} | ||
27 | - onPressProduct={this.props.onPressProduct} | ||
28 | - firstHaggle={this.props.firstHaggle} | ||
29 | - continueHaggle={this.props.continueHaggle} | ||
30 | - onStop = {this.props.onStop && this.props.onStop(this.state.categoryType)} | 25 | + <View style={styles.topImageView}> |
26 | + <Focus | ||
27 | + data={item.get('data')} | ||
28 | + height={121} | ||
29 | + resourceJumpWithUrl={this.props.resourceJumpWithUrl} | ||
31 | /> | 30 | /> |
31 | + </View> | ||
32 | + | ||
32 | ); | 33 | ); |
34 | + } | ||
35 | + return null; | ||
33 | } | 36 | } |
37 | + | ||
38 | +_renderRow(rowData, sectionID, rowID) { | ||
39 | + if(sectionID === 'resourceInfoList'){ | ||
40 | + return this._renderResourceInfoListRow(rowData) | ||
41 | + }else if (sectionID === 'productList') { | ||
42 | + return ( | ||
43 | + <ProductCell | ||
44 | + key={'row' + rowID} | ||
45 | + rowID={rowID} | ||
46 | + data={rowData} | ||
47 | + onPressProduct={this.props.onPressProduct} | ||
48 | + firstHaggle={this.props.firstHaggle} | ||
49 | + continueHaggle={this.props.continueHaggle} | ||
50 | + onStop = {this.props.onStop} | ||
51 | + /> | ||
52 | + ); | ||
53 | + }else { | ||
54 | + return null; | ||
55 | + } | ||
56 | +} | ||
57 | + | ||
34 | _changeCategory(index) { | 58 | _changeCategory(index) { |
35 | - if (index == this.state.categoryType) { | 59 | + let { |
60 | + categoryType, | ||
61 | + } = this.props; | ||
62 | + | ||
63 | + if (index == categoryType) { | ||
36 | return | 64 | return |
37 | } | 65 | } |
38 | - console.log(this.state.categoryType); | ||
39 | - this.setState({categoryType:index}); | 66 | + |
40 | this.props.onPressCategory && this.props.onPressCategory(index); | 67 | this.props.onPressCategory && this.props.onPressCategory(index); |
41 | } | 68 | } |
69 | + | ||
42 | render() { | 70 | render() { |
43 | let { | 71 | let { |
44 | data, | 72 | data, |
73 | + categoryType, | ||
74 | + resourceInfo, | ||
45 | } = this.props; | 75 | } = this.props; |
46 | 76 | ||
47 | - let productList = data.list ? data.list.toArray() : []; | ||
48 | - let color = this.state.categoryType == 0 ? '#444444' : '#b0b0b0'; | ||
49 | - let subcolor = this.state.categoryType == 1 ? '#444444' : '#b0b0b0'; | ||
50 | - | 77 | + let productList = data.list ? data.list.toArray() : []; |
78 | + let color = categoryType == 0 ? '#444444' : '#b0b0b0'; | ||
79 | + let subcolor = categoryType == 1 ? '#444444' : '#b0b0b0'; | ||
80 | + let dataSource = null; | ||
81 | + if (categoryType == 0) { | ||
82 | + dataSource = { | ||
83 | + resourceInfoList: resourceInfo.resourceList ? resourceInfo.resourceList.toArray() : [], | ||
84 | + productList: data.list ? data.list.toArray() : [], | ||
85 | + } | ||
86 | + }else { | ||
87 | + dataSource = { | ||
88 | + productList: data.list ? data.list.toArray() : [], | ||
89 | + } | ||
90 | + } | ||
51 | return ( | 91 | return ( |
52 | <View style={styles.container}> | 92 | <View style={styles.container}> |
53 | - | ||
54 | - {this.state.categoryType == 0 ? <View style={styles.topImageView}> | ||
55 | - <Image style={styles.topImageView} source={{uri:'https://cdn.yoho.cn/app/yohogain/invite/banner.jpg'}} resizeMode={'contain'}/> | ||
56 | - </View> | ||
57 | - : null } | ||
58 | - | ||
59 | - <ListView | ||
60 | - ref={(c) => { | ||
61 | - this.listView = c; | ||
62 | - }} | ||
63 | - contentContainerStyle={styles.contentContainer} | ||
64 | - enableEmptySections={true} | ||
65 | - dataSource={this.dataSource.cloneWithRows(productList)} | ||
66 | - renderRow={this._renderRow} | ||
67 | - renderFooter={this._renderFooter} | ||
68 | - | ||
69 | - onEndReached={() => { | ||
70 | - if (productList.size !== 0) { | ||
71 | - this.props.onEndReached && this.props.onEndReached(this.state.categoryType); | ||
72 | - } | ||
73 | - }}/> | 93 | + <ListView |
94 | + ref={(c) => { | ||
95 | + this.listView = c; | ||
96 | + }} | ||
97 | + enableEmptySections={true} | ||
98 | + contentContainerStyle={styles.contentContainer} | ||
99 | + dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} | ||
100 | + renderRow={this._renderRow} | ||
101 | + renderHeader={this._renderHeader} | ||
102 | + renderFooter={this._renderFooter} | ||
103 | + onEndReached={() => { | ||
104 | + if (productList.size !== 0) { | ||
105 | + this.props.onEndReached && this.props.onEndReached(categoryType); | ||
106 | + } | ||
107 | + }}/> | ||
74 | 108 | ||
75 | <View style={styles.bottomView}> | 109 | <View style={styles.bottomView}> |
76 | <TouchableOpacity activeOpacity={1} style={styles.textItemStyle} onPress={() => { | 110 | <TouchableOpacity activeOpacity={1} style={styles.textItemStyle} onPress={() => { |
@@ -78,7 +112,7 @@ _renderRow(rowData, sectionID, rowID) { | @@ -78,7 +112,7 @@ _renderRow(rowData, sectionID, rowID) { | ||
78 | }}> | 112 | }}> |
79 | <Text style={[styles.textsStyle, {color: color}]}>砍价商品</Text> | 113 | <Text style={[styles.textsStyle, {color: color}]}>砍价商品</Text> |
80 | </TouchableOpacity> | 114 | </TouchableOpacity> |
81 | - | 115 | + <View style={styles.separator}/> |
82 | <TouchableOpacity activeOpacity={1} style={styles.textItemStyle} onPress={() => { | 116 | <TouchableOpacity activeOpacity={1} style={styles.textItemStyle} onPress={() => { |
83 | this._changeCategory && this._changeCategory(1); | 117 | this._changeCategory && this._changeCategory(1); |
84 | }}> | 118 | }}> |
@@ -100,7 +134,7 @@ let styles = StyleSheet.create({ | @@ -100,7 +134,7 @@ let styles = StyleSheet.create({ | ||
100 | }, | 134 | }, |
101 | topImageView: { | 135 | topImageView: { |
102 | width: width, | 136 | width: width, |
103 | - height: 118 * DEVICE_WIDTH_RATIO, | 137 | + height: 121 * DEVICE_WIDTH_RATIO, |
104 | }, | 138 | }, |
105 | 139 | ||
106 | contentContainer: { | 140 | contentContainer: { |
@@ -116,7 +150,10 @@ let styles = StyleSheet.create({ | @@ -116,7 +150,10 @@ let styles = StyleSheet.create({ | ||
116 | bottom: 0, | 150 | bottom: 0, |
117 | flexDirection: 'row', | 151 | flexDirection: 'row', |
118 | backgroundColor: 'white', | 152 | backgroundColor: 'white', |
153 | + borderTopColor: '#e0e0e0', | ||
154 | + borderTopWidth: 1, | ||
119 | }, | 155 | }, |
156 | + | ||
120 | textItemStyle: { | 157 | textItemStyle: { |
121 | width: width/2, | 158 | width: width/2, |
122 | height: 50 * DEVICE_WIDTH_RATIO, | 159 | height: 50 * DEVICE_WIDTH_RATIO, |
@@ -132,6 +169,11 @@ let styles = StyleSheet.create({ | @@ -132,6 +169,11 @@ let styles = StyleSheet.create({ | ||
132 | height: 50 * DEVICE_WIDTH_RATIO, | 169 | height: 50 * DEVICE_WIDTH_RATIO, |
133 | backgroundColor: '#f0f0f0' | 170 | backgroundColor: '#f0f0f0' |
134 | }, | 171 | }, |
135 | - | 172 | + topLineSeparator: { |
173 | + width:width, | ||
174 | + height: 1, | ||
175 | + bottom: 55, | ||
176 | + backgroundColor: '#f0f0f0' | ||
177 | + }, | ||
136 | }) | 178 | }) |
137 | ; | 179 | ; |
js/haggle/components/cell/ImageSlider.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import YH_Swiper from '../../../common/components/YH_Swiper'; | ||
6 | +import YH_Image from '../../../common/components/YH_Image'; | ||
7 | +import Immutable from 'immutable'; | ||
8 | + | ||
9 | +const { | ||
10 | + View, | ||
11 | + Image, | ||
12 | + TouchableOpacity, | ||
13 | + StyleSheet, | ||
14 | + Dimensions, | ||
15 | + Platform, | ||
16 | +} = ReactNative; | ||
17 | + | ||
18 | +export default class ImageSlider extends React.Component { | ||
19 | + | ||
20 | + constructor(props) { | ||
21 | + super(props); | ||
22 | + this._handleParamsJumpWithUrl = this._handleParamsJumpWithUrl.bind(this); | ||
23 | + } | ||
24 | + | ||
25 | + shouldComponentUpdate(nextProps) { | ||
26 | + if (Immutable.is(nextProps.resource, this.props.resource) | ||
27 | + && nextProps.sliderWidth == this.props.sliderWidth | ||
28 | + && nextProps.sliderHeight == this.props.sliderHeight) { | ||
29 | + return false; | ||
30 | + } else { | ||
31 | + return true; | ||
32 | + } | ||
33 | + } | ||
34 | + | ||
35 | + _handleParamsJumpWithUrl(index, url) { | ||
36 | + // 为埋点提供参数组装 | ||
37 | + // 后期请将所有的点击事件由 resourceJumpWithUrl 修改为自己独有的事件 | ||
38 | + // 由于多数组件都使用的 resourceJumpWithUrl ,埋点传参无法正常进行 | ||
39 | + let params = { | ||
40 | + I_INDEX: index, | ||
41 | + F_URL: url | ||
42 | + }; | ||
43 | + this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(url, 'banner', params); | ||
44 | + } | ||
45 | + | ||
46 | + render() { | ||
47 | + | ||
48 | + let {resource, sliderWidth, sliderHeight} = this.props; | ||
49 | + if (!resource || resource.size == 0) { | ||
50 | + return null; | ||
51 | + } | ||
52 | + | ||
53 | + let data = this.props.resource.toJS(); | ||
54 | + if (data.length == 1) { | ||
55 | + let imageUrl = YH_Image.getSlicedUrl(data[0].src, sliderWidth, sliderHeight, 2); | ||
56 | + return ( | ||
57 | + <TouchableOpacity | ||
58 | + activeOpacity={1} | ||
59 | + yh_exposureData={data[0].yh_exposureData} | ||
60 | + style={{width: sliderWidth, height: sliderHeight}} | ||
61 | + onPress={() => { | ||
62 | + this._handleParamsJumpWithUrl(1, data[0].url) | ||
63 | + }} | ||
64 | + > | ||
65 | + <YH_Image | ||
66 | + url={imageUrl} | ||
67 | + style={{width: sliderWidth, height: sliderHeight}} | ||
68 | + /> | ||
69 | + </TouchableOpacity> | ||
70 | + ); | ||
71 | + } else { | ||
72 | + return ( | ||
73 | + <YH_Swiper | ||
74 | + showsButtons={false} | ||
75 | + loop={true} | ||
76 | + autoplay={true} | ||
77 | + autoplayTimeout={8} | ||
78 | + width={sliderWidth} | ||
79 | + height={sliderHeight} | ||
80 | + paginationStyle={{ | ||
81 | + backgroundColor: 'rgba(68, 68, 68, 0.2)', | ||
82 | + bottom: 10, | ||
83 | + height: 10, | ||
84 | + width: data.length * 12, | ||
85 | + borderRadius: 5, | ||
86 | + marginLeft: (sliderWidth - data.length * 12) / 2, | ||
87 | + paddingBottom: 0, | ||
88 | + }} | ||
89 | + > | ||
90 | + {data.map((item, i) => { | ||
91 | + let imageUrl = YH_Image.getSlicedUrl(item.src, sliderWidth, sliderHeight, 2); | ||
92 | + return ( | ||
93 | + <TouchableOpacity | ||
94 | + key={i} | ||
95 | + activeOpacity={1} | ||
96 | + yh_exposureData={item.yh_exposureData} | ||
97 | + onPress={() => { | ||
98 | + this._handleParamsJumpWithUrl(i + 1, item.url); | ||
99 | + }} | ||
100 | + > | ||
101 | + <YH_Image | ||
102 | + url={imageUrl} | ||
103 | + style={{width: sliderWidth, height: sliderHeight}} | ||
104 | + /> | ||
105 | + </TouchableOpacity> | ||
106 | + ); | ||
107 | + })} | ||
108 | + </YH_Swiper> | ||
109 | + ); | ||
110 | + } | ||
111 | + } | ||
112 | +} |
js/haggle/components/cell/YH_Alert.js
0 → 100644
1 | +/* | ||
2 | + * @Author: QC.L | ||
3 | + * @Date: 2018-09-11 16:07:56 | ||
4 | + * @Last Modified by: QC.L | ||
5 | + * @Last Modified time: 2018-09-11 16:14:40 | ||
6 | + * @Description 弹框 Alert 效果 | ||
7 | + */ | ||
8 | +'use strict'; | ||
9 | + | ||
10 | +import React from 'react'; | ||
11 | +import ReactNative from 'react-native'; | ||
12 | + | ||
13 | +const { | ||
14 | + StyleSheet, | ||
15 | + Text, | ||
16 | + View, | ||
17 | + Dimensions, | ||
18 | + TouchableOpacity, | ||
19 | + Modal, | ||
20 | +} = ReactNative; | ||
21 | +import PropTypes from 'prop-types'; | ||
22 | + | ||
23 | +/** | ||
24 | + * 参数1: showStatus 值 sure/cancel | ||
25 | + * 参数2: handleAction 要处理的事件 | ||
26 | + */ | ||
27 | +function YHAlertItem(props) { | ||
28 | + return ( | ||
29 | + <TouchableOpacity style={styles.click} onPress={() => { | ||
30 | + props.handleAction && props.handleAction(props.param ? props.param: {}); | ||
31 | + }}> | ||
32 | + <Text style={styles[props.showStatus]}>{props.children}</Text> | ||
33 | + </TouchableOpacity> | ||
34 | + ); | ||
35 | +} | ||
36 | + | ||
37 | +/** | ||
38 | + * 参数1: isShow true 显示 false 隐藏 | ||
39 | + */ | ||
40 | +class YHAlert extends React.Component { | ||
41 | + | ||
42 | + static propTypes = { | ||
43 | + show: PropTypes.func, // 显示 | ||
44 | + hide: PropTypes.func, // 隐藏 | ||
45 | + }; | ||
46 | + | ||
47 | + constructor(props) { | ||
48 | + super(props); | ||
49 | + this._renderChildren = this._renderChildren.bind(this); | ||
50 | + } | ||
51 | + | ||
52 | + static defaultProps = { | ||
53 | + confirmTitle:{}, | ||
54 | + }; | ||
55 | + | ||
56 | + _renderChildren(children) { | ||
57 | + | ||
58 | + if('[object Array]' == Object.prototype.toString.call(children)){ | ||
59 | + return children.map((element, index) => { | ||
60 | + if (index === children.length) return element | ||
61 | + return ( | ||
62 | + <React.Fragment> | ||
63 | + {element} | ||
64 | + <View style={{width: 0.5, height: '100%', backgroundColor: '#e0e0e0'}}></View> | ||
65 | + </React.Fragment> | ||
66 | + ) | ||
67 | + }); | ||
68 | + }else { | ||
69 | + return children | ||
70 | + } | ||
71 | + } | ||
72 | + | ||
73 | + render() { | ||
74 | + let { children } = this.props; | ||
75 | + return ( | ||
76 | + <Modal | ||
77 | + visible={this.props.isShow} | ||
78 | + animationType={'none'} | ||
79 | + transparent={true} | ||
80 | + onRequestClose={() => {}}> | ||
81 | + <View style={styles.modalContainer}> | ||
82 | + <View style={styles.modalView}> | ||
83 | + {this.props.title ? <View style={styles.confirmTitleContainer}> | ||
84 | + <Text style={[styles.confirmTitle,this.props.titleStyle]} numberOfLines={1}>{this.props.title}</Text> | ||
85 | + </View>: null} | ||
86 | + | ||
87 | + {this.props.content ? <View style={styles.confirmContentContainer}> | ||
88 | + <Text style={[styles.confirmContent,this.props.contentStyle]}numberOfLines={3}>{this.props.content}</Text> | ||
89 | + </View>: null} | ||
90 | + | ||
91 | + <View style={{width: '100%', height: 0.5, backgroundColor: '#e0e0e0'}}/> | ||
92 | + <View style={styles.confirmBtnContainer}> | ||
93 | + {this._renderChildren(children)} | ||
94 | + </View> | ||
95 | + </View> | ||
96 | + </View> | ||
97 | + </Modal> | ||
98 | + ); | ||
99 | + } | ||
100 | +}; | ||
101 | + | ||
102 | +export { YHAlert, YHAlertItem }; | ||
103 | + | ||
104 | +let {width, height} = Dimensions.get('window'); | ||
105 | + | ||
106 | +let styles = StyleSheet.create({ | ||
107 | + modalContainer: { | ||
108 | + flex: 1, | ||
109 | + width: width, | ||
110 | + height: height, | ||
111 | + alignItems: 'center', | ||
112 | + justifyContent: 'center', | ||
113 | + backgroundColor: 'rgba(0, 0, 0, 0.4)', | ||
114 | + }, | ||
115 | + modalView: { | ||
116 | + width: 270, | ||
117 | + alignItems: 'center', | ||
118 | + backgroundColor: '#ffffff', | ||
119 | + borderRadius : 5 | ||
120 | + }, | ||
121 | + confirmBtnContainer: { | ||
122 | + width: '100%', | ||
123 | + height: 50, | ||
124 | + flexDirection: 'row', | ||
125 | + justifyContent: 'space-between', | ||
126 | + }, | ||
127 | + confirmTitleContainer: { | ||
128 | + alignItems: 'center' | ||
129 | + }, | ||
130 | + confirmTitle: { | ||
131 | + paddingTop: 20, | ||
132 | + paddingLeft: 30, | ||
133 | + paddingRight: 30, | ||
134 | + paddingBottom: 10, | ||
135 | + color: '#000000', | ||
136 | + fontSize: 16, | ||
137 | + lineHeight: 24, | ||
138 | + textAlign: 'center', | ||
139 | + letterSpacing: -0.09, | ||
140 | + fontFamily: 'PingFang-SC-Regular', | ||
141 | + fontWeight: '600', | ||
142 | + }, | ||
143 | + confirmContentContainer: { | ||
144 | + alignItems: 'center' | ||
145 | + }, | ||
146 | + confirmContent: { | ||
147 | + paddingLeft: 30, | ||
148 | + paddingRight: 30, | ||
149 | + paddingBottom: 20, | ||
150 | + color: '#999999', | ||
151 | + fontSize: 14, | ||
152 | + lineHeight: 24, | ||
153 | + textAlign: 'center', | ||
154 | + letterSpacing: -0.09, | ||
155 | + fontFamily: 'PingFang-SC-Regular', | ||
156 | + }, | ||
157 | + click: { | ||
158 | + flex: 1, | ||
159 | + alignItems: 'center', | ||
160 | + justifyContent: 'center' | ||
161 | + }, | ||
162 | + cancel: { | ||
163 | + fontSize: 17, | ||
164 | + color: '#000000', | ||
165 | + letterSpacing: -0.41, | ||
166 | + fontFamily: 'PingFang-SC-Regular', | ||
167 | + fontWeight: 'bold', | ||
168 | + }, | ||
169 | + sure: { | ||
170 | + fontSize: 17, | ||
171 | + color: '#999999', | ||
172 | + letterSpacing: -0.41, | ||
173 | + }, | ||
174 | + blackButton: { | ||
175 | + fontSize: 17, | ||
176 | + color: 'black', | ||
177 | + letterSpacing: -0.41, | ||
178 | + }, | ||
179 | + LightGrayButton: { | ||
180 | + fontSize: 17, | ||
181 | + color: '#999999', | ||
182 | + letterSpacing: -0.41, | ||
183 | + fontFamily: 'PingFang-SC-Regular', | ||
184 | + }, | ||
185 | + redButton: { | ||
186 | + fontSize: 17, | ||
187 | + color: 'red', | ||
188 | + letterSpacing: -0.41, | ||
189 | + fontFamily: 'PingFang-SC-Regular', | ||
190 | + }, | ||
191 | +}); |
@@ -29,14 +29,14 @@ export default class productCell extends Component { | @@ -29,14 +29,14 @@ export default class productCell extends Component { | ||
29 | } | 29 | } |
30 | 30 | ||
31 | return ( | 31 | return ( |
32 | - <View> | ||
33 | - <ImageBackground source={require('../../images/timeBgBig.png')} style={styles.timeBg}> | ||
34 | - <View style={styles.timeContainer}> | ||
35 | - <Image source={require('../../images/timeIcon.png')} style={styles.timeIcon}></Image> | ||
36 | - {data.get('cutStatus')==1? <TimerLabel leftTime = {leftTime} style={styles.timeCount} onStop = {this.props.onStop}/>:null } | ||
37 | - <Text style={styles.timeDes}>{des}</Text> | ||
38 | - </View> | 32 | + <View style= {styles.timeFatherContainer}> |
33 | + <ImageBackground source={require('../../images/timeBg.png')} style={styles.timeBg}> | ||
39 | </ImageBackground> | 34 | </ImageBackground> |
35 | + <View style={styles.timeContainer}> | ||
36 | + {data.get('cutStatus')==1? <TimerLabel leftTime = {leftTime} style={styles.timeCount} onStop = {this.props.onStop}/>:null } | ||
37 | + <Text style={styles.timeDes}>{des}</Text> | ||
38 | + </View> | ||
39 | + | ||
40 | </View> | 40 | </View> |
41 | ); | 41 | ); |
42 | 42 | ||
@@ -87,23 +87,15 @@ export default class productCell extends Component { | @@ -87,23 +87,15 @@ export default class productCell extends Component { | ||
87 | return ( | 87 | return ( |
88 | <View > | 88 | <View > |
89 | {data.get('cutStatus') ? | 89 | {data.get('cutStatus') ? |
90 | - <TouchableOpacity style={styles.continueCutContainer} onPress={() => { | ||
91 | - this.props.continueHaggle && this.props.continueHaggle(data); | ||
92 | - }}> | ||
93 | - <View> | 90 | + <View style={styles.continueCutContainer}> |
94 | <Text style={styles.continueCut}>继续砍价</Text> | 91 | <Text style={styles.continueCut}>继续砍价</Text> |
95 | </View> | 92 | </View> |
96 | - </TouchableOpacity> | ||
97 | 93 | ||
98 | : | 94 | : |
99 | - <TouchableOpacity style={styles.cutActionContainer} onPress={() => { | ||
100 | - this.props.firstHaggle && this.props.firstHaggle(data); | ||
101 | - }}> | ||
102 | - <View> | 95 | + <View style={styles.cutActionContainer}> |
103 | <Image source={require('../../images/cutPriceBg.png')} style={styles.cutPriceBg}></Image> | 96 | <Image source={require('../../images/cutPriceBg.png')} style={styles.cutPriceBg}></Image> |
104 | <Text style={styles.cutPrice}>-¥{data && data.get('lowPrice')}</Text> | 97 | <Text style={styles.cutPrice}>-¥{data && data.get('lowPrice')}</Text> |
105 | </View> | 98 | </View> |
106 | - </TouchableOpacity> | ||
107 | } | 99 | } |
108 | </View> | 100 | </View> |
109 | ) | 101 | ) |
@@ -112,13 +104,12 @@ export default class productCell extends Component { | @@ -112,13 +104,12 @@ export default class productCell extends Component { | ||
112 | render() { | 104 | render() { |
113 | let data = this.props.data; | 105 | let data = this.props.data; |
114 | let prdImage = YH_Image.getSlicedUrl(data && data.get('defaultImages', ''), 98, 130, 2); | 106 | let prdImage = YH_Image.getSlicedUrl(data && data.get('defaultImages', ''), 98, 130, 2); |
115 | - let yh_exposureData = this.props.yh_exposureData ? this.props.yh_exposureData : null; | ||
116 | return ( | 107 | return ( |
117 | <View> | 108 | <View> |
118 | <View style={styles.fatherContainer}> | 109 | <View style={styles.fatherContainer}> |
119 | {data.get('cutStatus')?this._topTimerView(data):null} | 110 | {data.get('cutStatus')?this._topTimerView(data):null} |
120 | <TouchableOpacity | 111 | <TouchableOpacity |
121 | - yh_exposureData={yh_exposureData} activeOpacity={1} style={[styles.container]} | 112 | + activeOpacity={1} style={[styles.container]} |
122 | onPress={() => { | 113 | onPress={() => { |
123 | this.props.onPressProduct && this.props.onPressProduct(data); | 114 | this.props.onPressProduct && this.props.onPressProduct(data); |
124 | }}> | 115 | }}> |
@@ -170,6 +161,10 @@ let styles = StyleSheet.create({ | @@ -170,6 +161,10 @@ let styles = StyleSheet.create({ | ||
170 | width: nameWidth, | 161 | width: nameWidth, |
171 | letterSpacing: -0.34, | 162 | letterSpacing: -0.34, |
172 | }, | 163 | }, |
164 | + timeFatherContainer: { | ||
165 | + flexDirection: 'row', | ||
166 | + }, | ||
167 | + | ||
173 | priceFatherContainer: { | 168 | priceFatherContainer: { |
174 | flex:1, | 169 | flex:1, |
175 | marginBottom: 0, | 170 | marginBottom: 0, |
@@ -241,17 +236,18 @@ let styles = StyleSheet.create({ | @@ -241,17 +236,18 @@ let styles = StyleSheet.create({ | ||
241 | }, | 236 | }, |
242 | timeBg:{ | 237 | timeBg:{ |
243 | justifyContent: 'center', | 238 | justifyContent: 'center', |
244 | - width: 120, | 239 | + width: 21, |
245 | height: 31, | 240 | height: 31, |
246 | marginLeft:-3, | 241 | marginLeft:-3, |
247 | - | ||
248 | }, | 242 | }, |
249 | 243 | ||
250 | timeContainer :{ | 244 | timeContainer :{ |
251 | alignItems: 'center', | 245 | alignItems: 'center', |
252 | flexDirection: 'row', | 246 | flexDirection: 'row', |
253 | - marginTop: -5, | ||
254 | - marginLeft:2, | 247 | + marginLeft:-2, |
248 | + backgroundColor: '#222222', | ||
249 | + height: 24, | ||
250 | + | ||
255 | }, | 251 | }, |
256 | timeIcon:{ | 252 | timeIcon:{ |
257 | width: 9, | 253 | width: 9, |
@@ -267,6 +263,7 @@ let styles = StyleSheet.create({ | @@ -267,6 +263,7 @@ let styles = StyleSheet.create({ | ||
267 | fontSize: 12, | 263 | fontSize: 12, |
268 | color: 'white', | 264 | color: 'white', |
269 | marginLeft:3, | 265 | marginLeft:3, |
266 | + marginRight:10, | ||
270 | fontFamily: 'PingFang-SC-Medium', | 267 | fontFamily: 'PingFang-SC-Medium', |
271 | }, | 268 | }, |
272 | invalidDes: { | 269 | invalidDes: { |
js/haggle/components/floor/Focus.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import ImageSlider from '../cell/ImageSlider'; | ||
6 | +import Immutable from 'immutable'; | ||
7 | + | ||
8 | +const { | ||
9 | + StyleSheet, | ||
10 | + Dimensions, | ||
11 | + View, | ||
12 | +} = ReactNative; | ||
13 | + | ||
14 | + | ||
15 | +export default class Focus extends React.Component { | ||
16 | + | ||
17 | + constructor(props) { | ||
18 | + super(props); | ||
19 | + } | ||
20 | + | ||
21 | + shouldComponentUpdate(nextProps) { | ||
22 | + if (Immutable.is(nextProps.data, this.props.data)) { | ||
23 | + return false; | ||
24 | + } else { | ||
25 | + return true; | ||
26 | + } | ||
27 | + } | ||
28 | + | ||
29 | + render() { | ||
30 | + let {data} = this.props; | ||
31 | + let sliderHeight = Math.ceil(this.props.height * DEVICE_WIDTH_RATIO); | ||
32 | + | ||
33 | + return ( | ||
34 | + <View style={{height:sliderHeight, width:width}}> | ||
35 | + <ImageSlider | ||
36 | + resource={data} | ||
37 | + sliderWidth={width} | ||
38 | + sliderHeight={sliderHeight} | ||
39 | + resourceJumpWithUrl={this.props.resourceJumpWithUrl} | ||
40 | + /> | ||
41 | + </View> | ||
42 | + | ||
43 | + ); | ||
44 | + } | ||
45 | +} | ||
46 | + | ||
47 | +let {width, height} = Dimensions.get('window'); | ||
48 | + | ||
49 | +const DEVICE_WIDTH_RATIO = width / 375; | ||
50 | + | ||
51 | +let styles = StyleSheet.create({ | ||
52 | + banner: {}, | ||
53 | +}); |
@@ -9,6 +9,15 @@ export default keyMirror({ | @@ -9,6 +9,15 @@ export default keyMirror({ | ||
9 | PRODUCT_LIST_REQUEST: null, | 9 | PRODUCT_LIST_REQUEST: null, |
10 | PRODUCT_LIST_SUCCESS: null, | 10 | PRODUCT_LIST_SUCCESS: null, |
11 | PRODUCT_LIST_FAILURE: null, | 11 | PRODUCT_LIST_FAILURE: null, |
12 | + | ||
13 | + MYHAGGLE_PRODUCT_LIST_REQUEST: null, | ||
14 | + MYHAGGLE_PRODUCT_LIST_SUCCESS: null, | ||
15 | + MYHAGGLE_PRODUCT_LIST_FAILURE: null, | ||
16 | + | ||
17 | + RESOURCE_INFO_REQUEST: null, | ||
18 | + RESOURCE_INFO_SUCCESS: null, | ||
19 | + RESOURCE_INFO_FAILURE: null, | ||
20 | + | ||
12 | SET_SELECTED_CATEGORY: null, | 21 | SET_SELECTED_CATEGORY: null, |
13 | REFRESH_PRODUCT_LIST:null, | 22 | REFRESH_PRODUCT_LIST:null, |
14 | HAGGLE_STATUS_SUCCESS:null, | 23 | HAGGLE_STATUS_SUCCESS:null, |
@@ -10,6 +10,7 @@ import * as allianceActions from '../reducers/haggleListReducer/haggleActions'; | @@ -10,6 +10,7 @@ import * as allianceActions from '../reducers/haggleListReducer/haggleActions'; | ||
10 | import HaggleList from '../components/HaggleList' | 10 | import HaggleList from '../components/HaggleList' |
11 | import LoadingIndicator from '../../common/components/LoadingIndicator'; | 11 | import LoadingIndicator from '../../common/components/LoadingIndicator'; |
12 | import { TipsAlertItem, TipsAlert } from '../../common/components/YH_TipsAlert'; | 12 | import { TipsAlertItem, TipsAlert } from '../../common/components/YH_TipsAlert'; |
13 | +import { YHAlert, YHAlertItem } from '../components/cell/YH_Alert.js'; | ||
13 | 14 | ||
14 | const actions = [ | 15 | const actions = [ |
15 | allianceActions, | 16 | allianceActions, |
@@ -37,23 +38,43 @@ function mapDispatchToProps(dispatch) { | @@ -37,23 +38,43 @@ function mapDispatchToProps(dispatch) { | ||
37 | class HaggleListContainer extends Component { | 38 | class HaggleListContainer extends Component { |
38 | constructor(props) { | 39 | constructor(props) { |
39 | super(props); | 40 | super(props); |
40 | - this.state = {showAlert:false}; | 41 | + this.state = {showAlert:false, productItem:null}; |
41 | this._onEndReached = this._onEndReached.bind(this); | 42 | this._onEndReached = this._onEndReached.bind(this); |
42 | this._onPressProduct = this._onPressProduct.bind(this); | 43 | this._onPressProduct = this._onPressProduct.bind(this); |
43 | this._jumpHaggleDetail = this._jumpHaggleDetail.bind(this); | 44 | this._jumpHaggleDetail = this._jumpHaggleDetail.bind(this); |
44 | this._onPressCategory = this._onPressCategory.bind(this); | 45 | this._onPressCategory = this._onPressCategory.bind(this); |
45 | this._hiddenTipsAlertDialog = this._hiddenTipsAlertDialog.bind(this); | 46 | this._hiddenTipsAlertDialog = this._hiddenTipsAlertDialog.bind(this); |
46 | this._timerStop = this._timerStop.bind(this); | 47 | this._timerStop = this._timerStop.bind(this); |
48 | + this._resourceJumpWithUrl = this._resourceJumpWithUrl.bind(this); | ||
47 | } | 49 | } |
48 | 50 | ||
49 | componentDidMount() { | 51 | componentDidMount() { |
50 | this.props.actions.getProductList(); | 52 | this.props.actions.getProductList(); |
53 | + this.props.actions.getResourceInfo(function (json) { | ||
54 | + json && json.forEach(item => { | ||
55 | + }) | ||
56 | + }); | ||
57 | + | ||
51 | } | 58 | } |
52 | 59 | ||
53 | componentWillUnmount() { | 60 | componentWillUnmount() { |
54 | 61 | ||
55 | } | 62 | } |
56 | 63 | ||
64 | + _resourceJumpWithUrl(url, type, params) { | ||
65 | + if (!url) { | ||
66 | + return; | ||
67 | + } | ||
68 | + if (type === 'icon' && params) { | ||
69 | + ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CPS_MAIN_ICON_C', params); | ||
70 | + } else if (type === 'banner' && params) { | ||
71 | + ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CPS_MAIN_BANNER_C', params); | ||
72 | + } else if (type && params) { | ||
73 | + ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CPS_MAIN_ACTIVITY_C', params); | ||
74 | + } | ||
75 | + ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); | ||
76 | + } | ||
77 | + | ||
57 | _onEndReached(categoryType) { | 78 | _onEndReached(categoryType) { |
58 | if (categoryType == 0) { | 79 | if (categoryType == 0) { |
59 | this.props.actions.getProductList(); | 80 | this.props.actions.getProductList(); |
@@ -62,7 +83,8 @@ class HaggleListContainer extends Component { | @@ -62,7 +83,8 @@ class HaggleListContainer extends Component { | ||
62 | } | 83 | } |
63 | } | 84 | } |
64 | 85 | ||
65 | - _timerStop(categoryType) { | 86 | + _timerStop() { |
87 | + this.props.actions.refreshProductList(1); | ||
66 | } | 88 | } |
67 | 89 | ||
68 | _showTipsAlertDialog(){ | 90 | _showTipsAlertDialog(){ |
@@ -70,14 +92,14 @@ class HaggleListContainer extends Component { | @@ -70,14 +92,14 @@ class HaggleListContainer extends Component { | ||
70 | } | 92 | } |
71 | 93 | ||
72 | _hiddenTipsAlertDialog(){ | 94 | _hiddenTipsAlertDialog(){ |
73 | - this.setState({showAlert:false}); | 95 | + this.setState({showAlert:false, productItem:null}); |
74 | } | 96 | } |
75 | 97 | ||
76 | _onPressCategory(index) { | 98 | _onPressCategory(index) { |
77 | this.props.actions.setSelectedCategory(index); | 99 | this.props.actions.setSelectedCategory(index); |
78 | } | 100 | } |
79 | 101 | ||
80 | - _jumpHaggleDetail(product, status, cutRecordId) { | 102 | + _jumpHaggleDetail(product, status) { |
81 | let productSkn = product && product.get('productSkn', 0); | 103 | let productSkn = product && product.get('productSkn', 0); |
82 | let activityId = product && product.get('activityId', 0); | 104 | let activityId = product && product.get('activityId', 0); |
83 | if (!productSkn) { | 105 | if (!productSkn) { |
@@ -95,9 +117,11 @@ class HaggleListContainer extends Component { | @@ -95,9 +117,11 @@ class HaggleListContainer extends Component { | ||
95 | if (product.get('cutStatus')) { | 117 | if (product.get('cutStatus')) { |
96 | this._jumpHaggleDetail(product, null); | 118 | this._jumpHaggleDetail(product, null); |
97 | }else { | 119 | }else { |
120 | + | ||
98 | this.props.actions.getHaggleStatus(product.get('productSkn'), product.get('activityId'), function (json){ | 121 | this.props.actions.getHaggleStatus(product.get('productSkn'), product.get('activityId'), function (json){ |
122 | + | ||
99 | if (json) { | 123 | if (json) { |
100 | - that.setState({showAlert:true}); | 124 | + that.setState({showAlert:true, productItem:product}); |
101 | }else { | 125 | }else { |
102 | that._jumpHaggleDetail(product, json); | 126 | that._jumpHaggleDetail(product, json); |
103 | } | 127 | } |
@@ -106,26 +130,40 @@ class HaggleListContainer extends Component { | @@ -106,26 +130,40 @@ class HaggleListContainer extends Component { | ||
106 | 130 | ||
107 | } | 131 | } |
108 | render() { | 132 | render() { |
109 | - let {productList, isShowAlert} = this.props.haggle; | ||
110 | - let isFetching = productList.isFetching; | 133 | + let {productList, myHaggleProductList, resourceInfo, isShowAlert, categoryType} = this.props.haggle; |
134 | + let isFetching = productList.isFetching || myHaggleProductList.isFetching; | ||
135 | + | ||
111 | return ( | 136 | return ( |
112 | <View style={styles.container}> | 137 | <View style={styles.container}> |
113 | - <TipsAlert | ||
114 | - tips='该商品正在砍价中,去邀请好友帮忙砍价吧!' | ||
115 | - isShow={this.state.showAlert} | ||
116 | - > | ||
117 | - <TipsAlertItem showStatus='sure' >查看详情</TipsAlertItem> | ||
118 | - <TipsAlertItem showStatus='cancel' handleAction={this._hiddenTipsAlertDialog}>取消</TipsAlertItem> | ||
119 | - </TipsAlert> | 138 | + |
139 | + <YHAlert | ||
140 | + ref='YHAlert' | ||
141 | + isShow = {this.state.showAlert} | ||
142 | + title = '当前有未完成的砍价!' | ||
143 | + content={'该商品正在砍价中,去邀请好友帮忙砍价吧!'} | ||
144 | + > | ||
145 | + <YHAlertItem key={'minCancel'} param={this.state.productItem} showStatus='LightGrayButton' | ||
146 | + handleAction={(param) => { | ||
147 | + {this._hiddenTipsAlertDialog()}; | ||
148 | + }}>取消</YHAlertItem> | ||
149 | + <YHAlertItem key={'minSure'} param={this.state.productItem} showStatus='redButton' | ||
150 | + handleAction={(param) => { | ||
151 | + {this._hiddenTipsAlertDialog()}; | ||
152 | + {this._jumpHaggleDetail(param, null)}; | ||
153 | + }}>查看详情</YHAlertItem> | ||
154 | + </YHAlert> | ||
120 | 155 | ||
121 | <HaggleList | 156 | <HaggleList |
122 | - data={productList} | 157 | + data= {categoryType==0 ? productList : myHaggleProductList} |
158 | + resourceInfo = {resourceInfo} | ||
123 | onEndReached={this._onEndReached} | 159 | onEndReached={this._onEndReached} |
160 | + categoryType={categoryType} | ||
124 | onPressProduct={this._onPressProduct} | 161 | onPressProduct={this._onPressProduct} |
125 | firstHaggle={this._firstHaggle} | 162 | firstHaggle={this._firstHaggle} |
126 | continueHaggle={this._continueHaggle} | 163 | continueHaggle={this._continueHaggle} |
127 | onPressCategory={this._onPressCategory} | 164 | onPressCategory={this._onPressCategory} |
128 | - onStop={this._timerStop}/> | 165 | + onStop={this._timerStop} |
166 | + resourceJumpWithUrl={this._resourceJumpWithUrl}/> | ||
129 | <LoadingIndicator isVisible={isFetching}/> | 167 | <LoadingIndicator isVisible={isFetching}/> |
130 | </View> | 168 | </View> |
131 | ); | 169 | ); |
js/haggle/images/timeBg@2x.png
0 → 100644
919 Bytes
js/haggle/images/timeBg@3x.png
0 → 100644
1.31 KB
@@ -13,17 +13,33 @@ const { | @@ -13,17 +13,33 @@ const { | ||
13 | SHOW_HASCUT_ALERT, | 13 | SHOW_HASCUT_ALERT, |
14 | HAGGLE_STATUS_SUCCESS, | 14 | HAGGLE_STATUS_SUCCESS, |
15 | REFRESH_PRODUCT_LIST, | 15 | REFRESH_PRODUCT_LIST, |
16 | + MYHAGGLE_PRODUCT_LIST_REQUEST, | ||
17 | + MYHAGGLE_PRODUCT_LIST_SUCCESS, | ||
18 | + MYHAGGLE_PRODUCT_LIST_FAILURE, | ||
19 | + RESOURCE_INFO_REQUEST, | ||
20 | + RESOURCE_INFO_SUCCESS, | ||
21 | + RESOURCE_INFO_FAILURE, | ||
16 | } = require('../../constants/actionTypes').default; | 22 | } = require('../../constants/actionTypes').default; |
17 | 23 | ||
24 | +export function setSelectedCategoryType(index) { | ||
25 | + return { | ||
26 | + type: SET_SELECTED_CATEGORY, | ||
27 | + payload: index | ||
28 | + }; | ||
29 | +} | ||
30 | + | ||
18 | export function setSelectedCategory(index) { | 31 | export function setSelectedCategory(index) { |
19 | return (dispatch, getState) => { | 32 | return (dispatch, getState) => { |
20 | - dispatch({ | ||
21 | - type: SET_SELECTED_CATEGORY, | ||
22 | - payload: {index} | ||
23 | - }); | ||
24 | - if (index == 0) { | 33 | + dispatch(setSelectedCategoryType(index)); |
34 | + let {haggle} = getState(); | ||
35 | + let productList = haggle.productList; | ||
36 | + let myproductList = haggle.myHaggleProductList; | ||
37 | + let list = productList.list ? productList.list.toArray() : []; | ||
38 | + let myList = myproductList.list ? myproductList.list.toArray() : []; | ||
39 | + | ||
40 | + if (index == 0 && list.length == 0) { | ||
25 | dispatch(getProductList()); | 41 | dispatch(getProductList()); |
26 | - }else if (index == 1){ | 42 | + }else if (index == 1 && myList.length == 0){ |
27 | dispatch(getMyHaggleProductList()); | 43 | dispatch(getMyHaggleProductList()); |
28 | } | 44 | } |
29 | }; | 45 | }; |
@@ -76,6 +92,45 @@ export function productListFailure(error) { | @@ -76,6 +92,45 @@ export function productListFailure(error) { | ||
76 | }; | 92 | }; |
77 | } | 93 | } |
78 | 94 | ||
95 | +export function myHaggleProductListRequest() { | ||
96 | + return { | ||
97 | + type: MYHAGGLE_PRODUCT_LIST_REQUEST, | ||
98 | + }; | ||
99 | +} | ||
100 | + | ||
101 | +export function myHaggleProductListSuccess(json) { | ||
102 | + return { | ||
103 | + type: MYHAGGLE_PRODUCT_LIST_SUCCESS, | ||
104 | + payload: json | ||
105 | + }; | ||
106 | +} | ||
107 | + | ||
108 | +export function myHaggleProductListFailure(error) { | ||
109 | + return { | ||
110 | + type: MYHAGGLE_PRODUCT_LIST_FAILURE, | ||
111 | + payload: error | ||
112 | + }; | ||
113 | +} | ||
114 | +export function getResourceRequest() { | ||
115 | + return { | ||
116 | + type: RESOURCE_INFO_REQUEST, | ||
117 | + }; | ||
118 | +} | ||
119 | + | ||
120 | +export function getResourceSuccess(json) { | ||
121 | + return { | ||
122 | + type: RESOURCE_INFO_SUCCESS, | ||
123 | + payload: json | ||
124 | + }; | ||
125 | +} | ||
126 | + | ||
127 | +export function getResourceFailure(error) { | ||
128 | + return { | ||
129 | + type: RESOURCE_INFO_FAILURE, | ||
130 | + payload: error | ||
131 | + }; | ||
132 | +} | ||
133 | + | ||
79 | export function getProductList() { | 134 | export function getProductList() { |
80 | return (dispatch, getState) => { | 135 | return (dispatch, getState) => { |
81 | let {app, haggle} = getState(); | 136 | let {app, haggle} = getState(); |
@@ -114,7 +169,7 @@ export function getProductList() { | @@ -114,7 +169,7 @@ export function getProductList() { | ||
114 | export function getMyHaggleProductList() { | 169 | export function getMyHaggleProductList() { |
115 | return (dispatch, getState) => { | 170 | return (dispatch, getState) => { |
116 | let {app, haggle} = getState(); | 171 | let {app, haggle} = getState(); |
117 | - let list = haggle.productList; | 172 | + let list = haggle.myHaggleProductList; |
118 | 173 | ||
119 | /** | 174 | /** |
120 | * page: 0, //当前页面 | 175 | * page: 0, //当前页面 |
@@ -123,6 +178,7 @@ export function getMyHaggleProductList() { | @@ -123,6 +178,7 @@ export function getMyHaggleProductList() { | ||
123 | * page_total: 0, //总共多少页 | 178 | * page_total: 0, //总共多少页 |
124 | * endReached: false, //到达底部 | 179 | * endReached: false, //到达底部 |
125 | */ | 180 | */ |
181 | + | ||
126 | if (list.isFetching || list.endReached || list.error || (!list.endReached && list.page_total === 1)) { | 182 | if (list.isFetching || list.endReached || list.error || (!list.endReached && list.page_total === 1)) { |
127 | return; | 183 | return; |
128 | } | 184 | } |
@@ -130,7 +186,7 @@ export function getMyHaggleProductList() { | @@ -130,7 +186,7 @@ export function getMyHaggleProductList() { | ||
130 | let page = list.page + 1; | 186 | let page = list.page + 1; |
131 | let pageSize = list.page_size; | 187 | let pageSize = list.page_size; |
132 | let fetchMyHaggleProductList = (uid) => { | 188 | let fetchMyHaggleProductList = (uid) => { |
133 | - dispatch(productListRequest()); | 189 | + dispatch(myHaggleProductListRequest()); |
134 | return new haggleService(app.host).fetchMyHaggleProductList(uid, page, pageSize) | 190 | return new haggleService(app.host).fetchMyHaggleProductList(uid, page, pageSize) |
135 | .then(json => { | 191 | .then(json => { |
136 | let payload = json; | 192 | let payload = json; |
@@ -140,10 +196,10 @@ export function getMyHaggleProductList() { | @@ -140,10 +196,10 @@ export function getMyHaggleProductList() { | ||
140 | let newList = [...oldList, ...payload.list]; | 196 | let newList = [...oldList, ...payload.list]; |
141 | payload.list = newList; | 197 | payload.list = newList; |
142 | } | 198 | } |
143 | - dispatch(productListSuccess(payload)); | 199 | + dispatch(myHaggleProductListSuccess(payload)); |
144 | }) | 200 | }) |
145 | .catch(error => { | 201 | .catch(error => { |
146 | - dispatch(productListFailure(error)); | 202 | + dispatch(myHaggleProductListFailure(error)); |
147 | }); | 203 | }); |
148 | }; | 204 | }; |
149 | 205 | ||
@@ -183,3 +239,18 @@ export function getHaggleStatus(productSkn, activityId, callBack) { | @@ -183,3 +239,18 @@ export function getHaggleStatus(productSkn, activityId, callBack) { | ||
183 | }); | 239 | }); |
184 | }; | 240 | }; |
185 | } | 241 | } |
242 | + | ||
243 | +export function getResourceInfo(callback) { | ||
244 | + return (dispatch, getState) => { | ||
245 | + let {app} = getState(); | ||
246 | + dispatch(getResourceRequest()); | ||
247 | + return new haggleService(app.host).fetchResourceInfo('b688fc3b15100d23f247271b7dbe1193') | ||
248 | + .then(json => { | ||
249 | + dispatch(getResourceSuccess(json)); | ||
250 | + callback && typeof callback === 'function' && callback(json) | ||
251 | + }) | ||
252 | + .catch(error => { | ||
253 | + dispatch(getResourceFailure(error)); | ||
254 | + }); | ||
255 | + }; | ||
256 | +} |
@@ -15,7 +15,26 @@ let InitialState = Record({ | @@ -15,7 +15,26 @@ let InitialState = Record({ | ||
15 | endReached: false, //到达底部 | 15 | endReached: false, //到达底部 |
16 | list: List(), | 16 | list: List(), |
17 | })), | 17 | })), |
18 | + | ||
19 | + myHaggleProductList: new (Record({ | ||
20 | + isFetching: false, | ||
21 | + error: null, | ||
22 | + page: 0, //当前页面 | ||
23 | + page_size: 20, //每页显示的数量 | ||
24 | + total: 0, //总共多少条 | ||
25 | + page_total: 0, //总共多少页 | ||
26 | + endReached: false, //到达底部 | ||
27 | + list: List(), | ||
28 | + })), | ||
29 | + | ||
30 | + resourceInfo: new (Record({ | ||
31 | + isFetching: false, | ||
32 | + error: null, | ||
33 | + resourceList: List(), | ||
34 | + })), | ||
35 | + | ||
18 | isShowAlert: false, | 36 | isShowAlert: false, |
37 | + categoryType: 0, | ||
19 | }); | 38 | }); |
20 | 39 | ||
21 | export default InitialState; | 40 | export default InitialState; |
@@ -7,6 +7,12 @@ const { | @@ -7,6 +7,12 @@ const { | ||
7 | PRODUCT_LIST_REQUEST, | 7 | PRODUCT_LIST_REQUEST, |
8 | PRODUCT_LIST_SUCCESS, | 8 | PRODUCT_LIST_SUCCESS, |
9 | PRODUCT_LIST_FAILURE, | 9 | PRODUCT_LIST_FAILURE, |
10 | + MYHAGGLE_PRODUCT_LIST_REQUEST, | ||
11 | + MYHAGGLE_PRODUCT_LIST_SUCCESS, | ||
12 | + MYHAGGLE_PRODUCT_LIST_FAILURE, | ||
13 | + RESOURCE_INFO_REQUEST, | ||
14 | + RESOURCE_INFO_SUCCESS, | ||
15 | + RESOURCE_INFO_FAILURE, | ||
10 | SET_SELECTED_CATEGORY, | 16 | SET_SELECTED_CATEGORY, |
11 | SHOW_HASCUT_ALERT, | 17 | SHOW_HASCUT_ALERT, |
12 | REFRESH_PRODUCT_LIST, | 18 | REFRESH_PRODUCT_LIST, |
@@ -45,24 +51,71 @@ export default function couponReducer(state = initialState, action) { | @@ -45,24 +51,71 @@ export default function couponReducer(state = initialState, action) { | ||
45 | .setIn(['productList', 'error'], action.payload); | 51 | .setIn(['productList', 'error'], action.payload); |
46 | } | 52 | } |
47 | 53 | ||
54 | + case MYHAGGLE_PRODUCT_LIST_REQUEST: { | ||
55 | + return state.setIn(['myHaggleProductList', 'isFetching'], true) | ||
56 | + .setIn(['myHaggleProductList', 'error'], null); | ||
57 | + } | ||
58 | + | ||
59 | + case MYHAGGLE_PRODUCT_LIST_SUCCESS: { | ||
60 | + let { | ||
61 | + page, | ||
62 | + page_total, | ||
63 | + endReached, | ||
64 | + list, | ||
65 | + } = action.payload; | ||
66 | + return state.setIn(['myHaggleProductList', 'isFetching'], false) | ||
67 | + .setIn(['myHaggleProductList', 'page'], page) | ||
68 | + .setIn(['myHaggleProductList', 'page_total'], page_total) | ||
69 | + .setIn(['myHaggleProductList', 'endReached'], endReached) | ||
70 | + .setIn(['myHaggleProductList', 'list'], Immutable.fromJS(list)) | ||
71 | + .setIn(['myHaggleProductList', 'error'], null); | ||
72 | + } | ||
73 | + | ||
74 | + case MYHAGGLE_PRODUCT_LIST_FAILURE: { | ||
75 | + return state.setIn(['myHaggleProductList', 'isFetching'], false) | ||
76 | + .setIn(['myHaggleProductList', 'error'], action.payload); | ||
77 | + } | ||
78 | + | ||
48 | case SET_SELECTED_CATEGORY: { | 79 | case SET_SELECTED_CATEGORY: { |
49 | - let {index} = action.payload; | ||
50 | - return state.setIn(['productList', 'page'], 0) | ||
51 | - .setIn(['productList', 'page_total'], 0) | ||
52 | - .setIn(['productList', 'endReached'], false) | ||
53 | - .setIn(['productList', 'error'], null); | 80 | + return state.set('categoryType', action.payload); |
81 | + | ||
54 | } | 82 | } |
83 | + | ||
55 | case REFRESH_PRODUCT_LIST: { | 84 | case REFRESH_PRODUCT_LIST: { |
56 | - return state.setIn(['productList', 'page'], 0) | ||
57 | - .setIn(['productList', 'page_total'], 0) | ||
58 | - .setIn(['productList', 'endReached'], false) | ||
59 | - .setIn(['productList', 'error'], null) | ||
60 | - .setIn(['productList', 'isFetching'], false); | ||
61 | - } | 85 | + if (action.payload == 0) { |
86 | + return state.setIn(['productList', 'page'], 0) | ||
87 | + .setIn(['productList', 'page_total'], 0) | ||
88 | + .setIn(['productList', 'endReached'], false) | ||
89 | + .setIn(['productList', 'error'], null) | ||
90 | + .setIn(['productList', 'isFetching'], false); | ||
91 | + }else { | ||
92 | + return state.setIn(['myHaggleProductList', 'page'], 0) | ||
93 | + .setIn(['myHaggleProductList', 'page_total'], 0) | ||
94 | + .setIn(['myHaggleProductList', 'endReached'], false) | ||
95 | + .setIn(['myHaggleProductList', 'error'], null) | ||
96 | + .setIn(['myHaggleProductList', 'isFetching'], false); | ||
97 | + } | ||
98 | + } | ||
62 | 99 | ||
63 | break; | 100 | break; |
64 | case SHOW_HASCUT_ALERT: { | 101 | case SHOW_HASCUT_ALERT: { |
65 | - return state.setIn(['isShowAlert'], true); | 102 | + return state.set('isShowAlert', true); |
103 | + } | ||
104 | + | ||
105 | + case RESOURCE_INFO_REQUEST: { | ||
106 | + return state.setIn(['resourceInfo', 'isFetching'], true) | ||
107 | + .setIn(['resourceInfo', 'error'], action.payload); | ||
108 | + } | ||
109 | + | ||
110 | + case RESOURCE_INFO_SUCCESS: { | ||
111 | + return state.setIn(['resourceInfo', 'isFetching'], false) | ||
112 | + .setIn(['resourceInfo', 'resourceList'], Immutable.fromJS(action.payload)) | ||
113 | + .setIn(['resourceInfo', 'error'], null); | ||
114 | + } | ||
115 | + | ||
116 | + case RESOURCE_INFO_FAILURE: { | ||
117 | + return state.setIn(['resourceInfo', 'isFetching'], false) | ||
118 | + .setIn(['resourceInfo', 'error'], null); | ||
66 | } | 119 | } |
67 | 120 | ||
68 | } | 121 | } |
@@ -66,4 +66,20 @@ export default class haggleService { | @@ -66,4 +66,20 @@ export default class haggleService { | ||
66 | }); | 66 | }); |
67 | } | 67 | } |
68 | 68 | ||
69 | + async fetchResourceInfo(content_code) { | ||
70 | + return await this.api.get({ | ||
71 | + url: '/operations/api/v5/resource/get', | ||
72 | + body: { | ||
73 | + content_code, | ||
74 | + } | ||
75 | + }) | ||
76 | + .then((json) => { | ||
77 | + return json; | ||
78 | + }) | ||
79 | + .catch((error) => { | ||
80 | + throw(error); | ||
81 | + }); | ||
82 | + } | ||
83 | + | ||
84 | + | ||
69 | } | 85 | } |
-
Please register or login to post a comment