Commit c0652f9e89ff8c2538249d6ec04fdfcb0b5777f2
1 parent
de484b386c
Exists in
master
and in
2 other branches
no message
Showing 2 changed files with 29 additions and 2 deletions
littleApp_child/pages/childcare_knowledge/childcare_knowledge.js
View file @
c0652f9
| ... | ... | @@ -138,5 +138,32 @@ |
| 138 | 138 | isRefresh = false |
| 139 | 139 | }) |
| 140 | 140 | }, |
| 141 | + // 文章点赞 | |
| 142 | + articleLike(e) { | |
| 143 | + console.log(e) | |
| 144 | + var self = this | |
| 145 | + // 已经点赞 | |
| 146 | + if (self.data.articleDetail.isLike == 1) { | |
| 147 | + networkUtil.showErrorToast('您已经点过赞啦') | |
| 148 | + return; | |
| 149 | + } | |
| 150 | + networkUtil._post(api.articleLike, { id: articleId }, function (res) { | |
| 151 | + console.log(res) | |
| 152 | + var art = self.data.articleDetail | |
| 153 | + art.likeCount++ | |
| 154 | + art.isLike = 1 | |
| 155 | + self.setData({ | |
| 156 | + articleDetail: art | |
| 157 | + }) | |
| 158 | + if (categoryIndex) { | |
| 159 | + // 更新首页数据 | |
| 160 | + event.emit('likeChanged', { categoryIndex: categoryIndex, articleIdIndex: articleIdIndex }); | |
| 161 | + } else { | |
| 162 | + event.emit('listLikeChanged', { categoryIndex: categoryIndex, articleIdIndex: articleIdIndex }); | |
| 163 | + } | |
| 164 | + }, function (res) { | |
| 165 | + console.log(res) | |
| 166 | + }) | |
| 167 | + }, | |
| 141 | 168 | }) |
littleApp_child/pages/childcare_knowledge/childcare_knowledge.wxml
View file @
c0652f9
| ... | ... | @@ -27,8 +27,8 @@ |
| 27 | 27 | <view style="margin-left:15px;margin-right:75px;"> |
| 28 | 28 | <view class="content_title">{{item.title}}</view> |
| 29 | 29 | <view class="content_content">{{item.introduction}}</view> |
| 30 | - <view class="zar_box"> | |
| 31 | - <image class="zar_img" src="../../source/zar.png"></image> | |
| 30 | + <view class="zar_box" bindtap="articleLike" data-categaryIndex="{{sectionIndex}}" data-artIndex="{{index}}"> | |
| 31 | + <image class="zar_img" src="../../source/{{item.isLike == 1 ? 'zanguo.png' : 'like.png'}}"></image> | |
| 32 | 32 | <view class="content_zar">{{item.likeCount}}</view> |
| 33 | 33 | </view> |
| 34 | 34 |