|
@@ -12,39 +12,7 @@ import RxSwift
|
|
|
import RxCocoa
|
|
|
|
|
|
class ProductDetailSkuView: FWPopupView {
|
|
|
- var dataSource = [
|
|
|
- [
|
|
|
- "name": "重量",
|
|
|
- "value": ["3","5"],
|
|
|
- "i": 6,
|
|
|
- ],
|
|
|
- [
|
|
|
- "name": "大小",
|
|
|
- "value": ["6", "7", "8"],
|
|
|
- "i": 7,
|
|
|
- ],
|
|
|
- ]
|
|
|
-
|
|
|
- var skuData = [
|
|
|
- [
|
|
|
- "contition": "3_6",
|
|
|
- "price": "1120",
|
|
|
- "store": "167"
|
|
|
- ],
|
|
|
- [
|
|
|
- "contition": "3_7",
|
|
|
- "price": "1200",
|
|
|
- "store": "289"
|
|
|
- ],
|
|
|
- [
|
|
|
- "contition": "5_8",
|
|
|
- "price": "889",
|
|
|
- "store": "300"
|
|
|
- ]
|
|
|
- ]
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
let disposeBag = DisposeBag()
|
|
|
override init(frame: CGRect) {
|
|
|
super.init(frame: frame)
|
|
@@ -132,7 +100,7 @@ class ProductDetailSkuView: FWPopupView {
|
|
|
}
|
|
|
limitLabel.snp.makeConstraints { (make) in
|
|
|
make.centerY.equalTo(buyNumberLabel)
|
|
|
- make.left.equalTo(buyNumberLabel.snp.right)
|
|
|
+ make.left.equalTo(buyNumberLabel.snp.right).offset(5)
|
|
|
}
|
|
|
|
|
|
buyNumberBgView.snp.remakeConstraints { (make) in
|
|
@@ -281,7 +249,20 @@ class ProductDetailSkuView: FWPopupView {
|
|
|
plusButton.contentVerticalAlignment = .center
|
|
|
plusButton.contentHorizontalAlignment = .center
|
|
|
plusButton.rx.tap.subscribe(onNext: {
|
|
|
- [weak self](data) in
|
|
|
+ [weak self](data) in
|
|
|
+
|
|
|
+ if self?.productDetailModel?.limitNumber ?? 0 > 0 {
|
|
|
+
|
|
|
+ if self?.productCount ?? 1 < self?.productDetailSkuModel?.stock ?? 0 {
|
|
|
+ self?.productCount += 1
|
|
|
+ self?.numberLabel.text = "\(self?.productCount ?? 0)"
|
|
|
+ }else {
|
|
|
+ SwiftProgressHUD.shared().showText("该数量已是超库存数量",view: self!)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ self?.productCount += 1
|
|
|
+ self?.numberLabel.text = "\(self?.productCount ?? 0)"
|
|
|
+ }
|
|
|
}).disposed(by: disposeBag)
|
|
|
return plusButton
|
|
|
}()
|
|
@@ -295,6 +276,12 @@ class ProductDetailSkuView: FWPopupView {
|
|
|
reduceButton.contentHorizontalAlignment = .center
|
|
|
reduceButton.rx.tap.subscribe(onNext: {
|
|
|
[weak self] (data) in
|
|
|
+ if self?.productCount ?? 1 <= 1 {
|
|
|
+ SwiftProgressHUD.shared().showText("该数量已是最低数量",view: self!)
|
|
|
+ }else {
|
|
|
+ self?.productCount -= 1
|
|
|
+ self?.numberLabel.text = "\(self?.productCount ?? 0)"
|
|
|
+ }
|
|
|
}).disposed(by: disposeBag)
|
|
|
return reduceButton
|
|
|
}()
|
|
@@ -350,15 +337,28 @@ class ProductDetailSkuView: FWPopupView {
|
|
|
actionComplete()
|
|
|
productImageView.kf.setImage(with: kURLImage(name: productDetailModel?.img ?? "pic_preload")
|
|
|
, placeholder: kImage(name: "pic_preload"))
|
|
|
+ if productDetailModel?.limitNumber ?? 0 <= 0 {
|
|
|
+ limitLabel.isHidden = true
|
|
|
+ }else {
|
|
|
+ limitLabel.text = "(" + "每人限购\(productDetailModel?.limitNumber ?? 0)件" + ")"
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func actionComplete() {
|
|
|
let productDetailSkuModel = filter?.currentResult as? ProductDetailSkuModel
|
|
|
if productDetailSkuModel != nil {
|
|
|
+ self.productDetailSkuModel = productDetailSkuModel
|
|
|
priceLabel.text = "¥\(productDetailSkuModel!.price ?? 0)"
|
|
|
stockLabel.text = "库存\(productDetailSkuModel!.stock ?? 0)件"
|
|
|
- sureButton.isEnabled = true
|
|
|
+ if productDetailSkuModel!.stock ?? 0 > 0 {
|
|
|
+ sureButton.isEnabled = true
|
|
|
+ }else {
|
|
|
+ sureButton.isEnabled = false
|
|
|
+ }
|
|
|
+ if productDetailSkuModel!.stock ?? 0 < self.productCount {
|
|
|
+ self.productCount = productDetailSkuModel!.stock ?? 0
|
|
|
+ }
|
|
|
}else {
|
|
|
sureButton.isEnabled = false
|
|
|
}
|