|
@@ -352,7 +352,11 @@ class ProductDetailSkuView: FWPopupView {
|
|
|
var productDetailModel : ProductDetailModel? {
|
|
|
didSet {
|
|
|
filter = ORSKUDataFilter.init(dataSource: self)
|
|
|
- filter!.needDefaultValue = true
|
|
|
+ if productDetailSkuModel != nil {
|
|
|
+ selected()
|
|
|
+ }else {
|
|
|
+ defaultMainSelected()
|
|
|
+ }
|
|
|
self.collectionView.reloadData()
|
|
|
actionComplete()
|
|
|
productImageView.kf.setImage(with: kURLImage(name: productDetailModel?.img ?? "pic_preload")
|
|
@@ -365,6 +369,25 @@ class ProductDetailSkuView: FWPopupView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func defaultMainSelected() {
|
|
|
+ if !(self.productDetailModel?.sku?.isEmpty ?? true) { //skus是否为空
|
|
|
+ for (index,sku) in (self.productDetailModel?.sku)!.enumerated() {//便利skus
|
|
|
+ if sku.isMain == 1 {//sku是否是主规格
|
|
|
+ filter?.defaultIndex = Int32(index)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ func selected() {
|
|
|
+ if !(self.productDetailModel?.sku?.isEmpty ?? true) { //skus是否为空
|
|
|
+ for (index,sku) in (self.productDetailModel?.sku)!.enumerated() {//便利skus
|
|
|
+ if sku.id == productDetailSkuModel?.id {//sku是否是主规格
|
|
|
+ filter?.defaultIndex = Int32(index)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
func actionComplete() {
|
|
|
let productDetailSkuModel = filter?.currentResult as? ProductDetailSkuModel
|
|
|
if productDetailSkuModel != nil {
|
|
@@ -384,6 +407,7 @@ class ProductDetailSkuView: FWPopupView {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|