更新RN会员礼包 --review by 孙凯
Showing
14 changed files
with
482 additions
and
93 deletions
@@ -15,48 +15,103 @@ import { | @@ -15,48 +15,103 @@ import { | ||
15 | import {Immutable, Map} from 'immutable'; | 15 | import {Immutable, Map} from 'immutable'; |
16 | import ReceiveGiftAlert from './ReceiveGiftAlert'; | 16 | import ReceiveGiftAlert from './ReceiveGiftAlert'; |
17 | import ProductListCell from '../../common/components/ListCell/ProductListCell'; | 17 | import ProductListCell from '../../common/components/ListCell/ProductListCell'; |
18 | +import CouponsBagListCell from "./CouponsBagListCell"; | ||
18 | 19 | ||
19 | export default class AssociatorGift extends Component { | 20 | export default class AssociatorGift extends Component { |
20 | constructor(props) { | 21 | constructor(props) { |
21 | super(props); | 22 | super(props); |
22 | 23 | ||
23 | this._renderRow = this._renderRow.bind(this); | 24 | this._renderRow = this._renderRow.bind(this); |
25 | + this._renderHeader = this._renderHeader.bind(this); | ||
24 | 26 | ||
25 | this.dataSource = new ListView.DataSource({ | 27 | this.dataSource = new ListView.DataSource({ |
26 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | 28 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), |
29 | + sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2), | ||
27 | }); | 30 | }); |
28 | 31 | ||
29 | } | 32 | } |
30 | 33 | ||
34 | + _renderHeader() { | ||
35 | + let total = this.props.couponsBagCnt.total; | ||
36 | + let title = total > 0 ? '您有' + total + '个礼包可领取' : '暂时没有获得任何礼包'; | ||
37 | + let desc = total > 0 ? '以下是近期礼包' : ''; | ||
38 | + return ( | ||
39 | + <View style={styles.bagBackground}> | ||
40 | + <Image style={styles.bgImage} source={require('../images/xyzx_lb.png')}/> | ||
41 | + <Text style={styles.bagTitle}>{title}</Text> | ||
42 | + <Text style={styles.bagTips}>{desc}</Text> | ||
43 | + </View> | ||
44 | + ) | ||
45 | + } | ||
46 | + | ||
31 | _renderRow(rowData, sectionID, rowID) { | 47 | _renderRow(rowData, sectionID, rowID) { |
32 | let paddingLeft = rowID % 2 === 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal; | 48 | let paddingLeft = rowID % 2 === 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal; |
33 | let customStyle = rowID === 0 || rowID === 1 ? {paddingLeft} : {paddingLeft}; | 49 | let customStyle = rowID === 0 || rowID === 1 ? {paddingLeft} : {paddingLeft}; |
34 | 50 | ||
35 | - return ( | ||
36 | - <ProductListCell | ||
37 | - style={[styles.listContainer, customStyle]} | ||
38 | - key={'row' + rowID} | ||
39 | - rowID={rowID} | ||
40 | - data={rowData} | ||
41 | - onPressProduct={this.props.onPressProduct} | ||
42 | - needShopCar={true} | ||
43 | - onPressShopCar={this.props.onPressShopCar} | ||
44 | - /> | ||
45 | - ); | 51 | + switch (sectionID) { |
52 | + case 'couponsBag': { | ||
53 | + return ( | ||
54 | + <CouponsBagListCell | ||
55 | + style={[styles.listContainer, customStyle]} | ||
56 | + key={'row' + rowID} | ||
57 | + rowID={rowID} | ||
58 | + data={rowData} | ||
59 | + onPressGiftBag={this.props.onPressGiftBag} | ||
60 | + showGiftAlert={this.props.showGiftAlert} | ||
61 | + hiddenGiftAlert={this.props.hiddenGiftAlert} | ||
62 | + /> | ||
63 | + ); | ||
64 | + } | ||
65 | + case 'productListTitle': { | ||
66 | + return ( | ||
67 | + <View> | ||
68 | + <View style={styles.titleView}> | ||
69 | + <View style={styles.titleLine}/> | ||
70 | + <View style={styles.ViewForTextStyle}> | ||
71 | + <Text style={styles.textStyle}>猜你喜欢</Text> | ||
72 | + </View> | ||
73 | + </View> | ||
74 | + <View style={styles.titleBottomLine}/> | ||
75 | + </View> | ||
76 | + ) | ||
77 | + } | ||
78 | + case 'productList': { | ||
79 | + return ( | ||
80 | + <ProductListCell | ||
81 | + style={[styles.listContainer, customStyle]} | ||
82 | + key={'row' + rowID} | ||
83 | + rowID={rowID} | ||
84 | + data={rowData} | ||
85 | + onPressProduct={this.props.onPressProduct} | ||
86 | + needShopCar={true} | ||
87 | + onPressShopCar={this.props.onPressShopCar} | ||
88 | + /> | ||
89 | + ); | ||
90 | + } | ||
91 | + default: | ||
92 | + return null; | ||
93 | + } | ||
46 | } | 94 | } |
47 | 95 | ||
48 | render() { | 96 | render() { |
49 | let { | 97 | let { |
50 | showGiftAlert, | 98 | showGiftAlert, |
51 | - productList | 99 | + couponsBag, |
100 | + productList, | ||
101 | + drawCouponsBag | ||
52 | } = this.props; | 102 | } = this.props; |
53 | 103 | ||
54 | - let dataSource = productList.product_list.toArray(); | 104 | + let dataSource = { |
105 | + couponsBag: couponsBag.couponsBag_list ? couponsBag.couponsBag_list.toArray(): [], | ||
106 | + productListTitle: ['猜你喜欢'], | ||
107 | + productList: productList.product_list ? productList.product_list.toArray() : [], | ||
108 | + }; | ||
55 | 109 | ||
110 | + let drawCouponsBag_list = drawCouponsBag.drawCouponsBag_list.toArray(); | ||
56 | return ( | 111 | return ( |
57 | <View style={styles.container}> | 112 | <View style={styles.container}> |
58 | - <Text>aaaaa</Text> | ||
59 | <ReceiveGiftAlert | 113 | <ReceiveGiftAlert |
114 | + data={drawCouponsBag_list} | ||
60 | showGiftAlert={showGiftAlert} | 115 | showGiftAlert={showGiftAlert} |
61 | hiddenGiftAlert={this.props.hiddenGiftAlert} | 116 | hiddenGiftAlert={this.props.hiddenGiftAlert} |
62 | onPressCouponItem={this.props.onPressCouponItem} | 117 | onPressCouponItem={this.props.onPressCouponItem} |
@@ -66,11 +121,12 @@ export default class AssociatorGift extends Component { | @@ -66,11 +121,12 @@ export default class AssociatorGift extends Component { | ||
66 | ref={(c) => { | 121 | ref={(c) => { |
67 | this.listView = c; | 122 | this.listView = c; |
68 | }} | 123 | }} |
69 | - yh_viewVisible = {true} | 124 | + yh_viewVisible={true} |
70 | contentContainerStyle={styles.contentContainer} | 125 | contentContainerStyle={styles.contentContainer} |
71 | enableEmptySections={true} | 126 | enableEmptySections={true} |
72 | - dataSource={this.dataSource.cloneWithRows(dataSource)} | 127 | + dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} |
73 | renderRow={this._renderRow} | 128 | renderRow={this._renderRow} |
129 | + renderHeader={this._renderHeader} | ||
74 | /> | 130 | /> |
75 | </View> | 131 | </View> |
76 | ); | 132 | ); |
@@ -85,9 +141,59 @@ let styles = StyleSheet.create({ | @@ -85,9 +141,59 @@ let styles = StyleSheet.create({ | ||
85 | container: { | 141 | container: { |
86 | flex: 1, | 142 | flex: 1, |
87 | }, | 143 | }, |
144 | + bagBackground: { | ||
145 | + width: width, | ||
146 | + alignItems: 'center', | ||
147 | + backgroundColor: '#444444', | ||
148 | + }, | ||
149 | + bgImage: { | ||
150 | + width: 50, | ||
151 | + height: 57.4, | ||
152 | + marginTop: 39, | ||
153 | + marginBottom: 15.6 | ||
154 | + }, | ||
155 | + bagTitle: { | ||
156 | + fontFamily: 'PingFang-SC-Medium', | ||
157 | + fontSize: 14, | ||
158 | + color: '#FFFFFF', | ||
159 | + }, | ||
160 | + bagTips: { | ||
161 | + height: 45, | ||
162 | + fontFamily: 'PingFang-SC-Regula', | ||
163 | + fontSize: 12, | ||
164 | + color: '#B0B0B0', | ||
165 | + paddingTop: 4, | ||
166 | + }, | ||
167 | + titleView: { | ||
168 | + width: width, | ||
169 | + height: 40, | ||
170 | + backgroundColor: 'white', | ||
171 | + flexDirection: 'row', | ||
172 | + }, | ||
173 | + titleLine: { | ||
174 | + width: 2, | ||
175 | + height: 15, | ||
176 | + marginLeft: 15, | ||
177 | + marginTop: 12.5, | ||
178 | + backgroundColor: 'black' | ||
179 | + }, | ||
180 | + ViewForTextStyle: { | ||
181 | + height: 40, | ||
182 | + marginLeft: 10, | ||
183 | + justifyContent: 'center', | ||
184 | + }, | ||
185 | + textStyle: { | ||
186 | + fontSize: 16, | ||
187 | + }, | ||
188 | + titleBottomLine: { | ||
189 | + width: width, | ||
190 | + height: 1, | ||
191 | + backgroundColor: '#e0e0e0' | ||
192 | + }, | ||
88 | contentContainer: { | 193 | contentContainer: { |
89 | flexDirection: 'row', | 194 | flexDirection: 'row', |
90 | flexWrap: 'wrap', | 195 | flexWrap: 'wrap', |
196 | + backgroundColor: 'white' | ||
91 | }, | 197 | }, |
92 | listContainer: { | 198 | listContainer: { |
93 | width: width / 2, | 199 | width: width / 2, |
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | + | ||
6 | +const { | ||
7 | + StyleSheet, | ||
8 | + Text, | ||
9 | + View, | ||
10 | + Image, | ||
11 | + Dimensions, | ||
12 | + TouchableOpacity, | ||
13 | +} = ReactNative; | ||
14 | + | ||
15 | +export default class CouponsBagListCell extends React.Component { | ||
16 | + | ||
17 | + constructor(props) { | ||
18 | + super(props); | ||
19 | + } | ||
20 | + | ||
21 | + render() { | ||
22 | + | ||
23 | + let {data} = this.props; | ||
24 | + | ||
25 | + let nameStyle = data.get('notExpired') ? {color: '#222222'} : {color: '#B0B0B0'}; | ||
26 | + let bgStyle = data.get('status') === 0 && data.get('notExpired') ? {backgroundColor: '#A69073'} : {backgroundColor: '#B0B0B0'}; | ||
27 | + let textStyle = data.get('status') === 0 && data.get('notExpired') ? {fontFamily: 'PingFang-SC-Bold'} : {fontFamily: 'PingFang-SC-Medium'}; | ||
28 | + //"status": 是否已领取 未领取:0,已领取:1; | ||
29 | + //"notExpired": 未过期:true,过期:false; | ||
30 | + let text = data.get('status') === 1 ? '已领取' : data.get('notExpired') ? '领取' : '已失效'; | ||
31 | + return ( | ||
32 | + <View style={styles.container}> | ||
33 | + <View style={styles.contentContainer}> | ||
34 | + <Image style={styles.imgIconBg} | ||
35 | + source={data.get('notExpired') ? require('../images/bg_use.png') : require('../images/bg_used.png')}/> | ||
36 | + <View style={styles.contentText}> | ||
37 | + <Text style={[styles.name, nameStyle]}>{data.get('name')}</Text> | ||
38 | + <Text style={[styles.dateTitle, nameStyle]}>{data.get('dateTitle')}</Text> | ||
39 | + <Text style={styles.desc}>{data.get('desc')}</Text> | ||
40 | + </View> | ||
41 | + <TouchableOpacity activeOpacity={1} onPress={() => { | ||
42 | + this.props.onPressGiftBag && this.props.onPressGiftBag(data.get('id')); | ||
43 | + // data.get('status') === 0 && data.get('notExpired') && this.props.onPressGiftBag && this.props.onPressGiftBag(data.get('id')); | ||
44 | + }}> | ||
45 | + <View style={[styles.buttonBg, bgStyle]}> | ||
46 | + <Text style={[styles.textStyle, textStyle]}>{text}</Text> | ||
47 | + </View> | ||
48 | + </TouchableOpacity> | ||
49 | + </View> | ||
50 | + </View> | ||
51 | + ); | ||
52 | + } | ||
53 | +}; | ||
54 | + | ||
55 | +let {width, height} = Dimensions.get('window'); | ||
56 | +let styles = StyleSheet.create({ | ||
57 | + | ||
58 | + container: { | ||
59 | + width: width, | ||
60 | + alignItems: 'center', | ||
61 | + backgroundColor: '#444444', | ||
62 | + }, | ||
63 | + contentContainer: { | ||
64 | + width: 345, | ||
65 | + height: 70, | ||
66 | + marginLeft: 15, | ||
67 | + marginRight: 15, | ||
68 | + marginBottom: 10, | ||
69 | + borderRadius: 2, | ||
70 | + flexDirection: 'row', | ||
71 | + backgroundColor: 'white', | ||
72 | + }, | ||
73 | + imgIconBg: { | ||
74 | + width: 50, | ||
75 | + height: 50, | ||
76 | + marginTop: 10, | ||
77 | + marginLeft: 16, | ||
78 | + marginRight: 10, | ||
79 | + marginBottom: 10, | ||
80 | + }, | ||
81 | + contentText: { | ||
82 | + width: 194, | ||
83 | + }, | ||
84 | + name: { | ||
85 | + marginTop: 10, | ||
86 | + fontFamily: 'PingFang-SC-Medium', | ||
87 | + fontSize: 12, | ||
88 | + color: '#222222', | ||
89 | + }, | ||
90 | + dateTitle: { | ||
91 | + marginTop: 2, | ||
92 | + fontFamily: 'PingFang-SC-Regular', | ||
93 | + fontSize: 10, | ||
94 | + color: '#222222', | ||
95 | + }, | ||
96 | + desc: { | ||
97 | + marginTop: 2, | ||
98 | + fontFamily: 'PingFang-SC-Regular', | ||
99 | + fontSize: 10, | ||
100 | + color: '#B0B0B0', | ||
101 | + }, | ||
102 | + buttonBg: { | ||
103 | + width: 60, | ||
104 | + height: 26, | ||
105 | + marginTop: 22, | ||
106 | + borderRadius: 30, | ||
107 | + alignItems: 'center', | ||
108 | + justifyContent: 'center', | ||
109 | + backgroundColor: '#A69073', | ||
110 | + }, | ||
111 | + textStyle: { | ||
112 | + fontFamily: 'PingFang-SC-Bold', | ||
113 | + fontSize: 14, | ||
114 | + color: 'white', | ||
115 | + }, | ||
116 | + | ||
117 | +}); |
@@ -5,15 +5,15 @@ import ReactNative from 'react-native'; | @@ -5,15 +5,15 @@ import ReactNative from 'react-native'; | ||
5 | import Immutable, {Map} from 'immutable'; | 5 | import Immutable, {Map} from 'immutable'; |
6 | 6 | ||
7 | const { | 7 | const { |
8 | - AppRegistry, | ||
9 | - StyleSheet, | ||
10 | - Text, | ||
11 | - View, | ||
12 | - Image, | ||
13 | - ListView, | ||
14 | - Dimensions, | ||
15 | - TouchableOpacity, | ||
16 | - Modal, | 8 | + AppRegistry, |
9 | + StyleSheet, | ||
10 | + Text, | ||
11 | + View, | ||
12 | + Image, | ||
13 | + ListView, | ||
14 | + Dimensions, | ||
15 | + TouchableOpacity, | ||
16 | + Modal, | ||
17 | } = ReactNative; | 17 | } = ReactNative; |
18 | 18 | ||
19 | 19 | ||
@@ -29,93 +29,70 @@ export default class ReceiveGiftAlert extends React.Component { | @@ -29,93 +29,70 @@ export default class ReceiveGiftAlert extends React.Component { | ||
29 | 29 | ||
30 | } | 30 | } |
31 | 31 | ||
32 | - _onRequestClose(){ | 32 | + _onRequestClose() { |
33 | console.log('_onRequestClose'); | 33 | console.log('_onRequestClose'); |
34 | } | 34 | } |
35 | 35 | ||
36 | renderRow(rowData, sectionID, rowID, highlightRow) { | 36 | renderRow(rowData, sectionID, rowID, highlightRow) { |
37 | - let price = rowData.couponName; | ||
38 | - return( | 37 | + return ( |
39 | <View style={styles.row}> | 38 | <View style={styles.row}> |
40 | <TouchableOpacity style={styles.row} activeOpacity={0.5} onPress={() => { | 39 | <TouchableOpacity style={styles.row} activeOpacity={0.5} onPress={() => { |
41 | - this.props.onPressCouponItem && this.props.onPressCouponItem(rowData); | ||
42 | - }}> | ||
43 | - <Image source={require('../images/hyzx_yhq_bg.png')} style={styles.rowIcon} resizeMode={'contain'}></Image> | ||
44 | - <Text style={styles.price}>{price}</Text> | 40 | + this.props.onPressCouponItem && this.props.onPressCouponItem(rowData); |
41 | + }}> | ||
42 | + <Image source={require('../images/hyzx_yhq_bg.png')} style={styles.rowIcon} resizeMode={'contain'}/> | ||
43 | + <Text style={styles.price}>{rowData.get('couponName')}</Text> | ||
45 | </TouchableOpacity> | 44 | </TouchableOpacity> |
46 | </View> | 45 | </View> |
47 | ); | 46 | ); |
48 | } | 47 | } |
49 | 48 | ||
50 | render() { | 49 | render() { |
50 | + let {data} = this.props; | ||
51 | 51 | ||
52 | - let dataSource = [{ | ||
53 | - "couponAmount": 50, | ||
54 | - "couponCode": "", | ||
55 | - "couponName": "满199-50", | ||
56 | - "endTime": "2017-04-30 09:45:40", | ||
57 | - "id": 2030, | ||
58 | - "startTime": "2013-04-01 00:00:00", | ||
59 | - "status": 1, | ||
60 | - "useLimit": "199", | ||
61 | - "useLimitType": "2" | ||
62 | - }, | ||
63 | - { | ||
64 | - "couponAmount": 300, | ||
65 | - "couponCode": "", | ||
66 | - "couponName": "12月生日券-满799减300", | ||
67 | - "endTime": "2017-01-31 09:45:40", | ||
68 | - "id": 2033, | ||
69 | - "startTime": "2013-12-01 00:00:00", | ||
70 | - "status": 1, | ||
71 | - "useLimit": "799", | ||
72 | - "useLimitType": "2" | ||
73 | - }]; | ||
74 | - | ||
75 | - return ( | 52 | + return ( |
76 | <Modal | 53 | <Modal |
77 | visible={this.props.showGiftAlert} | 54 | visible={this.props.showGiftAlert} |
78 | animationType={'none'} | 55 | animationType={'none'} |
79 | - transparent = {true} | 56 | + transparent={true} |
80 | onRequestClose={this._onRequestClose} | 57 | onRequestClose={this._onRequestClose} |
81 | > | 58 | > |
82 | <View style={styles.modalStyle}> | 59 | <View style={styles.modalStyle}> |
83 | <View style={styles.container}> | 60 | <View style={styles.container}> |
84 | <Text style={styles.title}>恭喜你领取成功</Text> | 61 | <Text style={styles.title}>恭喜你领取成功</Text> |
85 | - <TouchableOpacity style={styles.delete} activeOpacity={0.5} onPress={() => { | 62 | + <TouchableOpacity style={styles.delete} activeOpacity={0.5} onPress={() => { |
86 | this.props.hiddenGiftAlert && this.props.hiddenGiftAlert(); | 63 | this.props.hiddenGiftAlert && this.props.hiddenGiftAlert(); |
87 | }}> | 64 | }}> |
88 | - <Image source={require('../images/close.png')} style={styles.deleteIcon} resizeMode={'contain'}></Image> | 65 | + <Image source={require('../images/close.png')} style={styles.deleteIcon} resizeMode={'contain'}/> |
89 | </TouchableOpacity> | 66 | </TouchableOpacity> |
90 | <View style={styles.contentContainer}> | 67 | <View style={styles.contentContainer}> |
91 | <ListView | 68 | <ListView |
92 | ref='giftList' | 69 | ref='giftList' |
93 | contentContainerStyle={styles.listContainer} | 70 | contentContainerStyle={styles.listContainer} |
94 | enableEmptySections={true} | 71 | enableEmptySections={true} |
95 | - dataSource={this.dataSource.cloneWithRows(dataSource)} | 72 | + dataSource={this.dataSource.cloneWithRows(data)} |
96 | renderRow={this.renderRow} | 73 | renderRow={this.renderRow} |
97 | /> | 74 | /> |
98 | </View> | 75 | </View> |
99 | <View style={styles.detailView}> | 76 | <View style={styles.detailView}> |
100 | <TouchableOpacity activeOpacity={0.5} onPress={() => { | 77 | <TouchableOpacity activeOpacity={0.5} onPress={() => { |
101 | - this.props.onPressLookDetail && this.props.onPressLookDetail(); | ||
102 | - }}> | 78 | + this.props.onPressLookDetail && this.props.onPressLookDetail(); |
79 | + }}> | ||
103 | <Text style={styles.detail}>查看详情</Text> | 80 | <Text style={styles.detail}>查看详情</Text> |
104 | </TouchableOpacity> | 81 | </TouchableOpacity> |
105 | </View> | 82 | </View> |
106 | </View> | 83 | </View> |
107 | </View> | 84 | </View> |
108 | </Modal> | 85 | </Modal> |
109 | - ); | 86 | + ); |
110 | } | 87 | } |
111 | }; | 88 | }; |
112 | 89 | ||
113 | let {width, height} = Dimensions.get('window'); | 90 | let {width, height} = Dimensions.get('window'); |
114 | let styles = StyleSheet.create({ | 91 | let styles = StyleSheet.create({ |
115 | - modalStyle: { | ||
116 | - width: width, | ||
117 | - height: height, | ||
118 | - backgroundColor: 'rgba(0, 0, 0, 0.6)', | 92 | + modalStyle: { |
93 | + width: width, | ||
94 | + height: height, | ||
95 | + backgroundColor: 'rgba(0, 0, 0, 0.6)', | ||
119 | flex: 1, | 96 | flex: 1, |
120 | justifyContent: 'center', | 97 | justifyContent: 'center', |
121 | alignItems: 'center', | 98 | alignItems: 'center', |
@@ -20,4 +20,8 @@ export default keyMirror({ | @@ -20,4 +20,8 @@ export default keyMirror({ | ||
20 | DRAW_COUPONS_BAG_SUCCESS: null, | 20 | DRAW_COUPONS_BAG_SUCCESS: null, |
21 | DRAW_COUPONS_BAG_FAILURE: null, | 21 | DRAW_COUPONS_BAG_FAILURE: null, |
22 | 22 | ||
23 | + COUPONS_BAG_CNT_REQUEST: null, | ||
24 | + COUPONS_BAG_CNT_SUCCESS: null, | ||
25 | + COUPONS_BAG_CNT_FAILURE: null, | ||
26 | + | ||
23 | }); | 27 | }); |
@@ -43,13 +43,16 @@ class AssociatorGiftContainer extends Component { | @@ -43,13 +43,16 @@ class AssociatorGiftContainer extends Component { | ||
43 | super(props); | 43 | super(props); |
44 | this._displayGiftAlert = this._displayGiftAlert.bind(this); | 44 | this._displayGiftAlert = this._displayGiftAlert.bind(this); |
45 | this._hiddenGiftAlert = this._hiddenGiftAlert.bind(this); | 45 | this._hiddenGiftAlert = this._hiddenGiftAlert.bind(this); |
46 | - this.onPressProduct = this.onPressProduct.bind(this); | 46 | + this._onPressGiftBag = this._onPressGiftBag.bind(this); |
47 | + this._onPressProduct = this._onPressProduct.bind(this); | ||
47 | this._onPressShopCar = this._onPressShopCar.bind(this); | 48 | this._onPressShopCar = this._onPressShopCar.bind(this); |
48 | this._onPressCouponItem = this._onPressCouponItem.bind(this); | 49 | this._onPressCouponItem = this._onPressCouponItem.bind(this); |
49 | this._onPressLookDetail = this._onPressLookDetail.bind(this); | 50 | this._onPressLookDetail = this._onPressLookDetail.bind(this); |
50 | } | 51 | } |
51 | 52 | ||
52 | componentDidMount() { | 53 | componentDidMount() { |
54 | + this.props.actions.getCouponsBagCnt(); | ||
55 | + this.props.actions.getCouponsBagList(); | ||
53 | this.props.actions.getProductListForAssociatorGift(); | 56 | this.props.actions.getProductListForAssociatorGift(); |
54 | } | 57 | } |
55 | 58 | ||
@@ -57,6 +60,10 @@ class AssociatorGiftContainer extends Component { | @@ -57,6 +60,10 @@ class AssociatorGiftContainer extends Component { | ||
57 | 60 | ||
58 | } | 61 | } |
59 | 62 | ||
63 | + _onPressGiftBag(couponsBagId) { | ||
64 | + this.props.actions.getDrawCouponsBag(couponsBagId); | ||
65 | + } | ||
66 | + | ||
60 | _displayGiftAlert(){ | 67 | _displayGiftAlert(){ |
61 | this.props.actions.displayGiftAlert(); | 68 | this.props.actions.displayGiftAlert(); |
62 | } | 69 | } |
@@ -83,7 +90,7 @@ class AssociatorGiftContainer extends Component { | @@ -83,7 +90,7 @@ class AssociatorGiftContainer extends Component { | ||
83 | ReactNative.NativeModules.YH_CommonHelper.showChooseInfoView(param) | 90 | ReactNative.NativeModules.YH_CommonHelper.showChooseInfoView(param) |
84 | } | 91 | } |
85 | 92 | ||
86 | - onPressProduct(product){ | 93 | + _onPressProduct(product){ |
87 | let productSkn = product && product.get('product_skn', 0); | 94 | let productSkn = product && product.get('product_skn', 0); |
88 | let is_global = product && product.get('is_global', 'N'); | 95 | let is_global = product && product.get('is_global', 'N'); |
89 | 96 | ||
@@ -104,15 +111,22 @@ class AssociatorGiftContainer extends Component { | @@ -104,15 +111,22 @@ class AssociatorGiftContainer extends Component { | ||
104 | 111 | ||
105 | let { | 112 | let { |
106 | showGiftAlert, | 113 | showGiftAlert, |
107 | - productList | 114 | + couponsBagCnt, |
115 | + couponsBag, | ||
116 | + productList, | ||
117 | + drawCouponsBag | ||
108 | } = this.props.associatorGift; | 118 | } = this.props.associatorGift; |
109 | return ( | 119 | return ( |
110 | <AssociatorGift | 120 | <AssociatorGift |
111 | showGiftAlert={showGiftAlert} | 121 | showGiftAlert={showGiftAlert} |
112 | displayGiftAlert={this._displayGiftAlert} | 122 | displayGiftAlert={this._displayGiftAlert} |
113 | hiddenGiftAlert={this._hiddenGiftAlert} | 123 | hiddenGiftAlert={this._hiddenGiftAlert} |
124 | + couponsBagCnt={couponsBagCnt} | ||
125 | + couponsBag={couponsBag} | ||
114 | productList={productList} | 126 | productList={productList} |
115 | - onPressProduct={this.onPressProduct} | 127 | + drawCouponsBag={drawCouponsBag} |
128 | + onPressGiftBag={this._onPressGiftBag} | ||
129 | + onPressProduct={this._onPressProduct} | ||
116 | onPressShopCar={this._onPressShopCar} | 130 | onPressShopCar={this._onPressShopCar} |
117 | onPressCouponItem={this._onPressCouponItem} | 131 | onPressCouponItem={this._onPressCouponItem} |
118 | onPressLookDetail={this._onPressLookDetail} | 132 | onPressLookDetail={this._onPressLookDetail} |
js/associatorGift/images/bg_use.png
0 → 100644
9.58 KB
js/associatorGift/images/bg_used.png
0 → 100644
6.67 KB
js/associatorGift/images/close_btn.png
0 → 100644
304 Bytes
js/associatorGift/images/lb_use_bg.png
0 → 100644
28.8 KB
js/associatorGift/images/xyzx_lb.png
0 → 100644
2.94 KB
@@ -20,9 +20,11 @@ const { | @@ -20,9 +20,11 @@ const { | ||
20 | DRAW_COUPONS_BAG_SUCCESS, | 20 | DRAW_COUPONS_BAG_SUCCESS, |
21 | DRAW_COUPONS_BAG_FAILURE, | 21 | DRAW_COUPONS_BAG_FAILURE, |
22 | 22 | ||
23 | -} = require('../../constants/actionTypes').default; | ||
24 | - | 23 | + COUPONS_BAG_CNT_REQUEST, |
24 | + COUPONS_BAG_CNT_SUCCESS, | ||
25 | + COUPONS_BAG_CNT_FAILURE, | ||
25 | 26 | ||
27 | +} = require('../../constants/actionTypes').default; | ||
26 | 28 | ||
27 | export function displayGiftAlert() { | 29 | export function displayGiftAlert() { |
28 | return { | 30 | return { |
@@ -96,6 +98,26 @@ export function drawCouponsBagFailure(error) { | @@ -96,6 +98,26 @@ export function drawCouponsBagFailure(error) { | ||
96 | }; | 98 | }; |
97 | } | 99 | } |
98 | 100 | ||
101 | +export function couponsBagCntRequest() { | ||
102 | + return { | ||
103 | + type: COUPONS_BAG_CNT_REQUEST, | ||
104 | + }; | ||
105 | +} | ||
106 | + | ||
107 | +export function couponsBagCntSuccess(json) { | ||
108 | + return { | ||
109 | + type: COUPONS_BAG_CNT_SUCCESS, | ||
110 | + payload: json | ||
111 | + }; | ||
112 | +} | ||
113 | + | ||
114 | +export function couponsBagCntFailure(error) { | ||
115 | + return { | ||
116 | + type: COUPONS_BAG_CNT_FAILURE, | ||
117 | + payload: error | ||
118 | + }; | ||
119 | +} | ||
120 | + | ||
99 | export function getCouponsBagList() { | 121 | export function getCouponsBagList() { |
100 | return (dispatch, getState) => { | 122 | return (dispatch, getState) => { |
101 | let {app} = getState(); | 123 | let {app} = getState(); |
@@ -137,14 +159,16 @@ export function getProductListForAssociatorGift() { | @@ -137,14 +159,16 @@ export function getProductListForAssociatorGift() { | ||
137 | 159 | ||
138 | } | 160 | } |
139 | 161 | ||
140 | -export function getDrawCouponsBag() { | 162 | +export function getDrawCouponsBag(couponsBagId) { |
141 | return (dispatch, getState) => { | 163 | return (dispatch, getState) => { |
142 | - let {app} = getState(); | ||
143 | - let fetchCouponsBag = (uid, couponsBagId) => { | 164 | + let {app, associatorGift} = getState(); |
165 | + let fetchCouponsBag = (uid) => { | ||
144 | dispatch(drawCouponsBagRequest()); | 166 | dispatch(drawCouponsBagRequest()); |
145 | return new AssociatorGiftService(app.host).fetchDrawCouponsBag(uid, couponsBagId) | 167 | return new AssociatorGiftService(app.host).fetchDrawCouponsBag(uid, couponsBagId) |
146 | .then(json => { | 168 | .then(json => { |
147 | - dispatch(drawCouponsBagSuccess(json)); | 169 | + let result = parseResourceResources(json, associatorGift, couponsBagId); |
170 | + dispatch(drawCouponsBagSuccess(result)); | ||
171 | + dispatch(getCouponsBagCnt()); | ||
148 | }) | 172 | }) |
149 | .catch(error => { | 173 | .catch(error => { |
150 | dispatch(drawCouponsBagFailure(error)); | 174 | dispatch(drawCouponsBagFailure(error)); |
@@ -159,6 +183,48 @@ export function getDrawCouponsBag() { | @@ -159,6 +183,48 @@ export function getDrawCouponsBag() { | ||
159 | .catch(error => { | 183 | .catch(error => { |
160 | fetchCouponsBag(uid) | 184 | fetchCouponsBag(uid) |
161 | }); | 185 | }); |
186 | + }; | ||
187 | +} | ||
188 | + | ||
189 | +export function getCouponsBagCnt() { | ||
190 | + return (dispatch, getState) => { | ||
191 | + let {app} = getState(); | ||
192 | + let fetchCouponsBagCnt = (uid) => { | ||
193 | + dispatch(couponsBagCntRequest()); | ||
194 | + return new AssociatorGiftService(app.host).fetchCouponsBagCnt(uid) | ||
195 | + .then(json => { | ||
196 | + dispatch(couponsBagCntSuccess(json)); | ||
197 | + }) | ||
198 | + .catch(error => { | ||
199 | + dispatch(couponsBagCntFailure(error)); | ||
200 | + }); | ||
201 | + }; | ||
162 | 202 | ||
203 | + let uid = 0; | ||
204 | + ReactNative.NativeModules.YH_CommonHelper.uid() | ||
205 | + .then(uid => { | ||
206 | + fetchCouponsBagCnt(uid) | ||
207 | + }) | ||
208 | + .catch(error => { | ||
209 | + fetchCouponsBagCnt(uid) | ||
210 | + }); | ||
211 | + | ||
212 | + }; | ||
213 | +} | ||
214 | + | ||
215 | +export function parseResourceResources(json, associatorGift, couponsBagId) { | ||
216 | + let isShow = json.length > 0; | ||
217 | + let associatorGiftList = associatorGift.toJS(); | ||
218 | + let couponsBagList = associatorGiftList && associatorGiftList.couponsBag && associatorGiftList.couponsBag.couponsBag_list; | ||
219 | + //更新礼包选中的状态 | ||
220 | + couponsBagList.map((item)=>{ | ||
221 | + if (item.id === couponsBagId) { | ||
222 | + item.status = 1; | ||
223 | + } | ||
224 | + }); | ||
225 | + return { | ||
226 | + isShow: isShow, | ||
227 | + couponsBagList, | ||
228 | + drawCouponsBagList: json, | ||
163 | }; | 229 | }; |
164 | } | 230 | } |
@@ -4,6 +4,13 @@ import {Record, List, Map} from 'immutable'; | @@ -4,6 +4,13 @@ import {Record, List, Map} from 'immutable'; | ||
4 | 4 | ||
5 | let InitialState = Record({ | 5 | let InitialState = Record({ |
6 | showGiftAlert: false, | 6 | showGiftAlert: false, |
7 | + | ||
8 | + couponsBagCnt: new (Record({ | ||
9 | + isFetching: false, | ||
10 | + error: null, | ||
11 | + total: 0, | ||
12 | + })), | ||
13 | + | ||
7 | couponsBag: new (Record({ | 14 | couponsBag: new (Record({ |
8 | isFetching: false, | 15 | isFetching: false, |
9 | error: null, | 16 | error: null, |
@@ -16,6 +23,12 @@ let InitialState = Record({ | @@ -16,6 +23,12 @@ let InitialState = Record({ | ||
16 | product_list: List(), | 23 | product_list: List(), |
17 | rec_id:'', | 24 | rec_id:'', |
18 | })), | 25 | })), |
26 | + | ||
27 | + drawCouponsBag: new (Record({ | ||
28 | + isFetching: false, | ||
29 | + error: null, | ||
30 | + drawCouponsBag_list: List(), | ||
31 | + })), | ||
19 | }); | 32 | }); |
20 | 33 | ||
21 | export default InitialState; | 34 | export default InitialState; |
@@ -4,37 +4,112 @@ import InitialState from './associatorGiftInitialState'; | @@ -4,37 +4,112 @@ import InitialState from './associatorGiftInitialState'; | ||
4 | import Immutable, {Map} from 'immutable'; | 4 | import Immutable, {Map} from 'immutable'; |
5 | 5 | ||
6 | const { | 6 | const { |
7 | - SHOWGIFTALERT, | ||
8 | - DISMISSGIFTALERT, | 7 | + SHOWGIFTALERT, |
8 | + DISMISSGIFTALERT, | ||
9 | + | ||
10 | + COUPONS_BAG_REQUEST, | ||
11 | + COUPONS_BAG_SUCCESS, | ||
12 | + COUPONS_BAG_FAILURE, | ||
13 | + | ||
14 | + ASSOCIATORGIFT_PRODUCT_REQUEST, | ||
9 | ASSOCIATORGIFT_PRODUCT_SUCCESS, | 15 | ASSOCIATORGIFT_PRODUCT_SUCCESS, |
10 | ASSOCIATORGIFT_PRODUCT_FAILURE, | 16 | ASSOCIATORGIFT_PRODUCT_FAILURE, |
17 | + | ||
18 | + DRAW_COUPONS_BAG_REQUEST, | ||
19 | + DRAW_COUPONS_BAG_SUCCESS, | ||
20 | + DRAW_COUPONS_BAG_FAILURE, | ||
21 | + | ||
22 | + COUPONS_BAG_CNT_REQUEST, | ||
23 | + COUPONS_BAG_CNT_SUCCESS, | ||
24 | + COUPONS_BAG_CNT_FAILURE, | ||
25 | + | ||
11 | } = require('../../constants/actionTypes').default; | 26 | } = require('../../constants/actionTypes').default; |
12 | 27 | ||
13 | const initialState = new InitialState; | 28 | const initialState = new InitialState; |
14 | 29 | ||
15 | -export default function couponReducer(state=initialState, action) { | ||
16 | - if (!(state instanceof InitialState)) { | 30 | +export default function couponReducer(state = initialState, action) { |
31 | + if (!(state instanceof InitialState)) { | ||
17 | return initialState.merge(state); | 32 | return initialState.merge(state); |
18 | - } | ||
19 | - | ||
20 | - switch(action.type) { | ||
21 | - case SHOWGIFTALERT: { | ||
22 | - return state.set('showGiftAlert', true); | ||
23 | - } | ||
24 | - case DISMISSGIFTALERT: { | ||
25 | - return state.set('showGiftAlert', false); | ||
26 | - } | 33 | + } |
34 | + | ||
35 | + switch (action.type) { | ||
36 | + case SHOWGIFTALERT: { | ||
37 | + return state.set('showGiftAlert', true); | ||
38 | + } | ||
39 | + case DISMISSGIFTALERT: { | ||
40 | + return state.set('showGiftAlert', false); | ||
41 | + } | ||
42 | + | ||
43 | + case COUPONS_BAG_REQUEST: { | ||
44 | + return state.setIn(['couponsBag', 'isFetching'], true) | ||
45 | + .setIn(['couponsBag', 'error'], null); | ||
46 | + } | ||
47 | + | ||
48 | + case COUPONS_BAG_SUCCESS: { | ||
49 | + return state.setIn(['couponsBag', 'isFetching'], false) | ||
50 | + .setIn(['couponsBag', 'couponsBag_list'], Immutable.fromJS(action.payload)) | ||
51 | + .setIn(['couponsBag', 'error'], null); | ||
52 | + } | ||
53 | + | ||
54 | + case COUPONS_BAG_FAILURE: { | ||
55 | + return state.setIn(['couponsBag', 'isFetching'], false) | ||
56 | + .setIn(['couponsBag', 'error'], action.payload); | ||
57 | + } | ||
58 | + | ||
59 | + case ASSOCIATORGIFT_PRODUCT_REQUEST: { | ||
60 | + return state.setIn(['productList', 'isFetching'], true) | ||
61 | + .setIn(['productList', 'error'], null); | ||
62 | + } | ||
63 | + | ||
27 | case ASSOCIATORGIFT_PRODUCT_SUCCESS: { | 64 | case ASSOCIATORGIFT_PRODUCT_SUCCESS: { |
28 | let { | 65 | let { |
29 | product_list, | 66 | product_list, |
30 | rec_id, | 67 | rec_id, |
31 | } = action.payload; | 68 | } = action.payload; |
32 | 69 | ||
33 | - return state.setIn(['productList', 'product_list'], Immutable.fromJS(product_list)) | ||
34 | - .setIn(['productList', 'rec_id'], rec_id); | 70 | + return state.setIn(['productList', 'isFetching'], false) |
71 | + .setIn(['productList', 'product_list'], Immutable.fromJS(product_list)) | ||
72 | + .setIn(['productList', 'rec_id'], rec_id) | ||
73 | + .setIn(['productList', 'error'], null); | ||
35 | } | 74 | } |
75 | + | ||
36 | case ASSOCIATORGIFT_PRODUCT_FAILURE: { | 76 | case ASSOCIATORGIFT_PRODUCT_FAILURE: { |
37 | - return state.setIn(['productList', 'error'], Immutable.fromJS(action.payload)); | 77 | + return state.setIn(['productList', 'isFetching'], false) |
78 | + .setIn(['productList', 'error'], action.payload); | ||
79 | + } | ||
80 | + | ||
81 | + case DRAW_COUPONS_BAG_REQUEST: { | ||
82 | + return state.setIn(['drawCouponsBag', 'isFetching'], true) | ||
83 | + .setIn(['drawCouponsBag', 'error'], null); | ||
84 | + } | ||
85 | + | ||
86 | + case DRAW_COUPONS_BAG_SUCCESS: { | ||
87 | + return state.setIn(['drawCouponsBag', 'isFetching'], false) | ||
88 | + .set('showGiftAlert', action.payload.isShow) | ||
89 | + .setIn(['couponsBag', 'couponsBag_list'], Immutable.fromJS(action.payload.couponsBagList)) | ||
90 | + .setIn(['drawCouponsBag', 'drawCouponsBag_list'], Immutable.fromJS(action.payload.drawCouponsBagList)) | ||
91 | + .setIn(['drawCouponsBag', 'error'], null); | ||
92 | + } | ||
93 | + | ||
94 | + case DRAW_COUPONS_BAG_FAILURE: { | ||
95 | + return state.setIn(['drawCouponsBag', 'isFetching'], false) | ||
96 | + .setIn(['drawCouponsBag', 'error'], action.payload); | ||
97 | + } | ||
98 | + | ||
99 | + case COUPONS_BAG_CNT_REQUEST: { | ||
100 | + return state.setIn(['couponsBagCnt', 'isFetching'], true) | ||
101 | + .setIn(['couponsBagCnt', 'error'], null); | ||
102 | + } | ||
103 | + | ||
104 | + case COUPONS_BAG_CNT_SUCCESS: { | ||
105 | + return state.setIn(['couponsBagCnt', 'isFetching'], false) | ||
106 | + .setIn(['couponsBagCnt', 'total'], action.payload.total) | ||
107 | + .setIn(['couponsBagCnt', 'error'], null); | ||
108 | + } | ||
109 | + | ||
110 | + case COUPONS_BAG_CNT_FAILURE: { | ||
111 | + return state.setIn(['couponsBagCnt', 'isFetching'], false) | ||
112 | + .setIn(['couponsBagCnt', 'error'], action.payload); | ||
38 | } | 113 | } |
39 | } | 114 | } |
40 | 115 |
@@ -17,6 +17,7 @@ export default class AssociatorGiftService { | @@ -17,6 +17,7 @@ export default class AssociatorGiftService { | ||
17 | url: '', | 17 | url: '', |
18 | body: { | 18 | body: { |
19 | uid, | 19 | uid, |
20 | + page: 1, | ||
20 | method: 'app.giftBag.getCouponsBagList', | 21 | method: 'app.giftBag.getCouponsBagList', |
21 | } | 22 | } |
22 | }) | 23 | }) |
@@ -63,4 +64,20 @@ export default class AssociatorGiftService { | @@ -63,4 +64,20 @@ export default class AssociatorGiftService { | ||
63 | }); | 64 | }); |
64 | } | 65 | } |
65 | 66 | ||
67 | + async fetchCouponsBagCnt(uid) { | ||
68 | + return await this.api.get({ | ||
69 | + url: '', | ||
70 | + body: { | ||
71 | + uid, | ||
72 | + method: 'app.giftBag.getCouponsBagCnt', | ||
73 | + } | ||
74 | + }) | ||
75 | + .then((json) => { | ||
76 | + return json; | ||
77 | + }) | ||
78 | + .catch((error) => { | ||
79 | + throw(error); | ||
80 | + }); | ||
81 | + } | ||
82 | + | ||
66 | } | 83 | } |
-
Please register or login to post a comment