CNLiveGoodsCategoryController.swift 25.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
//
//  CNLiveGoodsCategoryController.swift
//  metaCode
//
//  Created by zx on 2023/11/8.
//  商品分类/店铺分类

import Foundation
import QMUIKit
///分类类型
enum CNLiveGoodsCategoryType:Int {
    ///商品分类
    case goods
    ///店铺分类
    case shop
}

typealias finishSelectCategoryCallBack = ()->Void

typealias successComplete = ()->Void
    
class CNLiveGoodsCategoryController: CNLiveBaseViewController, UITableViewDataSource, UITableViewDelegate {
    
    let kCNLiveShopClassifyCellIdentifier = "kCNLiveShopClassifyCellIdentifier"

    // MARK: - 属性
    //开始输入前的文本
    var firCategoryId:Int = 0
    var secCategoryId:Int = 0
    var thiCategoryId:Int = 0
    var firCategoryName:String?
    var secCategoryName:String?
    var thiCategoryName:String?
    ///分类类型,现在有商品分类,店铺分类
    var categoryType:CNLiveGoodsCategoryType?
    //完成回调
    var finishBlock:finishSelectCategoryCallBack?
    
    var shadowView:UIView?
    var contentView:UIView?
    var line:UIImageView?//DSImageView
    var firCategoryBtn:UIButton?
    var secCategoryBtn:UIButton?
    var thiCategoryBtn:UIButton?
    var selectImageView:UIImageView?//DSImageView
    lazy var tableView : UITableView = {
        let tableView = UITableView(frame:CGRect(x: 0, y: self.line!.bottom, width: self.contentView!.width, height: self.contentView!.height - self.line!.bottom), style: .plain)
        tableView.dataSource = self
        tableView.delegate = self
        tableView.rowHeight = 40
        tableView.showsVerticalScrollIndicator = false
        tableView.backgroundColor = .white
        tableView.separatorStyle = .none
        let headerView = UIView(frame: CGRect(x: 0, y: 0, width: self.contentView!.width, height: 5))
        tableView.tableHeaderView = headerView
        tableView.register(CNLiveShopClassifyCell.self, forCellReuseIdentifier: kCNLiveShopClassifyCellIdentifier)
        return tableView
    }()

    lazy var firCategoryDataArr: NSMutableArray = {
        var firCategoryDataArr = NSMutableArray()
        return firCategoryDataArr
    }()
    lazy var secCategoryDataArr: NSMutableArray = {
        var secCategoryDataArr = NSMutableArray()
        return secCategoryDataArr
    }()
    lazy var thiCategoryDataArr: NSMutableArray = {
        var thiCategoryDataArr = NSMutableArray()
        return thiCategoryDataArr
    }()

