Commit 7a25e418 authored by 刘俊宏's avatar 刘俊宏

补全商品分类确定按钮,并完善数据交互

parent 8c012e06
...@@ -8,14 +8,16 @@ ...@@ -8,14 +8,16 @@
import UIKit import UIKit
import Dollar import Dollar
protocol GoodsClassViewControllerDelegate {
func blackGoodsClass(sender:GoodsClassModel)
}
class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITableViewDataSource{ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITableViewDataSource{
var delegate : GoodsClassViewControllerDelegate?
var dataModelArray : Array<GeneralInfoCatsModel>? = [] var dataModelArray : Array<GeneralInfoCatsModel>? = []
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
navbar.title = "请选择商品分类" navbar.title = "请选择商品分类"
print("商品分类数据==\(dataModelArray)")
self.view.addSubview(navbar) self.view.addSubview(navbar)
//先分级 //先分级
...@@ -97,14 +99,25 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl ...@@ -97,14 +99,25 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
setTabv() setTabv()
} }
@IBOutlet weak var sureBtn: UIButton!
//MARK:--确定按钮
@IBAction func sureBtnAcion(_ sender: UIButton) {
if selectModel == nil {
HUD.flash(.label("请选择商品分类"), delay: 1.2)
}else{
//返回确定数据
self.delegate?.blackGoodsClass(sender: selectModel!)
self.navigationController?.popViewController(animated: true)
}
}
var tableV :UITableView! var tableV :UITableView!
var dataArr:Array<Any> = [] var dataArr:Array<Any> = []
func setTabv() { func setTabv() {
tableV = UITableView() tableV = UITableView()
view.addSubview(tableV); view.addSubview(tableV);
tableV.snp.makeConstraints { (make) in tableV.snp.makeConstraints { (make) in
make.left.right.bottom.equalToSuperview() make.left.right.equalToSuperview()
make.bottom.equalTo(sureBtn.snp_top)
make.top.equalTo(navbar.snp_bottom) make.top.equalTo(navbar.snp_bottom)
} }
tableV.backgroundColor = UIColor.init(named: "app底色") tableV.backgroundColor = UIColor.init(named: "app底色")
...@@ -187,6 +200,8 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl ...@@ -187,6 +200,8 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
return cell return cell
} }
var selectModel: GoodsClassModel? = nil
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let arrs = dataArr[indexPath.section] as! Array<Any> let arrs = dataArr[indexPath.section] as! Array<Any>
let rowModel = arrs[indexPath.row] as! GoodsClassModel let rowModel = arrs[indexPath.row] as! GoodsClassModel
...@@ -199,6 +214,18 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl ...@@ -199,6 +214,18 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
}else{ }else{
rowModel.isSelect = !rowModel.isSelect! rowModel.isSelect = !rowModel.isSelect!
//MARK:--如果是单选,那么就要更改别的数据源
if rowModel.isSelect! {
if selectModel == nil {
selectModel = rowModel
}else{
selectModel?.isSelect = false
selectModel = rowModel
}
}else{
selectModel = nil
}
let reloadSet = IndexSet.init(arrayLiteral: indexPath.section) let reloadSet = IndexSet.init(arrayLiteral: indexPath.section)
tableV.reloadSections(reloadSet, with: .automatic) tableV.reloadSections(reloadSet, with: .automatic)
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="GoodsClassViewController" customModuleProvider="target"> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="GoodsClassViewController" customModule="GeliBusinessPlatform" customModuleProvider="target">
<connections> <connections>
<outlet property="sureBtn" destination="eo7-gg-VuW" id="1Uq-wf-ger"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections> </connections>
</placeholder> </placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eo7-gg-VuW">
<rect key="frame" x="0.0" y="813" width="414" height="83"/>
<color key="backgroundColor" name="蓝色字体颜色"/>
<connections>
<action selector="sureBtnAcion:" destination="-1" eventType="touchUpInside" id="950-0l-rjI"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZNg-Jh-xFg">
<rect key="frame" x="0.0" y="813" width="414" height="49"/>
<constraints>
<constraint firstAttribute="height" constant="49" id="Rgk-OM-IYa"/>
</constraints>
<attributedString key="attributedText">
<fragment content="确定">
<attributes>
<color key="NSColor" name="白色背景色"/>
<font key="NSFont" size="17" name="PingFangSC-Medium"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
</attributes>
</fragment>
</attributedString>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="eo7-gg-VuW" firstAttribute="top" secondItem="ZNg-Jh-xFg" secondAttribute="top" id="5AL-cv-8Ub"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="ZNg-Jh-xFg" secondAttribute="trailing" id="6J2-6S-dee"/>
<constraint firstAttribute="bottom" secondItem="eo7-gg-VuW" secondAttribute="bottom" id="KDj-tI-0PH"/>
<constraint firstItem="eo7-gg-VuW" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="X7g-ph-OQv"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="ZNg-Jh-xFg" secondAttribute="bottom" id="YE4-4v-l3s"/>
<constraint firstItem="ZNg-Jh-xFg" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="f2U-UA-ZzK"/>
<constraint firstItem="eo7-gg-VuW" firstAttribute="trailing" secondItem="fnl-2z-Ty3" secondAttribute="trailing" id="oru-RY-rax"/>
</constraints>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/> <viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<point key="canvasLocation" x="131.8840579710145" y="119.86607142857142"/>
</view> </view>
</objects> </objects>
<resources>
<namedColor name="白色背景色">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="蓝色字体颜色">
<color red="0.27799999713897705" green="0.56099998950958252" blue="0.88999998569488525" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document> </document>
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
import UIKit import UIKit
import LGButton import LGButton
class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,CommendCellDelegate,TitleAndBtnCellDelegate,GLAlertSelectViewDelegate{ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,CommendCellDelegate,TitleAndBtnCellDelegate,GLAlertSelectViewDelegate,GoodsClassViewControllerDelegate{
var glSelectView:GLAlertSelectView? var glSelectView:GLAlertSelectView?
let titleArr = ["商品信息","商品图片","商品规格","预售设置","其它信息","商品详情"] let titleArr = ["商品信息","商品图片","商品规格","预售设置","其它信息","商品详情"]
...@@ -274,6 +274,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -274,6 +274,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
} }
if cell.nameLbl.text == "商品分类" { if cell.nameLbl.text == "商品分类" {
let vc = GoodsClassViewController() let vc = GoodsClassViewController()
vc.delegate = self
vc.dataModelArray = generalInfoModel?.data?.cats vc.dataModelArray = generalInfoModel?.data?.cats
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
} }
...@@ -297,6 +298,11 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -297,6 +298,11 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
} }
print(cell.nameLbl.text) print(cell.nameLbl.text)
} }
//MARK:---选择商品分类返回数据
func blackGoodsClass(sender: GoodsClassModel) {
print("选择商品分类返回数据=\(sender)")
}
func GLAlertSelectViewClick(selectNum: Int, view: UIView) { func GLAlertSelectViewClick(selectNum: Int, view: UIView) {
print("单选",selectNum) print("单选",selectNum)
glSelectView?.removeFromSuperview() glSelectView?.removeFromSuperview()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment