Commit c8c78ff111e870bf2dd4d5ca0fad833dc9a87207
Exists in
master
and in
2 other branches
Merge branch 'master' of https://git.healthbaby.com.cn/luoye/littleapp_child
Showing 3 changed files
littleApp_child/pages/home/home.js
View file @
c8c78ff
| ... | ... | @@ -172,24 +172,16 @@ |
| 172 | 172 | console.log(e) |
| 173 | 173 | var self = this |
| 174 | 174 | // 已经点赞 |
| 175 | - if (self.data.articleDetail.isLike == 1) { | |
| 175 | + if (e.currentTarget.dataset.islike == 1) { | |
| 176 | 176 | networkUtil.showErrorToast('您已经点过赞啦') |
| 177 | 177 | return; |
| 178 | 178 | } |
| 179 | - networkUtil._post(api.articleLike, { id: articleId }, function (res) { | |
| 180 | - console.log(res) | |
| 181 | - var art = self.data.articleDetail | |
| 182 | - art.likeCount++ | |
| 183 | - art.isLike = 1 | |
| 179 | + networkUtil._post(api.articleLike, { id: e.currentTarget.dataset.artid }, function (res) { | |
| 180 | + var artList = self.data.list | |
| 181 | + artList[e.currentTarget.dataset.categaryindex].article[e.currentTarget.dataset.artindex].likeCount++ | |
| 184 | 182 | self.setData({ |
| 185 | - articleDetail: art | |
| 186 | - }) | |
| 187 | - if (categoryIndex) { | |
| 188 | - // 更新首页数据 | |
| 189 | - event.emit('likeChanged', { categoryIndex: categoryIndex, articleIdIndex: articleIdIndex }); | |
| 190 | - } else { | |
| 191 | - event.emit('listLikeChanged', { categoryIndex: categoryIndex, articleIdIndex: articleIdIndex }); | |
| 192 | - } | |
| 183 | + list: artList | |
| 184 | + }); | |
| 193 | 185 | }, function (res) { |
| 194 | 186 | console.log(res) |
| 195 | 187 | }) |
littleApp_child/pages/home/home.wxml
View file @
c8c78ff
| ... | ... | @@ -71,8 +71,8 @@ |
| 71 | 71 | <view class="article_content_bottomBar util_bottom_line"> |
| 72 | 72 | <!-- <view class="article_content_bottomBar_labels"> |
| 73 | 73 | </view> --> |
| 74 | - <!-- bindtap="articleLike" data-categaryIndex="{{sectionIndex}}" data-artIndex="{{index}}" --> | |
| 75 | - <view class="article_content_bottomBar_likes"> | |
| 74 | + <!-- bindtap="articleLike" data-categaryIndex="{{sectionIndex}}" data-artIndex="{{index}}" --> | |
| 75 | + <view class="article_content_bottomBar_likes" catchtap="articleLike" data-isLike="{{item.isLike}}" data-artId="{{item.id}}" data-categaryIndex="{{sectionIndex}}" data-artIndex="{{index}}"> | |
| 76 | 76 | <image class="article_content_bottomBar_likes_icon" src="../../source/{{item.isLike == 1 ? 'zanguo.png' : 'like.png'}}"></image> |
| 77 | 77 | <label class="article_content_bottomBar_likes_text">{{item.likeCount ? item.likeCount : 0}}</label> |
| 78 | 78 | </view> |