| | |
| | | import UIKit |
| | | import JQTools |
| | | |
| | | class PaymentResultVC: BaseVC { |
| | | class PaymentResultVC: BaseVC, UITableViewDelegate, UITableViewDataSource { |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return couponList.count + ticketList.count |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | if indexPath.row < couponList.count { |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_WelfareCouponsTCell", for: indexPath) as! WelfareCouponsTCell |
| | | cell.indexPath = indexPath |
| | | let m = couponList[indexPath.row] |
| | | m.useStatus = .unused |
| | | m.goJB = true |
| | | cell.couponModel = m |
| | | return cell |
| | | }else{ |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "CouponCellTwoId", for: indexPath) as! CouponCellTwo |
| | | |
| | | cell.nameLab.text = ticketList[indexPath.row - couponList.count].name |
| | | cell.timeLab.text = "领取后\(ticketList[indexPath.row - couponList.count].time )有效" |
| | | cell.numberLab.text = "\(ticketList[indexPath.row - couponList.count].count )张" |
| | | |
| | | |
| | | return cell |
| | | } |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| | | |
| | | if indexPath.row < couponList.count { |
| | | let model = couponList[indexPath.row ] |
| | | if rows.contains(where: {$0 == indexPath.row}){ |
| | | let h = max(String.jq_getHeight(text: model.instructionsForUse , width: UIScreen.main.bounds.size.width - 200, font: 12), 30) |
| | | return h + 125 |
| | | }else{ |
| | | return 125 |
| | | } |
| | | }else{ |
| | | return 110 |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | enum PaymentResult:Equatable{ |
| | | case success |
| | |
| | | |
| | | var isExtend:Bool = false |
| | | var otherInfo:Dictionary<String,Any>? |
| | | |
| | | required init(result:PaymentResult,objType:PaymentObjType,handleVC:UIViewController? = nil,courseConfigId:Int? = nil,againClouse:(()->Void)? = nil) { |
| | | private var rows = Set<Int>() |
| | | @IBOutlet weak var tableview: UITableView! |
| | | @IBOutlet weak var tabBgView: UIView! |
| | | |
| | | var couponList = [CouponModel]() |
| | | var ticketList = [TicketModel]() |
| | | required init(result:PaymentResult,objType:PaymentObjType,handleVC:UIViewController? = nil,courseConfigId:Int? = nil,list1:[CouponModel] = [],list2:[TicketModel] = [],againClouse:(()->Void)? = nil) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.result = result |
| | | self.objType = objType |
| | | self.handleVC = handleVC |
| | | self.againClouse = againClouse |
| | | self.courseConfigId = courseConfigId |
| | | self.couponList = list1 |
| | | self.ticketList = list2 |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | |
| | | tableview.separatorStyle = .none |
| | | tableview.delegate = self |
| | | tableview.dataSource = self |
| | | tableview.register(UINib(nibName: "CouponCellTwo", bundle: nil), forCellReuseIdentifier: "CouponCellTwoId") |
| | | tableview.register(UINib(nibName: "WelfareCouponsTCell", bundle: nil), forCellReuseIdentifier: "_WelfareCouponsTCell") |
| | | NotificationCenter.default.rx.notification(WelfareCoupons_Noti).take(until: self.rx.deallocated).subscribe(onNext: {noti in |
| | | if let row = noti.object as? Int{ |
| | | if self.rows.contains(row){ |
| | | self.rows.remove(row) |
| | | }else{ |
| | | self.rows.insert(row) |
| | | } |
| | | self.tableview.beginUpdates() |
| | | self.tableview.reloadRows(at: [IndexPath(row: row, section: 0)], with: .fade) |
| | | self.tableview.endUpdates() |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | tableview.reloadData() |
| | | if result == .success{ |
| | | title = "支付成功" |
| | | img_paymentState.image = UIImage(named: "icon_success") |
| | |
| | | NotificationCenter.default.post(name: StudentRefresh_Nofi, object: nil) |
| | | case .none:break |
| | | } |
| | | Services.queryMemberCoupon(menthod: 2).subscribe(onNext: {[weak self] data in |
| | | if let models = data.data{ |
| | | self?.models = models |
| | | if models.count > 0{ |
| | | self?.label_content.text = "支付成功,恭喜您成为玩湃会员!并获得优惠券!" |
| | | } |
| | | self?.collectionView.reloadData() |
| | | } |
| | | }) { error in |
| | | |
| | | }.disposed(by: disposeBag) |
| | | // Services.queryMemberCoupon(menthod: 2).subscribe(onNext: {[weak self] data in |
| | | // if let models = data.data{ |
| | | // self?.models = models |
| | | // if models.count > 0{ |
| | | // self?.label_content.text = "支付成功,恭喜您成为玩湃会员!并获得优惠券!" |
| | | // } |
| | | // self?.collectionView.reloadData() |
| | | // } |
| | | // }) { error in |
| | | // |
| | | // }.disposed(by: disposeBag) |
| | | |
| | | case .courseApply: |
| | | //课时购买 |