增加了明星原创资讯相关点击事件。review by 孙凯。
Showing
20 changed files
with
169 additions
and
93 deletions
@@ -18,10 +18,11 @@ export default function native(platform) { | @@ -18,10 +18,11 @@ export default function native(platform) { | ||
18 | Classify(platform); | 18 | Classify(platform); |
19 | Seckill(platform); | 19 | Seckill(platform); |
20 | Guang(platform); | 20 | Guang(platform); |
21 | + Plustar(platform); | ||
22 | + | ||
21 | 23 | ||
22 | if (Platform.OS === 'ios') { | 24 | if (Platform.OS === 'ios') { |
23 | Community(platform); | 25 | Community(platform); |
24 | - Plustar(platform); | ||
25 | QRCode(platform); | 26 | QRCode(platform); |
26 | } else { | 27 | } else { |
27 | 28 |
@@ -36,7 +36,6 @@ import { | @@ -36,7 +36,6 @@ import { | ||
36 | 36 | ||
37 | import { | 37 | import { |
38 | setBrandId, | 38 | setBrandId, |
39 | - setUdid, | ||
40 | setId, | 39 | setId, |
41 | } from './reducers/detail/detailActions'; | 40 | } from './reducers/detail/detailActions'; |
42 | 41 | ||
@@ -105,7 +104,6 @@ export default function native(platform) { | @@ -105,7 +104,6 @@ export default function native(platform) { | ||
105 | let id=this.props.id; | 104 | let id=this.props.id; |
106 | let udid=this.props.udid; | 105 | let udid=this.props.udid; |
107 | store.dispatch(setId(id)); | 106 | store.dispatch(setId(id)); |
108 | - store.dispatch(setUdid(udid)); | ||
109 | return ( | 107 | return ( |
110 | <Provider store={store}> | 108 | <Provider store={store}> |
111 | <DetailContainer /> | 109 | <DetailContainer /> |
@@ -15,6 +15,8 @@ import ReactNative, { | @@ -15,6 +15,8 @@ import ReactNative, { | ||
15 | NativeAppEventEmitter, | 15 | NativeAppEventEmitter, |
16 | StyleSheet, | 16 | StyleSheet, |
17 | } from 'react-native'; | 17 | } from 'react-native'; |
18 | +import SingleImage from './SingleImage'; | ||
19 | + | ||
18 | import {SlicedImage} from '../../../common/components/SlicedImage'; | 20 | import {SlicedImage} from '../../../common/components/SlicedImage'; |
19 | 21 | ||
20 | 22 | ||
@@ -27,30 +29,28 @@ export default class BrandArticleCell extends Component { | @@ -27,30 +29,28 @@ export default class BrandArticleCell extends Component { | ||
27 | 29 | ||
28 | } | 30 | } |
29 | 31 | ||
30 | - componentDidMount() { | ||
31 | - | ||
32 | - } | ||
33 | - | ||
34 | - | ||
35 | //时间和访问次数以及是否喜欢 | 32 | //时间和访问次数以及是否喜欢 |
36 | - _renderTimeAndVisit(time, visit, likeNum, id, isliked){ | 33 | + _renderTimeAndVisit(time, visit, likeNum, id, rowID, isliked){ |
37 | 34 | ||
38 | let likeicon = isliked ? require("../../images/like_on.png") : require("../../images/like_off.png"); | 35 | let likeicon = isliked ? require("../../images/like_on.png") : require("../../images/like_off.png"); |
36 | + let likestyle = isliked ? styles.darkgrayfont : styles.grayfont; | ||
39 | 37 | ||
40 | return ( | 38 | return ( |
41 | <View style={styles.timebar}> | 39 | <View style={styles.timebar}> |
42 | - <Text style={styles.time} numberOfLines={1}>{time} </Text> | 40 | + <Image style={styles.timeicon} source={require("../../images/time_icon.png")} /> |
41 | + <Text style={styles.grayfont} numberOfLines={1}>{time} </Text> | ||
43 | 42 | ||
44 | - <Text style={styles.time} numberOfLines={1}>{visit} </Text> | 43 | + <Image style={styles.eyeicon} source={require("../../images/eye_icon.png")} /> |
44 | + <Text style={styles.grayfont} numberOfLines={1}>{visit} </Text> | ||
45 | 45 | ||
46 | <TouchableOpacity | 46 | <TouchableOpacity |
47 | + style={styles.likecontainer} | ||
47 | activeOpacity={1} | 48 | activeOpacity={1} |
48 | onPress={()=>{ | 49 | onPress={()=>{ |
49 | - this.props.onPressArticleLike && this.props.onPressArticleLike(id, !isliked) | 50 | + this.props.onPressArticleLike && this.props.onPressArticleLike(id, rowID, !isliked, likeNum) |
50 | }}> | 51 | }}> |
51 | <Image style={styles.likeicon} source={likeicon} /> | 52 | <Image style={styles.likeicon} source={likeicon} /> |
52 | - | ||
53 | - <Text style={styles.time} numberOfLines={1}>{likeNum}</Text> | 53 | + <Text style={likestyle} numberOfLines={1}>{likeNum}</Text> |
54 | </TouchableOpacity> | 54 | </TouchableOpacity> |
55 | 55 | ||
56 | 56 | ||
@@ -61,7 +61,7 @@ export default class BrandArticleCell extends Component { | @@ -61,7 +61,7 @@ export default class BrandArticleCell extends Component { | ||
61 | 61 | ||
62 | 62 | ||
63 | render() { | 63 | render() { |
64 | - let {rowData} = this.props; | 64 | + let {rowData, rowID} = this.props; |
65 | //url跳转地址 | 65 | //url跳转地址 |
66 | let url = rowData.get('url'); | 66 | let url = rowData.get('url'); |
67 | //id | 67 | //id |
@@ -69,9 +69,8 @@ export default class BrandArticleCell extends Component { | @@ -69,9 +69,8 @@ export default class BrandArticleCell extends Component { | ||
69 | //标题 | 69 | //标题 |
70 | let title = rowData.get('title'); | 70 | let title = rowData.get('title'); |
71 | //图片 | 71 | //图片 |
72 | - let imgUrl = rowData.get('src').replace('{mode}', 2).replace('{width}', 290).replace('{height}', 386); | ||
73 | - //imgUrl = SlicedImage.getSlicedUrl(rowData.get('src'), 290, 386, 2); | ||
74 | - //let brandIconUrl = SlicedImage.getSlicedUrl(data.get('brand_img', ''), 150, 80, 2); | 72 | + let imgUrl = rowData.get('src').replace('{mode}', 2).replace('{width}', width).replace('{height}', width); |
73 | + // let imgUrl = SlicedImage.getSlicedUrl(rowData.get('src'), width, width, 2); | ||
75 | //介绍 | 74 | //介绍 |
76 | let intro = rowData.get('intro'); | 75 | let intro = rowData.get('intro'); |
77 | //发布时间 | 76 | //发布时间 |
@@ -79,11 +78,11 @@ export default class BrandArticleCell extends Component { | @@ -79,11 +78,11 @@ export default class BrandArticleCell extends Component { | ||
79 | //访问次数 | 78 | //访问次数 |
80 | let viewsNum = rowData.get('views_num'); | 79 | let viewsNum = rowData.get('views_num'); |
81 | //喜欢信息 | 80 | //喜欢信息 |
82 | - let like = rowData.get('like'); | 81 | + let likedata = rowData.get('like'); |
83 | //是否喜欢 | 82 | //是否喜欢 |
84 | - let isLiked = like.get("isLiked"); | 83 | + let isLiked = likedata ? likedata.get("isLiked") : false; |
85 | //喜欢人数 | 84 | //喜欢人数 |
86 | - let likeCount = like.get("count"); | 85 | + let likeCount = likedata ? likedata.get("count") : "0"; |
87 | 86 | ||
88 | return ( | 87 | return ( |
89 | <View style={styles.cellContainer}> | 88 | <View style={styles.cellContainer}> |
@@ -95,7 +94,7 @@ export default class BrandArticleCell extends Component { | @@ -95,7 +94,7 @@ export default class BrandArticleCell extends Component { | ||
95 | this.props.onPressArticle && this.props.onPressArticle(url) | 94 | this.props.onPressArticle && this.props.onPressArticle(url) |
96 | }}> | 95 | }}> |
97 | 96 | ||
98 | - <Image style={styles.image} source={{uri:imgUrl}} /> | 97 | + <SingleImage source={imgUrl} /> |
99 | 98 | ||
100 | <Text style={styles.title}>{title}</Text> | 99 | <Text style={styles.title}>{title}</Text> |
101 | 100 | ||
@@ -103,7 +102,7 @@ export default class BrandArticleCell extends Component { | @@ -103,7 +102,7 @@ export default class BrandArticleCell extends Component { | ||
103 | 102 | ||
104 | <Text style={styles.content} numberOfLines={4}>{intro}</Text> | 103 | <Text style={styles.content} numberOfLines={4}>{intro}</Text> |
105 | 104 | ||
106 | - {this._renderTimeAndVisit(publishTime, viewsNum, likeCount, id, isLiked)} | 105 | + {this._renderTimeAndVisit(publishTime, viewsNum, likeCount, id, rowID, isLiked)} |
107 | 106 | ||
108 | 107 | ||
109 | </View> | 108 | </View> |
@@ -121,11 +120,10 @@ let styles = StyleSheet.create({ | @@ -121,11 +120,10 @@ let styles = StyleSheet.create({ | ||
121 | touchableContainer: { | 120 | touchableContainer: { |
122 | width: width, | 121 | width: width, |
123 | }, | 122 | }, |
124 | - image: { | ||
125 | - width: width, | ||
126 | - height: width / 1.5, | ||
127 | - }, | ||
128 | - | 123 | + // image: { |
124 | + // width: width, | ||
125 | + // height: Math.ceil(width * 410 / 655), | ||
126 | + // }, | ||
129 | 127 | ||
130 | title:{ | 128 | title:{ |
131 | width: width, | 129 | width: width, |
@@ -139,24 +137,49 @@ let styles = StyleSheet.create({ | @@ -139,24 +137,49 @@ let styles = StyleSheet.create({ | ||
139 | content:{ | 137 | content:{ |
140 | width: width, | 138 | width: width, |
141 | fontSize: 15, | 139 | fontSize: 15, |
142 | - color: '#999999', | 140 | + color: '#3E3A39', |
143 | paddingLeft: 15, | 141 | paddingLeft: 15, |
144 | paddingRight: 15, | 142 | paddingRight: 15, |
145 | paddingBottom:5, | 143 | paddingBottom:5, |
146 | }, | 144 | }, |
147 | timebar:{ | 145 | timebar:{ |
148 | width: width, | 146 | width: width, |
147 | + height: 30, | ||
149 | flexDirection: 'row', | 148 | flexDirection: 'row', |
149 | + justifyContent: 'center', | ||
150 | + alignItems: 'center', | ||
150 | paddingLeft: 15, | 151 | paddingLeft: 15, |
151 | paddingRight: 15, | 152 | paddingRight: 15, |
152 | paddingBottom:5, | 153 | paddingBottom:5, |
153 | }, | 154 | }, |
154 | - time:{ | 155 | + likecontainer:{ |
156 | + flex: 1, | ||
157 | + flexDirection: 'row', | ||
158 | + justifyContent: 'flex-end', | ||
159 | + | ||
160 | + }, | ||
161 | + grayfont:{ | ||
155 | fontSize: 15, | 162 | fontSize: 15, |
156 | - color: '#b0b0b0', | 163 | + color: '#A5A5A5', |
164 | + marginLeft: 5, | ||
165 | + }, | ||
166 | + darkgrayfont:{ | ||
167 | + fontSize: 15, | ||
168 | + color: '#444444', | ||
169 | + marginLeft: 5, | ||
170 | + }, | ||
171 | + timeicon:{ | ||
172 | + width: 12, | ||
173 | + height:12, | ||
174 | + }, | ||
175 | + eyeicon:{ | ||
176 | + width: 16, | ||
177 | + height:12, | ||
178 | + marginLeft: 6, | ||
157 | }, | 179 | }, |
158 | likeicon:{ | 180 | likeicon:{ |
159 | - width: 20, | ||
160 | - height:20, | 181 | + width: 18, |
182 | + height:17, | ||
183 | + marginTop: 1, | ||
161 | }, | 184 | }, |
162 | }); | 185 | }); |
@@ -16,7 +16,6 @@ import ReactNative, { | @@ -16,7 +16,6 @@ import ReactNative, { | ||
16 | TouchableOpacity, | 16 | TouchableOpacity, |
17 | } from 'react-native'; | 17 | } from 'react-native'; |
18 | 18 | ||
19 | -//import SlicedImage from '../../../common/components/SlicedImage'; | ||
20 | import BrandArticleCell from './BrandArticleCell'; | 19 | import BrandArticleCell from './BrandArticleCell'; |
21 | 20 | ||
22 | export default class BrandArticleList extends Component { | 21 | export default class BrandArticleList extends Component { |
@@ -64,22 +63,24 @@ export default class BrandArticleList extends Component { | @@ -64,22 +63,24 @@ export default class BrandArticleList extends Component { | ||
64 | render() { | 63 | render() { |
65 | let {articleList} = this.props; | 64 | let {articleList} = this.props; |
66 | 65 | ||
67 | - return ( | ||
68 | - <View style={styles.container}> | ||
69 | - | ||
70 | - <ListView | ||
71 | - contentContainerStyle={styles.contentContainer} | ||
72 | - dataSource={this.dataSource.cloneWithRows(articleList)} | ||
73 | - renderRow={this._renderRow} | ||
74 | - enableEmptySections = {true} | ||
75 | - renderSeparator={this._renderSeparator} | ||
76 | - onPressArticle={this.props.onPressArticle} | ||
77 | - onPressArticleLike={this.props.onPressArticleLike} | ||
78 | - renderHeader={this._renderHeader} | ||
79 | - /> | 66 | + if(articleList){ |
67 | + return ( | ||
68 | + <View style={styles.container}> | ||
80 | 69 | ||
81 | - </View> | ||
82 | - ); | 70 | + <ListView |
71 | + contentContainerStyle={styles.contentContainer} | ||
72 | + dataSource={this.dataSource.cloneWithRows(articleList)} | ||
73 | + renderRow={this._renderRow} | ||
74 | + enableEmptySections = {true} | ||
75 | + renderSeparator={this._renderSeparator} | ||
76 | + onPressArticle={this.props.onPressArticle} | ||
77 | + onPressArticleLike={this.props.onPressArticleLike} | ||
78 | + renderHeader={this._renderHeader} | ||
79 | + /> | ||
80 | + | ||
81 | + </View> | ||
82 | + ); | ||
83 | + } | ||
83 | } | 84 | } |
84 | } | 85 | } |
85 | 86 |
js/plustar/components/detail/SingleImage.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import Immutable, {Map} from 'immutable'; | ||
6 | + | ||
7 | +const { | ||
8 | + AppRegistry, | ||
9 | + StyleSheet, | ||
10 | + Text, | ||
11 | + View, | ||
12 | + Image, | ||
13 | + ListView, | ||
14 | + Dimensions, | ||
15 | + TouchableOpacity, | ||
16 | +} = ReactNative; | ||
17 | + | ||
18 | + | ||
19 | +export default class SingleImage extends React.Component { | ||
20 | + constructor(props) { | ||
21 | + super(props); | ||
22 | + this.state = { | ||
23 | + width: Dimensions.get('window').width, | ||
24 | + height: 0, | ||
25 | + }; | ||
26 | + } | ||
27 | + | ||
28 | + shouldComponentUpdate(nextProps,nextState){ | ||
29 | + if (Immutable.is(nextProps.source, this.props.source) && nextState.height==this.state.height) { | ||
30 | + return false; | ||
31 | + } else { | ||
32 | + return true; | ||
33 | + } | ||
34 | + } | ||
35 | + | ||
36 | + componentDidMount() { | ||
37 | + let {source} = this.props; | ||
38 | + Image.getSize(source, (width, height) => { | ||
39 | + this.setState({width, height}); | ||
40 | + }); | ||
41 | + } | ||
42 | + | ||
43 | + render() { | ||
44 | + let {source} = this.props; | ||
45 | + return ( | ||
46 | + <View style={{width: Dimensions.get('window').width,height: (this.state.height/this.state.width)*Dimensions.get('window').width}}> | ||
47 | + <Image | ||
48 | + source={{uri: source}} | ||
49 | + style={{width: Dimensions.get('window').width,height: (this.state.height/this.state.width)*Dimensions.get('window').width}} | ||
50 | + > | ||
51 | + </Image> | ||
52 | + </View> | ||
53 | + ); | ||
54 | + return null; | ||
55 | + } | ||
56 | +}; | ||
57 | + | ||
58 | + | ||
59 | +let styles = StyleSheet.create({ | ||
60 | + | ||
61 | +}); |
@@ -8,7 +8,6 @@ export default keyMirror({ | @@ -8,7 +8,6 @@ export default keyMirror({ | ||
8 | SET_GENDER: null, | 8 | SET_GENDER: null, |
9 | SET_ID: null, | 9 | SET_ID: null, |
10 | SET_BRAND_ID:null, | 10 | SET_BRAND_ID:null, |
11 | - SET_UDID:null, | ||
12 | SET_BRAND_INTRO_UNFOLD: null, | 11 | SET_BRAND_INTRO_UNFOLD: null, |
13 | SET_MORE_PRODUCT_URL: null, | 12 | SET_MORE_PRODUCT_URL: null, |
14 | CLEAR_ADD_CANCEL_TIP: null, | 13 | CLEAR_ADD_CANCEL_TIP: null, |
@@ -50,6 +49,7 @@ export default keyMirror({ | @@ -50,6 +49,7 @@ export default keyMirror({ | ||
50 | CANCEL_FAVORITE_SUCCESS: null, | 49 | CANCEL_FAVORITE_SUCCESS: null, |
51 | CANCEL_FAVORITE_FAILURE: null, | 50 | CANCEL_FAVORITE_FAILURE: null, |
52 | 51 | ||
52 | + PRAISE_ARTICLE_CHANGE: null, | ||
53 | PRAISE_ARTICLE_REQUEST: null, | 53 | PRAISE_ARTICLE_REQUEST: null, |
54 | PRAISE_ARTICLE_SUCCESS: null, | 54 | PRAISE_ARTICLE_SUCCESS: null, |
55 | PRAISE_ARTICLE_FAILURE: null, | 55 | PRAISE_ARTICLE_FAILURE: null, |
@@ -77,14 +77,11 @@ class DetailContainer extends Component { | @@ -77,14 +77,11 @@ class DetailContainer extends Component { | ||
77 | } | 77 | } |
78 | 78 | ||
79 | _onPressArticle(url) { | 79 | _onPressArticle(url) { |
80 | - console.log("chenlin", "_onPressArticle:URL:" + url); | 80 | + ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); |
81 | } | 81 | } |
82 | 82 | ||
83 | - _onPressArticleLike(id, isLiked) { | ||
84 | - console.log("chenlin", "_onPressArticleLike:id" + id + ",isLiked:" + isLiked); | ||
85 | - let opt = isLiked ? "ok" : "cancel"; | ||
86 | - | ||
87 | - this.props.actions.praiseArticle(id,opt); | 83 | + _onPressArticleLike(id, index, isLiked, oldLikeNum) { |
84 | + this.props.actions.praiseArticle(id, index, isLiked, oldLikeNum); | ||
88 | } | 85 | } |
89 | 86 | ||
90 | _onPressFav(bFav='true') { | 87 | _onPressFav(bFav='true') { |
js/plustar/images/eye_icon@2x.png
0 → 100644

1.51 KB
js/plustar/images/eye_icon@3x.png
0 → 100644

1.85 KB
js/plustar/images/like_off.png
deleted
100644 → 0

18.8 KB
js/plustar/images/like_off@2x.png
0 → 100644

1.32 KB
js/plustar/images/like_off@3x.png
0 → 100644

1.55 KB
js/plustar/images/like_on.png
deleted
100644 → 0

19.3 KB
js/plustar/images/like_on@2x.png
0 → 100644

1.31 KB
js/plustar/images/like_on@3x.png
0 → 100644

1.49 KB
js/plustar/images/time_icon@2x.png
0 → 100644

1.2 KB
js/plustar/images/time_icon@3x.png
0 → 100644

1.38 KB
@@ -15,7 +15,6 @@ const { | @@ -15,7 +15,6 @@ const { | ||
15 | SET_ID, | 15 | SET_ID, |
16 | SET_BRAND_ID, | 16 | SET_BRAND_ID, |
17 | SET_GENDER, | 17 | SET_GENDER, |
18 | - SET_UDID, | ||
19 | SET_BRAND_INTRO_UNFOLD, | 18 | SET_BRAND_INTRO_UNFOLD, |
20 | SET_MORE_PRODUCT_URL, | 19 | SET_MORE_PRODUCT_URL, |
21 | CLEAR_ADD_CANCEL_TIP, | 20 | CLEAR_ADD_CANCEL_TIP, |
@@ -41,6 +40,7 @@ const { | @@ -41,6 +40,7 @@ const { | ||
41 | CANCEL_FAVORITE_SUCCESS, | 40 | CANCEL_FAVORITE_SUCCESS, |
42 | CANCEL_FAVORITE_FAILURE, | 41 | CANCEL_FAVORITE_FAILURE, |
43 | 42 | ||
43 | + PRAISE_ARTICLE_CHANGE, | ||
44 | PRAISE_ARTICLE_REQUEST, | 44 | PRAISE_ARTICLE_REQUEST, |
45 | PRAISE_ARTICLE_SUCCESS, | 45 | PRAISE_ARTICLE_SUCCESS, |
46 | PRAISE_ARTICLE_FAILURE, | 46 | PRAISE_ARTICLE_FAILURE, |
@@ -155,13 +155,6 @@ export function setGender(gender) { | @@ -155,13 +155,6 @@ export function setGender(gender) { | ||
155 | }; | 155 | }; |
156 | } | 156 | } |
157 | 157 | ||
158 | -export function setUdid(udid){ | ||
159 | - return { | ||
160 | - type: SET_UDID, | ||
161 | - payload:udid | ||
162 | - }; | ||
163 | -} | ||
164 | - | ||
165 | export function addCanelFavTipRemove(){ | 158 | export function addCanelFavTipRemove(){ |
166 | return { | 159 | return { |
167 | type: CLEAR_ADD_CANCEL_TIP | 160 | type: CLEAR_ADD_CANCEL_TIP |
@@ -436,10 +429,17 @@ export function praiseArticleRequest(){ | @@ -436,10 +429,17 @@ export function praiseArticleRequest(){ | ||
436 | }; | 429 | }; |
437 | } | 430 | } |
438 | 431 | ||
439 | -export function praiseArticleSuccess(json){ | 432 | +export function praiseArticleChange(index, isLiked, likenum){ |
433 | + return { | ||
434 | + type: PRAISE_ARTICLE_CHANGE, | ||
435 | + payload:{index, isLiked, likenum} | ||
436 | + }; | ||
437 | +} | ||
438 | + | ||
439 | +export function praiseArticleSuccess(index, isLiked, likenum){ | ||
440 | return { | 440 | return { |
441 | type: PRAISE_ARTICLE_SUCCESS, | 441 | type: PRAISE_ARTICLE_SUCCESS, |
442 | - payload:json | 442 | + payload:{index, isLiked, likenum} |
443 | }; | 443 | }; |
444 | } | 444 | } |
445 | 445 | ||
@@ -450,24 +450,23 @@ export function praiseArticleFailure(error){ | @@ -450,24 +450,23 @@ export function praiseArticleFailure(error){ | ||
450 | }; | 450 | }; |
451 | } | 451 | } |
452 | 452 | ||
453 | -export function praiseArticle(articleId, opt) { | 453 | +export function praiseArticle(articleId, index, isLiked, oldLikeNum) { |
454 | return (dispatch, getState) => { | 454 | return (dispatch, getState) => { |
455 | let {app, detail} = getState(); | 455 | let {app, detail} = getState(); |
456 | - let {udid} = detail; | ||
457 | - console.log("chenlin", "getState:" + JSON.stringify(getState())); | 456 | + let newNum = isLiked ? parseInt(oldLikeNum) + 1 : parseInt(oldLikeNum) - 1; |
458 | 457 | ||
459 | - let articleRequest = (articleId, udid, opt) => { | ||
460 | - dispatch(praiseArticleRequest()); | ||
461 | - return new DetailService(app.servicehost).praiseArticle(articleId, udid, opt) | 458 | + let articleRequest = (articleId, isLiked) => { |
459 | + dispatch(praiseArticleChange(index, isLiked, newNum)); | ||
460 | + return new DetailService(app.servicehost).praiseArticle(articleId, isLiked) | ||
462 | .then(json=>{ | 461 | .then(json=>{ |
463 | - dispatch(praiseArticleSuccess(json)); | 462 | + dispatch(praiseArticleSuccess(index, isLiked, json)); |
464 | }) | 463 | }) |
465 | .catch(error=>{ | 464 | .catch(error=>{ |
466 | dispatch(praiseArticleFailure(error)); | 465 | dispatch(praiseArticleFailure(error)); |
467 | }); | 466 | }); |
468 | } | 467 | } |
469 | 468 | ||
470 | - articleRequest(articleId, udid, opt); | 469 | + articleRequest(articleId, isLiked); |
471 | 470 | ||
472 | }; | 471 | }; |
473 | } | 472 | } |
@@ -12,7 +12,6 @@ const { | @@ -12,7 +12,6 @@ const { | ||
12 | SET_ID, | 12 | SET_ID, |
13 | SET_BRAND_ID, | 13 | SET_BRAND_ID, |
14 | SET_GENDER, | 14 | SET_GENDER, |
15 | - SET_UDID, | ||
16 | SET_BRAND_INTRO_UNFOLD, | 15 | SET_BRAND_INTRO_UNFOLD, |
17 | SET_MORE_PRODUCT_URL, | 16 | SET_MORE_PRODUCT_URL, |
18 | CLEAR_ADD_CANCEL_TIP, | 17 | CLEAR_ADD_CANCEL_TIP, |
@@ -37,6 +36,7 @@ const { | @@ -37,6 +36,7 @@ const { | ||
37 | CANCEL_FAVORITE_SUCCESS, | 36 | CANCEL_FAVORITE_SUCCESS, |
38 | CANCEL_FAVORITE_FAILURE, | 37 | CANCEL_FAVORITE_FAILURE, |
39 | 38 | ||
39 | + PRAISE_ARTICLE_CHANGE, | ||
40 | PRAISE_ARTICLE_REQUEST, | 40 | PRAISE_ARTICLE_REQUEST, |
41 | PRAISE_ARTICLE_SUCCESS, | 41 | PRAISE_ARTICLE_SUCCESS, |
42 | PRAISE_ARTICLE_FAILURE, | 42 | PRAISE_ARTICLE_FAILURE, |
@@ -66,9 +66,6 @@ export default function plustarReducer(state=initialState, action) { | @@ -66,9 +66,6 @@ export default function plustarReducer(state=initialState, action) { | ||
66 | case SET_BRAND_ID:{ | 66 | case SET_BRAND_ID:{ |
67 | return state.set('brandId', action.payload); | 67 | return state.set('brandId', action.payload); |
68 | } | 68 | } |
69 | - case SET_UDID:{ | ||
70 | - return state.set('udid', action.payload); | ||
71 | - } | ||
72 | case SET_BRAND_INTRO_UNFOLD:{ | 69 | case SET_BRAND_INTRO_UNFOLD:{ |
73 | return state.setIn(['brandInfo', 'titleUnfold'], action.payload); | 70 | return state.setIn(['brandInfo', 'titleUnfold'], action.payload); |
74 | } | 71 | } |
@@ -84,11 +81,14 @@ export default function plustarReducer(state=initialState, action) { | @@ -84,11 +81,14 @@ export default function plustarReducer(state=initialState, action) { | ||
84 | case ARTICLE_BY_BRAND_SUCCESS:{ | 81 | case ARTICLE_BY_BRAND_SUCCESS:{ |
85 | return state.set('articleList', Immutable.fromJS(action.payload)); | 82 | return state.set('articleList', Immutable.fromJS(action.payload)); |
86 | } | 83 | } |
87 | - case PRAISE_ARTICLE_SUCCESS:{ | ||
88 | - console.log("chenlin", "PRAISE_ARTICLE_SUCCESS:" + JSON.stringify(action.payload)); | 84 | + case PRAISE_ARTICLE_CHANGE:{ |
85 | + let {index, isLiked, likenum} = action.payload; | ||
86 | + let like = {isLiked: isLiked, count: likenum}; | ||
87 | + return state.setIn(['articleList', index, 'like'], Immutable.fromJS(like)); | ||
89 | } | 88 | } |
89 | + case PRAISE_ARTICLE_SUCCESS: | ||
90 | case PRAISE_ARTICLE_FAILURE:{ | 90 | case PRAISE_ARTICLE_FAILURE:{ |
91 | - console.log("chenlin", "PRAISE_ARTICLE_FAILURE:" + JSON.stringify(action.payload)); | 91 | + return state; |
92 | } | 92 | } |
93 | case BRADN_FAV_REQUEST:{ | 93 | case BRADN_FAV_REQUEST:{ |
94 | return state.setIn(['brandFav', 'isFetching'], true) | 94 | return state.setIn(['brandFav', 'isFetching'], true) |
@@ -71,11 +71,7 @@ export default class DetailService { | @@ -71,11 +71,7 @@ export default class DetailService { | ||
71 | url: '/guang/service/v1/article/getArticleByBrand', | 71 | url: '/guang/service/v1/article/getArticleByBrand', |
72 | body: { | 72 | body: { |
73 | brand_id: brandId, | 73 | brand_id: brandId, |
74 | - uid: uid, | ||
75 | - udid: udid, | ||
76 | - // client_type: clientType, | ||
77 | - // limit: 3, | ||
78 | - // private_key: privateKeyList[clientType], | 74 | + limit: 3, |
79 | } | 75 | } |
80 | }) | 76 | }) |
81 | .then((json) => { | 77 | .then((json) => { |
@@ -140,18 +136,18 @@ export default class DetailService { | @@ -140,18 +136,18 @@ export default class DetailService { | ||
140 | }); | 136 | }); |
141 | } | 137 | } |
142 | 138 | ||
143 | - //点赞,opt:ok表示点赞,cancel表示取消点赞 | ||
144 | - async praiseArticle(id, udid, opt='ok') { | 139 | + //点赞,isLiked:true表示点赞,false表示取消点赞 |
140 | + async praiseArticle(id, isLiked) { | ||
141 | + | ||
142 | + let url = isLiked ? '/guang/api/v2/praise/setPraise' : '/guang/api/v2/praise/cancel'; | ||
143 | + | ||
145 | return await this.api.post({ | 144 | return await this.api.post({ |
146 | - url: '/guang/opt/praiseArticle', | 145 | + url: url, |
147 | body: { | 146 | body: { |
148 | - id: id, | ||
149 | - udid: udid, | ||
150 | - opt: opt | 147 | + article_id: id, |
151 | } | 148 | } |
152 | }) | 149 | }) |
153 | .then((json) => { | 150 | .then((json) => { |
154 | - console.log("chenlin", "点赞返回数据:" + JSON.stringify(json)); | ||
155 | return json; | 151 | return json; |
156 | }) | 152 | }) |
157 | .catch((error) => { | 153 | .catch((error) => { |
-
Please register or login to post a comment