|
@@ -9,24 +9,12 @@
|
|
|
import UIKit
|
|
|
import SwiftyJSON
|
|
|
|
|
|
-class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
+class ProductDetailProductLabelTableViewCell: UITableViewCell {
|
|
|
|
|
|
- var productDetailModel : ProductDetailModel? {
|
|
|
- didSet {
|
|
|
- if productDetailModel?.report?.isEmpty ?? true {
|
|
|
- iconImageView.isHidden = true
|
|
|
- titleLabel.isHidden = true
|
|
|
- }else {
|
|
|
- iconImageView.isHidden = false
|
|
|
- titleLabel.isHidden = false
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailProductSkuTableViewCell {
|
|
|
+ class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailProductLabelTableViewCell {
|
|
|
let ID = "ProductDetailProductSkuTableViewCell"
|
|
|
- tableView.register(ProductDetailProductSkuTableViewCell.self, forCellReuseIdentifier: ID)
|
|
|
- let cell : ProductDetailProductSkuTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! ProductDetailProductSkuTableViewCell
|
|
|
+ tableView.register(ProductDetailProductLabelTableViewCell.self, forCellReuseIdentifier: ID)
|
|
|
+ let cell : ProductDetailProductLabelTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! ProductDetailProductLabelTableViewCell
|
|
|
cell.indexPath = indexPath
|
|
|
return cell
|
|
|
}
|
|
@@ -49,55 +37,41 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
//MRAK: - 设置View
|
|
|
private func setupViews() {
|
|
|
self.selectionStyle = .none
|
|
|
- addSubview(bgView)
|
|
|
- bgView.addSubview(skuLabel)
|
|
|
- bgView.addSubview(goImageView)
|
|
|
- bgView.addSubview(selectedLabel)
|
|
|
-
|
|
|
addSubview(iconCollectionView)
|
|
|
- addSubview(iconImageView)
|
|
|
- addSubview(titleLabel)
|
|
|
+ addSubview(bgView)
|
|
|
+ bgView.addSubview(iconImageView)
|
|
|
+ bgView.addSubview(titleLabel)
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
private func setupLayouts() {
|
|
|
- bgView.snp.makeConstraints { (make) in
|
|
|
- make.top.left.right.equalToSuperview()
|
|
|
- make.bottom.equalTo(iconCollectionView.snp.top)
|
|
|
- }
|
|
|
+// bgView.snp.makeConstraints { (make) in
|
|
|
+// make.top.left.right.equalToSuperview()
|
|
|
+// make.bottom.equalTo(iconCollectionView.snp.top)
|
|
|
+// }
|
|
|
|
|
|
-
|
|
|
- goImageView.snp.makeConstraints { (make) in
|
|
|
- make.centerY.equalToSuperview()
|
|
|
- make.right.equalTo(-14)
|
|
|
- }
|
|
|
-
|
|
|
- selectedLabel.snp.makeConstraints { (make) in
|
|
|
- make.centerY.equalToSuperview()
|
|
|
- make.left.equalTo(14)
|
|
|
- }
|
|
|
-
|
|
|
- skuLabel.snp.makeConstraints { (make) in
|
|
|
- make.centerY.equalToSuperview()
|
|
|
- make.left.equalTo(selectedLabel.snp.right).offset(27)
|
|
|
- make.right.equalTo(-14)
|
|
|
- make.bottom.equalToSuperview()
|
|
|
- }
|
|
|
|
|
|
iconCollectionView.snp.makeConstraints { (make) in
|
|
|
- make.top.equalTo(bgView.snp.bottom)
|
|
|
- make.height.equalTo(75)
|
|
|
+ make.top.equalToSuperview()
|
|
|
+ make.height.equalTo(65 * kScaleWidth)
|
|
|
make.left.equalTo(0)
|
|
|
make.width.equalTo(4*(kScreenWidth/5))
|
|
|
}
|
|
|
- iconImageView.snp.remakeConstraints { (make) in
|
|
|
- make.top.equalTo(bgView.snp.bottom).offset(10)
|
|
|
- make.left.equalTo(iconCollectionView.snp.right).offset(((kScreenWidth/5)-(32*kScaleWidth))/2)
|
|
|
- make.size.equalTo(32*kScaleWidth)
|
|
|
+ bgView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(10)
|
|
|
+ make.bottom.equalTo(10)
|
|
|
+ make.right.equalToSuperview()
|
|
|
+ make.width.equalTo(kScreenWidth/5)
|
|
|
+ }
|
|
|
+ iconImageView.snp.makeConstraints { (make) in
|
|
|
+ make.top.centerX.equalToSuperview()
|
|
|
+ make.size.equalTo(32 * kScaleWidth)
|
|
|
}
|
|
|
- titleLabel.snp.remakeConstraints { (make) in
|
|
|
+ titleLabel.snp.makeConstraints { (make) in
|
|
|
make.top.equalTo(iconImageView.snp.bottom).offset(5)
|
|
|
- make.centerX.equalTo(iconImageView)
|
|
|
+ make.centerX.equalToSuperview()
|
|
|
+ make.bottom.equalToSuperview()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -111,28 +85,6 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
ProductDetailSkuView.productDetailSkuView(productDetailModel: productDetailModel!)
|
|
|
}
|
|
|
|
|
|
- lazy var skuLabel: UILabel = {
|
|
|
- let skuLabel = UILabel()
|
|
|
- skuLabel.text = "请选择规格"
|
|
|
- skuLabel.textColor = k333333Color
|
|
|
- skuLabel.font = kRegularFont13
|
|
|
- return skuLabel
|
|
|
- }()
|
|
|
-
|
|
|
- private lazy var selectedLabel : UILabel = {
|
|
|
- let selectedLabel = UILabel()
|
|
|
- selectedLabel.text = "选择"
|
|
|
- selectedLabel.textColor = k999999Color
|
|
|
- selectedLabel.font = kScaleRegularFont13
|
|
|
- return selectedLabel
|
|
|
- }()
|
|
|
-
|
|
|
- lazy var goImageView: UIImageView = {
|
|
|
- let goImageView = UIImageView()
|
|
|
- goImageView.image = kImage(name: "my_arrows_unfold")
|
|
|
- return goImageView
|
|
|
- }()
|
|
|
-
|
|
|
|
|
|
private lazy var iconCollectionView: UICollectionView = {
|
|
|
let iconCollectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: iconCollectionViewLayout)
|
|
@@ -144,6 +96,7 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
iconCollectionView.cornerRadius = 4
|
|
|
iconCollectionView.masksToBounds = true
|
|
|
return iconCollectionView
|
|
|
+
|
|
|
}()
|
|
|
|
|
|
private lazy var iconCollectionViewLayout: UICollectionViewFlowLayout = {
|
|
@@ -151,7 +104,7 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
iconCollectionViewLayout.minimumLineSpacing = 0
|
|
|
iconCollectionViewLayout.minimumInteritemSpacing = 0
|
|
|
iconCollectionViewLayout.itemSize = CGSize(width: kScreenWidth/5, height: kScaleWidth * 55)
|
|
|
-// iconCollectionViewLayout.scrollDirection = .horizontal
|
|
|
+ iconCollectionViewLayout.scrollDirection = .horizontal
|
|
|
return iconCollectionViewLayout
|
|
|
}()
|
|
|
lazy var iconImageView : UIImageView = {
|
|
@@ -168,6 +121,18 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
return titleLabel
|
|
|
}()
|
|
|
|
|
|
+ var productDetailModel : ProductDetailModel? {
|
|
|
+ didSet {
|
|
|
+ if productDetailModel?.report?.isEmpty ?? true {
|
|
|
+ iconImageView.isHidden = true
|
|
|
+ titleLabel.isHidden = true
|
|
|
+ }else {
|
|
|
+ iconImageView.isHidden = false
|
|
|
+ titleLabel.isHidden = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//加载数据
|
|
|
func reloadData() {
|
|
@@ -177,7 +142,7 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
//更新collectionView的高度约束
|
|
|
let contentSize1 = self.iconCollectionView.collectionViewLayout.collectionViewContentSize
|
|
|
iconCollectionView.snp.remakeConstraints { (make) in
|
|
|
- make.top.equalTo(bgView.snp.bottom)
|
|
|
+ make.top.equalToSuperview()
|
|
|
make.height.equalTo(contentSize1.height)
|
|
|
make.left.equalTo(0)
|
|
|
make.width.equalTo(4*(kScreenWidth/5))
|
|
@@ -188,7 +153,7 @@ class ProductDetailProductSkuTableViewCell: UITableViewCell {
|
|
|
|
|
|
}
|
|
|
|
|
|
-extension ProductDetailProductSkuTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
|
|
|
+extension ProductDetailProductLabelTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
|
|
|
func numberOfSections(in collectionView: UICollectionView) -> Int {
|
|
|
return 1
|
|
|
}
|
|
@@ -198,7 +163,7 @@ extension ProductDetailProductSkuTableViewCell: UICollectionViewDelegateFlowLayo
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
- let cell = ProductDetailProductSkuIconCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
+ let cell = ProductDetailProductLabelIconCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
return cell
|
|
|
|
|
|
}
|