Authored by 于良

Merge branch 'local' into develop

... ... @@ -60,7 +60,7 @@ export default class ListCell extends React.Component {
let data = this.props.data.toJS();
let {author, timeago, isOwner, isTop, isLike, title, desc, thumbs, section, commentCount, likeCount} = data;
let likeImage = isLike ? require('../../images/home/like.png') : require('../../images/home/unlike.png');
return (
<TouchableOpacity
style={styles.row}
... ... @@ -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,43 +43,38 @@ export function setChannel(channel) {
export function goAction(inputUrl) {
return (dispatch, getState) => {
return new RouterService().parseUrl(inputUrl)
.then((json) => {
let {action, params} = json;
let {param, share, shareparam, title, url} = params;
let json = new RouterService().parseUrl(inputUrl);
let {action, params} = json;
let {param, share, shareparam, title, url} = params;
if (action == 'go.comm.forum') {
let id = params && params.forumid ? params.forumid : 0;
let name = '';
if (id != 0) {
dispatch(goToSection({id, name}));
}
if (action == 'go.comm.forum') {
let id = params && params.forumid ? params.forumid : 0;
let name = '';
if (id != 0) {
dispatch(goToSection({id, name}));
}
} else if (action == 'go.comm.postdetail') {
let id = params && params.postid ? params.postid : 0;
if (id != 0) {
dispatch(goToPost(id));
}
} else if (action == 'go.comm.postdetail') {
let id = params && params.postId ? params.postId : 0;
if (id != 0) {
dispatch(goToPost(id));
}
} else if (action == 'go.comm.h5') {
let title = params.title ? params.title : '';
let url = params.url ? params.url : '';
if (!url || url.length == 0) {
return;
}
ReactNative.NativeModules.YH_CommunityHelper.displayH5({url, title});
} else if (action == 'go.comm.productDetail') {
let productSkn = params.product_skn ? params.product_skn : '';
productSkn = productSkn + '';
let tag = params.tag ? params.tag : '';
if (!productSkn || productSkn.length == 0) {
return;
}
ReactNative.NativeModules.YH_CommunityHelper.displayProductDetail({productSkn, tag});
}
})
.catch(error => {
__DEV__ && console.log(error);
});
} else if (action == 'go.comm.h5') {
let title = params.title ? params.title : '';
let url = params.url ? params.url : '';
if (!url || url.length == 0) {
return;
}
ReactNative.NativeModules.YH_CommunityHelper.displayH5({url, title});
} else if (action == 'go.comm.productDetail') {
let productSkn = params.product_skn ? params.product_skn : '';
productSkn = productSkn + '';
let tag = params.tag ? params.tag : '';
if (!productSkn || productSkn.length == 0) {
return;
}
ReactNative.NativeModules.YH_CommunityHelper.displayProductDetail({productSkn, tag});
}
};
}
... ...
... ... @@ -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');
}
... ...