func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 2
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if section == 0{
if chiefModel?.data?.banner != nil {
return 1
}
}else if section == 1{
let number = chiefModel?.data?.chefList?.count
if number != nil {
return number!
}
}
return 0
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
if indexPath.section == 0{
let cell = HPChiefBannerCell.createChiefBannerCellForCollectionView(collectionView, atIndexPath: indexPath, withChiefModel: chiefModel!)
return cell
} else if indexPath.section == 1{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("chiefCellId", forIndexPath: indexPath) as! HPChiefCollectionViewCell
Util.decorateView(cell)
let models = chiefModel?.data?.chefList
let model = models![indexPath.item]
let urlString = model.imageurl
let url = NSURL(string: urlString!)
cell.imageView.kf_setImageWithURL(url, placeholderImage: UIImage(named: "sdefaultImage"), optionsInfo: nil, progressBlock: nil, completionHandler: nil)
cell.nameLabel.text = model.name
cell.orderLabel.text = "\((model.orderedCount)!)人已预订 | \((model.likeCount)!)人喜欢"
cell.introduceLabel.text = model.introduce
return cell
}
return UICollectionViewCell()
}