Authored by 王钱钧

Merge branch 'develop' of http://git.yoho.cn/mobile/YH_RNComponent into develop

... ... @@ -22,6 +22,10 @@ export default class SlicedImage extends React.Component {
this.mode = 1;
}
setNativeProps(nativeProps) {
this._root.setNativeProps(nativeProps);
}
_generateImageUrl(src) {
let style = StyleSheet.flatten(this.props.style);
let {width, height} = style;
... ... @@ -55,12 +59,12 @@ export default class SlicedImage extends React.Component {
if (source && source.uri && this._isRemoteImageSrc(source.uri)) {
let uri = this._generateImageUrl(source.uri);
return (
<Image {...this.props} source={{uri}}/>
<Image ref={component => this._root = component} {...this.props} source={{uri}}/>
);
}
return (
<Image {...this.props}/>
<Image ref={component => this._root = component} {...this.props}/>
);
}
}
... ...
... ... @@ -338,18 +338,6 @@ export default function community(platform) {
state.dispatch(startEditPost(state.getPostingState()));
},
pushPostingWithUID(uid) {
new PostingService().getPostUser(uid).then(json => {
if (json.forbidSpeaking === 'Y') {
Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~');
} else {
Actions.Posting();
}
}).catch(error => {
Actions.Posting();
});
},
/*
* 自定义导航push动画
*
... ...
... ... @@ -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: {
... ...
... ... @@ -54,13 +54,14 @@ export default class SuperMan extends React.Component {
render() {
let avatarContainerStyle = this.props.uid > 0 ? styles.avatarContainer : null;
let avatarStyle = this.props.uid > 0 ? styles.avatarBorder : null;
let defaultSource = this.props.uid > 0 ? null : require('../../images/home/superman.png');
return (
<View style={[styles.container, this.props.fly]}>
<TouchableOpacity activeOpacity={0.8} onPress={() => {
this.props.onSaveingTheWorld && this.props.onSaveingTheWorld();
}}>
<View style={avatarContainerStyle}>
<SlicedImage style={[styles.avatar, avatarStyle]} source={{uri: this.props.avatar}} resizeMode={'cover'} defaultSource={require('../../images/home/superman.png')}/>
<SlicedImage style={[styles.avatar, avatarStyle]} source={{uri: this.props.avatar}} resizeMode={'cover'} defaultSource={defaultSource}/>
</View>
{this.renderText()}
{this.renderMsgCount()}
... ...
... ... @@ -80,7 +80,6 @@ export default class UploadProgress extends React.Component {
}
return (
<Animated.View style={[styles.container, {opacity: this.state.fadeAnim,}]}>
<Image
style={styles.image}
... ... @@ -99,7 +98,7 @@ export default class UploadProgress extends React.Component {
style={styles.bar}
/>
{this._renderButton(uploadState)}
</Animated.View >
</Animated.View>
);
}
... ...
... ... @@ -3,6 +3,7 @@
import React from 'react';
import ReactNative from 'react-native';
import ImmutablePropTypes from 'react-immutable-proptypes';
import SlicedImage from '../../../common/components/SlicedImage';
const {
View,
... ... @@ -44,7 +45,7 @@ export default class UserCenterTop extends React.Component {
this.props.onPressBackgroundImg && this.props.onPressBackgroundImg();
}}
>
<Image
<SlicedImage
style={styles.backgroundImage}
defaultSource={require('../../images/user-bg.png')}
source={{uri:backgroundImage}}
... ... @@ -54,12 +55,11 @@ export default class UserCenterTop extends React.Component {
this.props.onPressUserAvatar && this.props.onPressUserAvatar();
}}
>
<Image
<SlicedImage
style={styles.avatarImage}
defaultSource={require('../../images/avatar-default.png')}
source={{uri:avatar}}
>
</Image>
/>
</TouchableOpacity>
<Text
style={styles.name}
... ... @@ -72,7 +72,7 @@ export default class UserCenterTop extends React.Component {
>
{sign}
</Text>
</Image>
</SlicedImage>
</TouchableHighlight>
</View>
);
... ...
... ... @@ -64,14 +64,16 @@ class PostingContainer extends Component{
}
componentDidMount() {
if (this.props.section.name.length && this.props.section.id>0) {
this.boardSelectedWithName(this.props.section.name,this.props.section.id);
}else {
if (this.props.section.sid>-1) {
let section = this.props.section.items.get(this.props.section.sid);
this.boardSelectedWithName(section.name,section.id);
} else {
InteractionManager.runAfterInteractions(() => {
this._onGetBordList();
});
}
if (shouldHideTabBar(this.props.navigationState)) {
NativeModules.YH_CommunityHelper.hideTabBar();
}
... ... @@ -120,6 +122,12 @@ class PostingContainer extends Component{
this.props.actions.contentEdited (content);
}
render() {
let fromSection=false;
if (this.props.section.sid>-1) {
let section = this.props.section.items.get(this.props.section.sid);
fromSection = section.name.length && section.id>0;
}
return(
<View style={styles.container}>
<Posting
... ... @@ -132,7 +140,7 @@ class PostingContainer extends Component{
contentEdited={this.contentEdited}
titleValue={this.props.posting.title}
contentValue={this.props.posting.content}
fromSection={this.props.section.name.length && this.props.section.id>0}
fromSection={fromSection}
/>
</View>
);
... ...
... ... @@ -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,41 @@ 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) {
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 {
... ...
... ... @@ -70,9 +70,13 @@ function drillToEditPostPage(uid,postingPageFunc) {
if (json.forbidSpeaking === 'Y') {
Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~');
} else {
console.log('yyyyyyyyyyyyyyyyyyy');
Actions.Posting();
}
}).catch(error => {
console.log('eeeeeeeeeeeeeee');
console.log(error);
Actions.Posting();
})
}
... ...
... ... @@ -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');
}
... ...