Commit bf53e195a555539c8b00ea6084ef5f8cdb6e37c1
1 parent
1a9a8031
点赞处理数据
Showing
2 changed files
with
22 additions
and
11 deletions
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
| @@ -866,14 +866,14 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -866,14 +866,14 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 866 | return cell | 866 | return cell |
| 867 | } | 867 | } |
| 868 | cell.vodPlayBlockListModel = vodPlayBlockListModel | 868 | cell.vodPlayBlockListModel = vodPlayBlockListModel |
| 869 | - cell.updateCellBlock = {[weak self] isExpand,isFavorite,isCollection,type,vodPlayBlockListListModel in | 869 | + cell.updateCellBlock = {[weak self] isExpand,isFavorite,favoriteNum,isCollection,type,vodPlayBlockListListModel in |
| 870 | guard let self = self else { return } | 870 | guard let self = self else { return } |
| 871 | if type == "1"{ | 871 | if type == "1"{ |
| 872 | //点击了详情按钮 | 872 | //点击了详情按钮 |
| 873 | self.introducCellDetailBtnAction(vodPlayBlockListListModel: vodPlayBlockListListModel) | 873 | self.introducCellDetailBtnAction(vodPlayBlockListListModel: vodPlayBlockListListModel) |
| 874 | }else if type == "2"{ | 874 | }else if type == "2"{ |
| 875 | //点击了点赞按钮 | 875 | //点击了点赞按钮 |
| 876 | - self.vodSupport(vodPlayBlockListListModel: vodPlayBlockListListModel, isLiked: isFavorite) | 876 | + self.vodSupport(vodPlayBlockListListModel: vodPlayBlockListListModel, isLiked: isFavorite, favoriteNum: favoriteNum) |
| 877 | }else if type == "3"{ | 877 | }else if type == "3"{ |
| 878 | //点击了收藏按钮 | 878 | //点击了收藏按钮 |
| 879 | self.vodCollection(vodPlayBlockListListModel: vodPlayBlockListListModel, isCollectioned: isCollection) | 879 | self.vodCollection(vodPlayBlockListListModel: vodPlayBlockListListModel, isCollectioned: isCollection) |
| @@ -1328,11 +1328,21 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -1328,11 +1328,21 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 1328 | 1328 | ||
| 1329 | } | 1329 | } |
| 1330 | 1330 | ||
| 1331 | - func vodSupport(vodPlayBlockListListModel:CNLiveVodPlayBlockListListModel,isLiked:Bool){ | 1331 | + func vodSupport(vodPlayBlockListListModel:CNLiveVodPlayBlockListListModel,isLiked:Bool,favoriteNum:Int){ |
| 1332 | CNLiveVodPlayViewModel.vodSupport(contentId: vodPlayBlockListListModel.pid, support: isLiked) {[weak self] result, status in | 1332 | CNLiveVodPlayViewModel.vodSupport(contentId: vodPlayBlockListListModel.pid, support: isLiked) {[weak self] result, status in |
| 1333 | guard let self = self else { return } | 1333 | guard let self = self else { return } |
| 1334 | if status == .success{ | 1334 | if status == .success{ |
| 1335 | - | 1335 | + if let vodPlayBlockListModel = self.dataArray[0] as? CNLiveVodPlayBlockListModel{ |
| 1336 | + if vodPlayBlockListModel.type == "5"{//简介 | ||
| 1337 | + if let model = vodPlayBlockListModel.list.first{ | ||
| 1338 | + model.liked = isLiked | ||
| 1339 | + model.likesNum = favoriteNum | ||
| 1340 | + self.dataArray.replaceObject(at: 0, with: vodPlayBlockListModel) | ||
| 1341 | + } | ||
| 1342 | + | ||
| 1343 | + } | ||
| 1344 | + } | ||
| 1345 | + self.tableView.reloadRow(at: IndexPath(row: 0, section: 0), with: .none) | ||
| 1336 | } | 1346 | } |
| 1337 | } | 1347 | } |
| 1338 | } | 1348 | } |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodIntroductionCell.swift
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | 9 | ||
| 10 | // type 1详情按钮 2点赞按钮 3收藏按钮 4分享按钮 | 10 | // type 1详情按钮 2点赞按钮 3收藏按钮 4分享按钮 |
| 11 | -typealias CNLiveVodIntroductionCellUpdateBlock = (_ isExpandDetail:Bool,_ isFavorite:Bool,_ isCollection:Bool,_ type:String,_ model:CNLiveVodPlayBlockListListModel)->Void | 11 | +typealias CNLiveVodIntroductionCellUpdateBlock = (_ isExpandDetail:Bool,_ isFavorite:Bool ,_ favoriteNum:Int,_ isCollection:Bool,_ type:String,_ model:CNLiveVodPlayBlockListListModel)->Void |
| 12 | class CNLiveVodIntroductionCell:UITableViewCell{ | 12 | class CNLiveVodIntroductionCell:UITableViewCell{ |
| 13 | 13 | ||
| 14 | var updateCellBlock:CNLiveVodIntroductionCellUpdateBlock? | 14 | var updateCellBlock:CNLiveVodIntroductionCellUpdateBlock? |
| @@ -171,24 +171,25 @@ class CNLiveVodIntroductionCell:UITableViewCell{ | @@ -171,24 +171,25 @@ class CNLiveVodIntroductionCell:UITableViewCell{ | ||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | @objc func detailBtnAction(){ | 173 | @objc func detailBtnAction(){ |
| 174 | - self.updateCellBlock?(true, false, false, "1",self.vodPlayBlockListModel!.list.first!) | 174 | + self.updateCellBlock?(true, false,0, false, "1",self.vodPlayBlockListModel!.list.first!) |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | @objc func likeBtnAction(){ | 177 | @objc func likeBtnAction(){ |
| 178 | likeBtn.isSelected = likeBtn.isSelected ? false : true | 178 | likeBtn.isSelected = likeBtn.isSelected ? false : true |
| 179 | let vodMdl = self.vodPlayBlockListModel!.list.first! | 179 | let vodMdl = self.vodPlayBlockListModel!.list.first! |
| 180 | let num = likeBtn.isSelected ? 1 : -1 | 180 | let num = likeBtn.isSelected ? 1 : -1 |
| 181 | - likeBtn.setTitle("\(vodMdl.likesNum+num)", for: .normal) | ||
| 182 | - likeBtn.setTitle("\(vodMdl.likesNum+num)", for: .selected) | 181 | + let likeNum = ((vodMdl.likesNum+num) == -1) ? 0 : vodMdl.likesNum+num |
| 182 | + likeBtn.setTitle("\(likeNum)", for: .normal) | ||
| 183 | + likeBtn.setTitle("\(likeNum)", for: .selected) | ||
| 183 | 184 | ||
| 184 | - self.updateCellBlock?(false, likeBtn.isSelected, false, "2",self.vodPlayBlockListModel!.list.first!) | 185 | + self.updateCellBlock?(false, likeBtn.isSelected,likeNum, false, "2",self.vodPlayBlockListModel!.list.first!) |
| 185 | } | 186 | } |
| 186 | @objc func collectionBtnAction(){ | 187 | @objc func collectionBtnAction(){ |
| 187 | collectionBtn.isSelected = collectionBtn.isSelected ? false : true | 188 | collectionBtn.isSelected = collectionBtn.isSelected ? false : true |
| 188 | - self.updateCellBlock?(false, false, true, "3",self.vodPlayBlockListModel!.list.first!) | 189 | + self.updateCellBlock?(false, false,0, true, "3",self.vodPlayBlockListModel!.list.first!) |
| 189 | } | 190 | } |
| 190 | @objc func shareBtnAction(){ | 191 | @objc func shareBtnAction(){ |
| 191 | - self.updateCellBlock?(false, false, false, "4",self.vodPlayBlockListModel!.list.first!) | 192 | + self.updateCellBlock?(false, false,0, false, "4",self.vodPlayBlockListModel!.list.first!) |
| 192 | } | 193 | } |
| 193 | 194 | ||
| 194 | 195 |