Commit 8d8216a8 authored by David黄金龙's avatar David黄金龙

首页 逻辑

parent 1b118b8a
...@@ -62,9 +62,7 @@ class YHHomePageViewController: YHBaseViewController { ...@@ -62,9 +62,7 @@ class YHHomePageViewController: YHBaseViewController {
func getData() { func getData() {
viewModel.getHomeNewsList {[weak self] success, error in viewModel.getHomeNewsList {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
// DispatchQueue.main.async { self.homeCollectView.reloadData()
self.homeCollectView.reloadData()
// }
} }
viewModel.getHomeBanner(0) {[weak self] success, error in viewModel.getHomeBanner(0) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
......
...@@ -15,7 +15,8 @@ class YHHomeListModel: YHBaseModel { ...@@ -15,7 +15,8 @@ class YHHomeListModel: YHBaseModel {
var content: String = "" var content: String = ""
var view_count: Int = 0 var view_count: Int = 0
var img_url: String = "" var img_url: String = ""
var type: Int = 0 var type: Int = 0 //文章类型 '文章类型 1视频 2图文 3图片',
var is_like : Bool = false
//网络返回的图片宽高 //网络返回的图片宽高
var img_width: CGFloat = 0 var img_width: CGFloat = 0
...@@ -48,8 +49,8 @@ class YHHomeListModel: YHBaseModel { ...@@ -48,8 +49,8 @@ class YHHomeListModel: YHBaseModel {
var textHeight : CGFloat = size.height var textHeight : CGFloat = size.height
if textHeight > 40.0 { if textHeight > 40.0 {
textHeight = 40.0 textHeight = 40.0
} else if textHeight < 20.0 { } else if textHeight < 16 {
textHeight = 20.0 textHeight = 16
} }
self.textH = textHeight self.textH = textHeight
...@@ -64,12 +65,13 @@ class YHHomeListModel: YHBaseModel { ...@@ -64,12 +65,13 @@ class YHHomeListModel: YHBaseModel {
} }
} }
let totalHeight = imageHeight + textHeight + 30 + 18 let totalHeight = imageHeight + textHeight + 30 + 16
self.img_width_use = width self.img_width_use = width
self.img_height_use = imageHeight self.img_height_use = imageHeight
self.img_width_cell = width self.img_width_cell = width
self.img_height_cell = totalHeight self.img_height_cell = totalHeight
} }
} }
...@@ -95,7 +95,7 @@ class YHHomeCollectionViewCell: UICollectionViewCell { ...@@ -95,7 +95,7 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
numLable.snp.makeConstraints { make in numLable.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-8) make.right.equalToSuperview().offset(-8)
make.top.equalTo(descripeLable.snp.bottom).offset(10) make.top.equalTo(descripeLable.snp.bottom).offset(10)
make.height.equalTo(18) make.height.equalTo(16)
} }
subHoldView.addSubview(heartImageView) subHoldView.addSubview(heartImageView)
...@@ -125,5 +125,12 @@ class YHHomeCollectionViewCell: UICollectionViewCell { ...@@ -125,5 +125,12 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
make.bottom.equalTo(-36) make.bottom.equalTo(-36)
} }
numLable.text = listModel.collect_count.string numLable.text = listModel.collect_count.string
if listModel.is_like {
headImageView.image = UIImage(named: "home_red_heart")
} else {
headImageView.image = UIImage(named: "home_grey_heart")
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment