Commit 319ce06e26741581dc0398b165d401e32610639f
1 parent
d64bb2f9f3
Exists in
master
and in
2 other branches
no message
Showing 2 changed files with 21 additions and 16 deletions
littleApp_child/pages/childcare_knowledge/childcare_knowledge.js
View file @
319ce06
| ... | ... | @@ -110,6 +110,13 @@ |
| 110 | 110 | url: '../SearchPage/SearchPage', |
| 111 | 111 | }) |
| 112 | 112 | }, |
| 113 | + toDetail:function(e){ | |
| 114 | + var self = this | |
| 115 | + var id = e.currentTarget.dataset.id | |
| 116 | + wx.navigateTo({ | |
| 117 | + url: '../childcare_knowledge_detail/childcare_knowledge_detail?id=' + id + ' & category=' + self.data.category, | |
| 118 | + }) | |
| 119 | + }, | |
| 113 | 120 | /*---------自定义函数--------*/ |
| 114 | 121 | requestData(){ |
| 115 | 122 | var self = this |
| 116 | 123 | |
| 117 | 124 | |
| 118 | 125 | |
| 119 | 126 | |
| 120 | 127 | |
| 121 | 128 | |
| 122 | 129 | |
| ... | ... | @@ -139,31 +146,29 @@ |
| 139 | 146 | }) |
| 140 | 147 | }, |
| 141 | 148 | // 文章点赞 |
| 142 | - articleLike(e) { | |
| 149 | + articleLike: function (e){ | |
| 143 | 150 | console.log(e) |
| 144 | 151 | var self = this |
| 152 | + var id = e.currentTarget.dataset.id | |
| 153 | + var index = e.currentTarget.dataset.index | |
| 145 | 154 | // 已经点赞 |
| 146 | - if (self.data.articleDetail.isLike == 1) { | |
| 155 | + if (self.data.list[index].isLike == 1) { | |
| 147 | 156 | networkUtil.showErrorToast('您已经点过赞啦') |
| 148 | 157 | return; |
| 149 | 158 | } |
| 150 | - networkUtil._post(api.articleLike, { id: articleId }, function (res) { | |
| 159 | + networkUtil._post(api.articleLike, { id: id }, function (res) { | |
| 151 | 160 | console.log(res) |
| 152 | - var art = self.data.articleDetail | |
| 153 | - art.likeCount++ | |
| 154 | - art.isLike = 1 | |
| 161 | + | |
| 162 | + self.data.list[index].likeCount++ | |
| 163 | + self.data.list[index].isLike = 1 | |
| 155 | 164 | self.setData({ |
| 156 | - articleDetail: art | |
| 165 | + list: self.data.list | |
| 157 | 166 | }) |
| 158 | - if (categoryIndex) { | |
| 159 | - // 更新首页数据 | |
| 160 | - event.emit('likeChanged', { categoryIndex: categoryIndex, articleIdIndex: articleIdIndex }); | |
| 161 | - } else { | |
| 162 | - event.emit('listLikeChanged', { categoryIndex: categoryIndex, articleIdIndex: articleIdIndex }); | |
| 163 | - } | |
| 167 | + | |
| 164 | 168 | }, function (res) { |
| 165 | 169 | console.log(res) |
| 166 | 170 | }) |
| 167 | 171 | }, |
| 172 | + | |
| 168 | 173 | }) |
littleApp_child/pages/childcare_knowledge/childcare_knowledge.wxml
View file @
319ce06
| ... | ... | @@ -22,12 +22,12 @@ |
| 22 | 22 | </swiper> --> |
| 23 | 23 | <image class="swiper" mode="aspectFill" src="{{images.medium}}"></image> |
| 24 | 24 | <view> |
| 25 | - <navigator url="../childcare_knowledge_detail/childcare_knowledge_detail?{{'id=' + item.id + '&category=' + category}}" wx:for="{{list}}" wx:key="{{index}}"> | |
| 25 | + <view bindtap="toDetail" data-id="{{item.id}}" wx:for="{{list}}" wx:key="{{index}}"> | |
| 26 | 26 | <view class="content_item"> |
| 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" bindtap="articleLike" data-categaryIndex="{{sectionIndex}}" data-artIndex="{{index}}"> | |
| 30 | + <view class="zar_box" catchtap="articleLike" data-id="{{item.id}}" data-index="{{index}}"> | |
| 31 | 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> |
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | <image class="content_image" src="{{item.image.medium}}"></image> |
| 37 | 37 | </view> |
| 38 | 38 | <view class="home__list-item__bottom"></view> |
| 39 | - </navigator> | |
| 39 | + </view> | |
| 40 | 40 | <view class="loadMoreView" wx:if="{{hasMore}}">加载更多...</view> |
| 41 | 41 | </view> |
| 42 | 42 | </scroll-view> |