|
@@ -9,13 +9,149 @@
|
|
|
import UIKit
|
|
|
|
|
|
class ProductAllCommentView: BaseView {
|
|
|
+
|
|
|
+ var productAllCommentArray : Array<ProductCommentModel>? {
|
|
|
+ didSet {
|
|
|
+ if productAllCommentArray?.isEmpty ?? true {
|
|
|
+ tableView.isHiddenFooter(true)
|
|
|
+ }else {
|
|
|
+ tableView.isHiddenFooter(false)
|
|
|
+ }
|
|
|
+ tableView.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /*
|
|
|
- // Only override draw() if you perform custom drawing.
|
|
|
- // An empty implementation adversely affects performance during animation.
|
|
|
- override func draw(_ rect: CGRect) {
|
|
|
- // Drawing code
|
|
|
+
|
|
|
+ override func setupViews() {
|
|
|
+ addSubview(bottomBgView)
|
|
|
+ bottomBgView.addSubview(cartButton)
|
|
|
+ cartButton.addSubview(cartImageView)
|
|
|
+ bottomBgView.addSubview(addCartButton)
|
|
|
+ bottomBgView.addSubview(buyButton)
|
|
|
+ addSubview(tableView)
|
|
|
+ let emptyView = EmptyView.shared.diyCustomEmptyViewStyle2(iconStr: "page04", titleStr: "当前暂无数据")
|
|
|
+ emptyView.contentViewY = kScaleValue(value: 182)
|
|
|
+ tableView.ly_emptyView = emptyView
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupLayouts() {
|
|
|
+ bottomBgView.snp.makeConstraints { (make) in
|
|
|
+ make.left.bottom.right.equalToSuperview()
|
|
|
+ make.height.equalTo(50 + kSafeTabBarHeight)
|
|
|
+ }
|
|
|
+ cartButton.snp.makeConstraints { (make) in
|
|
|
+ make.top.left.equalToSuperview()
|
|
|
+ make.width.equalTo(71 * kScaleWidth)
|
|
|
+ make.bottom.equalTo(-kSafeTabBarHeight)
|
|
|
+ }
|
|
|
+ cartImageView.snp.makeConstraints { (make) in
|
|
|
+ make.center.equalToSuperview()
|
|
|
+ }
|
|
|
+ addCartButton.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalTo(cartButton.snp.right)
|
|
|
+ make.top.bottom.equalTo(cartButton)
|
|
|
+ make.width.equalTo(152 * kScaleWidth)
|
|
|
+ }
|
|
|
+ buyButton.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalTo(addCartButton.snp.right)
|
|
|
+ make.top.bottom.equalTo(cartButton)
|
|
|
+ make.width.equalTo(152 * kScaleWidth)
|
|
|
+ }
|
|
|
+ tableView.snp.makeConstraints { (make) in
|
|
|
+ make.top.left.right.equalToSuperview()
|
|
|
+ make.bottom.equalTo(bottomBgView.snp.top)
|
|
|
+ }
|
|
|
}
|
|
|
- */
|
|
|
+
|
|
|
+ lazy var tableView: UITableView = {
|
|
|
+ let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
|
|
|
+ tableView.separatorStyle = .none
|
|
|
+ tableView.backgroundColor = kf7f8faColor
|
|
|
+ tableView.dataSource = self
|
|
|
+ tableView.delegate = self
|
|
|
+ tableView.estimatedRowHeight = 0.000001
|
|
|
+ return tableView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var bottomBgView: UIView = {
|
|
|
+ let bottomBgView = UIView()
|
|
|
+ return bottomBgView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var cartButton : UIButton = {
|
|
|
+ let cartButton = UIButton()
|
|
|
+ return cartButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var cartImageView: UIImageView = {
|
|
|
+ let cartImageView = UIImageView()
|
|
|
+ cartImageView.image = kImage(name: "tabbar_shopping")
|
|
|
+ cartImageView.pp.addBadge(number: 2)
|
|
|
+ // shoppingCarButton.pp.setBadge(height: 14)
|
|
|
+ // shoppingCarButton.pp.badgeView.font = kRegularFont10
|
|
|
+ cartImageView.pp.badgeView.backgroundColor = kfe352bColor
|
|
|
+ cartImageView.pp.moveBadge(x: -2, y: 2)
|
|
|
+ return cartImageView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var addCartButton : UIButton = {
|
|
|
+ let addCartButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ addCartButton.setTitle("加入购物车", for: UIControl.State.normal)
|
|
|
+ addCartButton.setTitleColor(UIColor.white, for: UIControl.State.normal)
|
|
|
+ addCartButton.backgroundColor = k404040Color
|
|
|
+ addCartButton.titleLabel?.font = kRegularFont16
|
|
|
+ return addCartButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var buyButton : UIButton = {
|
|
|
+ let buyButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ buyButton.setTitle("立即购买", for: UIControl.State.normal)
|
|
|
+ buyButton.setTitleColor(UIColor.white, for: UIControl.State.normal)
|
|
|
+ buyButton.backgroundColor = kFFA42FColor
|
|
|
+ buyButton.titleLabel?.font = kRegularFont16
|
|
|
+ buyButton.rx.tap.subscribe(onNext: {
|
|
|
+ [weak self](data) in
|
|
|
+// self?.productDetailSkuView()
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return buyButton
|
|
|
+ }()
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
+extension ProductAllCommentView : UITableViewDelegate, UITableViewDataSource {
|
|
|
+ func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
+ return productAllCommentArray?.isEmpty ?? true ? 0 : 1
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
+ return productAllCommentArray?.isEmpty ?? true ? 0 : productAllCommentArray?.count ?? 0
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
+
|
|
|
+ let cell = ProductDetailEvaluationListTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ cell.productCommentModel = productAllCommentArray?[indexPath.row]
|
|
|
+ return cell
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
|
+ return UITableView.automaticDimension
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
|
+ return 10
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
|
|
|
+ return 10
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
}
|