File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
src/components/TopicDetail Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -67,15 +67,20 @@ class TopicDetail extends Component {
6767 is_collect : topic . is_collect
6868 } )
6969 }
70- like ( id ) {
70+ like ( id , author ) {
7171 const {
7272 accesstoken,
73- likeComment
73+ likeComment,
74+ self
7475 } = this . props
7576 if ( ! accesstoken ) {
7677 alert ( '请先登录!' )
7778 return
7879 }
80+ if ( author === self ) {
81+ alert ( '不能给自己点赞哦!' )
82+ return
83+ }
7984
8085 likeComment ( {
8186 accesstoken,
@@ -132,7 +137,7 @@ class TopicDetail extends Component {
132137 < span className = "time_stamp" > { format ( item . create_at ) } </ span >
133138 < span className = "floor" > { index + 1 } 楼</ span >
134139 </ div >
135- < div className = { 'user_action ' + ( item . is_uped ? 'liked' : '' ) } onClick = { this . like . bind ( this , item . id ) } >
140+ < div className = { 'user_action ' + ( item . is_uped ? 'liked' : '' ) } onClick = { this . like . bind ( this , item . id , item . author . loginname ) } >
136141 < span className = "iconfont icon-thumbup" > </ span >
137142 < span className = "up_number" > { item . ups . length } </ span >
138143 </ div >
@@ -171,11 +176,13 @@ class TopicDetail extends Component {
171176
172177function mapStateToProps ( {
173178 topic,
174- accesstoken
179+ accesstoken,
180+ self
175181} ) {
176182 return {
177183 topic,
178- accesstoken
184+ accesstoken,
185+ self : self . loginname
179186 }
180187}
181188
You can’t perform that action at this time.
0 commit comments