添加站内信相关模块 review by 于良
Showing
22 changed files
with
357 additions
and
38 deletions
@@ -43,15 +43,24 @@ export default class EmptyContent extends Component { | @@ -43,15 +43,24 @@ export default class EmptyContent extends Component { | ||
43 | let {listId} = this.props; | 43 | let {listId} = this.props; |
44 | return( | 44 | return( |
45 | <View style={styles.container}> | 45 | <View style={styles.container}> |
46 | - <Image style={styles.iconStyle}/> | 46 | + <Image |
47 | + style={styles.iconStyle} | ||
48 | + source={require('../../images/message_empty_ic.png')} | ||
49 | + /> | ||
47 | <Text style={styles.textStyle}> | 50 | <Text style={styles.textStyle}> |
48 | {this.emptyText(listId)} | 51 | {this.emptyText(listId)} |
49 | </Text> | 52 | </Text> |
53 | + <TouchableOpacity | ||
54 | + onPress={() => { | ||
55 | + this.props.onPressEmptyItem && this.props.onPressEmptyItem(); | ||
56 | + }} | ||
57 | + > | ||
50 | <View style={styles.aroundStyle}> | 58 | <View style={styles.aroundStyle}> |
51 | <Text style={styles.aroundTitle}> | 59 | <Text style={styles.aroundTitle}> |
52 | 随便逛逛 | 60 | 随便逛逛 |
53 | </Text> | 61 | </Text> |
54 | </View> | 62 | </View> |
63 | + </TouchableOpacity> | ||
55 | </View> | 64 | </View> |
56 | ); | 65 | ); |
57 | }; | 66 | }; |
@@ -70,7 +79,7 @@ let styles = StyleSheet.create({ | @@ -70,7 +79,7 @@ let styles = StyleSheet.create({ | ||
70 | iconStyle: { | 79 | iconStyle: { |
71 | width: Math.ceil(96*scale), | 80 | width: Math.ceil(96*scale), |
72 | height: Math.ceil(70*scale), | 81 | height: Math.ceil(70*scale), |
73 | - backgroundColor: 'red', | 82 | + backgroundColor: 'transparent', |
74 | }, | 83 | }, |
75 | textStyle: { | 84 | textStyle: { |
76 | marginTop: Math.ceil(28*scale), | 85 | marginTop: Math.ceil(28*scale), |
@@ -13,10 +13,13 @@ import ReactNative, { | @@ -13,10 +13,13 @@ import ReactNative, { | ||
13 | } from 'react-native'; | 13 | } from 'react-native'; |
14 | 14 | ||
15 | import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator'; | 15 | import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator'; |
16 | +import LoadingIndicator from '../../../common/components/LoadingIndicator'; | ||
16 | import EmptyContent from './EmptyContent'; | 17 | import EmptyContent from './EmptyContent'; |
17 | import MessageListCellHeader from './MessageListCellHeader'; | 18 | import MessageListCellHeader from './MessageListCellHeader'; |
18 | import MessageListSmallIconCell from './MessageListSmallIconCell'; | 19 | import MessageListSmallIconCell from './MessageListSmallIconCell'; |
19 | import MessageListBigIconCell from './MessageListBigIconCell'; | 20 | import MessageListBigIconCell from './MessageListBigIconCell'; |
21 | +import MessageListTextCell from './MessageListTextCell'; | ||
22 | +import MessageListOrderCell from './MessageListOrderCell'; | ||
20 | 23 | ||
21 | export default class MessageList extends Component { | 24 | export default class MessageList extends Component { |
22 | 25 | ||
@@ -26,39 +29,104 @@ export default class MessageList extends Component { | @@ -26,39 +29,104 @@ export default class MessageList extends Component { | ||
26 | this.dataSource = new ListView.DataSource({ | 29 | this.dataSource = new ListView.DataSource({ |
27 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | 30 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), |
28 | }); | 31 | }); |
32 | + this.loadMessageListCell = this.loadMessageListCell.bind(this); | ||
29 | } | 33 | } |
30 | componentDidMount() { | 34 | componentDidMount() { |
31 | } | 35 | } |
32 | 36 | ||
37 | + loadMessageListCell(rowData) { | ||
38 | + let cellType = rowData.get('businessType'); | ||
39 | + switch (cellType) { | ||
40 | + case 100: | ||
41 | + case 101: | ||
42 | + case 102: | ||
43 | + case 103: | ||
44 | + case 202: | ||
45 | + case 203: | ||
46 | + case 204: | ||
47 | + case 205: | ||
48 | + case 206: | ||
49 | + case 207: | ||
50 | + case 306: | ||
51 | + { | ||
52 | + return( | ||
53 | + <MessageListSmallIconCell | ||
54 | + itemData={rowData} | ||
55 | + onPressListItem={this.props.onPressListItem} | ||
56 | + /> | ||
57 | + ); | ||
58 | + } | ||
59 | + break; | ||
60 | + case 200: | ||
61 | + case 201: | ||
62 | + case 403: | ||
63 | + { | ||
64 | + return( | ||
65 | + <MessageListBigIconCell | ||
66 | + itemData={rowData} | ||
67 | + onPressListItem={this.props.onPressListItem} | ||
68 | + /> | ||
69 | + ); | ||
70 | + } | ||
71 | + break; | ||
72 | + case 300: | ||
73 | + case 301: | ||
74 | + case 302: | ||
75 | + case 303: | ||
76 | + case 304: | ||
77 | + case 305: | ||
78 | + case 402: | ||
79 | + { | ||
80 | + return( | ||
81 | + <MessageListOrderCell | ||
82 | + itemData={rowData} | ||
83 | + onPressListItem={this.props.onPressListItem} | ||
84 | + /> | ||
85 | + ); | ||
86 | + } | ||
87 | + break; | ||
88 | + case 400: | ||
89 | + case 401: | ||
90 | + { | ||
91 | + return( | ||
92 | + <MessageListTextCell | ||
93 | + itemData={rowData} | ||
94 | + /> | ||
95 | + ); | ||
96 | + } | ||
97 | + break; | ||
98 | + default: | ||
99 | + return( | ||
100 | + <View /> | ||
101 | + ); | ||
102 | + } | ||
103 | + } | ||
104 | + | ||
33 | renderRow(rowData, sectionID, rowID) { | 105 | renderRow(rowData, sectionID, rowID) { |
34 | return ( | 106 | return ( |
35 | <View style= {styles.cellContainer}> | 107 | <View style= {styles.cellContainer}> |
36 | <MessageListCellHeader | 108 | <MessageListCellHeader |
37 | - timestamp= {'09:30'} | ||
38 | - /> | ||
39 | - | ||
40 | - <MessageListSmallIconCell | ||
41 | - data= {rowData} | 109 | + timestamp= {rowData.get('create_date')} |
42 | /> | 110 | /> |
111 | + {this.loadMessageListCell(rowData)} | ||
43 | </View> | 112 | </View> |
44 | - // <MessageListBigIconCell /> | ||
45 | - | ||
46 | ); | 113 | ); |
47 | } | 114 | } |
48 | 115 | ||
49 | render() { | 116 | render() { |
50 | - let {isFetching, endReached, list, listId} = this.props.data; | 117 | + let {isFetching, endReached, list, listId, shouldShowEmpty} = this.props.data; |
51 | let isLoadingMore = list.size != 0 && isFetching; | 118 | let isLoadingMore = list.size != 0 && isFetching; |
52 | - let shouldShowEmpty = list.size == 0 && !isFetching; | ||
53 | 119 | ||
54 | if (shouldShowEmpty) { | 120 | if (shouldShowEmpty) { |
55 | return ( | 121 | return ( |
56 | <View style={styles.container}> | 122 | <View style={styles.container}> |
57 | - <EmptyContent listId={listId}/> | 123 | + <EmptyContent |
124 | + listId={listId} | ||
125 | + onPressEmptyItem={this.props.onPressEmptyItem} | ||
126 | + /> | ||
58 | </View> | 127 | </View> |
59 | ); | 128 | ); |
60 | } | 129 | } |
61 | - | ||
62 | return ( | 130 | return ( |
63 | <View style={styles.container}> | 131 | <View style={styles.container}> |
64 | <ListView | 132 | <ListView |
@@ -85,6 +153,9 @@ export default class MessageList extends Component { | @@ -85,6 +153,9 @@ export default class MessageList extends Component { | ||
85 | } | 153 | } |
86 | }} | 154 | }} |
87 | /> | 155 | /> |
156 | + <LoadingIndicator | ||
157 | + isVisible={isFetching} | ||
158 | + /> | ||
88 | </View> | 159 | </View> |
89 | ); | 160 | ); |
90 | } | 161 | } |
@@ -18,6 +18,11 @@ export default class MessageListBigIconCell extends Component { | @@ -18,6 +18,11 @@ export default class MessageListBigIconCell extends Component { | ||
18 | } | 18 | } |
19 | 19 | ||
20 | render() { | 20 | render() { |
21 | + let itemData = this.props.itemData; | ||
22 | + let body = itemData.get('body'); | ||
23 | + let imageUri = body ? body.get('img_url') : 'www.yohobuy.com'; | ||
24 | + let content = body ? body.get('content') : ''; | ||
25 | + imageUri = imageUri.replace('{width}', width).replace('{height}', 117).replace('{mode}',2); | ||
21 | return( | 26 | return( |
22 | <View style={styles.container}> | 27 | <View style={styles.container}> |
23 | <View style={styles.titleContainer}> | 28 | <View style={styles.titleContainer}> |
@@ -25,19 +30,25 @@ export default class MessageListBigIconCell extends Component { | @@ -25,19 +30,25 @@ export default class MessageListBigIconCell extends Component { | ||
25 | numberOfLines={2} | 30 | numberOfLines={2} |
26 | style={styles.titleStyle} | 31 | style={styles.titleStyle} |
27 | > | 32 | > |
28 | - 我是标题 | 33 | + {itemData.get('title')} |
29 | </Text> | 34 | </Text> |
30 | </View> | 35 | </View> |
31 | - <Image style={styles.iconStyle}/> | 36 | + <Image |
37 | + style={styles.iconStyle} | ||
38 | + source={{uri: imageUri}} | ||
39 | + /> | ||
32 | <View style={styles.descContainer}> | 40 | <View style={styles.descContainer}> |
33 | <Text | 41 | <Text |
34 | numberOfLines={2} | 42 | numberOfLines={2} |
35 | style={styles.detail} | 43 | style={styles.detail} |
36 | > | 44 | > |
37 | - 我是详情我是详情我是详情我是详情我是详情我是详情我是详情我是详情我是详情我是详情我是详情我是详情我是详情我是详情我是详情我是详情 | 45 | + {content} |
38 | </Text> | 46 | </Text> |
39 | </View> | 47 | </View> |
40 | - <MessageListCellFooter /> | 48 | + <MessageListCellFooter |
49 | + onPressListItem={this.props.onPressListItem} | ||
50 | + itemData={itemData} | ||
51 | + /> | ||
41 | </View> | 52 | </View> |
42 | ) | 53 | ) |
43 | } | 54 | } |
@@ -60,12 +71,12 @@ let styles = StyleSheet.create({ | @@ -60,12 +71,12 @@ let styles = StyleSheet.create({ | ||
60 | fontSize: 14, | 71 | fontSize: 14, |
61 | fontWeight: 'bold', | 72 | fontWeight: 'bold', |
62 | color: '#444444', | 73 | color: '#444444', |
63 | - maxWidth: width-30, | 74 | + marginRight: 15, |
64 | }, | 75 | }, |
65 | iconStyle: { | 76 | iconStyle: { |
66 | width, | 77 | width, |
67 | height: 117, | 78 | height: 117, |
68 | - backgroundColor: 'yellow' | 79 | + backgroundColor: 'transparent' |
69 | }, | 80 | }, |
70 | descContainer: { | 81 | descContainer: { |
71 | flexDirection: 'column', | 82 | flexDirection: 'column', |
@@ -76,7 +87,7 @@ let styles = StyleSheet.create({ | @@ -76,7 +87,7 @@ let styles = StyleSheet.create({ | ||
76 | marginTop: 8, | 87 | marginTop: 8, |
77 | marginBottom: 15, | 88 | marginBottom: 15, |
78 | marginLeft: 15, | 89 | marginLeft: 15, |
79 | - maxWidth: width-30, | 90 | + marginRight: 15, |
80 | fontSize: 12, | 91 | fontSize: 12, |
81 | color: '#b0b0b0', | 92 | color: '#b0b0b0', |
82 | textAlign: 'left' | 93 | textAlign: 'left' |
@@ -17,8 +17,14 @@ export default class MessageListCellFooter extends Component { | @@ -17,8 +17,14 @@ export default class MessageListCellFooter extends Component { | ||
17 | } | 17 | } |
18 | 18 | ||
19 | render() { | 19 | render() { |
20 | + let {itemData} = this.props; | ||
20 | return( | 21 | return( |
21 | - <TouchableOpacity> | 22 | + <TouchableOpacity |
23 | + onPress={() => { | ||
24 | + this.props.onPressListItem && this.props.onPressListItem(itemData) | ||
25 | + } | ||
26 | + } | ||
27 | + > | ||
22 | <View style={styles.container}> | 28 | <View style={styles.container}> |
23 | <View style={styles.topSeparator} /> | 29 | <View style={styles.topSeparator} /> |
24 | <View style={styles.textContainer}> | 30 | <View style={styles.textContainer}> |
1 | +'use strict'; | ||
2 | + | ||
3 | +import React, {Component} from 'react'; | ||
4 | +import ReactNative, { | ||
5 | + View, | ||
6 | + Text, | ||
7 | + Image, | ||
8 | + StyleSheet, | ||
9 | + Dimensions, | ||
10 | + Platform, | ||
11 | +} from 'react-native'; | ||
12 | + | ||
13 | +import MessageListCellFooter from './MessageListCellFooter' | ||
14 | + | ||
15 | +export default class MessageListOrderCell extends Component { | ||
16 | + constructor(props) { | ||
17 | + super(props); | ||
18 | + } | ||
19 | + | ||
20 | + render() { | ||
21 | + let itemData = this.props.itemData; | ||
22 | + let body = itemData.get('body'); | ||
23 | + let imageUri = body ? body.get('img_url') : 'www.yohobuy.com'; | ||
24 | + let content = body ? body.get('content') : ''; | ||
25 | + imageUri = imageUri.replace('{width}', 46).replace('{height}', 60).replace('{mode}',2); | ||
26 | + return( | ||
27 | + <View style={styles.container}> | ||
28 | + <View style={styles.contentContainer}> | ||
29 | + <Text | ||
30 | + numberOfLines={2} | ||
31 | + style={styles.titleStyle} | ||
32 | + > | ||
33 | + {itemData.get('title')} | ||
34 | + </Text> | ||
35 | + <View style={styles.descStyle}> | ||
36 | + <Image | ||
37 | + style={styles.iconStyle} | ||
38 | + source={{uri: imageUri}} | ||
39 | + /> | ||
40 | + <Text | ||
41 | + style={styles.detail} | ||
42 | + numberOfLines={3} | ||
43 | + > | ||
44 | + {content} | ||
45 | + </Text> | ||
46 | + </View> | ||
47 | + </View> | ||
48 | + <MessageListCellFooter | ||
49 | + onPressListItem={this.props.onPressListItem} | ||
50 | + data={itemData} | ||
51 | + /> | ||
52 | + </View> | ||
53 | + ) | ||
54 | + }; | ||
55 | +} | ||
56 | + | ||
57 | +let {width, height} = Dimensions.get('window'); | ||
58 | + | ||
59 | +let styles = StyleSheet.create({ | ||
60 | + container: { | ||
61 | + backgroundColor: 'white' | ||
62 | + }, | ||
63 | + contentContainer: { | ||
64 | + flex: 1, | ||
65 | + minHeight: 97, | ||
66 | + flexDirection: 'column' | ||
67 | + }, | ||
68 | + titleStyle: { | ||
69 | + marginTop: 15, | ||
70 | + marginLeft: 15, | ||
71 | + fontSize: 14, | ||
72 | + fontWeight: 'bold', | ||
73 | + color: '#444444', | ||
74 | + marginRight: 15, | ||
75 | + }, | ||
76 | + descStyle:{ | ||
77 | + flexDirection: 'row' | ||
78 | + }, | ||
79 | + iconStyle: { | ||
80 | + marginLeft: 15, | ||
81 | + marginTop: 10, | ||
82 | + marginBottom: 10, | ||
83 | + backgroundColor: 'red', | ||
84 | + width: 46, | ||
85 | + height: 60 | ||
86 | + }, | ||
87 | + detail:{ | ||
88 | + marginLeft: 10, | ||
89 | + marginTop: 9, | ||
90 | + fontSize: 12, | ||
91 | + color: '#686868', | ||
92 | + maxWidth: width-15-50-10-20, | ||
93 | + lineHeight: 18, | ||
94 | + } | ||
95 | +}) |
@@ -16,8 +16,12 @@ export default class MessageListSmallIconCell extends Component { | @@ -16,8 +16,12 @@ export default class MessageListSmallIconCell extends Component { | ||
16 | constructor(props) { | 16 | constructor(props) { |
17 | super(props); | 17 | super(props); |
18 | } | 18 | } |
19 | - | ||
20 | render() { | 19 | render() { |
20 | + let itemData = this.props.itemData; | ||
21 | + let body = itemData.get('body'); | ||
22 | + let imageUri = body ? body.get('img_url') : 'www.yohobuy.com'; | ||
23 | + let content = body ? body.get('content') : ''; | ||
24 | + // imageUri = imageUri.replace('{width}', 50).replace('{height}', 50).replace('{mode}',2); | ||
21 | return( | 25 | return( |
22 | <View style={styles.container}> | 26 | <View style={styles.container}> |
23 | <View style={styles.contentContainer}> | 27 | <View style={styles.contentContainer}> |
@@ -25,19 +29,25 @@ export default class MessageListSmallIconCell extends Component { | @@ -25,19 +29,25 @@ export default class MessageListSmallIconCell extends Component { | ||
25 | numberOfLines={2} | 29 | numberOfLines={2} |
26 | style={styles.titleStyle} | 30 | style={styles.titleStyle} |
27 | > | 31 | > |
28 | - 我是标题 | 32 | + {itemData.get('title')} |
29 | </Text> | 33 | </Text> |
30 | <View style={styles.descStyle}> | 34 | <View style={styles.descStyle}> |
31 | - <Image style={styles.iconStyle}/> | 35 | + <Image |
36 | + style={styles.iconStyle} | ||
37 | + source={{uri: imageUri}} | ||
38 | + /> | ||
32 | <Text | 39 | <Text |
33 | style={styles.detail} | 40 | style={styles.detail} |
34 | numberOfLines={3} | 41 | numberOfLines={3} |
35 | > | 42 | > |
36 | - 昂好看的哈萨克就实打实的爱好是的哈按时到家啊爱神的箭卡是爱神的箭卡号是按时打算爱上的空间安徽省安徽电视剧爱上爱神的箭卡是昂贵的航按时给大哥说按施工队几行阿萨德噶好几十个点都干啥 | 43 | + {content} |
37 | </Text> | 44 | </Text> |
38 | </View> | 45 | </View> |
39 | </View> | 46 | </View> |
40 | - <MessageListCellFooter /> | 47 | + <MessageListCellFooter |
48 | + onPressListItem={this.props.onPressListItem} | ||
49 | + itemData={itemData} | ||
50 | + /> | ||
41 | </View> | 51 | </View> |
42 | ) | 52 | ) |
43 | }; | 53 | }; |
@@ -60,7 +70,7 @@ let styles = StyleSheet.create({ | @@ -60,7 +70,7 @@ let styles = StyleSheet.create({ | ||
60 | fontSize: 14, | 70 | fontSize: 14, |
61 | fontWeight: 'bold', | 71 | fontWeight: 'bold', |
62 | color: '#444444', | 72 | color: '#444444', |
63 | - maxWidth: width-30 | 73 | + marginRight: 15, |
64 | }, | 74 | }, |
65 | descStyle:{ | 75 | descStyle:{ |
66 | flexDirection: 'row' | 76 | flexDirection: 'row' |
@@ -69,7 +79,7 @@ let styles = StyleSheet.create({ | @@ -69,7 +79,7 @@ let styles = StyleSheet.create({ | ||
69 | marginLeft: 15, | 79 | marginLeft: 15, |
70 | marginTop: 10, | 80 | marginTop: 10, |
71 | marginBottom: 10, | 81 | marginBottom: 10, |
72 | - backgroundColor: 'red', | 82 | + backgroundColor: 'transparent', |
73 | width: 50, | 83 | width: 50, |
74 | height: 50 | 84 | height: 50 |
75 | }, | 85 | }, |
1 | +'use strict'; | ||
2 | + | ||
3 | +import React, {Component} from 'react'; | ||
4 | +import ReactNative, { | ||
5 | + View, | ||
6 | + Text, | ||
7 | + Image, | ||
8 | + StyleSheet, | ||
9 | + Dimensions, | ||
10 | + Platform, | ||
11 | +} from 'react-native'; | ||
12 | + | ||
13 | +export default class MessageListTextCell extends Component { | ||
14 | + constructor(props) { | ||
15 | + super(props); | ||
16 | + } | ||
17 | + | ||
18 | + render() { | ||
19 | + let itemData = this.props.itemData; | ||
20 | + let body = itemData.get('body'); | ||
21 | + let content = body ? body.get('content') : ''; | ||
22 | + return( | ||
23 | + <View style={styles.container}> | ||
24 | + <Text | ||
25 | + numberOfLines={2} | ||
26 | + style={styles.titleStyle} | ||
27 | + > | ||
28 | + {itemData.get('title')} | ||
29 | + </Text> | ||
30 | + <Text | ||
31 | + style={styles.detail} | ||
32 | + > | ||
33 | + {content} | ||
34 | + </Text> | ||
35 | + <View style={styles.separator}/> | ||
36 | + </View> | ||
37 | + ) | ||
38 | + } | ||
39 | +} | ||
40 | + | ||
41 | +let {width, height} = Dimensions.get('window'); | ||
42 | + | ||
43 | +let styles = StyleSheet.create({ | ||
44 | + container: { | ||
45 | + width, | ||
46 | + backgroundColor: 'white' | ||
47 | + }, | ||
48 | + titleStyle: { | ||
49 | + marginLeft: 15, | ||
50 | + marginRight: 15, | ||
51 | + marginTop: 15, | ||
52 | + fontSize: 14, | ||
53 | + fontWeight: 'bold', | ||
54 | + color: '#444444', | ||
55 | + }, | ||
56 | + detail: { | ||
57 | + marginTop: 10, | ||
58 | + marginBottom: 15, | ||
59 | + marginLeft: 15, | ||
60 | + marginRight: 15, | ||
61 | + fontSize: 12, | ||
62 | + color: '#b0b0b0', | ||
63 | + textAlign: 'left' | ||
64 | + }, | ||
65 | + separator: { | ||
66 | + height: 0.5, | ||
67 | + width, | ||
68 | + backgroundColor: '#e0e0e0' | ||
69 | + } | ||
70 | +}) |
@@ -15,6 +15,7 @@ export default class MessageCell extends Component { | @@ -15,6 +15,7 @@ export default class MessageCell extends Component { | ||
15 | constructor(props) { | 15 | constructor(props) { |
16 | super(props); | 16 | super(props); |
17 | this.renderUnreaderMsg = this.renderUnreaderMsg.bind(this); | 17 | this.renderUnreaderMsg = this.renderUnreaderMsg.bind(this); |
18 | + this.emptyText = this.emptyText.bind(this); | ||
18 | } | 19 | } |
19 | 20 | ||
20 | renderUnreaderMsg(rowData) { | 21 | renderUnreaderMsg(rowData) { |
@@ -32,6 +33,29 @@ export default class MessageCell extends Component { | @@ -32,6 +33,29 @@ export default class MessageCell extends Component { | ||
32 | ); | 33 | ); |
33 | } | 34 | } |
34 | 35 | ||
36 | + emptyText(rowData){ | ||
37 | + let text = ''; | ||
38 | + let content = rowData.get('content'); | ||
39 | + let isEmpty = content ? false : true; | ||
40 | + | ||
41 | + switch (rowData.get('id')) { | ||
42 | + case 1: | ||
43 | + text = isEmpty ? '会员等级变更提醒、会员生日福利' : content; | ||
44 | + break; | ||
45 | + case 2: | ||
46 | + text = isEmpty ? '新注册用户提示新人专享优惠券信息' : content; | ||
47 | + break; | ||
48 | + case 3: | ||
49 | + text = isEmpty ? '没有收到任何关于你的消息' : content; | ||
50 | + break; | ||
51 | + case 4: | ||
52 | + text = isEmpty ? '没有收到任何系统消息' : content; | ||
53 | + break; | ||
54 | + default: | ||
55 | + } | ||
56 | + return text; | ||
57 | + } | ||
58 | + | ||
35 | render() { | 59 | render() { |
36 | let {data, rowID} = this.props; | 60 | let {data, rowID} = this.props; |
37 | let images = [require('../../images/message_vip_ic.png'), | 61 | let images = [require('../../images/message_vip_ic.png'), |
@@ -62,8 +86,10 @@ export default class MessageCell extends Component { | @@ -62,8 +86,10 @@ export default class MessageCell extends Component { | ||
62 | {data.get('createTime')} | 86 | {data.get('createTime')} |
63 | </Text> | 87 | </Text> |
64 | </View> | 88 | </View> |
65 | - <Text style={styles.subTitle}> | ||
66 | - {data.get('content')} | 89 | + <Text |
90 | + numberOfLines={1} | ||
91 | + style={styles.subTitle}> | ||
92 | + {this.emptyText(data)} | ||
67 | </Text> | 93 | </Text> |
68 | </View> | 94 | </View> |
69 | </View> | 95 | </View> |
@@ -71,6 +97,7 @@ export default class MessageCell extends Component { | @@ -71,6 +97,7 @@ export default class MessageCell extends Component { | ||
71 | ); | 97 | ); |
72 | } | 98 | } |
73 | } | 99 | } |
100 | +// {data.get('content')} | ||
74 | 101 | ||
75 | let {width, height} = Dimensions.get('window'); | 102 | let {width, height} = Dimensions.get('window'); |
76 | 103 |
@@ -47,6 +47,8 @@ class MessageListContainer extends Component { | @@ -47,6 +47,8 @@ class MessageListContainer extends Component { | ||
47 | constructor(props) { | 47 | constructor(props) { |
48 | super(props); | 48 | super(props); |
49 | this.onEndReached = this.onEndReached.bind(this); | 49 | this.onEndReached = this.onEndReached.bind(this); |
50 | + this.onPressListItem = this.onPressListItem.bind(this); | ||
51 | + this.onPressEmptyItem = this.onPressEmptyItem.bind(this); | ||
50 | } | 52 | } |
51 | 53 | ||
52 | componentDidMount() { | 54 | componentDidMount() { |
@@ -61,6 +63,14 @@ class MessageListContainer extends Component { | @@ -61,6 +63,14 @@ class MessageListContainer extends Component { | ||
61 | this.props.actions.messageList(); | 63 | this.props.actions.messageList(); |
62 | } | 64 | } |
63 | 65 | ||
66 | + onPressListItem(item) { | ||
67 | + NativeModules.YH_MessageHelper.messagePush(item); | ||
68 | + } | ||
69 | + | ||
70 | + onPressEmptyItem() { | ||
71 | + NativeModules.YH_MessageHelper.jumpNew(); | ||
72 | + } | ||
73 | + | ||
64 | render() { | 74 | render() { |
65 | let {list} = this.props; | 75 | let {list} = this.props; |
66 | return ( | 76 | return ( |
@@ -68,6 +78,8 @@ class MessageListContainer extends Component { | @@ -68,6 +78,8 @@ class MessageListContainer extends Component { | ||
68 | <MessageList | 78 | <MessageList |
69 | data={list} | 79 | data={list} |
70 | onEndReached={this.onEndReached} | 80 | onEndReached={this.onEndReached} |
81 | + onPressListItem={this.onPressListItem} | ||
82 | + onPressEmptyItem={this.onPressEmptyItem} | ||
71 | /> | 83 | /> |
72 | </View> | 84 | </View> |
73 | ); | 85 | ); |
js/message/images/message_coupon_ic@2x.png
0 → 100644
2.28 KB
js/message/images/message_coupon_ic@3x.png
0 → 100644
4.85 KB
js/message/images/message_empty_ic@2x.png
0 → 100644
4.29 KB
js/message/images/message_empty_ic@3x.png
0 → 100644
6.26 KB
2.58 KB
7.36 KB
4.67 KB
11.5 KB
@@ -63,6 +63,10 @@ export function messageList() { | @@ -63,6 +63,10 @@ export function messageList() { | ||
63 | let newList = [...oldList, ...payload.list]; | 63 | let newList = [...oldList, ...payload.list]; |
64 | payload.list = newList; | 64 | payload.list = newList; |
65 | } | 65 | } |
66 | + if (payload.currentPage == 1 && payload.list.length == 0) { | ||
67 | + payload.shouldShowEmpty = true; | ||
68 | + } | ||
69 | + | ||
66 | dispatch(messageListSuccess(payload)); | 70 | dispatch(messageListSuccess(payload)); |
67 | }) | 71 | }) |
68 | .catch(error => { | 72 | .catch(error => { |
@@ -82,7 +86,7 @@ export function messageList() { | @@ -82,7 +86,7 @@ export function messageList() { | ||
82 | 86 | ||
83 | function parseMessageList(json) { | 87 | function parseMessageList(json) { |
84 | let currentPage = json && json.page ? json.page : 1; | 88 | let currentPage = json && json.page ? json.page : 1; |
85 | - let pageCount = json && json.total_page ? json.total_page : 0; | 89 | + let pageCount = json && json.page_total ? json.page_total : 0; |
86 | let total = json && json.total ? json.total : 0; | 90 | let total = json && json.total ? json.total : 0; |
87 | 91 | ||
88 | let list = json && json.list ? json.list : []; | 92 | let list = json && json.list ? json.list : []; |
@@ -13,6 +13,7 @@ let InitialState = Record({ | @@ -13,6 +13,7 @@ let InitialState = Record({ | ||
13 | pageSize: 60, | 13 | pageSize: 60, |
14 | total: 0, | 14 | total: 0, |
15 | endReached: false, | 15 | endReached: false, |
16 | + shouldShowEmpty: false, | ||
16 | }); | 17 | }); |
17 | 18 | ||
18 | export default InitialState; | 19 | export default InitialState; |
@@ -32,6 +32,7 @@ export default function listReducer(state=initialState, action) { | @@ -32,6 +32,7 @@ export default function listReducer(state=initialState, action) { | ||
32 | pageCount, | 32 | pageCount, |
33 | total, | 33 | total, |
34 | endReached, | 34 | endReached, |
35 | + shouldShowEmpty, | ||
35 | } = action.payload; | 36 | } = action.payload; |
36 | 37 | ||
37 | let newState = state.set('isFetching', false) | 38 | let newState = state.set('isFetching', false) |
@@ -40,14 +41,16 @@ export default function listReducer(state=initialState, action) { | @@ -40,14 +41,16 @@ export default function listReducer(state=initialState, action) { | ||
40 | .set('currentPage', currentPage) | 41 | .set('currentPage', currentPage) |
41 | .set('pageCount', pageCount) | 42 | .set('pageCount', pageCount) |
42 | .set('total', total) | 43 | .set('total', total) |
43 | - .set('endReached', endReached); | 44 | + .set('endReached', endReached) |
45 | + .set('shouldShowEmpty', shouldShowEmpty); | ||
44 | 46 | ||
45 | return newState; | 47 | return newState; |
46 | } | 48 | } |
47 | 49 | ||
48 | case MESSAGE_LIST_FAILURE: { | 50 | case MESSAGE_LIST_FAILURE: { |
49 | return state.set('isFetching', false) | 51 | return state.set('isFetching', false) |
50 | - .set('error', action.payload); | 52 | + .set('error', action.payload) |
53 | + .set('shouldShowEmpty', true); | ||
51 | } | 54 | } |
52 | 55 | ||
53 | } | 56 | } |
@@ -4,28 +4,28 @@ import Immutable, {Record, List, Map} from 'immutable'; | @@ -4,28 +4,28 @@ import Immutable, {Record, List, Map} from 'immutable'; | ||
4 | 4 | ||
5 | let defaults = Immutable.fromJS([ | 5 | let defaults = Immutable.fromJS([ |
6 | { | 6 | { |
7 | - id: '1', | 7 | + id: 1, |
8 | inboxCatName: '会员信息', | 8 | inboxCatName: '会员信息', |
9 | content: '会员等级变更提醒、会员生日福利', | 9 | content: '会员等级变更提醒、会员生日福利', |
10 | unReadCount:0, | 10 | unReadCount:0, |
11 | createTime:'' | 11 | createTime:'' |
12 | }, | 12 | }, |
13 | { | 13 | { |
14 | - id: '2', | 14 | + id: 2, |
15 | inboxCatName: '我的资产', | 15 | inboxCatName: '我的资产', |
16 | content: '新注册用户提示新人专享优惠券信息', | 16 | content: '新注册用户提示新人专享优惠券信息', |
17 | unReadCount:0, | 17 | unReadCount:0, |
18 | createTime:'' | 18 | createTime:'' |
19 | }, | 19 | }, |
20 | { | 20 | { |
21 | - id: '3', | 21 | + id: 3, |
22 | inboxCatName: '客户服务', | 22 | inboxCatName: '客户服务', |
23 | content: '没有收到任何关于你的消息', | 23 | content: '没有收到任何关于你的消息', |
24 | unReadCount:0, | 24 | unReadCount:0, |
25 | createTime:'' | 25 | createTime:'' |
26 | }, | 26 | }, |
27 | { | 27 | { |
28 | - id: '4', | 28 | + id: 4, |
29 | inboxCatName: '其他', | 29 | inboxCatName: '其他', |
30 | content: '没有收到任何系统给消息', | 30 | content: '没有收到任何系统给消息', |
31 | unReadCount:0, | 31 | unReadCount:0, |
@@ -21,7 +21,7 @@ export default function messageReducer(state=initialState, action) { | @@ -21,7 +21,7 @@ export default function messageReducer(state=initialState, action) { | ||
21 | 21 | ||
22 | case LATEST_MESSAGE_SUCCESS: { | 22 | case LATEST_MESSAGE_SUCCESS: { |
23 | return state.setIn(['latest', 'isFetching'], false) | 23 | return state.setIn(['latest', 'isFetching'], false) |
24 | - .setIn(['latest', 'data'], Immutable.fromJS(action.payload)) | 24 | + .setIn(['latest', 'data'], Immutable.fromJS(action.payload.list)) |
25 | .setIn(['latest', 'error'], null); | 25 | .setIn(['latest', 'error'], null); |
26 | } | 26 | } |
27 | 27 |
-
Please register or login to post a comment