Authored by 孙凯

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

... ... @@ -114,7 +114,7 @@ export default class List extends Component {
<Text style={styles.text}>{publish_time}</Text>
<Image source={require('../../image/shared_view_icon.png')} style={styles.iconThumb}resizeMode={'contain'}></Image>
<Text style={styles.text}>{views_num}</Text>
<TouchableOpacity activeOpacity={1.0} style={styles.likeButton} onPress={()=>{this.props.onPressLike&&this.props.onPressLike(id, isLike)}}>
<TouchableOpacity activeOpacity={1.0} style={styles.likeButton} onPress={()=>{this.props.onPressLike&&this.props.onPressLike(id, isLike, this.props.rowID)}}>
<Image source={likeImg}/>
</TouchableOpacity>
<TouchableOpacity activeOpacity={1.0} style={styles.shareButton} onPress={()=>{this.props.onPressShare&&this.props.onPressShare(shareParam)}}>
... ...
... ... @@ -66,8 +66,8 @@ class MineGuangContainer extends Component {
ReactNative.NativeModules.YH_CommonHelper.shareWithParam(param);
}
_onPressLike(article_id, isLike) {
this.props.actions.onPressLike(article_id, isLike);
_onPressLike(article_id,isLike,rowID) {
this.props.actions.onPressLike(article_id,rowID);
}
_onEndReached() {
... ...
... ... @@ -64,8 +64,6 @@ export function fetchUserFavArticleList() {
}
return new MineGuangService(app.serviceHost).getUserFavArticleList(params)
.then(json => {
console.log('------mine guang');
console.log(json);
if (favArticleList && favArticleList.size) {
favArticleList = favArticleList.toJS();
}
... ... @@ -75,8 +73,6 @@ export function fetchUserFavArticleList() {
dispatch(fetchSimpleArticleList(json.data))
})
.catch(error => {
console.log('------error');
console.log(error);
dispatch(fetchUserFavArticleListFailure(error));
})
}
... ... @@ -112,16 +108,10 @@ export function fetchSimpleArticleList(favArticleList) {
return new MineGuangService(app.serviceHost).getSimpleArticleList(params)
.then(json => {
//将请求到的文章相关数据合并到favArticleList
console.log('------mine guang');
console.log(json);
let newFavArticleList = mergeSimpleArticleToFavList(favArticleList,json.artList);
console.log('------merged');
console.log(newFavArticleList);
dispatch(updateUserFavArticleList(newFavArticleList));
})
.catch(error => {
console.log('------error');
console.log(error);
})
}
... ... @@ -157,28 +147,28 @@ function mergeSimpleArticleToFavList(favArticleList,simpleArticleList) {
return favArticleList;
}
export function onPressLike(article_id, isLike) {
export function onPressLike(article_id,rowID) {
return (dispatch, getState) => {
let {app, mineGuang} = getState();
let likeRequest = (article_id, uid, isLike) => {
// dispatch(likeArticle({article_id, isLike}));
//
// if (isLike) {
// return new ListService(app.serviceHost).setArticleFavorite(article_id, uid)
// }else {
// return new ListService(app.serviceHost).cancleArticleFavorite(article_id, uid)
// }
let {userFavArticleList} = mineGuang;
let {favArticleList} = userFavArticleList;
let likeRequest = (article_id, uid) => {
if (!favArticleList || favArticleList.size == 0) {
return;
}
let newFavArticleList = favArticleList.delete(rowID);
dispatch(updateUserFavArticleList(newFavArticleList));
return new MineGuangService(app.serviceHost).cancelFavorite({article_id,uid});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
likeRequest(article_id, uid, isLike);
likeRequest(article_id, uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
likeRequest(article_id, uid, isLike);
likeRequest(article_id, uid);
})
.catch(error => {
... ...
... ... @@ -41,4 +41,19 @@ export default class MineGuangService {
throw(error);
});
}
async cancelFavorite(params) {
return await this.api.get({
url: '/guang/api/v1/favorite/cancelFavorite',
body: {
...params,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...