123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- //
- // ShoppingCartFinishPayController.swift
- // RainbowPlanet
- //
- // Created by Christopher on 2019/5/9.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- // 购物车--支付完成Vc
- import UIKit
- import RxSwift
- /// OrderFinishPayVCType
- ///
- /// - cart: 购物车
- /// - productDetail: 订单详情
- /// - order: 订单
- /// - orderDetails: 订单详情
- enum OrderFinishPayVCType {
- case cart
- case productDetail
- case order
- case orderDetail
- }
- class OrderFinishPayController: BaseViewController {
-
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- }
-
- var payStatus: Bool? = true {
- didSet {
- if payStatus ?? true {
- navigationBar.title = "支付成功"
- } else {
- navigationBar.title = "支付失败"
- }
- }
- }
-
- var orderFinishPayVCType : OrderFinishPayVCType?
-
- typealias ReloadClosure = () -> Void
- var reloadClosure : ReloadClosure?
-
- var productSearchModelArray = Array<ProductSearchModel>()
-
- override func viewDidLoad() {
- super.viewDidLoad()
- setupViews()
- setupLayouts()
- setupData()
- }
-
- override func setupViews() {
- view.addSubview(finishPayView)
- }
-
- override func setupLayouts() {
- finishPayView.snp.makeConstraints { (make) in
- make.bottom.left.right.equalToSuperview()
- make.top.equalTo(kNavBarTotalHeight)
- }
- }
-
- override func setupData() {
-
- if !(payStatus ?? true) {
- self.finishPayView.configModel = ConfigModel.shared.object()
- }
-
- finishPayView.tableView.addHeader(withBeginRefresh: true, animation: false) { [weak self] (page) in
- self?.productHotSaleApi(page: page)
- }
-
- navigationBar.onClickLeftButton = {
- [weak self] in
-
- switch self?.orderFinishPayVCType {
- case .cart?:
- self?.navigationController?.popToRootViewController(animated: true)
- break
- case .productDetail?:
- self?.navigationController?.popToClass(type: ProductDetailViewController.self)
- break
- case .order?:
- if self?.payStatus ?? true {
- if let reloadClosure = self?.reloadClosure {
- reloadClosure()
- }
- }
- self?.navigationController?.popViewController(animated: true)
- break
- case .orderDetail?:
- if self?.payStatus ?? true {
- NotificationCenter.default.post(name: NSNotification.Name(rawValue: "OrderFinishPayVCOrderDetail"), object: nil)
- self?.navigationController?.popToClass(type: OrderViewController.self)
- }else {
- self?.navigationController?.popViewController(animated: true)
- }
- break
- default:
- break
- }
-
- }
- }
-
- private lazy var finishPayView: OrderFinishPayView = {
- let finishPayView = OrderFinishPayView()
- finishPayView.payStatus = payStatus
- finishPayView.repayTransBlock = {
- [weak self] in
- let vc = OrderViewController()
- vc.orderVCType = .pendingPayment
- self?.navigationController?.pushViewController(vc, animated: true)
- }
- finishPayView.jumpTransBlock = {
- [weak self] (jType) in
- switch jType {
- case PayJumpDes.homePage:
- self?.tabBarController?.selectedIndex = 0
- self?.navigationController?.popToRootViewController(animated: false)
- case PayJumpDes.checkOrder:
- let vc = OrderViewController()
- vc.orderVCType = .toBeShipped
- self?.navigationController?.pushViewController(vc, animated: true)
- }
- }
- finishPayView.jumpToDetailTransClosure = {
- [weak self] (proId, shopId) in
- let vc = ProductDetailViewController()
- vc.productId = proId
- vc.shopId = shopId
- self?.navigationController?.pushViewController(vc, animated: true)
- }
-
- return finishPayView
- }()
-
- /// 商品热销
- func productHotSaleApi(page:Int = 1) {
- SwiftMoyaNetWorkServiceProduct.shared().productHotSaleApi(page: page) { [weak self] (productSearchListModel) -> (Void) in
- let productSearchListModel = productSearchListModel as? ProductSearchListModel
- if productSearchListModel?.pagination?.currentPage ?? 1 <= productSearchListModel?.pagination?.totalPages ?? 1 {
- if productSearchListModel?.pagination?.currentPage == 1{
- self?.productSearchModelArray.removeAll()
- }
- self?.productSearchModelArray = (self?.productSearchModelArray)! + (productSearchListModel?.data!)!
-
- self?.finishPayView.hotSaleModelArr = self?.productSearchModelArray
-
- } else {
- self?.finishPayView.hotSaleModelArr = self?.productSearchModelArray
- }
- }
- }
-
- }
|