Authored by 王钱钧

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

Conflicts:
	js/community/reducers/message/messageActions.js
... ... @@ -50,6 +50,7 @@ import SettingContainer from './containers/UserSettingContainer';
import LikeListContainer from './containers/LikeListContainer';
import SystemMessageContainer from './containers/SystemMessageContainer';
import NavBar from './components/NavBar';
import NavBarTitle from './components/home/NavBarTitle';
import {
setPlatform,
... ... @@ -101,12 +102,6 @@ function getInitialState() {
return _initState;
}
let titleMarginLeft = Math.ceil(70 * Dimensions.get('window').width / 320);
let titleWidth = Math.ceil(180 * Dimensions.get('window').width / 320);
let titleItemWidth = Math.ceil(titleWidth / 3) - 3;
export default function community(platform) {
let YH_Community = React.createClass({
... ... @@ -213,6 +208,9 @@ export default function community(platform) {
rightTitle={null}
rightButtonImage={rightImage}
onRight={this.homeOnRight}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
getTitle={(childState) => {
let sid = store.getState().section.sid;
let item = store.getState().section.items.get(sid);
... ... @@ -243,6 +241,9 @@ export default function community(platform) {
hideNavBar={false}
component={MessageCenterContainer}
initial={false}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
<Scene
... ... @@ -251,6 +252,9 @@ export default function community(platform) {
hideNavBar={false}
component={LikeMessageContainer}
initial={false}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
<Scene
... ... @@ -260,6 +264,9 @@ export default function community(platform) {
component={SystemMessageContainer}
initial={false}
onBack={this.onBack}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
<Scene
... ... @@ -271,6 +278,9 @@ export default function community(platform) {
rightTitle='确认'
onRight={this.settingOnRight}
rightButtonTextStyle={{color: 'white'}}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
<Scene
... ... @@ -295,6 +305,13 @@ export default function community(platform) {
onBack={this.onBack}
rightButtonImage={require('./images/posting/share.png')}
onRight={this.subjectPostOnRight}
getSid={()=>{
let sid = store.getState().subject.sid;
return sid;
}}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
<Scene
... ... @@ -303,6 +320,9 @@ export default function community(platform) {
component={LikeListContainer}
initial={false}
clone={true}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
<Scene
... ... @@ -311,6 +331,9 @@ export default function community(platform) {
hideNavBar={false}
component={PostingContainer}
initial={false}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
rightTitle='发送'
onRight={()=>{
if (store.getState().posting.dataValid) {
... ... @@ -345,58 +368,8 @@ export default function community(platform) {
},
renderHomeTitle(navProps) {
let {width, height} = Dimensions.get('window');
return (
<Animated.View style={[styles.title,]}>
<TouchableOpacity onPress={() => {
ReactNative.NativeModules.YH_CommunityHelper.hideRNNavBar(0);
}}>
<Text style={[styles.text, {}]}></Text>
</TouchableOpacity>
<View style={[{}]}>
<Text style={[styles.text, {marginLeft: -10.5}]}>社区</Text>
<Image
style={{
position: 'absolute',
left: titleItemWidth / 2,
top: -10,
width: 20,
height: 10,
marginLeft: -10
}}
resizeMode={'contain'}
source={require('./images/home/nav_new.png')}
/>
</View>
<TouchableOpacity onPress={() => {
ReactNative.NativeModules.YH_CommunityHelper.hideRNNavBar(2);
}}>
<Image style={{left: -5.5, top: -0.5}} source={require('./images/home/sd_show_ic.png')}/>
<Image
style={{
position: 'absolute',
left: titleItemWidth / 2 + 0,
top: -10,
width: 20,
height: 10,
}}
resizeMode={'contain'}
source={require('./images/home/nav_hot.png')}
/>
</TouchableOpacity>
<View style={{
backgroundColor: 'white',
position: 'absolute',
width: 45,
height: 2,
left: (titleWidth - 45) / 2 + 0,
top: 30,
}}/>
</Animated.View>
<NavBarTitle {...navProps}/>
);
},
... ... @@ -410,7 +383,8 @@ export default function community(platform) {
},
subjectPostOnRight(state) {
state.dispatch(onRightPressed());
let sid = state.getSid();
state.dispatch(onRightPressed(sid));
},
/*
* 自定义导航push动画
... ... @@ -484,32 +458,4 @@ let styles = StyleSheet.create({
textAlign: 'right',
fontSize: 17,
},
title: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
width: titleWidth,
marginTop: 12,
marginLeft: titleMarginLeft,
position: 'absolute',
...Platform.select({
ios: {
top: 20,
},
android: {
top: 5,
},
}),
left: 0,
right: 0,
backgroundColor: 'transparent',
},
text: {
textAlign: 'center',
fontSize: 18,
fontWeight: 'bold',
color: '#ffffff',
width: titleItemWidth,
marginTop: 1,
},
});
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
View,
Text,
Image,
TouchableOpacity,
StyleSheet,
Animated,
Dimensions,
Platform,
} = ReactNative;
let {width, height} = Dimensions.get('window');
let titleMarginLeft = Math.ceil(70 * width / 320);
let titleWidth = Math.ceil(180 * width / 320);
let titleItemWidth = Math.ceil(titleWidth / 3) - 3;
export default class NavBarTitle extends React.Component {
constructor(props) {
super (props);
}
render() {
let index = this.props.index;
return (
<Animated.View
style={[
styles.title,
{
opacity: this.props.position.interpolate({
inputRange: [index - 1, index, index + 1],
outputRange: [0, this.props.titleOpacity, 0],
}),
left: this.props.position.interpolate({
inputRange: [index - 1, index + 1],
outputRange: [200, -200],
}),
right: this.props.position.interpolate({
inputRange: [index - 1, index + 1],
outputRange: [-200, 200],
}),
},
]}>
<TouchableOpacity onPress={() => {
ReactNative.NativeModules.YH_CommunityHelper.hideRNNavBar(0);
}}>
<Text style={[styles.text, {}]}></Text>
</TouchableOpacity>
<View style={[{}]}>
<Text style={[styles.text, {marginLeft: -10.5}]}>社区</Text>
<Image
style={{
position: 'absolute',
left: titleItemWidth / 2,
top: -10,
width: 20,
height: 10,
marginLeft: -10
}}
resizeMode={'contain'}
source={require('../../images/home/nav_new.png')}
/>
</View>
<TouchableOpacity onPress={() => {
ReactNative.NativeModules.YH_CommunityHelper.hideRNNavBar(2);
}}>
<Image style={{left: -5.5, top: -0.5}} source={require('../../images/home/sd_show_ic.png')}/>
<Image
style={{
position: 'absolute',
left: titleItemWidth / 2 + 0,
top: -10,
width: 20,
height: 10,
}}
resizeMode={'contain'}
source={require('../../images/home/nav_hot.png')}
/>
</TouchableOpacity>
<View style={{
backgroundColor: 'white',
position: 'absolute',
width: 45,
height: 2,
left: (titleWidth - 45) / 2 + 0,
top: 30,
}}/>
</Animated.View>
);
}
}
let styles = StyleSheet.create({
title: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
width: titleWidth,
marginTop: 12,
marginLeft: titleMarginLeft,
position: 'absolute',
...Platform.select({
ios: {
top: 20,
},
android: {
top: 5,
},
}),
left: 0,
right: 0,
backgroundColor: 'transparent',
},
text: {
textAlign: 'center',
fontSize: 18,
fontWeight: 'bold',
color: '#ffffff',
width: titleItemWidth,
marginTop: 1,
},
});
... ...
... ... @@ -75,6 +75,7 @@ let styles = StyleSheet.create({
flexDirection: 'row',
alignItems: 'center',
backgroundColor: 'white',
flex:1,
},
avatar: {
width: 30,
... ...
... ... @@ -18,8 +18,8 @@ export default class MessageIcon extends React.Component {
static propTypes = {
isRedDot: React.PropTypes.bool,
defaultSource: React.PropTypes.string,
image:React.PropTypes.string,
defaultSource: Image.propTypes.source,
image: React.PropTypes.string,
iconTap: React.PropTypes.func,
}
... ... @@ -41,7 +41,7 @@ export default class MessageIcon extends React.Component {
render() {
let defaultSource = this.props.defaultSource || require('../../images/user/avatar-default.png')
let defaultSource = this.props.defaultSource || require('../../images/user/avatar-default.png');
return (
<View style={[styles.container, this.props.extraStyle]}>
... ...
... ... @@ -126,18 +126,10 @@ export default class MessageCenter extends React.Component {
break;
default:
return null;
}
}
/*
<ListView
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
renderRow={this._renderRow}
renderSeparator={this._renderSeparator}
/>
*/
render() {
let {sysMsg, likeMsg, list, endReached, isRefreshing, isLoadingMore, isFetching,} = this.props;
... ... @@ -167,8 +159,6 @@ export default class MessageCenter extends React.Component {
this.props.onEndReached && this.props.onEndReached(this.currentPage);
}}
renderFooter={() => {
console.log('render footer !!!!!!!!!!!!!!!!!');
if (endReached) {
console.log('没有更多啦');
return <LoadMoreIndicator
... ...
'use strict'
/**
* 照片选择页面
*/
import React, {Component} from 'react';
import {
StyleSheet,
View,
TextInput,
Image,
Platform,
Dimensions,
Text,
TouchableOpacity,
Keyboard,
Animated,
Easing,
ScrollView,
TouchableOpacity,
Platform,
Dimensions,
StyleSheet,
NativeModules,
NativeAppEventEmitter,
CameraRoll,
} from 'react-native'
} from 'react-native';
let YH_CommunityAssetsPicker = NativeModules.YH_CommunityAssetsPicker;
export default class AssertsPicker extends Component {
constructor(props) {
super(props);
this.observer = null;
this.renderContent = this.renderContent.bind(this);
this.renderPlus = this.renderPlus.bind(this);
this.deleteAsset = this.deleteAsset.bind(this);
}
componentDidMount() {
this.observer = NativeAppEventEmitter.addListener('EventReminder', (event) => {
this.props.assetsSelected(event.assets);
})
}
componentWillUnmount() {
this.observer.remove();
}
renderPlus(assets) {
if (assets.length >= 9) {
return null;
}
let plusStyle = styles.itemContainer;
if (assets.length == 0) {
plusStyle = {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
};
}
function renderPlus(assets) {
if (assets.length<9) {
return(
return (
<TouchableOpacity
style={styles.itemContainer}
onPress={()=>{YH_CommunityAssetsPicker.presentImagePicker(assets);}}
>
style={plusStyle}
onPress={() => {
YH_CommunityAssetsPicker.presentImagePicker(assets);
}}
>
<Image style={styles.item} source={require('../../images/posting/add.png')}/>
</TouchableOpacity>
);
}
}
function renderContent(assets, delAction) {
if (assets.length) {
return(
renderContent(assets) {
if (assets.length == 0) {
return this.renderPlus(assets);
}
return (
<ScrollView
style={styles.scroll}
contentContainerStyle={styles.scrollContainer}
horizontal={true}
>
<View style={styles.scrollContainer}>
{
assets.map((asset,index)=>{
return(
<View style={styles.itemContainer} key={index}>
<Image style={styles.item} source={asset}/>
<TouchableOpacity onPress={()=>{delAction(index);}}>
{assets.map((asset, index) => {
return (
<View style={styles.itemContainer} key={index}>
<Image style={styles.item} source={asset}/>
<TouchableOpacity onPress={() => {this.deleteAsset(index);}}>
<Image style={styles.itemDelete} source={require('../../images/posting/delete.png')}/>
</TouchableOpacity>
</View>
);
})
}
{renderPlus(assets)}
</View>
</TouchableOpacity>
</View>
);
})}
{this.renderPlus(assets)}
</ScrollView>
);
}else {
return(
<TouchableOpacity
style={{flex:1,alignItems:'center',justifyContent:'center',}}
onPress={()=>{YH_CommunityAssetsPicker.presentImagePicker(assets);}}
>
<Image style={styles.item} source={require('../../images/posting/add.png')}/>
</TouchableOpacity>
);
}
}
export default class AssertsPicker extends Component {
constructor(props) {
super(props);
this.observer;
this.deleteAsset=this.deleteAsset.bind(this);
}
componentDidMount() {
this.observer = NativeAppEventEmitter.addListener('EventReminder',(event)=>{
this.props.assetsSelected(event.assets);
})
}
componentWillUnmount() {
this.observer.remove();
}
deleteAsset(assetIndex) {
let existedAssets=this.props.assets;
existedAssets.splice(assetIndex,1);
let existedAssets = this.props.assets;
existedAssets.splice(assetIndex, 1);
this.props.assetsSelected(existedAssets);
YH_CommunityAssetsPicker.deleteAssetAtIndex(assetIndex);
}
render() {
return (
<View style={styles.container} opacity={this.props.opacityToHide>0}>
{renderContent(this.props.assets,this.deleteAsset)}
<Text style={styles.pageText}>{this.props.assets.length + '/9'} </Text>
<View style={styles.container} opacity={this.props.opacityToHide > 0}>
{this.renderContent(this.props.assets)}
<Text style={styles.pageText}>{this.props.assets.length + '/9'}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container:{
flex:1,
container: {
flex: 1,
},
scroll: {
flex:1,
height: 200,
},
scrollContainer: {
flex:1,
flexDirection:'row',
alignItems:'center',
paddingLeft: 15,
flexDirection: 'row',
alignItems: 'center',
paddingLeft: 24,
paddingRight: 12,
},
itemContainer: {
flexDirection: 'row',
width: 90,
height: 130,
right:10,
flexDirection:'row',
},
item: {
top:10,
width:80,
height:120,
backgroundColor:'#b0b0b0',
top: 10,
width: 80,
height: 120,
backgroundColor: '#b0b0b0',
},
itemDelete: {
width:20,
height:20,
left:-13
width: 20,
height: 20,
left: -13,
},
pageText: {
color: '#a0a0a0',
height: 41,
fontSize:14,
color: '#B0B0B0',
fontFamily: 'Helvetica Light',
fontSize: 13,
textAlign: 'center',
fontWeight:'100',
bottom: 15,
},
});
... ...
... ... @@ -36,7 +36,6 @@ export default class SPLikeCell extends React.Component {
_renderLikeAvatar(avatars) {
let users = this.props.users;
if (users.length) {
users.reverse();
let space = 10;
let left = (users.length - 1) * space;
return (
... ...
... ... @@ -29,7 +29,7 @@ export default class SubjectContent extends Component {
<Text key={i} style={styles.contentText}>
<Text>回复</Text>
<Text style={{color:'#4a90e2'}} onPress={()=>{this.props.onPressAvatar(this.props.replyTo.uid);}}>{this.props.replyTo.nickName}</Text>
<Text>':'+{content}</Text>
<Text>:+{content}</Text>
</Text>
)
}else {
... ...
... ... @@ -63,11 +63,12 @@ export default class SubjectPost extends Component {
this.renderToolContainer = this.renderToolContainer.bind(this);
this.someOneToReply = '';
this.replyToSomeOneElse = this.replyToSomeOneElse.bind(this);
this.renderDeleteCommentButton = this.renderDeleteCommentButton.bind(this);
this.commentId = '';
this.cidTo = '';
this.replyContent='';
this.commitComment = this.commitComment.bind(this);
this.cnameTo = '';
}
componentDidMount(){
... ... @@ -119,45 +120,45 @@ export default class SubjectPost extends Component {
render() {
return(
<View style={styles.container}>
<Animated.View
style={[styles.contentInputContainer,{height:this.state.contentInputHeight}]}
>
<ListView
style={styles.container}
dataSource={this.dataSource.cloneWithRowsAndSections(this.props.dataBlob)}
renderRow={this.renderRow}
enableEmptySections={true}
onEndReached={() => {
this.props.onEndReached && this.props.onEndReached();
}}
renderFooter={()=>{
if (!this.props.dataBlob.comments.length) {
return <View style={styles.sofaContainer}>
<Image style={styles.sofaImage} source={require('../../images/posting/ic_null_message.png')}/>
<Text style={styles.sofaText}>快来抢沙发吧~</Text>
</View>
}
if (this.props.endReached) {
return <LoadMoreIndicator
isVisible={true}
text={'没有更多啦'}
/>
} else {
return <LoadMoreIndicator
isVisible={true}
animating={this.props.isFetching}
/>
}
}}
/>
{this.renderToolContainer(this.state.replyState)}
</Animated.View>
<AssertsPicker
style={[styles.boardSelectionContainer,{height:this.state.imageState,}]}
opacityToHide={this.state.imageState}
assets={this.props.assets}
assetsSelected={this.props.assetsSelected}
/>
<Animated.View
style={[styles.contentInputContainer,{height:this.state.contentInputHeight}]}
>
<ListView
style={styles.container}
dataSource={this.dataSource.cloneWithRowsAndSections(this.props.dataBlob)}
renderRow={this.renderRow}
enableEmptySections={true}
onEndReached={() => {
this.props.onEndReached && this.props.onEndReached();
}}
renderFooter={()=>{
if (!this.props.dataBlob.comments.length) {
return <View style={styles.sofaContainer}>
<Image style={styles.sofaImage} source={require('../../images/posting/ic_null_message.png')}/>
<Text style={styles.sofaText}>快来抢沙发吧~</Text>
</View>
}
if (this.props.endReached) {
return <LoadMoreIndicator
isVisible={true}
text={'没有更多啦'}
/>
} else {
return <LoadMoreIndicator
isVisible={true}
animating={this.props.isFetching}
/>
}
}}
/>
{this.renderToolContainer(this.state.replyState)}
</Animated.View>
{this.state.imageState == 0 ? null : <AssertsPicker
style={[styles.boardSelectionContainer,{height:this.state.imageState,}]}
opacityToHide={this.state.imageState}
assets={this.props.assets}
assetsSelected={this.props.assetsSelected}
/>}
</View>
);
}
... ... @@ -183,6 +184,7 @@ export default class SubjectPost extends Component {
onPress={
()=>{
this.cidTo = this.props.authorUid;
this.cnameTo = '';
this.commentId = '';
NativeModules.YH_CommunityHelper.uid()
.then(uid => {
... ... @@ -218,6 +220,8 @@ export default class SubjectPost extends Component {
</TouchableOpacity>
</View>
<View style={styles.toolTopLine}/>
<View style={styles.toolBottomLine}/>
</View>
);
}
... ... @@ -250,6 +254,8 @@ export default class SubjectPost extends Component {
/>
<Text style={styles.submitText} onPress={this.commitComment}>发送</Text>
</View>
<View style={styles.toolTopLine}/>
<View style={styles.toolBottomLine}/>
</View>
);
}
... ... @@ -282,6 +288,8 @@ export default class SubjectPost extends Component {
/>
<Text style={styles.submitText} onPress={this.commitComment}>发送</Text>
</View>
<View style={styles.toolTopLine}/>
<View style={styles.toolBottomLine}/>
</View>
);
}
... ... @@ -304,7 +312,37 @@ export default class SubjectPost extends Component {
authorUid: this.props.authorUid,
content: this.replyContent,
}
this.props.commentWithParams(params);
let blocks = [];
let textBlock = {
"contentData": this.replyContent,
"templateKey": "text",
"orderBy": 1,
};
blocks.push(textBlock);
if (this.props.assets.length) {
for (var i = 0; i < assets.length; i++) {
let asset = assets[i];
let imgBlock = {
"contentData": asset.url,
"templateKey": "image",
"size": asset.width + 'x' + asset.height,
};
blocks.push(imgBlock);
}
}
let replyTo;
if (this.cnameTo.length) {
replyTo = {
nickName: this.cnameTo,
uid: this.cidTo,
}
}
let fakeComment = {
blocks,
replyTo,
}
this.props.commentWithParams(params, fakeComment);
this.blurAll();
}
renderRow(rowData, sectionId) {
... ... @@ -341,9 +379,9 @@ export default class SubjectPost extends Component {
return (
<TouchableOpacity onPress={this.props.onPressShareGoods}>
<View style={styles.shareGoodsContainer}>
<SlicedImage style={styles.shareGoodsImage} source={{uri:rowData.productUrl}}/>
<SlicedImage style={styles.shareGoodsImage} source={{uri:rowData.goodsImage}}/>
<View style={styles.shareGoodsRightPannel}>
<Text style={styles.productNameText}>rowData.productName</Text>
<Text style={styles.productNameText}>{rowData.productName}</Text>
<Text style={styles.productPriceText}>{'¥'+rowData.salesPrice}</Text>
</View>
</View>
... ... @@ -369,9 +407,8 @@ export default class SubjectPost extends Component {
onPress={
()=> {
this.cidTo = rowData.cidTo;
this.cnameTo = rowData.nickName;
this.commentId = rowData.commentId;
NativeModules.YH_CommunityHelper.uid()
.then(uid => {
new PostingService().getPostUser(uid).then(json => {
... ... @@ -403,15 +440,19 @@ export default class SubjectPost extends Component {
}
>
<View>
<UserBrief
avatar={rowData.headIcon}
name={rowData.nickName}
timeago={rowData.timeago}
isOwner={rowData.LZ}
onPressAvatar={() => {
this.props.onPressAvatar && this.props.onPressAvatar();
}}
/>
<View style={{flexDirection:'row'}}>
<UserBrief
avatar={rowData.headIcon}
name={rowData.nickName}
timeago={rowData.timeago}
isOwner={rowData.LZ}
onPressAvatar={() => {
this.props.onPressAvatar && this.props.onPressAvatar();
}}
/>
{this.renderDeleteCommentButton(rowData.cidTo,rowData.commentId)}
</View>
<SubjectContent contentWidth={width-65} left={20} blocks={rowData.blocks} replyTo={rowData.replyTo} onPressAvatar={this.props.onPressAvatar}/>
<View style={styles.commentSeparator}/>
</View>
... ... @@ -424,26 +465,26 @@ export default class SubjectPost extends Component {
}
}
renderDeleteCommentButton(commentUserId,id) {
if (this.props.dataBlob.header.LZ||(commentUserId == this.props.cidFrom)) {
return(
<TouchableOpacity
style={{width:20,height:20}}
onPress={()=>{
this.props.onPressDeleteComment&&this.props.onPressDeleteComment(id);
}}
>
<Image style={{width:20,height:20}} resizeMode={'contain'} source={require('../../images/posting/ic_dian.png')}/>
</TouchableOpacity>
)
}
}
replyToSomeOneElse(someOne) {
this.someOneToReply = someOne;
this.currentReplyState = ReplyState.replySomeone;
this.setState({replyState: this.currentReplyState});
}
renderLikeAvatar(avatars) {
if (avatars.length) {
return (
<View style={styles.avatarPannel}>
{avatars.map((item, i)=> {
let headURI = item.headIcon||'';
return (
<SlicedImage key={i} style={[styles.likeAvatar,{right:10*i}]} source={{uri:headURI}}/>
);
})}
</View>
);
}
}
}
const styles = StyleSheet.create({
... ... @@ -452,51 +493,6 @@ const styles = StyleSheet.create({
flex: 1,
backgroundColor: 'white',
},
likePannel: {
backgroundColor: 'white',
height: 50,
borderColor: '#a0a0a0',
borderTopWidth: 0.5,
borderBottomWidth: 0.5,
paddingLeft: 15,
paddingRight: 15,
flexDirection: 'row',
},
likeContainer: {
height:50,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
leftLikeContainer: {
height: 50,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
avatarPannel: {
flexDirection: 'row-reverse',
justifyContent: 'flex-end',
},
rightLikeContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-end',
},
likeAvatar: {
width: 30,
height: 30,
borderRadius: 15,
},
likeText: {
fontSize: 14,
left: -10,
},
browseText: {
fontSize: 14,
paddingLeft: 15,
},
header: {
flexDirection: 'row',
paddingTop: 10,
... ... @@ -542,14 +538,27 @@ const styles = StyleSheet.create({
toolContainer: {
flexDirection: 'row',
height: 41,
borderColor: '#a0a0a0',
borderBottomWidth:0.5,
borderTopWidth:0.5,
alignItems:'center',
backgroundColor: 'white',
paddingLeft: 15,
paddingRight: 15,
},
toolTopLine: {
position: 'absolute',
left: 0,
top: 0,
width: width,
height: 0.5,
backgroundColor: '#e0e0e0',
},
toolBottomLine: {
position: 'absolute',
left: 0,
bottom: 0,
width: width,
height: 0.5,
backgroundColor: '#e0e0e0',
},
imgIcon: {
left:0,
width:19,
... ...
... ... @@ -219,7 +219,7 @@ let styles = StyleSheet.create({
},
sectionHeaderBottomLine: {
position: 'absolute',
left: 17,
left: 0,
bottom: 0,
width: width,
height: 0.5,
... ...
... ... @@ -131,6 +131,11 @@ export default keyMirror({
SUBJECT_COMMENTS_FAILURE: null,
SUBJECT_ASSETS_SELECTED: null,
SUBJECT_DEL_COMMENT_REQUEST: null,
SUBJECT_DEL_COMMENT_SUCCESS: null,
SUBJECT_DEL_COMMENT_FAILURE: null,
SUBJECT_SHARE_DATA_PREPARED: null,
LIKE_MESSAGE_REQUEST: null, // 消息中心收到的赞列表
LIKE_MESSAGE_SUCCESS: null,
LIKE_MESSAGE_FAILURE: null,
... ...
... ... @@ -10,7 +10,7 @@ import {Actions} from 'react-native-router-flux';
import LikeList from '../components/likeList/LikeList';
import * as likeListAction from '../reducers/likeList/likeListActions';
import * as homeActions from '../reducers/home/homeActions';
import * as appActions from '../reducers/app/appActions';
const {
Text,
... ... @@ -23,7 +23,7 @@ const {
const actions = [
likeListAction,
homeActions,
appActions
];
function mapStateToProps(state) {
... ...
... ... @@ -10,7 +10,7 @@ import {Actions} from 'react-native-router-flux';
import LikeMessage from '../components/message/LikeMessage';
import * as messageActions from '../reducers/message/messageActions';
import * as homeActions from '../reducers/home/homeActions';
import * as appActions from '../reducers/app/appActions';
const {
Text,
... ... @@ -23,7 +23,7 @@ const {
const actions = [
messageActions,
homeActions,
appActions,
];
function mapStateToProps(state) {
... ...
... ... @@ -9,7 +9,7 @@ import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import MessageCenter from '../components/message/MessageCenter';
import * as homeActions from '../reducers/home/homeActions';
import * as appActions from '../reducers/app/appActions';
import * as messageActions from '../reducers/message/messageActions';
import * as userThatNotMeActions from '../reducers/userThatNotMe/userThatNotMeActions';
... ... @@ -25,7 +25,7 @@ const {
const actions = [
messageActions,
userThatNotMeActions,
homeActions,
appActions,
];
function mapStateToProps(state) {
... ... @@ -63,7 +63,7 @@ class MessageCenterContainer extends React.Component {
_onPressAvatar(uid) {
console.log('avatar');
this.props.actions.goToUserNotMe(uid);
this.props.actions.goToUserThatNotMe(uid);
}
_onPressPost(id) {
... ...
... ... @@ -8,6 +8,7 @@ import {
Platform,
InteractionManager,
NativeModules,
ActionSheetIOS,
} from 'react-native';
import {bindActionCreators} from 'redux';
... ... @@ -21,11 +22,13 @@ import SubjectPost from '../components/subjectPost/SubjectPost';
import * as subjectPostActions from '../reducers/subject/subjectPostActions';
import * as homeActions from '../reducers/home/homeActions';
import * as appActions from '../reducers/app/appActions';
const actions = [
subjectPostActions,
homeActions,
appActions,
];
/**
... ... @@ -67,14 +70,31 @@ class SubjectPostContainer extends Component {
this.onPressLikeOrDislike = this.onPressLikeOrDislike.bind(this);
this.onPressShareGoods = this.onPressShareGoods.bind(this);
this.onPressLargeImage = this.onPressLargeImage.bind(this);
this.onPressDeleteComment = this.onPressDeleteComment.bind(this);
this.sid = this.props.subject.sid;
}
onPressDeleteComment(id) {
const BUTTONS = ['删除','取消'];
ActionSheetIOS.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: 1,
},
(buttonIndex) => {
if (buttonIndex == 0) {
this.props.actions.deleteComment(this.sid,id);
}
});
}
componentDidMount() {
let item = this.props.subject.items.get(this.sid);
InteractionManager.runAfterInteractions(() => {
this.props.actions.requestPostContent(this.sid,item.id);
this.props.actions.requestPostComments(this.sid,item.id);
this.props.actions.prepareShareData(this.sid,item.id);
});
}
... ... @@ -91,21 +111,43 @@ class SubjectPostContainer extends Component {
}
onPressLargeImage(index) {
NativeModules.YH_CommunityHelper.showLargeImages(this.props.subject.largeImages,index);
let item = this.props.subject.items.get(this.sid);
NativeModules.YH_CommunityHelper.showLargeImages(item.largeImages,index);
}
assetsSelected(assets) {
this.props.actions.assetsSelected(this.sid,assets);
}
commentWithParams(params) {
this.props.actions.commentWithParams(this.sid,params);
commentWithParams(params, fakeComment) {
let item = this.props.subject.items.get(this.sid);
let {blocks, replyTo} = fakeComment;
let commentId = new Date();
let cidTo = this.props.user.profile.uid;
let timeago = '刚刚';
let headIcon = this.props.user.profile.avatar;
let nickName = this.props.user.profile.nickName;
let LZ = false;
let newFakeComment = {
commentId,
cidTo,
timeago,
headIcon,
nickName,
LZ,
blocks,
replyTo,
}
console.log(newFakeComment);
let currentCommentList = item.commentList.toJS();
let newList = [newFakeComment,...currentCommentList];
this.props.actions.commentWithParams(this.sid,params,newList);
}
onPressShareGoods() {
let item = this.props.subject.items.get(this.sid);
let params = {
productSkn: item.shareProductSkn,
productSkn: item.shareGoods.productId,
};
NativeModules.YH_CommunityHelper.displayProductDetail(params);
}
... ... @@ -138,7 +180,7 @@ class SubjectPostContainer extends Component {
}
if (item.hasPraise == 'Y') {
this.props.actions.subjectUnlike(this.sid,item.id);
}else if(this.props.subject.hasPraise == 'N'){
}else if(item.hasPraise == 'N'){
this.props.actions.subjectLike(this.sid,item.id);
}
}
... ... @@ -170,15 +212,18 @@ class SubjectPostContainer extends Component {
if (item.shareGoods.productName.length) {
shareGoods.push(item.shareGoods);
}
let titleBlob = [];
if (item.postsTitle&&item.postsTitle.length) {
titleBlob = [item.postsTitle];
}
let dataBlob = {
header : [header],
title: [item.postsTitle],
title: titleBlob,
content: [item.blocks.toJS()],
shareGoods,
like: [likeData],
comments: item.commentList.toJS(),
};
return (
<View style={styles.container}>
<SubjectPost
... ... @@ -188,7 +233,7 @@ class SubjectPostContainer extends Component {
isFetching={item.isCommentsFetching}
assetsSelected={this.assetsSelected}
assets={item.assets.toJS()}
commentCount={item.commentCount}
commentCount={item.commentCount||0}
commentWithParams={this.commentWithParams}
postId={item.id}
cidFrom={this.props.user.profile.uid}
... ... @@ -201,6 +246,7 @@ class SubjectPostContainer extends Component {
likeState={item.hasPraise}
onPressShareGoods={this.onPressShareGoods}
onPressLargeImage={this.onPressLargeImage}
onPressDeleteComment={this.onPressDeleteComment}
/>
</View>
);
... ... @@ -213,7 +259,8 @@ let navbarHeight = (Platform.OS === 'android') ? 50 : 64;
let styles = StyleSheet.create({
container: {
top: navbarHeight,
height: height - navbarHeight - 49,
marginBottom: navbarHeight,
flex: 1,
},
});
... ...
... ... @@ -13,7 +13,7 @@ import {Actions} from 'react-native-router-flux';
import * as userActions from '../reducers/user/userActions';
import * as homeActions from '../reducers/home/homeActions';
import * as appActions from '../reducers/app/appActions';
const {
StatusBar,
... ... @@ -42,6 +42,7 @@ let SourceType = {
const actions = [
userActions,
homeActions,
appActions,
];
function mapStateToProps(state) {
... ...
... ... @@ -11,6 +11,7 @@ import {Actions} from 'react-native-router-flux';
import UserThatNotMe from '../components/userThatNotMe/UserThatNotMe';
import * as userThatNotMeActions from '../reducers/userThatNotMe/userThatNotMeActions';
import * as homeActions from '../reducers/home/homeActions';
import * as appActions from '../reducers/app/appActions';
const {
StatusBar,
... ... @@ -26,6 +27,7 @@ const {
const actions = [
userThatNotMeActions,
homeActions,
appActions,
];
function mapStateToProps(state) {
... ...
... ... @@ -11,15 +11,132 @@ 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';
const {
SET_PLATFORM,
SET_CONTAINER,
SET_CHANNEL,
GO_ACTION,
GO_TO_SECTION,
GO_TO_POST,
GO_TO_LIKE_LIST,
GO_TO_USER,
GO_TO_USER_THAT_NOT_ME,
GO_TO_SETTING,
GO_TO_MESSAGE_CENTER,
GO_TO_SYS_MESSAGE,
GO_TO_LIKE_MESSAGE,
} = require('../../constants/actionTypes').default;
export function goToSection(section) {
Actions.Section();
return {
type: GO_TO_SECTION,
payload: section,
};
}
export function goToPost(id) {
Actions.SubjectPost({postId:id});
return {
type: GO_TO_POST,
payload: id,
};
}
export function goToLikeList(postId, likeCount) {
Actions.LikeList({title: `共有${likeCount}个赞`});
return {
type: GO_TO_LIKE_LIST,
payload: postId,
};
}
export function goToUserOrMe(uid) {
return (dispatch, getState) => {
let {user} = getState();
if (uid != 0 && uid == user.profile.uid) {
Actions.User();
dispatch({
type: GO_TO_USER,
});
} else {
Actions.UserThatNotMe();
dispatch({
type: GO_TO_USER_THAT_NOT_ME,
payload: uid,
});
}
};
}
export function goToUser() {
return (dispatch, getState) => {
let operation = () => {
Actions.User();
return {
type: GO_TO_USER,
};
};
let {user} = getState();
if (user.profile.uid == 0) {
dispatch(loginThenSyncUserInfo(operation));
} else {
dispatch(operation());
}
};
}
export function goToUserThatNotMe(uid) {
return (dispatch, getState) => {
let {user} = getState();
if (user.profile.uid == uid) {
} else {
Actions.UserThatNotMe();
dispatch({
type: GO_TO_USER_THAT_NOT_ME,
payload: uid,
});
}
};
}
export function goToSetting() {
Actions.Setting();
return {
type: GO_TO_SETTING,
};
}
export function goToMessageCenter() {
Actions.MessageCenter();
return {
type: GO_TO_MESSAGE_CENTER,
};
}
export function goToLikeMessage() {
Actions.LikeMessage();
return {
type: GO_TO_LIKE_MESSAGE,
// payload:
};
}
export function goToSystemMessage() {
Actions.SystemMessage();
return {
type: GO_TO_SYS_MESSAGE,
// payload:
};
}
export function setPlatform(platform) {
return {
type: SET_PLATFORM,
... ... @@ -47,7 +164,7 @@ export function goAction(inputUrl) {
if (json === null) {
return;
}
let {action, params} = json;
let {param, share, shareparam, title, url} = params;
... ...
... ... @@ -23,10 +23,6 @@ const {
HOME_RECOMMENDATION_SUCCESS,
HOME_RECOMMENDATION_FAILURE,
GO_TO_SECTION,
GO_TO_USER_THAT_NOT_ME,
GO_TO_POST,
POST_LIKE_REQUEST,
POST_LIKE_SUCCESS,
POST_LIKE_FAILURE,
... ... @@ -34,69 +30,12 @@ const {
POST_UNLIKE_SUCCESS,
POST_UNLIKE_FAILURE,
GO_TO_USER,
SYNC_USER_REQUEST,
SYNC_USER_SUCCESS,
SYNC_USER_FAILURE,
END_REFRESHING,
INCREASE_ERROR_COUNT,
RESET_ERROR_COUNT,
} = require('../../constants/actionTypes').default;
export function goToSection(section) {
Actions.Section();
return {
type: GO_TO_SECTION,
payload: section,
};
}
export function goToUserOrMe(uid) {
return (dispatch, getState) => {
let {user} = getState();
if (uid != 0 && uid == user.profile.uid) {
Actions.User();
dispatch({
type: GO_TO_USER,
});
} else {
Actions.UserThatNotMe();
dispatch({
type: GO_TO_USER_THAT_NOT_ME,
payload: uid,
});
}
};
}
export function goToUser() {
return (dispatch, getState) => {
let operation = () => {
Actions.User();
return {
type: GO_TO_USER,
};
};
let {user} = getState();
if (user.profile.uid == 0) {
dispatch(loginThenSyncUserInfo(operation));
} else {
dispatch(operation());
}
};
}
export function goToPost(id) {
Actions.SubjectPost({postId:id});
return {
type: GO_TO_POST,
payload: id,
};
}
export function likeOperation(post) {
return (dispatch, getState) => {
... ...
... ... @@ -9,9 +9,7 @@ import moment from 'moment';
const {
GO_TO_MESSAGE_CENTER,
GO_TO_SYS_MESSAGE,
GO_TO_LIKE_MESSAGE,
MESSAGE_INFO_REQUEST,
MESSAGE_INFO_SUCCESS,
MESSAGE_INFO_FAILURE,
... ... @@ -252,6 +250,7 @@ export function systemMessage(ptr = false) {
};
}
export function goToLikeMessage() {
Actions.LikeMessage();
return {
... ... @@ -268,7 +267,6 @@ export function goToSystemMessage() {
};
}
function parseMessageInfo(json) {
let {praiseMsg, systemMsg} = json;
... ...
... ... @@ -30,20 +30,45 @@ const {
SUBJECT_REPLY_FAILURE,
SUBJECT_REPLY_UPDATE,
GO_TO_LIKE_LIST,
SUBJECT_DO_NOTHING,
SUBJECT_LIKE_SUCCESS,
SUBJECT_UNLIKE_SUCCESS,
SUBJECT_LIKE_REQUEST,
SUBJECT_UNLIKE_REQUEST,
SUBJECT_DEL_COMMENT_REQUEST,
SUBJECT_DEL_COMMENT_SUCCESS,
SUBJECT_DEL_COMMENT_FAILURE,
SUBJECT_SHARE_DATA_PREPARED,
} = require('../../constants/actionTypes').default;
export function goToLikeList(postId, likeCount) {
Actions.LikeList({title: `共有${likeCount}个赞`});
export function deleteComment(sid, id) {
return (dispatch, getState) => {
let {subject, user} = getState();
let uid = user.profile.uid;
let item = subject.items.get(sid);
let commentsArray = item.commentList.toJS();
let newArray = [];
for (var i = 0; i < commentsArray.length; i++) {
let commentItem = commentsArray[i];
if (commentItem.commentId != id) {
newArray.push(commentItem);
}
}
dispatch(commitDeleteComment(sid, newArray));
new PostingService().deleteComment(id, uid).then(json => {
Alert.alert('提示','删除成功');
}).catch(error => {
Alert.alert('提示','删除成功');
})
}
}
export function commitDeleteComment(sid, newArray) {
return {
type: GO_TO_LIKE_LIST,
payload: postId,
};
type: SUBJECT_DEL_COMMENT_REQUEST,
payload: {sid, newArray},
}
}
export function subjectLikeRequest(sid,json) {
... ... @@ -55,8 +80,8 @@ export function subjectLikeRequest(sid,json) {
export function subjectLike(sid,postId) {
return (dispatch, getState) => {
dispatch(subjectLikeRequest(sid,postId));
let {user} = getState();
dispatch(subjectLikeRequest(sid,user.profile.avatar));
return new HomeService().postLike(postId, user.profile.uid)
.then(json => {
dispatch({
... ... @@ -79,8 +104,8 @@ export function subjectUnlikeRequest(sid,json) {
export function subjectUnlike(sid,postId) {
return (dispatch, getState) => {
dispatch(subjectUnlikeRequest(sid,postId));
let {user} = getState();
dispatch(subjectUnlikeRequest(sid,user.profile.avatar));
return new HomeService().postUnlike(postId, user.profile.uid)
.then(json => {
dispatch({
... ... @@ -113,18 +138,14 @@ export function onRightPressed(sid) {
}
});
} else {
let params = {
postsId: item.id,
appType: 1,
}
new PostingService().getShareUrl(params).then(json => {
let {subject} = getState();
let item = subject.items.get(sid);
let {subject} = getState();
let item = subject.items.get(sid);
if (item.shareUrl.length) {
let blockAry = item.blocks.toJS();
let content = '';
let contentStr = '';
for (var i = 0; i < blockAry.length; i++) {
if (blockAry[i].templateKey == 'text') {
content = blockAry[i].contentData||'';
contentStr = blockAry[i].contentData||'';
break;
}
}
... ... @@ -145,21 +166,43 @@ export function onRightPressed(sid) {
.replace('{height}', '320');
}
}
let title = item.postsTitle||contentStr||'潮流社区';
let content = item.authorInfo.nickName||''+'在潮流社区发布的潮流主题帖很赞,快来看看!'
let shareInfo = {
title: subject.postsTitle||'',
title,
content,
'picUrl':newSrc,
linkUrl: json.shareUrl,
picUrl:newSrc,
linkUrl: item.shareUrl,
}
dispatch(doShare(sid,shareInfo));
}).catch(error => {
} else {
Alert.alert('提示','获取分享信息失败');
})
}
}
}
}
export function prepareShareData(sid, postId) {
return dispatch => {
let params = {
postsId: postId,
appType: 1,
};
new PostingService().getShareUrl(params).then(json => {
dispatch(shareDataPrepared(sid, json.shareUrl));
}).catch(error => {
});
}
}
export function shareDataPrepared(sid, shareUrl) {
return {
type: SUBJECT_SHARE_DATA_PREPARED,
payload: {sid, shareUrl},
}
}
export function onRight(sid) {
return {
type:'SUBJECT_DO_NOTHING',
... ... @@ -168,10 +211,7 @@ export function onRight(sid) {
}
export function doShare(sid,shareInfo) {
console.log(shareInfo);
NativeModules.YH_CommunityHelper.showShare(shareInfo);
return {
type:'SUBJECT_DO_NOTHING',
payload: sid,
... ... @@ -186,13 +226,10 @@ export function doDelete(sid,postsId) {
Actions.pop();
new PostingService().deletePost(postsId).then(json => {
Alert.alert('提示','删除成功');
console.log('......del success ....... ' + json);
}).catch(error => {
Alert.alert('提示','删除失败');
console.log('....error.......... ' +error);
})
}}]);
console.log('deleted.............');
return {
type:'SUBJECT_DO_NOTHING',
payload:sid,
... ... @@ -346,7 +383,7 @@ export function commentsRequestSuccess(sid,json) {
}
let newObj={
commentId: id||'',
cidTo: postInfo.authorUid||'',
cidTo: reply.uid||'',
timeago: timeagoStr||'',
headIcon: reply.headIcon||'',
nickName: reply.nickName||'',
... ... @@ -364,6 +401,10 @@ export function commentsRequestSuccess(sid,json) {
}
}
function createFakeComment() {
}
export function commentsRequestFailure(sid,error) {
return {
type: SUBJECT_COMMENTS_FAILURE,
... ... @@ -378,7 +419,7 @@ export function assetsSelected(sid,assets) {
}
}
export function commentWithParams(sid,params) {
export function commentWithParams(sid,params, newList) {
return (dispatch, getState) => {
dispatch(startComment(sid));
let {subject} = getState();
... ... @@ -390,13 +431,13 @@ export function commentWithParams(sid,params) {
new PostingService().uploadImageAsset(asset)
.then(response => {
dispatch(updateCommentProgress(sid,response, params));
dispatch(updateCommentProgress(sid,response, params, newList));
}).catch(error => {
dispatch(commentFail(sid,error));
});
}
} else {
dispatch(commitComment(sid,params));
dispatch(commitComment(sid,params, newList));
}
}
}
... ... @@ -408,18 +449,21 @@ export function startComment(sid) {
}
}
export function commitComment(sid,params) {
export function commitComment(sid,params, newList) {
return dispatch => {
new PostingService().commitReply(params)
.then(response => {
dispatch(commentSuccess(sid,response));
Alert.alert('提示','回复成功');
newList[0].commentId = response.id;
dispatch(commentSuccess(sid,response, newList));
}).catch(error => {
Alert.alert('提示','回复失败');
dispatch(commentFail(sid,error));
});
}
}
export function updateCommentProgress(sid, url, params) {
export function updateCommentProgress(sid, url, params, newList) {
return (dispatch, getState) => {
let {subject} = getState();
let item = subject.items.get(sid);
... ... @@ -440,7 +484,7 @@ export function updateCommentProgress(sid, url, params) {
...params,
images: item.assetsUrlStr,
}
dispatch(commitComment(sid,newParams));
dispatch(commitComment(sid,newParams, newList));
}
});
}
... ... @@ -453,10 +497,10 @@ export function commentImageStateChanged(payloadData) {
}
}
export function commentSuccess(sid,json) {
export function commentSuccess(sid,json, newList) {
return {
type: SUBJECT_REPLY_SUCCESS,
payload: {sid, json},
payload: {sid, json, newList},
}
}
... ...
... ... @@ -40,6 +40,7 @@ let item = new (Record({
productUrl: '',
salesPrice: 0,
goodsImage: '',
productId:'',
})),
publishTimeString: '',
shareProductSkn: 0,
... ... @@ -58,6 +59,7 @@ let item = new (Record({
inLikeAction: false,
largeImages:[],
shareUrl: '',
}));
let InitialState = Record({
... ...
... ... @@ -35,6 +35,12 @@ const {
SUBJECT_UNLIKE_SUCCESS,
SUBJECT_LIKE_REQUEST,
SUBJECT_UNLIKE_REQUEST,
SUBJECT_DEL_COMMENT_REQUEST,
SUBJECT_DEL_COMMENT_SUCCESS,
SUBJECT_DEL_COMMENT_FAILURE,
SUBJECT_SHARE_DATA_PREPARED,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -121,10 +127,16 @@ export default function postingReducer(state = initialState, action) {
.set('largeImages',largeImages)
.set('hasPraise',hasPraise||'N');
if (shareGoods) {
item.setIn(['shareGoods','productName'],shareGoods.productName||'')
let imgUrl = '';
if (shareGoods.goodsImage.length) {
let ary=shareGoods.goodsImage.split('?');
imgUrl = ary[0];
}
item = item.setIn(['shareGoods','productName'],shareGoods.productName||'')
.setIn(['shareGoods','productUrl'],shareGoods.productUrl||'')
.setIn(['shareGoods','salesPrice'],shareGoods.salesPrice||'')
.setIn(['shareGoods','goodsImage'],shareGoods.goodsImage||'')
.setIn(['shareGoods','goodsImage'],imgUrl||'')
.setIn(['shareGoods','productId'],shareGoods.productId)
}
let nextState = state.setIn(['items', sid], item);
return nextState;
... ... @@ -142,6 +154,7 @@ export default function postingReducer(state = initialState, action) {
case SUBJECT_COMMENTS_SUCCESS:{
let {sid,json} = action.payload;
let item = state.items.get(sid);
let {lastedTime, total, list, pageSize} = json;
let tailCount = (total%pageSize)>0?1:0;
... ... @@ -194,13 +207,14 @@ export default function postingReducer(state = initialState, action) {
}
break;
case SUBJECT_REPLY_SUCCESS:{
let {sid, json} = action.payload;
let {sid, json, newList} = action.payload;
let item = state.items.get(sid);
item = item.set('assets',Immutable.fromJS([]))
.set('assetsUrlStr','')
.set('assetFinishCount',0)
.set('isReplying',false)
.set('replyError',error);
.set('replyError',error)
.set('commentList',Immutable.fromJS(newList));
let nextState = state.setIn(['items', sid], item);
return nextState;
}
... ... @@ -223,7 +237,9 @@ export default function postingReducer(state = initialState, action) {
case SUBJECT_LIKE_REQUEST: {
let {sid,json} = action.payload;
let item = state.items.get(sid);
item = item.set('hasPraise','Y');
let users = item.praiseUsers.toJS();
let newUsers = [{headIcon:json},...users];
item = item.set('hasPraise','Y').set('praiseUsers',Immutable.fromJS(newUsers));
let nextState = state.setIn(['items', sid], item);
return nextState;
}
... ... @@ -231,7 +247,31 @@ export default function postingReducer(state = initialState, action) {
case SUBJECT_UNLIKE_REQUEST: {
let {sid,json} = action.payload;
let item = state.items.get(sid);
item = item.set('hasPraise','N');
let users = item.praiseUsers.toJS();
let newUsers = [];
for (var i = 0; i < users.length; i++) {
let item = users[i];
if (item.headIcon != json) {
newUsers.push(item);
}
}
item = item.set('hasPraise','N').set('praiseUsers',Immutable.fromJS(newUsers));
let nextState = state.setIn(['items', sid], item);
return nextState;
}
break;
case SUBJECT_DEL_COMMENT_REQUEST: {
let {sid, newArray} = action.payload;
let item = state.items.get(sid);
item = item.set('commentList',Immutable.fromJS(newArray));
let nextState = state.setIn(['items', sid], item);
return nextState;
}
break;
case SUBJECT_SHARE_DATA_PREPARED: {
let {sid, shareUrl} = action.payload;
let item = state.items.get(sid);
item = item.set('shareUrl',shareUrl);
let nextState = state.setIn(['items', sid], item);
return nextState;
}
... ...
... ... @@ -23,9 +23,6 @@ const {
USER_REPLY_SUCCESS,
USER_REPLY_FAILURE,
GO_TO_SETTING,
GO_TO_MESSAGE_CENTER,
SYNC_USER_REQUEST,
SYNC_USER_SUCCESS,
SYNC_USER_FAILURE,
... ... @@ -61,20 +58,6 @@ const {
} = require('../../constants/actionTypes').default;
export function goToMessageCenter() {
Actions.MessageCenter();
return {
type: GO_TO_MESSAGE_CENTER,
};
}
export function goToSetting() {
Actions.Setting();
return {
type: GO_TO_SETTING,
};
}
export function userDidLogout() {
return {
type: USER_DID_LOGOUT,
... ...
... ... @@ -19,40 +19,6 @@ const {
} = require('../../constants/actionTypes').default;
export function goToUserOrMe(uid) {
return (dispatch, getState) => {
let {user} = getState();
if (user.profile.uid == uid) {
Actions.User();
} else {
Actions.UserThatNotMe();
}
dispatch({
type: GO_TO_USER_OR_ME,
payload: uid,
});
};
}
export function goToUserNotMe(uid) {
console.log('uid =========== ' + uid);
return (dispatch, getState) => {
let {user} = getState();
if (user.profile.uid == uid) {
// Actions.User();
} else {
Actions.UserThatNotMe();
}
// dispatch({
// type: GO_TO_USER_OR_ME,
// payload: uid,
// });
};
}
export function userThatNotMeInfoRequest(sid) {
return {
type: USER_TNM_INFO_REQUEST,
... ...
... ... @@ -14,6 +14,22 @@ export default class PostingService {
this.api = new Request();
}
async deleteComment(id,uid) {
return await this.api.get({
url:'',
body: {
method:'app.social.delComment',
id,
uid,
}
}).then((json) => {
return json;
}).catch((error) => {
throw(error);
});
}
async getShareUrl(params) {
return await this.api.get({
url:'',
... ...
... ... @@ -24,6 +24,8 @@
"react-native-simple-store": "^1.0.1",
"react-native-swiper": "^1.4.7",
"react-redux": "^4.4.5",
"react-static-container": "^1.0.1",
"react-timer-mixin": "^0.13.3",
"redux": "^3.5.2",
"redux-logger": "^2.6.1",
"redux-thunk": "^2.0.1",
... ...