|
@@ -11,88 +11,9 @@ import PPBadgeViewSwift
|
|
|
import FWPopupView
|
|
|
|
|
|
class ProductDetailView: BaseView {
|
|
|
+
|
|
|
|
|
|
- typealias LookAllCommentClosure = () -> Void
|
|
|
- var lookAllCommentClosure : LookAllCommentClosure?
|
|
|
-
|
|
|
- typealias AddCartClosure = (ProductDetailSkuModel) -> Void
|
|
|
- var addCartClosure : AddCartClosure?
|
|
|
-
|
|
|
- typealias BuyNowClosure = (ProductDetailSkuModel) -> Void
|
|
|
- var buyNowClosure : BuyNowClosure?
|
|
|
-
|
|
|
- typealias CartButtonClosure = () -> Void
|
|
|
- var cartButtonClosure : CartButtonClosure?
|
|
|
-
|
|
|
- typealias JumpToShopTransClosure = (_ shopName: String,_ shopId : Int) -> Void
|
|
|
- var jumpToShopTransClosure : JumpToShopTransClosure?
|
|
|
-
|
|
|
- typealias JumpToDetailTransClosure = (_ proId: Int,_ shopId : Int) -> Void
|
|
|
- var jumpToDetailTransClosure : JumpToDetailTransClosure?
|
|
|
-
|
|
|
- var productDetailSkuModel : ProductDetailSkuModel?
|
|
|
-
|
|
|
- var titles = ["","","商品评价","","热销排行","商品参数","商品详情"]
|
|
|
-
|
|
|
- var index : Int? {
|
|
|
- didSet {
|
|
|
- if index == 0 {
|
|
|
- tableView.scrollToTop()
|
|
|
- }else {
|
|
|
- let reloadSection = 2 * index!
|
|
|
- let rect = tableView.rect(forSection: reloadSection)
|
|
|
- tableView.setContentOffset(CGPoint(x: 0, y: rect.origin.y - kNavBarTotalHeight), animated: true)
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var productDetailModel : ProductDetailModel? {
|
|
|
- didSet {
|
|
|
- tableView.ly_startLoading()
|
|
|
- if productDetailModel != nil {
|
|
|
- bottomBgView.isHidden = false
|
|
|
- topButton.isHidden = false
|
|
|
- if productDetailModel?.commentNumber != 0 && productDetailModel?.commentNumber != nil {
|
|
|
- titles[2] = "商品评价" + "(" + "\(productDetailModel?.commentNumber ?? 0)" + ")"
|
|
|
-
|
|
|
- }else {
|
|
|
- titles[2] = "商品评价" + "(" + "0" + ")"
|
|
|
- }
|
|
|
- if productDetailModel?.imgs?.isEmpty ?? true {
|
|
|
- tableView.tableHeaderView = nil
|
|
|
- }else {
|
|
|
- tableView.ly_hideEmpty()
|
|
|
- tableView.tableHeaderView = productDetailTableViewHeaderView
|
|
|
- productDetailTableViewHeaderView.productDetailModel = productDetailModel
|
|
|
- }
|
|
|
- //是否可以点击购买
|
|
|
- if productDetailModel?.totalStock == 0 || productDetailModel?.upStatus == 0 {
|
|
|
- self.nuablebuyLabel.isHidden = false
|
|
|
- }else {
|
|
|
- self.nuablebuyLabel.isHidden = true
|
|
|
- }
|
|
|
- }else {
|
|
|
- bottomBgView.isHidden = true
|
|
|
- topButton.isHidden = true
|
|
|
- }
|
|
|
- tableView.reloadData()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var productSearchListModel: ProductSearchListModel? {
|
|
|
- didSet {
|
|
|
- tableView.reloadData()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var productCommentListModel :ProductCommentListModel? {
|
|
|
- didSet {
|
|
|
- tableView.reloadData()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ /// 添加View
|
|
|
override func setupViews() {
|
|
|
backgroundColor = kf7f8faColor
|
|
|
addSubview(bottomBgView)
|
|
@@ -103,6 +24,7 @@ class ProductDetailView: BaseView {
|
|
|
bottomBgView.addSubview(nuablebuyLabel)
|
|
|
addSubview(tableView)
|
|
|
addSubview(topButton)
|
|
|
+ setProductDetailSkuView()
|
|
|
if #available(iOS 11.0, *) {
|
|
|
tableView.contentInsetAdjustmentBehavior = .never
|
|
|
}
|
|
@@ -111,6 +33,7 @@ class ProductDetailView: BaseView {
|
|
|
tableView.ly_emptyView = emptyView
|
|
|
}
|
|
|
|
|
|
+ /// 约束
|
|
|
override func setupLayouts() {
|
|
|
bottomBgView.snp.makeConstraints { (make) in
|
|
|
make.left.bottom.right.equalToSuperview()
|
|
@@ -178,11 +101,9 @@ class ProductDetailView: BaseView {
|
|
|
let cartButton = UIButton()
|
|
|
cartButton.rx.tap.subscribe(onNext: {
|
|
|
[weak self] (data) in
|
|
|
-
|
|
|
if let cartButtonClosure = self?.cartButtonClosure {
|
|
|
cartButtonClosure()
|
|
|
}
|
|
|
-
|
|
|
}).disposed(by: disposeBag)
|
|
|
return cartButton
|
|
|
}()
|
|
@@ -251,15 +172,14 @@ class ProductDetailView: BaseView {
|
|
|
return topButton
|
|
|
}()
|
|
|
|
|
|
+ let productDetailSkuView = ProductDetailSkuView(frame: CGRect(x: 0, y: 0, width: kScreenWidth , height: kScreenHeight - 76 - kNavBarTotalHeight))
|
|
|
|
|
|
- lazy var productDetailSkuView: ProductDetailSkuView = {
|
|
|
- let productDetailSkuView = ProductDetailSkuView(frame: CGRect(x: 0, y: 0, width: kScreenWidth , height: kScreenHeight - 76 - kNavBarTotalHeight))
|
|
|
+ func setProductDetailSkuView() {
|
|
|
let vProperty1 = FWPopupViewProperty()
|
|
|
vProperty1.popupCustomAlignment = .bottomCenter
|
|
|
vProperty1.popupAnimationType = .frame
|
|
|
vProperty1.maskViewColor = UIColor(white: 0, alpha: 0.5)
|
|
|
vProperty1.touchWildToHide = "0"
|
|
|
- vProperty1.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
|
|
|
vProperty1.animationDuration = 0.2
|
|
|
productDetailSkuView.vProperty = vProperty1
|
|
|
productDetailSkuView.sureClosure = {
|
|
@@ -268,10 +188,10 @@ class ProductDetailView: BaseView {
|
|
|
switch productDetailSkuViewType {
|
|
|
case .selectSku:
|
|
|
self?.tableView.reloadData()
|
|
|
- productDetailSkuView.hide()
|
|
|
+ self?.productDetailSkuView.hide()
|
|
|
break
|
|
|
case .buyNow:
|
|
|
- productDetailSkuView.hide(popupDidDisappearBlock: { (FWPopupView) in
|
|
|
+ self?.productDetailSkuView.hide(popupDidDisappearBlock: { (FWPopupView) in
|
|
|
self?.tableView.reloadData()
|
|
|
if let buyNowClosure = self?.buyNowClosure {
|
|
|
buyNowClosure((self?.productDetailSkuModel)!)
|
|
@@ -279,15 +199,94 @@ class ProductDetailView: BaseView {
|
|
|
})
|
|
|
break
|
|
|
case .addCart:
|
|
|
-
|
|
|
+
|
|
|
if let addCartClosure = self?.addCartClosure {
|
|
|
addCartClosure((self?.productDetailSkuModel)!)
|
|
|
}
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- return productDetailSkuView
|
|
|
- }()
|
|
|
+ }
|
|
|
+
|
|
|
+ typealias LookAllCommentClosure = () -> Void
|
|
|
+ var lookAllCommentClosure : LookAllCommentClosure?
|
|
|
+
|
|
|
+ typealias AddCartClosure = (ProductDetailSkuModel) -> Void
|
|
|
+ var addCartClosure : AddCartClosure?
|
|
|
+
|
|
|
+ typealias BuyNowClosure = (ProductDetailSkuModel) -> Void
|
|
|
+ var buyNowClosure : BuyNowClosure?
|
|
|
+
|
|
|
+ typealias CartButtonClosure = () -> Void
|
|
|
+ var cartButtonClosure : CartButtonClosure?
|
|
|
+
|
|
|
+ typealias JumpToShopTransClosure = (_ shopName: String,_ shopId : Int) -> Void
|
|
|
+ var jumpToShopTransClosure : JumpToShopTransClosure?
|
|
|
+
|
|
|
+ typealias JumpToDetailTransClosure = (_ proId: Int,_ shopId : Int) -> Void
|
|
|
+ var jumpToDetailTransClosure : JumpToDetailTransClosure?
|
|
|
+
|
|
|
+ var productDetailSkuModel : ProductDetailSkuModel?
|
|
|
+
|
|
|
+ var titles = ["","","商品评价","","热销排行","商品参数","商品详情"]
|
|
|
+
|
|
|
+ var index : Int? {
|
|
|
+ didSet {
|
|
|
+ if index == 0 {
|
|
|
+ tableView.scrollToTop()
|
|
|
+ }else {
|
|
|
+ let reloadSection = 2 * index!
|
|
|
+ let rect = tableView.rect(forSection: reloadSection)
|
|
|
+ tableView.setContentOffset(CGPoint(x: 0, y: rect.origin.y - kNavBarTotalHeight), animated: true)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var productDetailModel : ProductDetailModel? {
|
|
|
+ didSet {
|
|
|
+ tableView.ly_startLoading()
|
|
|
+ if productDetailModel != nil {
|
|
|
+ bottomBgView.isHidden = false
|
|
|
+ topButton.isHidden = false
|
|
|
+ if productDetailModel?.commentNumber != 0 && productDetailModel?.commentNumber != nil {
|
|
|
+ titles[2] = "商品评价" + "(" + "\(productDetailModel?.commentNumber ?? 0)" + ")"
|
|
|
+
|
|
|
+ }else {
|
|
|
+ titles[2] = "商品评价" + "(" + "0" + ")"
|
|
|
+ }
|
|
|
+ if productDetailModel?.imgs?.isEmpty ?? true {
|
|
|
+ tableView.tableHeaderView = nil
|
|
|
+ }else {
|
|
|
+ tableView.ly_hideEmpty()
|
|
|
+ tableView.tableHeaderView = productDetailTableViewHeaderView
|
|
|
+ productDetailTableViewHeaderView.productDetailModel = productDetailModel
|
|
|
+ }
|
|
|
+ //是否可以点击购买
|
|
|
+ if productDetailModel?.totalStock == 0 || productDetailModel?.upStatus == 0 {
|
|
|
+ self.nuablebuyLabel.isHidden = false
|
|
|
+ }else {
|
|
|
+ self.nuablebuyLabel.isHidden = true
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ bottomBgView.isHidden = true
|
|
|
+ topButton.isHidden = true
|
|
|
+ }
|
|
|
+ tableView.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var productSearchListModel: ProductSearchListModel? {
|
|
|
+ didSet {
|
|
|
+ tableView.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var productCommentListModel :ProductCommentListModel? {
|
|
|
+ didSet {
|
|
|
+ tableView.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
var productCartCount : Int = 0 {
|
|
|
didSet {
|