Showing
5 changed files
with
74 additions
and
59 deletions
@@ -60,7 +60,7 @@ export default class ListCell extends React.Component { | @@ -60,7 +60,7 @@ export default class ListCell extends React.Component { | ||
60 | let data = this.props.data.toJS(); | 60 | let data = this.props.data.toJS(); |
61 | let {author, timeago, isOwner, isTop, isLike, title, desc, thumbs, section, commentCount, likeCount} = data; | 61 | let {author, timeago, isOwner, isTop, isLike, title, desc, thumbs, section, commentCount, likeCount} = data; |
62 | let likeImage = isLike ? require('../../images/home/like.png') : require('../../images/home/unlike.png'); | 62 | let likeImage = isLike ? require('../../images/home/like.png') : require('../../images/home/unlike.png'); |
63 | - | 63 | + |
64 | return ( | 64 | return ( |
65 | <TouchableOpacity | 65 | <TouchableOpacity |
66 | style={styles.row} | 66 | style={styles.row} |
@@ -82,16 +82,9 @@ export default class ListCell extends React.Component { | @@ -82,16 +82,9 @@ export default class ListCell extends React.Component { | ||
82 | /> | 82 | /> |
83 | {isTop ? <Text style={styles.topTag}>置顶</Text> : null} | 83 | {isTop ? <Text style={styles.topTag}>置顶</Text> : null} |
84 | </View> | 84 | </View> |
85 | - <Text style={styles.title} numberOfLines={2}> | ||
86 | - {title} | ||
87 | - </Text> | ||
88 | - <Text style={styles.desc} numberOfLines={2}> | ||
89 | - {desc} | ||
90 | - </Text> | ||
91 | - <Thumbs | ||
92 | - style={styles.thumbs} | ||
93 | - data={thumbs} | ||
94 | - /> | 85 | + {title ? <Text style={styles.title} numberOfLines={2}>{title}</Text> : null} |
86 | + {desc ? <Text style={styles.desc} numberOfLines={2}>{desc}</Text> : null} | ||
87 | + {thumbs.length > 0 ? <Thumbs style={styles.thumbs} data={thumbs}/> : null} | ||
95 | <View style={styles.bottom}> | 88 | <View style={styles.bottom}> |
96 | <SectionItem | 89 | <SectionItem |
97 | name={section.name} | 90 | name={section.name} |
@@ -155,11 +148,11 @@ let styles = StyleSheet.create({ | @@ -155,11 +148,11 @@ let styles = StyleSheet.create({ | ||
155 | }, | 148 | }, |
156 | thumbs: { | 149 | thumbs: { |
157 | marginTop: 15, | 150 | marginTop: 15, |
158 | - marginBottom: 15, | ||
159 | }, | 151 | }, |
160 | bottom: { | 152 | bottom: { |
161 | flexDirection: 'row', | 153 | flexDirection: 'row', |
162 | justifyContent: 'space-between', | 154 | justifyContent: 'space-between', |
155 | + marginTop: 15, | ||
163 | marginBottom: 15, | 156 | marginBottom: 15, |
164 | }, | 157 | }, |
165 | buttonContainer: { | 158 | buttonContainer: { |
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | 8 | ||
9 | import ReactNative from 'react-native'; | 9 | import ReactNative from 'react-native'; |
10 | import {Actions} from 'react-native-router-flux'; | 10 | import {Actions} from 'react-native-router-flux'; |
11 | +import Immutable, {Map} from 'immutable'; | ||
11 | import AppService from '../../services/AppService'; | 12 | import AppService from '../../services/AppService'; |
12 | import RouterService from '../../services/RouterService'; | 13 | import RouterService from '../../services/RouterService'; |
13 | import {goToSection, goToPost} from '../home/homeActions'; | 14 | import {goToSection, goToPost} from '../home/homeActions'; |
@@ -42,43 +43,38 @@ export function setChannel(channel) { | @@ -42,43 +43,38 @@ export function setChannel(channel) { | ||
42 | 43 | ||
43 | export function goAction(inputUrl) { | 44 | export function goAction(inputUrl) { |
44 | return (dispatch, getState) => { | 45 | return (dispatch, getState) => { |
45 | - return new RouterService().parseUrl(inputUrl) | ||
46 | - .then((json) => { | ||
47 | - let {action, params} = json; | ||
48 | - let {param, share, shareparam, title, url} = params; | 46 | + let json = new RouterService().parseUrl(inputUrl); |
47 | + let {action, params} = json; | ||
48 | + let {param, share, shareparam, title, url} = params; | ||
49 | 49 | ||
50 | - if (action == 'go.comm.forum') { | ||
51 | - let id = params && params.forumid ? params.forumid : 0; | ||
52 | - let name = ''; | ||
53 | - if (id != 0) { | ||
54 | - dispatch(goToSection({id, name})); | ||
55 | - } | 50 | + if (action == 'go.comm.forum') { |
51 | + let id = params && params.forumid ? params.forumid : 0; | ||
52 | + let name = ''; | ||
53 | + if (id != 0) { | ||
54 | + dispatch(goToSection({id, name})); | ||
55 | + } | ||
56 | 56 | ||
57 | - } else if (action == 'go.comm.postdetail') { | ||
58 | - let id = params && params.postid ? params.postid : 0; | ||
59 | - if (id != 0) { | ||
60 | - dispatch(goToPost(id)); | ||
61 | - } | 57 | + } else if (action == 'go.comm.postdetail') { |
58 | + let id = params && params.postId ? params.postId : 0; | ||
59 | + if (id != 0) { | ||
60 | + dispatch(goToPost(id)); | ||
61 | + } | ||
62 | 62 | ||
63 | - } else if (action == 'go.comm.h5') { | ||
64 | - let title = params.title ? params.title : ''; | ||
65 | - let url = params.url ? params.url : ''; | ||
66 | - if (!url || url.length == 0) { | ||
67 | - return; | ||
68 | - } | ||
69 | - ReactNative.NativeModules.YH_CommunityHelper.displayH5({url, title}); | ||
70 | - } else if (action == 'go.comm.productDetail') { | ||
71 | - let productSkn = params.product_skn ? params.product_skn : ''; | ||
72 | - productSkn = productSkn + ''; | ||
73 | - let tag = params.tag ? params.tag : ''; | ||
74 | - if (!productSkn || productSkn.length == 0) { | ||
75 | - return; | ||
76 | - } | ||
77 | - ReactNative.NativeModules.YH_CommunityHelper.displayProductDetail({productSkn, tag}); | ||
78 | - } | ||
79 | - }) | ||
80 | - .catch(error => { | ||
81 | - __DEV__ && console.log(error); | ||
82 | - }); | 63 | + } else if (action == 'go.comm.h5') { |
64 | + let title = params.title ? params.title : ''; | ||
65 | + let url = params.url ? params.url : ''; | ||
66 | + if (!url || url.length == 0) { | ||
67 | + return; | ||
68 | + } | ||
69 | + ReactNative.NativeModules.YH_CommunityHelper.displayH5({url, title}); | ||
70 | + } else if (action == 'go.comm.productDetail') { | ||
71 | + let productSkn = params.product_skn ? params.product_skn : ''; | ||
72 | + productSkn = productSkn + ''; | ||
73 | + let tag = params.tag ? params.tag : ''; | ||
74 | + if (!productSkn || productSkn.length == 0) { | ||
75 | + return; | ||
76 | + } | ||
77 | + ReactNative.NativeModules.YH_CommunityHelper.displayProductDetail({productSkn, tag}); | ||
78 | + } | ||
83 | }; | 79 | }; |
84 | } | 80 | } |
@@ -277,14 +277,6 @@ export function resetErrorCount() { | @@ -277,14 +277,6 @@ export function resetErrorCount() { | ||
277 | }; | 277 | }; |
278 | } | 278 | } |
279 | 279 | ||
280 | -export function goToSection(section) { | ||
281 | - Actions.Section(); | ||
282 | - return { | ||
283 | - type: GO_TO_SECTION, | ||
284 | - payload: section, | ||
285 | - }; | ||
286 | -} | ||
287 | - | ||
288 | export function goToUser(user, previousScene) { | 280 | export function goToUser(user, previousScene) { |
289 | Actions.User(); | 281 | Actions.User(); |
290 | return { | 282 | return { |
@@ -8,7 +8,7 @@ export default class RouterService { | @@ -8,7 +8,7 @@ export default class RouterService { | ||
8 | this.api = new Request(); | 8 | this.api = new Request(); |
9 | } | 9 | } |
10 | 10 | ||
11 | - parseUrl(url) { | 11 | + parseUrlWithPromise(url) { |
12 | return new Promise((resolve, reject) => { | 12 | return new Promise((resolve, reject) => { |
13 | if (!url) { | 13 | if (!url) { |
14 | reject('Illegal url: ' + url); | 14 | reject('Illegal url: ' + url); |
@@ -39,4 +39,34 @@ export default class RouterService { | @@ -39,4 +39,34 @@ export default class RouterService { | ||
39 | } | 39 | } |
40 | }); | 40 | }); |
41 | } | 41 | } |
42 | + | ||
43 | + parseUrl(url) { | ||
44 | + if (!url) { | ||
45 | + __DEV__ && console.log('Illegal url: ' + url); | ||
46 | + } | ||
47 | + | ||
48 | + // url解码 | ||
49 | + url = decodeURI(url); | ||
50 | + // 处理半角等号和全角等号 | ||
51 | + let mark = 'yohobuy='; | ||
52 | + let markIndex = url.indexOf(mark); | ||
53 | + if (markIndex == -1) { | ||
54 | + mark = 'yohobuy='; | ||
55 | + markIndex = url.indexOf(mark); | ||
56 | + } | ||
57 | + | ||
58 | + if (markIndex == -1) { | ||
59 | + __DEV__ && console.log('Can not find url rule: ' + url); | ||
60 | + } | ||
61 | + | ||
62 | + let rule = url.substring(markIndex + mark.length); | ||
63 | + | ||
64 | + let json; | ||
65 | + try { | ||
66 | + json = JSON.parse(rule); | ||
67 | + return json; | ||
68 | + } catch (e) { | ||
69 | + __DEV__ && console.log('Parse json string fail: ' + e); | ||
70 | + } | ||
71 | + } | ||
42 | } | 72 | } |
@@ -7,12 +7,16 @@ export default function timeago(timestamp) { | @@ -7,12 +7,16 @@ export default function timeago(timestamp) { | ||
7 | let timeagoStr = TA().format(timestamp, 'zh_CN'); | 7 | let timeagoStr = TA().format(timestamp, 'zh_CN'); |
8 | 8 | ||
9 | let isNSecondsAgo = timeagoStr.indexOf('秒'); | 9 | let isNSecondsAgo = timeagoStr.indexOf('秒'); |
10 | - if (timeagoStr === '刚刚' || timeagoStr === '1分钟前' || isNSecondsAgo !== -1) { | ||
11 | - return '刚刚'; | 10 | + if (timeagoStr === '刚刚' || isNSecondsAgo !== -1) { |
11 | + return '1分钟前'; | ||
12 | + } | ||
13 | + | ||
14 | + if (timeagoStr === '1天前') { | ||
15 | + return '昨天'; | ||
12 | } | 16 | } |
13 | 17 | ||
14 | let isNDaysAgo = timeagoStr.indexOf('天'); | 18 | let isNDaysAgo = timeagoStr.indexOf('天'); |
15 | - if (timeagoStr === '1天前' || isNDaysAgo !== -1) { | 19 | + if (isNDaysAgo !== -1) { |
16 | return moment(timestamp, 'x').format('MM.DD.YYYY'); | 20 | return moment(timestamp, 'x').format('MM.DD.YYYY'); |
17 | } | 21 | } |
18 | 22 |
-
Please register or login to post a comment