123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //
- // ShoppingMallViewController.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/3/7.
- // Copyright © 2019 南鑫林. All rights reserved.
- //
- import UIKit
- class ShoppingMallViewController: BaseViewController {
-
- deinit {
- if observe != nil {
- NotificationCenter.default.removeObserver(observe!)
- }
- }
- weak var observe : NSObjectProtocol?
-
- override func viewDidLoad() {
- super.viewDidLoad()
- setupViews()
- setupLayouts()
- setupData()
-
- NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "ChooseSelfAddressNoti"), object: nil, queue: operationQueue) {
- [weak self] (notification) in
-
- }
- }
- override func setupViews() {
- super.setupViews()
- navigationBar.addSubview(navigationBarView)
- view.addSubview(shoppingMallView)
- }
- override func setupLayouts() {
- navigationBarView.snp.makeConstraints { (make) in
- make.top.equalToSuperview().offset(kSafeStatusBarHeight)
- make.left.right.bottom.equalToSuperview()
- }
- shoppingMallView.snp.makeConstraints { (make) in
- make.bottom.left.right.equalToSuperview()
- make.top.equalTo(kNavBarTotalHeight)
- }
- }
-
- override func setupData() {
- observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ProductDetailVC"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
- let productModel = notification.object as! ProductModel
- let vc = ProductDetailViewController()
- vc.productId = productModel.id
- vc.shopId = productModel.shopId
- self?.navigationController?.pushViewController(vc, animated: true)
- }
- observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ShoppingMallBanner"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
- let cmsRuleModel = notification.object as? CMSRuleModel
- self?.pushVCCMSRule(cmsRuleModel: cmsRuleModel, areaType: "banner")
- }
- observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ShoppingMallCategory"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
- let cmsRuleModel = notification.object as? CMSRuleModel
- self?.pushVCCMSRule(cmsRuleModel: cmsRuleModel, areaType: "category")
- }
- observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ShoppingMallSpecial"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
- let cmsRuleModel = notification.object as? CMSRuleModel
- self?.pushVCCMSRule(cmsRuleModel: cmsRuleModel, areaType: "special")
- }
- observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ShoppingMallFloor"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
- let cmsRuleModel = notification.object as? CMSRuleModel
- self?.pushVCCMSRule(cmsRuleModel: cmsRuleModel, areaType: "floor")
- }
- //搜索
- navigationBarView.searchBlock = {
- [weak self] in
- let vc = SearchViewController()
- let nav = BaseNavigationViewController.init(rootViewController: vc)
- self?.present(nav, animated: true, completion: {
-
- })
- }
- //分类
- navigationBarView.categoryButton.rx.tap.subscribe(onNext: {
- [weak self] in
- let vc = CategoryViewController()
- vc.navigationBar.title = "团购分类"
- self?.navigationController?.pushViewController(vc, animated: true)
- }).disposed(by: disposeBag)
- }
-
- func pushVCCMSRule(cmsRuleModel:CMSRuleModel?,areaType:String) {
- switch cmsRuleModel?.linkType {
- case 1:
- let vc = SpecialViewController()
- vc.navigationBar.title = cmsRuleModel?.title
- vc.cmsRuleModel = cmsRuleModel
- vc.area_type = areaType
- self.navigationController?.pushViewController(vc, animated: true)
- break
- case 2:
- let vc = BaseWebViewController()
- vc.URLString = cmsRuleModel?.linkUrl
- self.navigationController?.pushViewController(vc, animated: true)
- break
- default:
- break
- }
- }
- private lazy var navigationBarView: ShoppingMallNavigationBarView = {
- let navigationBarView = ShoppingMallNavigationBarView()
- navigationBarView.selfAddrTipClosure = {
- [weak self] in
- let model = DeliveryMethodTypeModel.shared().getModel()
- if model?.deliveryMethodType == "1" { //自提
-
- }
- }
- return navigationBarView
- }()
- private lazy var shoppingMallView: ShoppingMallView = {
- let shoppingMallView = ShoppingMallView()
- return shoppingMallView
- }()
- }
|