|
@@ -21,12 +21,25 @@ class SpecialView: BaseView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var cmsRuleModel : CMSRuleModel? {
|
|
|
+ didSet {
|
|
|
+ specialBannerView.cmsRuleModel = cmsRuleModel
|
|
|
+ tableView.tableHeaderView = specialBannerView
|
|
|
+ tableView.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
typealias DidSelectRow = (_ indexPath: IndexPath) -> Void
|
|
|
var didSelectRow : DidSelectRow?
|
|
|
|
|
|
+ typealias AddCartClosure = (ProductSearchModel,IndexPath) -> Void
|
|
|
+ var addCartClosure : AddCartClosure?
|
|
|
|
|
|
override func setupViews() {
|
|
|
addSubview(tableView)
|
|
|
+ let emptyView = EmptyView.shared.diyCustomEmptyViewStyle2(iconStr: "page04", titleStr: "当前暂无数据")
|
|
|
+ emptyView.contentViewY = kScaleValue(value: 182)
|
|
|
+ tableView.ly_emptyView = emptyView
|
|
|
+ tableView.ly_startLoading()
|
|
|
}
|
|
|
|
|
|
override func setupLayouts() {
|
|
@@ -37,16 +50,15 @@ class SpecialView: BaseView {
|
|
|
|
|
|
//左侧表格
|
|
|
lazy var tableView : UITableView = {
|
|
|
- let tableView = UITableView()
|
|
|
+ let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
|
|
|
tableView.delegate = self
|
|
|
tableView.dataSource = self
|
|
|
tableView.showsVerticalScrollIndicator = false
|
|
|
tableView.separatorColor = UIColor.clear
|
|
|
tableView.backgroundColor = kf5f5f5Color
|
|
|
- tableView.tableHeaderView = specialBannerView
|
|
|
return tableView
|
|
|
}()
|
|
|
- //
|
|
|
+
|
|
|
lazy var specialBannerView: SpecialBannerView = {
|
|
|
let specialBannerView = SpecialBannerView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 110 * kScaleWidth))
|
|
|
return specialBannerView
|
|
@@ -57,14 +69,12 @@ class SpecialView: BaseView {
|
|
|
extension SpecialView : UITableViewDataSource, UITableViewDelegate {
|
|
|
//表格分区数
|
|
|
func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
-// return productSearchModelArray?.isEmpty ?? true ? 0 : 1
|
|
|
- return 1
|
|
|
+ return productSearchModelArray?.isEmpty ?? true ? 0 : 1
|
|
|
}
|
|
|
|
|
|
//分区下单元格数量
|
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
-// return productSearchModelArray?.isEmpty ?? true ? 0 : productSearchModelArray?.count ?? 0
|
|
|
- return 10
|
|
|
+ return productSearchModelArray?.isEmpty ?? true ? 0 : productSearchModelArray?.count ?? 0
|
|
|
}
|
|
|
|
|
|
//返回自定义单元格
|
|
@@ -77,29 +87,46 @@ extension SpecialView : UITableViewDataSource, UITableViewDelegate {
|
|
|
//下面为设置圆角操作(通过遮罩实现)
|
|
|
let shapeLayer = CAShapeLayer()
|
|
|
cell.layer.mask = nil
|
|
|
- switch indexPath.row {
|
|
|
- //如果是第一行,左上、右上角为圆角
|
|
|
- case 0:
|
|
|
+ if productSearchModelArray!.count == 1 {
|
|
|
var bounds = cell.bounds
|
|
|
bounds.origin.y += 1.0 //这样每一组首行顶部分割线不显示
|
|
|
let bezierPath = UIBezierPath(roundedRect: bounds,
|
|
|
- byRoundingCorners: [.topLeft,.topRight],
|
|
|
+ byRoundingCorners: [.allCorners],
|
|
|
cornerRadii: CGSize(width: cornerRadius,height: cornerRadius))
|
|
|
shapeLayer.path = bezierPath.cgPath
|
|
|
cell.layer.mask = shapeLayer
|
|
|
- //如果是最后一行,左下、右下角为圆角
|
|
|
- case 9:
|
|
|
- var bounds = cell.bounds
|
|
|
- bounds.size.height -= 1.0 //这样每一组尾行底部分割线不显示
|
|
|
- let bezierPath = UIBezierPath(roundedRect: bounds,
|
|
|
- byRoundingCorners: [.bottomLeft,.bottomRight],
|
|
|
- cornerRadii: CGSize(width: cornerRadius,height: cornerRadius))
|
|
|
- shapeLayer.path = bezierPath.cgPath
|
|
|
- cell.layer.mask = shapeLayer
|
|
|
- default:
|
|
|
- break
|
|
|
+ }else {
|
|
|
+ switch indexPath.row {
|
|
|
+ //如果是第一行,左上、右上角为圆角
|
|
|
+ case 0:
|
|
|
+ var bounds = cell.bounds
|
|
|
+ bounds.origin.y += 1.0 //这样每一组首行顶部分割线不显示
|
|
|
+ let bezierPath = UIBezierPath(roundedRect: bounds,
|
|
|
+ byRoundingCorners: [.topLeft,.topRight],
|
|
|
+ cornerRadii: CGSize(width: cornerRadius,height: cornerRadius))
|
|
|
+ shapeLayer.path = bezierPath.cgPath
|
|
|
+ cell.layer.mask = shapeLayer
|
|
|
+ //如果是最后一行,左下、右下角为圆角
|
|
|
+ case productSearchModelArray!.count - 1:
|
|
|
+ var bounds = cell.bounds
|
|
|
+ bounds.size.height -= 1.0 //这样每一组尾行底部分割线不显示
|
|
|
+ let bezierPath = UIBezierPath(roundedRect: bounds,
|
|
|
+ byRoundingCorners: [.bottomLeft,.bottomRight],
|
|
|
+ cornerRadii: CGSize(width: cornerRadius,height: cornerRadius))
|
|
|
+ shapeLayer.path = bezierPath.cgPath
|
|
|
+ cell.layer.mask = shapeLayer
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
-// cell.productSearchModel = productSearchModelArray![indexPath.row]
|
|
|
+ cell.productSearchModel = productSearchModelArray![indexPath.row]
|
|
|
+ cell.plusClosure = {
|
|
|
+ [weak self] (productSearchModel,indexPath) in
|
|
|
+
|
|
|
+ if let addCartClosure = self?.addCartClosure {
|
|
|
+ addCartClosure(productSearchModel!,indexPath!)
|
|
|
+ }
|
|
|
+ }
|
|
|
return cell
|
|
|
}
|
|
|
|
|
@@ -113,14 +140,31 @@ extension SpecialView : UITableViewDataSource, UITableViewDelegate {
|
|
|
return 140
|
|
|
}
|
|
|
|
|
|
- //分区头高度(只有右侧表格有分区头)
|
|
|
+ //分区头高度
|
|
|
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
|
- return 0
|
|
|
+ if cmsRuleModel == nil {
|
|
|
+ return 10
|
|
|
+ }else {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //返回自定义分区头(只有右侧表格有分区头)
|
|
|
+ //返回自定义分区头
|
|
|
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
|
|
+ let view = UIView(frame: CGRect(x: 0, y: 0, width: kScaleWidth, height: 10))
|
|
|
+ view.backgroundColor = kf5f5f5Color
|
|
|
+ return view
|
|
|
+ }
|
|
|
+
|
|
|
+ //分区头高度
|
|
|
+ func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+
|
|
|
+ //返回自定义分区头
|
|
|
+ func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|