    /// 创建店铺分类按钮,没创建过店铺分类时展示
    lazy var addShopCalssifyBtn: UIButton = {
        let  addShopCalssifyBtn = UIButton(type: .custom)
        addShopCalssifyBtn.frame = CGRect(x: 0, y: self.contentView!.height/2, width: KSreenWidth, height: 40)
        addShopCalssifyBtn.setTitle("创建店铺分类", for: .normal)
        addShopCalssifyBtn.setImage(UIImage(named: "DS_WB_CJDP"), for: .normal)
        addShopCalssifyBtn.setupButtonImageAndTitlePossitionWith(padding: 8, style: .left)
        addShopCalssifyBtn.setTitleColor(HexColor("FD862E"), for: .normal)
        addShopCalssifyBtn.titleLabel?.font = Font_15
        addShopCalssifyBtn.addTarget(self, action: #selector(createBtnClick), for: .touchUpInside)
        return addShopCalssifyBtn
    }()

    var _displayLevel:Int = 0
    var displayLevel:Int {
        get{
            _displayLevel
        }
        set{
            _displayLevel = newValue
            UIView.animate(withDuration: 0.2) {
                if self.displayLevel == 2{
                    self.selectImageView?.centerX = self.secCategoryBtn!.centerX
                    self.secCategoryBtn?.setTitleColor(HexColor("333333"), for: .normal)
                }else if self.displayLevel == 3{
                    self.selectImageView?.centerX = self.thiCategoryBtn!.centerX
                    self.thiCategoryBtn?.setTitleColor(HexColor("333333"), for: .normal)
                }else{
                    self.selectImageView?.centerX = self.firCategoryBtn!.centerX
                }
            }
        }
    }
    
    //临时选中一级分类
    var _temp_selectFirCategoryModel :CNLiveShopClassifyModel?
    var temp_selectFirCategoryModel :CNLiveShopClassifyModel?{
        get{
            _temp_selectFirCategoryModel
        }
        set{
            if newValue != nil{
                _temp_selectFirCategoryModel = newValue!
            }else{
                return
            }
            if Int(_temp_selectFirCategoryModel?.id ?? "0")! > 0{
                self.firCategoryBtn?.setTitle(_temp_selectFirCategoryModel?.title, for: .normal)
            }else{
                self.firCategoryBtn?.setTitle("请选择", for: .normal)
            }
        }
    }
    //临时选中二级分类
    var _temp_selectSecCategoryModel :CNLiveShopClassifyModel?
    var temp_selectSecCategoryModel :CNLiveShopClassifyModel?{
        get{
            _temp_selectSecCategoryModel
        }
        set{
            if newValue != nil{
                _temp_selectSecCategoryModel = newValue!
            }else{
                return
            }
            if Int(_temp_selectSecCategoryModel?.id ?? "0")! > 0{
                self.secCategoryBtn?.setTitle(_temp_selectSecCategoryModel?.title, for: .normal)
                self.secCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal)
            }else{
                self.secCategoryBtn?.setTitle("请选择", for: .normal)
                if self.displayLevel == 2{
                    self.secCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal)
                }else{
                    self.secCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal)
                }
            }
        }
    }
    //临时选中三级分类
    var _temp_selectThiCategoryModel :CNLiveShopClassifyModel?
    var temp_selectThiCategoryModel :CNLiveShopClassifyModel?{
        get{
            _temp_selectThiCategoryModel
        }
        set{
            if newValue != nil{
                _temp_selectThiCategoryModel = newValue!
            }else{
                return
            }
            if Int(_temp_selectThiCategoryModel!.id ?? "0")! > 0{
                self.thiCategoryBtn?.setTitle(_temp_selectThiCategoryModel?.title, for: .normal)
                self.thiCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal)
            }else{
                self.thiCategoryBtn?.setTitle("请选择", for: .normal)
                if self.displayLevel == 3{
                    self.thiCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal)
                }else{
                    self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal)
                }
            }
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBarHidden = false
        self.view.backgroundColor = .clear
        self.initUI()
        if self.firCategoryId == 0{
            self.secCategoryId = 0
            self.thiCategoryId = 0
        }else if self.secCategoryId == 0 || self.secCategoryId == 0{
            self.thiCategoryId = 0
        }
        if self.categoryType == .goods{
            self.postDataWithPid(pid: "0", level: 1) {
                if self.secCategoryId > 0{
                    self.postDataWithPid(pid:String(format: "%d", self.firCategoryId), level: 2) {
                        if self.thiCategoryId > 0{
                            self.postDataWithPid(pid:String(format: "%d",self.secCategoryId), level: 3) {
                            }
                        }
                    }
                }
            }
        }else if self.categoryType == .shop{
            self.postShopClassify()
        }
    }
    
    func initTitleName(name:String){
        titleName = name
    }
    
    // MARK: - initUI
    func initUI(){
        self.shadowView = UIView(frame: CGRect(x: 0, y: self.topNavView.height, width: self.view.width, height: self.view.height - self.topNavView.height))
        self.shadowView?.backgroundColor = UIColor(white: 0, alpha: 0.26)
        self.shadowView?.isHidden = true
        self.view.addSubview(self.shadowView!)
        let shadowViewTap = UITapGestureRecognizer(target: self, action: #selector(shadowViewTap))
        self.shadowView?.addGestureRecognizer(shadowViewTap)
        
        self.contentView = UIView(frame: CGRect(x: 0, y: self.view.height, width: self.view.width, height: 400))
        self.contentView?.backgroundColor = .white
        self.view.addSubview(self.contentView!)
        
        self.line = UIImageView(frame: CGRect(x: 0, y: 49-DS_RRV_ONE_PIXEL, width: self.view.width, height: DS_RRV_ONE_PIXEL))
        self.line!.clipsToBounds = true
        self.line!.contentMode = .scaleAspectFit
        self.line!.backgroundColor = HexColor("#EBE9EA")
        self.contentView?.addSubview(self.line!)
        
        self.firCategoryBtn = UIButton(type: .custom)
        self.firCategoryBtn?.frame = CGRect(x: 5, y: 0, width: 59, height: 49)
        self.firCategoryBtn?.setTitle("请选择", for: .normal)
        self.firCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal)
        self.firCategoryBtn?.clipsToBounds = true
        self.firCategoryBtn?.titleLabel?.font = Font_13
        self.firCategoryBtn?.titleLabel?.lineBreakMode = .byTruncatingTail
        self.firCategoryBtn?.addTarget(self, action: #selector(firCategoryBtnClick), for: .touchUpInside)
        self.contentView?.addSubview(self.firCategoryBtn!)
        
        self.secCategoryBtn = UIButton(type: .custom)
        self.secCategoryBtn?.frame = CGRect(x: self.firCategoryBtn!.right+5, y: 0, width: 59, height: 49)
        self.secCategoryBtn?.setTitle("请选择", for: .normal)
        self.secCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal)
        self.secCategoryBtn?.clipsToBounds = true
        self.secCategoryBtn?.titleLabel?.font = Font_13
        self.secCategoryBtn?.titleLabel?.lineBreakMode = .byTruncatingTail
        self.secCategoryBtn?.addTarget(self, action: #selector(secCategoryBtnClick), for: .touchUpInside)
        self.contentView?.addSubview(self.secCategoryBtn!)
        
        self.thiCategoryBtn = UIButton(type: .custom)
        self.thiCategoryBtn?.frame = CGRect(x: self.secCategoryBtn!.right+5, y: 0, width: 59, height: 49)
        self.thiCategoryBtn?.setTitle("请选择", for: .normal)
        self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal)
        self.thiCategoryBtn?.clipsToBounds = true
        self.thiCategoryBtn?.titleLabel?.font = Font_13
        self.thiCategoryBtn?.titleLabel?.lineBreakMode = .byTruncatingTail
        self.thiCategoryBtn?.addTarget(self, action: #selector(thiCategoryBtnClick), for: .touchUpInside)
        self.contentView?.addSubview(self.thiCategoryBtn!)
        
        if self.categoryType == .goods{
            ///商品分类三级
            self.thiCategoryBtn?.isHidden = false
        }else if self.categoryType == .shop{
            ///店铺分类二级
            self.thiCategoryBtn?.isHidden = true
        }
        self.selectImageView = UIImageView(frame: CGRect(x: 0, y: self.line!.bottom - 2, width: 39, height: 2))
        self.selectImageView!.clipsToBounds = true
        self.selectImageView!.contentMode = .scaleAspectFit
        self.selectImageView!.backgroundColor = HexColor("#FC1541")
        self.contentView?.addSubview(self.selectImageView!)
        self.selectImageView!.centerX = self.firCategoryBtn!.centerX
        
        
        let confirmBtn = UIButton(type: .custom)
        confirmBtn.frame = CGRect(x: self.contentView!.width-49, y: 0, width: 49, height: 49)
        confirmBtn.setTitle("确定", for: .normal)
        confirmBtn.setTitleColor(HexColor("#333333"), for: .normal)
        confirmBtn.titleLabel?.font = Font_13
        confirmBtn.addTarget(self, action: #selector(confirmBtnClick), for: .touchUpInside)
        self.contentView?.addSubview(confirmBtn)
        
        self.contentView?.addSubview(self.tableView)
    }
    deinit {
        print("CNLiveGoodsCategoryController销毁")
    }
    
    // MARK: - 显示/隐藏方法
    public func display(){

        self.view.isUserInteractionEnabled = true
        UIView.animate(withDuration: 0.2) {
            self.shadowView?.isHidden = false
            self.contentView!.top = self.view.height-400
        }
    }
    public func hide(){
        let vc = self.view.superview?.qmui_viewController?.qmui_visibleViewControllerIfExist() as! CNLiveShopNewProductController
        if self.categoryType == .goods{
            vc.isShowGoodsCategory = false
        }else{
            vc.isShowShopCategory = false
        }
        UIView.animate(withDuration: 0.2) {
            self.shadowView?.isHidden = true
            self.contentView!.top = self.view.height
            self.view.removeFromSuperview()
        }completion: { finished in
            self.view.isUserInteractionEnabled = false
        }
    }
    public func hideView(){
        self.shadowView?.isHidden = true
        self.contentView!.top = self.view.height
        self.view.isUserInteractionEnabled = false
    }

    // MARK: - UITableViewDelegate
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if (self.displayLevel == 1) {
            return self.firCategoryDataArr.count
        }else if (self.displayLevel == 2) {
            return self.secCategoryDataArr.count
        }else if (self.displayLevel == 3) {
            return self.thiCategoryDataArr.count
        }else {
            return 0
        }
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveShopClassifyCellIdentifier) as? CNLiveShopClassifyCell
        else {
            let cell = CNLiveShopClassifyCell()
            return cell
        }
        if self.displayLevel == 1{
            let model = self.firCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel
            
            cell.titleLabel.text = model.title
            if model.id == self.temp_selectFirCategoryModel?.id{
                cell.titleLabel.textColor = HexColor("#FC1541")
            }else{
                cell.titleLabel.textColor = HexColor("#666666")
            }
        }else if (self.displayLevel == 2) {
            let model = self.secCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel
            
            cell.titleLabel.text = model.title
            if model.id == self.temp_selectSecCategoryModel?.id{
                cell.titleLabel.textColor = HexColor("#FC1541")
            }else{
                cell.titleLabel.textColor = HexColor("#666666")
            }
        }else if (self.displayLevel == 3) {
            let model = self.thiCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel
            cell.titleLabel.text = model.title
            if model.id == self.temp_selectThiCategoryModel?.id{
                cell.titleLabel.textColor = HexColor("#FC1541")
            }else{
                cell.titleLabel.textColor = HexColor("#666666")
            }
        }else{
            cell.titleLabel.text = ""
        }
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if self.categoryType == .goods{
            if self.displayLevel == 1{
                let model = self.firCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel
                self.postDataWithPid(pid: model.id ?? "", level: 2) {
//                self.postDataWithPid(pid: String(format: "%d", model.id), level: 2) {
                    self.temp_selectFirCategoryModel = model
                    self.temp_selectSecCategoryModel = nil
                    self.temp_selectThiCategoryModel = nil
                }
            }else if (self.displayLevel == 2) {
                let model = self.secCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel
                self.postDataWithPid(pid: model.id ?? "", level: 3) {
//                self.postDataWithPid(pid: String(format: "%d", model.id), level: 3) {
                    self.temp_selectSecCategoryModel = model
                    self.temp_selectThiCategoryModel = nil
                }
            }else if (self.displayLevel == 3) {
                let model = self.thiCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel
                self.temp_selectThiCategoryModel = model
                self.tableView.reloadData()
            }
        }else if self.categoryType == .shop{
            if (self.displayLevel == 1) {
                let model = self.firCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel
                self.temp_selectFirCategoryModel = model
                self.temp_selectSecCategoryModel = nil
                if (model.child.count == 0) {
                    self.tableView.reloadData()
                    return
                }
                self.displayLevel = 2
                self.secCategoryDataArr = NSMutableArray(array: model.child)
                self.tableView.reloadData()
            }else if (self.displayLevel == 2){
                let model = self.secCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel
                self.temp_selectSecCategoryModel = model
                self.tableView.reloadData()
            }
        }
    }
    
    // MARK: - 触发事件
    @objc func shadowViewTap(){
        self.hide()
    }

    @objc func confirmBtnClick(){
        if self.categoryType == .goods{
            if (self.temp_selectFirCategoryModel == nil) || (self.temp_selectSecCategoryModel == nil) || (self.temp_selectThiCategoryModel == nil){
                showMessage(message: "未选择三级分类")
                return
            }
        }else if self.categoryType == .shop{
            if (self.temp_selectFirCategoryModel == nil && self.temp_selectSecCategoryModel == nil){
                showMessage(message: "请选择级分类")
                return
            }
            if let classModel = self.temp_selectFirCategoryModel{
                if classModel.child.count > 0 && self.temp_selectSecCategoryModel == nil{
                    showMessage(message: "未选择二级分类")
                    return
                }
            }
        }
        
        self.firCategoryId = Int(self.temp_selectFirCategoryModel?.id ?? "0")!
        self.firCategoryName = self.temp_selectFirCategoryModel?.title
        self.secCategoryId = Int(self.temp_selectSecCategoryModel?.id ?? "0")!
        self.secCategoryName = self.temp_selectSecCategoryModel?.title
        self.thiCategoryId = Int(self.temp_selectThiCategoryModel?.id ?? "0")!
        self.thiCategoryName = self.temp_selectThiCategoryModel?.title
        self.finishBlock!()
        self.hide()
    }

    @objc func firCategoryBtnClick(){
        self.displayLevel = 1
        self.tableView.reloadData()
        self.tableView.setContentOffset(CGPointZero, animated: true)
        if self.temp_selectSecCategoryModel != nil{
            self.secCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal)
            if self.temp_selectThiCategoryModel != nil{
                self.thiCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal)
            }else{
                self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal)
            }
        }else{
            self.secCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal)
            self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal)
        }
    }

    @objc func secCategoryBtnClick(){
        if self.categoryType == .shop{
            let model = self.temp_selectFirCategoryModel
            if model?.child.count == 0 {
                showMessage(message: "该分类暂没有添加子分类")
                return
            }
        }
        if self.temp_selectFirCategoryModel == nil{
            return
        }
        self.displayLevel = 2
        self.tableView.reloadData()
        self.tableView.setContentOffset(CGPointZero, animated: true)
        if self.temp_selectThiCategoryModel != nil{
            self.thiCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal)
        }else{
            self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal)
        }
    }
    @objc func thiCategoryBtnClick(){
        if self.temp_selectSecCategoryModel == nil{
            return
        }
        self.displayLevel = 3
        self.tableView.reloadData()
        self.tableView.setContentOffset(CGPointZero, animated: true)
    }
    
    ///创建店铺分类
    @objc func createBtnClick(){
        let vc = CNLiveCreateShopClassifyViewController()
        vc.classifyType = .oneLevelClassify
        vc.successCompleteBlock = {
            self.postShopClassify()
        }
        if self.navigationController == nil{
            print("self nil")
        }
        navigationViewController().pushViewController(vc, animated: pushAnimated)
//        currentViewController()?.navigationController?.pushViewController(vc, animated: pushAnimated)
    }
    
    // MARK: - 数据请求
    /**
     商品分类数据请求

     @param pid 父级id
     @param level 第几级
     */
    func postDataWithPid(pid:String,level:Int,successCompleteBlock:@escaping successComplete){
        showLoading(message: "")
        CNLiveShopGoodListViewModel.getGetGroupWithUid(uid: DSUserInfoManager.shared.dsUserInfo.uid!, pid: pid) { result, status in
            hiddenLoading()
            if status == .success{
                
                let dataArr = result as! [CNLiveShopClassifyModel]
                self.displayLevel = level
                if level == 1{
                    self.firCategoryDataArr = NSMutableArray(array: dataArr)
                    self.temp_selectSecCategoryModel = nil
                    self.temp_selectThiCategoryModel = nil
                    self.secCategoryDataArr.removeAllObjects()
                    self.thiCategoryDataArr.removeAllObjects()
                    if self.firCategoryId > 0{
                        
                        let tempDataArr = Array(self.firCategoryDataArr)
                        for (_,mdl) in tempDataArr.enumerated() {
                            let model = mdl as! CNLiveShopClassifyModel
                            if Int(model.id ?? "0")! == self.firCategoryId{
                                self.temp_selectFirCategoryModel = model
                                break
                            }
                        }
                    }
                }else if (level == 2){
                    self.secCategoryDataArr = NSMutableArray(array: dataArr)
                    self.temp_selectSecCategoryModel = nil
                    self.temp_selectThiCategoryModel = nil
                    self.thiCategoryDataArr.removeAllObjects()
                    if self.secCategoryId > 0{
                        let tempDataArr = Array(self.thiCategoryDataArr)
                        for (_,mdl) in tempDataArr.enumerated() {
                            let model = mdl as! CNLiveShopClassifyModel
                            if Int(model.id ?? "0")! == self.secCategoryId{
                                self.temp_selectSecCategoryModel = model
                                break
                            }
                        }
                    }else {
                        self.secCategoryBtn?.setTitle("请选择", for: .normal)
                    }
                }else if (level == 3) {
                    self.thiCategoryDataArr = NSMutableArray(array: dataArr)
                    self.temp_selectThiCategoryModel = nil
                    if self.thiCategoryId > 0{
                        let tempDataArr = Array(self.thiCategoryDataArr)
                        for (_,mdl) in tempDataArr.enumerated() {
                            let model = mdl as! CNLiveShopClassifyModel
                            if Int(model.id ?? "0")! == self.thiCategoryId{
                                self.temp_selectThiCategoryModel = model
                                break
                            }
                        }
                    }else {
                        self.thiCategoryBtn?.setTitle("请选择", for: .normal)
                    }
                }
                self.tableView.reloadData()
                self.tableView.setContentOffset(CGPointZero, animated: true)
                successCompleteBlock()
                
            }else if (status == .failed){
//                self.network_type = .failed
            }else if (status == .noNetwork){
//                self.network_type = .noNetwork
            }
        }
    }
    
    ///店铺分类数据请求
    func postShopClassify(){
        showLoading(message: "")
        CNLiveShopGoodListViewModel.getCateListWithShopId(shopId: DSUserInfoManager.shared.dsUserInfo.id!) { result, status in
            hiddenLoading()
            if status == .success{
                let classifyListModel = result as! CNLiveShopClassifyListModel
                self.firCategoryDataArr = NSMutableArray(array: classifyListModel.list)
                self.displayLevel = 1
                self.tableView.reloadData()
                
                if (self.firCategoryDataArr.count == 0) {
                    self.contentView?.addSubview(self.addShopCalssifyBtn)
                }
                else{
                    self.addShopCalssifyBtn.removeFromSuperview()
                }
            }else if (status == .failed){
                //self.network_type = .failed
                
            }else if (status == .noNetwork){
                //self.network_type = .noNetwork
            }
        }
    }
    
}