| | |
| | | cell.vipList = model?.vipList |
| | | cell.selectBlock = { index in |
| | | self.selectIndex = index |
| | | tableView.reloadData() |
| | | } |
| | | return cell |
| | | |
| | |
| | | // cell.timeLab.text = "有效期至\(model?.vipList[selectIndex].couponList[indexPath.row - 1].effectiveTime ?? "")" |
| | | // cell.contentLab.text = model?.vipList[selectIndex].couponList[indexPath.row - 1].instructionsForUse |
| | | if let m = model?.vipList[selectIndex].couponList[indexPath.row - 1] { |
| | | |
| | | m.useStatus = .unused |
| | | cell.couponModel = m |
| | | cell.btn_toUse.isHidden = true |
| | | |
| | | } |
| | | |
| | | return cell |
| | | }else{ |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "CouponCellTwoId", for: indexPath) as! CouponCellTwo |
| | | let index = indexPath.row - ((model?.vipList[selectIndex].couponList.count ?? 0) + 1) |
| | | cell.nameLab.text = model?.vipList[selectIndex].ticketList[index].name |
| | | cell.timeLab.text = "领取后\(model?.vipList[selectIndex].ticketList[index].time ?? 0)有效" |
| | | cell.numberLab.text = "\(model?.vipList[selectIndex].ticketList[index].count ?? 0)张" |
| | | if model?.vipList[selectIndex].ticketList.count ?? 0 > 0 { |
| | | |
| | | let index = indexPath.row - ((model?.vipList[selectIndex].couponList.count ?? 0) ) - 1 |
| | | cell.nameLab.text = model?.vipList[selectIndex].ticketList[index].name |
| | | cell.timeLab.text = "领取后\(model?.vipList[selectIndex].ticketList[index].time ?? 0)有效" |
| | | cell.numberLab.text = "\(model?.vipList[selectIndex].ticketList[index].count ?? 0)张" |
| | | cell.to_use.isHidden = true |
| | | } |
| | | return cell |
| | | } |
| | | |
| | |
| | | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| | | |
| | | if indexPath.row == 0 { |
| | | if (model?.vipList.count ?? 0) > 3 { |
| | | return 450 |
| | | } |
| | | return 295 |
| | | // if (model?.vipList.count ?? 0) > 3 { |
| | | // return 450 |
| | | // } |
| | | let index = ((model?.vipList.count ?? 0) / 3) + (((model?.vipList.count ?? 0) % 3) > 0 ? 1 : 0) |
| | | return CGFloat(140 + index * 155) |
| | | |
| | | }else if indexPath.row > 0 && indexPath.row < ((model?.vipList[selectIndex].couponList.count ?? 0) + 1) { |
| | | let model = model?.vipList[selectIndex].couponList[indexPath.row - 1] |
| | | 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) |
| | | print("ttttttttt\(h)") |
| | | return h + 125 |
| | | }else{ |
| | | return 125 |
| | |
| | | tabView.register(UINib(nibName: "CouponCellTwo", bundle: nil), forCellReuseIdentifier: "CouponCellTwoId") |
| | | tabView.register(UINib(nibName: "WelfareCouponsTCell", bundle: nil), forCellReuseIdentifier: "_WelfareCouponsTCell") |
| | | // tabView.register(UINib(nibName: "CouponCell", bundle: nil), forCellReuseIdentifier: "CouponCellId") |
| | | Services.vipPayment().subscribe(onNext: { [weak self]data in |
| | | self?.model = data.data |
| | | self?.tabView.reloadData() |
| | | self?.nameLab.text = data.data?.name |
| | | if data.data?.isVip ?? 0 == 0 { |
| | | self?.memberLab.text = "当前暂未开通会员" |
| | | }else{ |
| | | self?.memberLab.text = "Vip" |
| | | } |
| | | |
| | | self?.headerImg.sd_setImage(with: URL(string: self?.model?.headImg ?? "") ,placeholderImage: UIImage(named: "user_default")) |
| | | }).disposed(by: disposeBag) |
| | | |
| | | 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){ |
| | |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | |
| | | override func viewWillAppear(_ animated: Bool) { |
| | | Services.vipPayment().subscribe(onNext: { [weak self]data in |
| | | self?.model = data.data |
| | | self?.tabView.reloadData() |
| | | if data.data?.name.count ?? 0 > 0 { |
| | | self?.nameLab.text = data.data?.name |
| | | }else { |
| | | self?.nameLab.text = "未命名" |
| | | } |
| | | |
| | | if data.data?.isVip ?? 0 == 0 { |
| | | self?.memberLab.text = "当前暂未开通会员" |
| | | }else{ |
| | | |
| | | self?.memberLab.text = Date.jq_TheTimeStampConversionMinutes(Double((data.data?.vipEndTime ?? 0) / 1000), "yyyy-MM-dd") |
| | | } |
| | | |
| | | self?.headerImg.sd_setImage(with: URL(string: self?.model?.headImg ?? "") ,placeholderImage: UIImage(named: "user_default")) |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | @IBAction func selectAcceptAction(_ sender: UIButton) { |
| | | sender.isSelected = !sender.isSelected |
| | | acceptXy = sender.isSelected |
| | |
| | | guard let weakSelf = self else { return } |
| | | switch result { |
| | | case .success: |
| | | let vc = PaymentResultVC(result: .success, objType: .member, handleVC: nil, courseConfigId: nil, againClouse: nil) |
| | | let vc = PaymentResultVC(result: .success, objType: .member, handleVC: nil, courseConfigId: nil,list1: weakSelf.model?.vipList[weakSelf.selectIndex].couponList ?? [], |
| | | list2: weakSelf.model?.vipList[weakSelf.selectIndex].ticketList ?? [], againClouse: nil) |
| | | weakSelf.push(vc: vc) |
| | | case .cancel: |
| | | let vc = PaymentResultVC(result: .fail("已取消支付", 0), objType: .member, handleVC: nil, courseConfigId: nil, againClouse: nil) |
| | |
| | | guard let weakSelf = self else { return } |
| | | switch result { |
| | | case .success: |
| | | let vc = PaymentResultVC(result: .success, objType: .member, handleVC: nil, courseConfigId: nil, againClouse: nil) |
| | | let vc = PaymentResultVC(result: .success, objType: .member, handleVC: nil, courseConfigId: nil,list1: weakSelf.model?.vipList[weakSelf.selectIndex].couponList ?? [], |
| | | list2: weakSelf.model?.vipList[weakSelf.selectIndex].ticketList ?? [], againClouse: nil) |
| | | weakSelf.push(vc: vc) |
| | | case .cancel: |
| | | let vc = PaymentResultVC(result: .fail("已取消支付", 0), objType: .member, handleVC: nil, courseConfigId: nil, againClouse: nil) |