diff --git a/littleApp_child/pages/home/home.js b/littleApp_child/pages/home/home.js index 4f84f72..0291723 100644 --- a/littleApp_child/pages/home/home.js +++ b/littleApp_child/pages/home/home.js @@ -172,24 +172,16 @@ Page({ console.log(e) var self = this // 已经点赞 - if (self.data.articleDetail.isLike == 1) { + if (e.currentTarget.dataset.islike == 1) { networkUtil.showErrorToast('您已经点过赞啦') return; } - networkUtil._post(api.articleLike, { id: articleId }, function (res) { - console.log(res) - var art = self.data.articleDetail - art.likeCount++ - art.isLike = 1 + networkUtil._post(api.articleLike, { id: e.currentTarget.dataset.artid }, function (res) { + var artList = self.data.list + artList[e.currentTarget.dataset.categaryindex].article[e.currentTarget.dataset.artindex].likeCount++ self.setData({ - articleDetail: art - }) - if (categoryIndex) { - // 更新首页数据 - event.emit('likeChanged', { categoryIndex: categoryIndex, articleIdIndex: articleIdIndex }); - } else { - event.emit('listLikeChanged', { categoryIndex: categoryIndex, articleIdIndex: articleIdIndex }); - } + list: artList + }); }, function (res) { console.log(res) }) diff --git a/littleApp_child/pages/home/home.wxml b/littleApp_child/pages/home/home.wxml index 1873b97..d0937fb 100644 --- a/littleApp_child/pages/home/home.wxml +++ b/littleApp_child/pages/home/home.wxml @@ -71,8 +71,8 @@ - - + + diff --git a/littleApp_child/pages/home/home.wxss b/littleApp_child/pages/home/home.wxss index e23644d..b8f6bb7 100644 --- a/littleApp_child/pages/home/home.wxss +++ b/littleApp_child/pages/home/home.wxss @@ -107,6 +107,7 @@ font: medium; text-align: center; line-height: 30px; + margin-bottom: 1px; } /*---------foundation---------*/