Authored by 于良

Merge branch 'local' into develop

@@ -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,8 +43,7 @@ export function setChannel(channel) { @@ -42,8 +43,7 @@ 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) => { 46 + let json = new RouterService().parseUrl(inputUrl);
47 let {action, params} = json; 47 let {action, params} = json;
48 let {param, share, shareparam, title, url} = params; 48 let {param, share, shareparam, title, url} = params;
49 49
@@ -55,7 +55,7 @@ export function goAction(inputUrl) { @@ -55,7 +55,7 @@ export function goAction(inputUrl) {
55 } 55 }
56 56
57 } else if (action == 'go.comm.postdetail') { 57 } else if (action == 'go.comm.postdetail') {
58 - let id = params && params.postid ? params.postid : 0; 58 + let id = params && params.postId ? params.postId : 0;
59 if (id != 0) { 59 if (id != 0) {
60 dispatch(goToPost(id)); 60 dispatch(goToPost(id));
61 } 61 }
@@ -76,9 +76,5 @@ export function goAction(inputUrl) { @@ -76,9 +76,5 @@ export function goAction(inputUrl) {
76 } 76 }
77 ReactNative.NativeModules.YH_CommunityHelper.displayProductDetail({productSkn, tag}); 77 ReactNative.NativeModules.YH_CommunityHelper.displayProductDetail({productSkn, tag});
78 } 78 }
79 - })  
80 - .catch(error => {  
81 - __DEV__ && console.log(error);  
82 - });  
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