//
|
// TravelCardDetailVC.swift
|
// OKProject
|
//
|
// Created by 无故事王国 on 2022/2/10.
|
// Copyright © 2022 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
|
class TravelCardDetailVC: YYViewController {
|
|
var id = 0
|
var type:OrderType = .taxi
|
@IBOutlet weak var titleL: UILabel!
|
@IBOutlet weak var nameL: UILabel!
|
@IBOutlet weak var infoL: UILabel!
|
@IBOutlet weak var info2L: UILabel!
|
@IBOutlet weak var noteL: UILabel!
|
@IBOutlet weak var usualTimeL: UILabel!
|
@IBOutlet weak var tableView: UITableView!
|
@IBOutlet weak var tableViewHeiCons: NSLayoutConstraint!
|
|
|
private var couponListModel:CouponListModel?
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
title = "会员卡详情"
|
view.backgroundColor = UIColor(hexString: "#F3F4F5")
|
|
tableView.delegate = self
|
tableView.dataSource = self
|
tableView.isScrollEnabled = false
|
tableView.backgroundColor = .clear
|
tableView.separatorStyle = .none
|
tableView.register(cellName: "TravelCouponTCell", identifier: "_TravelCouponTCell")
|
|
switch type {
|
case .special:titleL.text = "快车/专车"
|
case .taxi:titleL.text = "出租车"
|
case .travel:titleL.text = "跨城出行"
|
case .cityLogistics:titleL.text = "同城物流"
|
case .acrossLogistics:titleL.text = "跨城物流"
|
default:break
|
}
|
|
APIManager.shared.provider.rx.request(.getMyTaxiCardInfo(id: id)).map(YYModel<CouponListModel>.self).subscribe(onSuccess: { data in
|
if let m = data.data{
|
self.couponListModel = m
|
self.nameL.text = m.name
|
|
self.tableViewHeiCons.constant = Double(98) * Double(m.couponList.count)
|
|
var text = [String]()
|
var text2 = [String]()
|
switch m.type {
|
case .numberOfDiscounts: // 1
|
text.append(String(format: "享%ld次打车打%.1lf折", m.time,m.discounts))
|
text2.append("有效期至:\(m.endTime)")
|
text2.append("还剩\(m.lastTime)次")
|
case .dicountCard: //2
|
text.append(String(format: "每次打车最高抵扣%@元",m.discounts.ld_formatFloat))
|
text2.append("有效期至:\(m.endTime)")
|
case .numberCard: // 3
|
text.append(String(format: "享%ld次打车优惠%@元",m.time,m.discounts.ld_formatFloat))
|
text2.append("有效期至:\(m.endTime)")
|
text2.append("还剩\(m.lastTime)次")
|
case .discountDayCard: //4
|
text.append(String(format: "每次打车打%.1lf折",m.discounts))
|
text2.append("有效期至:\(m.endTime)")
|
case .expressCard: // 5
|
text.append(String(format: "每次寄件打%.1lf折",m.discounts))
|
text2.append("有效期至:\(m.endTime)")
|
case .expressPaket: //6
|
text.append(String(format: "送%ld张优惠券",m.couponNum))
|
text2.append("有效期至:\(m.endTime)")
|
}
|
|
if !m.cityName.isEmpty{
|
text.append("\(m.cityName)可用")
|
}
|
self.infoL.text = text.joined(separator: " | ")
|
self.info2L.text = text2.filter({!$0.isEmpty}).joined(separator: "|")
|
|
if m.timeQuantum.count == 0 || m.timeQuantum.contains("00:00:00 - 23:59:59"){
|
self.usualTimeL.text = "全天可用"
|
}else{
|
var temp = Array<String>()
|
for (index,str) in m.timeQuantum.enumerated() {
|
temp.append(str)
|
if (index + 1) % 2 == 0{
|
temp.append("\n")
|
}else{
|
temp.append(" ")
|
}
|
}
|
self.usualTimeL.text = String(format: "%@可用", temp.joined(separator: ""))
|
}
|
self.noteL.attributedText = m.note.ld_setHtmlAttributedString(font: nil)
|
self.tableView.reloadData()
|
}
|
}) { error in
|
|
}.disposed(by: disposeBag)
|
}
|
}
|
|
extension TravelCardDetailVC:UITableViewDelegate{
|
|
}
|
|
extension TravelCardDetailVC:UITableViewDataSource{
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
let m = couponListModel!.couponList[indexPath.row]
|
let cell = tableView.dequeueReusableCell(withIdentifier: "_TravelCouponTCell", for: indexPath) as! TravelCouponTCell
|
cell.couponModel = m
|
cell.checkImg.isHidden = true
|
cell.backgroundColor = .clear
|
return cell
|
}
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
98
|
}
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
return couponListModel?.couponList.count ?? 0
|
}
|
}
|