| | |
| | | |
| | | enum PaymentResult:Equatable{ |
| | | case success |
| | | case fail(String) |
| | | case fail(String,Int) |
| | | } |
| | | enum PaymentObjType{ |
| | | case member //会员 |
| | |
| | | private var handleVC:UIViewController? |
| | | private var models = [CourseCouponModel]() |
| | | |
| | | required init(result:PaymentResult,objType:PaymentObjType,handleVC:UIViewController? = nil,courseConfigId:Int? = nil) { |
| | | private var againClouse:(()->Void)? |
| | | |
| | | required init(result:PaymentResult,objType:PaymentObjType,handleVC:UIViewController? = nil,courseConfigId:Int? = nil,againClouse:(()->Void)? = nil) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.result = result |
| | | self.objType = objType |
| | | self.handleVC = handleVC |
| | | self.againClouse = againClouse |
| | | self.courseConfigId = courseConfigId |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | |
| | | } |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "成为会员" |
| | | |
| | | |
| | | |
| | | if result == .success{ |
| | | title = "支付成功" |
| | | img_paymentState.image = UIImage(named: "icon_success") |
| | | NotificationCenter.default.post(name: UpdateWelfare_Noti, object: nil, userInfo: nil) |
| | | }else{ |
| | | title = "支付失败" |
| | | img_paymentState.image = UIImage(named: "icon_fail") |
| | | } |
| | | |
| | | switch objType{ |
| | | case .member: |
| | | btn_again.isHidden = result == .success |
| | |
| | | collectionView.isHidden = result != .success |
| | | switch result { |
| | | case .fail: |
| | | img_paymentState.image = UIImage(named: "icon_fail") |
| | | label_content.text = "支付失败,这是失败原因!" |
| | | case .success: |
| | | img_paymentState.image = UIImage(named: "icon_success") |
| | | label_content.text = "支付成功,恭喜您成为玩湃会员!并获得优惠券!" |
| | | case .none:break |
| | | } |
| | |
| | | }.disposed(by: disposeBag) |
| | | } |
| | | switch result { |
| | | case .fail(let str): |
| | | label_title.text = "支付失败" |
| | | case .fail(let str,let code): |
| | | btn_again.setTitle("再次支付", for: .normal) |
| | | btn_back.setTitle("返回", for: .normal) |
| | | img_paymentState.image = UIImage(named: "icon_fail") |
| | | label_content.text = str |
| | | case .success: |
| | | label_title.text = "支付成功" |
| | | btn_again.setTitle("立即预约", for: .normal) |
| | | btn_back.setTitle("返回首页", for: .normal) |
| | | img_paymentState.image = UIImage(named: "icon_success") |
| | | label_content.text = "报名成功,请及时预约课程上课!" |
| | | case .none:break |
| | | } |
| | |
| | | collectionView.isHidden = true |
| | | switch result { |
| | | case .fail: |
| | | btn_again.setTitle("再次支付", for: .normal) |
| | | btn_back.setTitle("返回", for: .normal) |
| | | img_paymentState.image = UIImage(named: "icon_fail") |
| | | label_content.text = "报名失败,这是失败原因!" |
| | | case .success: |
| | | btn_again.setTitle("查看报名", for: .normal) |
| | | btn_back.setTitle("返回首页", for: .normal) |
| | | img_paymentState.image = UIImage(named: "icon_success") |
| | | label_content.text = "报名成功,请注意赛事开始时间!" |
| | | case .none:break |
| | | } |
| | |
| | | btn_backHome.isHidden = true |
| | | collectionView.isHidden = true |
| | | switch result { |
| | | case .fail(let str): |
| | | case .fail(let str,let code): |
| | | btn_again.setTitle("再次支付", for: .normal) |
| | | btn_back.setTitle("返回", for: .normal) |
| | | img_paymentState.image = UIImage(named: "icon_fail") |
| | | label_content.text = str |
| | | case .success: |
| | | btn_again.setTitle("查看预约", for: .normal) |
| | | btn_back.setTitle("返回首页", for: .normal) |
| | | img_paymentState.image = UIImage(named: "icon_success") |
| | | label_content.text = "报名成功,请注意预约开始时间!" |
| | | case .none:break |
| | | } |
| | |
| | | btn_backHome.isHidden = true |
| | | collectionView.isHidden = true |
| | | switch result { |
| | | case .fail(let str): |
| | | label_title.text = "支付失败" |
| | | case .fail(let str,let code): |
| | | btn_again.setTitle("再次支付", for: .normal) |
| | | btn_back.setTitle("返回", for: .normal) |
| | | img_paymentState.image = UIImage(named: "icon_fail") |
| | | label_content.text = str |
| | | case .success: |
| | | label_title.text = "支付成功" |
| | | btn_again.isHidden = true |
| | | btn_back.setTitleColor(.white, for: .normal) |
| | | btn_back.backgroundColor = Def_ThemeColor |
| | | btn_back.setTitle("我的数据", for: .normal) |
| | | img_paymentState.image = UIImage(named: "icon_success") |
| | | label_content.text = "支付成功" |
| | | case .none:break |
| | | } |
| | |
| | | self?.handleVC?.navigationController?.pushViewController(vc) |
| | | } |
| | | case "立即预约": |
| | | handleVC?.navigationController?.tabBarController?.selectedIndex = 1 |
| | | handleVC?.navigationController?.popToRootViewController(animated: true) |
| | | dismiss(animated:true) |
| | | navigationController?.popToRootViewController(animated: true) |
| | | |
| | | case "查看报名": |
| | | dismiss(animated:true){ [weak self] in |
| | | let vc = ActivitySignupListVC() |
| | | self?.handleVC?.navigationController?.pushViewController(vc) |
| | | } |
| | | case "再次支付": |
| | | navigationController?.popViewController(animated: true, {[weak self] in |
| | | self?.againClouse?() |
| | | }) |
| | | default:break |
| | | } |
| | | } |
| | | |
| | | |
| | | @IBAction func backAction(_ sender: UIButton) { |
| | | if let handleVC{ |
| | | handleVC.navigationController?.popToRootViewController(animated: true) |
| | | } |
| | | dismiss(animated: true) { |
| | | |
| | | navigationController?.popViewController(animated: true, { |
| | | if sender.titleLabel?.text == "我的数据"{ |
| | | JQ_currentViewController().jq_push(vc: GamesDataSourceVC()) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | override var preferredStatusBarStyle: UIStatusBarStyle{ |
| | | return .default |
| | | } |
| | | } |
| | | |
| | | extension PaymentResultVC:UICollectionViewDelegate{ |