Authored by 于良

Merge branch 'local' into develop

... ... @@ -82,16 +82,9 @@ export default class ListCell extends React.Component {
/>
{isTop ? <Text style={styles.topTag}>置顶</Text> : null}
</View>
<Text style={styles.title} numberOfLines={2}>
{title}
</Text>
<Text style={styles.desc} numberOfLines={2}>
{desc}
</Text>
<Thumbs
style={styles.thumbs}
data={thumbs}
/>
{title ? <Text style={styles.title} numberOfLines={2}>{title}</Text> : null}
{desc ? <Text style={styles.desc} numberOfLines={2}>{desc}</Text> : null}
{thumbs.length > 0 ? <Thumbs style={styles.thumbs} data={thumbs}/> : null}
<View style={styles.bottom}>
<SectionItem
name={section.name}
... ... @@ -155,11 +148,11 @@ let styles = StyleSheet.create({
},
thumbs: {
marginTop: 15,
marginBottom: 15,
},
bottom: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 15,
marginBottom: 15,
},
buttonContainer: {
... ...
... ... @@ -8,6 +8,7 @@
import ReactNative from 'react-native';
import {Actions} from 'react-native-router-flux';
import Immutable, {Map} from 'immutable';
import AppService from '../../services/AppService';
import RouterService from '../../services/RouterService';
import {goToSection, goToPost} from '../home/homeActions';
... ... @@ -42,8 +43,7 @@ export function setChannel(channel) {
export function goAction(inputUrl) {
return (dispatch, getState) => {
return new RouterService().parseUrl(inputUrl)
.then((json) => {
let json = new RouterService().parseUrl(inputUrl);
let {action, params} = json;
let {param, share, shareparam, title, url} = params;
... ... @@ -55,7 +55,7 @@ export function goAction(inputUrl) {
}
} else if (action == 'go.comm.postdetail') {
let id = params && params.postid ? params.postid : 0;
let id = params && params.postId ? params.postId : 0;
if (id != 0) {
dispatch(goToPost(id));
}
... ... @@ -76,9 +76,5 @@ export function goAction(inputUrl) {
}
ReactNative.NativeModules.YH_CommunityHelper.displayProductDetail({productSkn, tag});
}
})
.catch(error => {
__DEV__ && console.log(error);
});
};
}
... ...
... ... @@ -277,14 +277,6 @@ export function resetErrorCount() {
};
}
export function goToSection(section) {
Actions.Section();
return {
type: GO_TO_SECTION,
payload: section,
};
}
export function goToUser(user, previousScene) {
Actions.User();
return {
... ...
... ... @@ -8,7 +8,7 @@ export default class RouterService {
this.api = new Request();
}
parseUrl(url) {
parseUrlWithPromise(url) {
return new Promise((resolve, reject) => {
if (!url) {
reject('Illegal url: ' + url);
... ... @@ -39,4 +39,34 @@ export default class RouterService {
}
});
}
parseUrl(url) {
if (!url) {
__DEV__ && console.log('Illegal url: ' + url);
}
// url解码
url = decodeURI(url);
// 处理半角等号和全角等号
let mark = 'yohobuy=';
let markIndex = url.indexOf(mark);
if (markIndex == -1) {
mark = 'yohobuy=';
markIndex = url.indexOf(mark);
}
if (markIndex == -1) {
__DEV__ && console.log('Can not find url rule: ' + url);
}
let rule = url.substring(markIndex + mark.length);
let json;
try {
json = JSON.parse(rule);
return json;
} catch (e) {
__DEV__ && console.log('Parse json string fail: ' + e);
}
}
}
... ...
... ... @@ -7,12 +7,16 @@ export default function timeago(timestamp) {
let timeagoStr = TA().format(timestamp, 'zh_CN');
let isNSecondsAgo = timeagoStr.indexOf('秒');
if (timeagoStr === '刚刚' || timeagoStr === '1分钟前' || isNSecondsAgo !== -1) {
return '刚刚';
if (timeagoStr === '刚刚' || isNSecondsAgo !== -1) {
return '1分钟前';
}
if (timeagoStr === '1天前') {
return '昨天';
}
let isNDaysAgo = timeagoStr.indexOf('天');
if (timeagoStr === '1天前' || isNDaysAgo !== -1) {
if (isNDaysAgo !== -1) {
return moment(timestamp, 'x').format('MM.DD.YYYY');
}
... ...