Commit 2cf6711fa97528ef05cd0cd67b44a62f804f49c9

Authored by luoye
1 parent 319ce06e26

首页点赞

Showing 3 changed files with 9 additions and 16 deletions

littleApp_child/pages/home/home.js View file @ 2cf6711
... ... @@ -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 @ 2cf6711
... ... @@ -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>
littleApp_child/pages/home/home.wxss View file @ 2cf6711
... ... @@ -107,6 +107,7 @@
107 107 font: medium;
108 108 text-align: center;
109 109 line-height: 30px;
  110 + margin-bottom: 1px;
110 111 }
111 112  
112 113 /*---------foundation---------*/