//
|
// MerchantCouponTCell.swift
|
// OKProject
|
//
|
// Created by 无故事王国 on 2022/2/14.
|
// Copyright © 2022 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
|
class MerchantCouponTCell: UITableViewCell {
|
|
var merchantCouponModel:MerchantCouponModel!{
|
didSet{
|
nameL.text = merchantCouponModel.name
|
infoL.text = String(format: "%ld张券,领取有%ld人,使用%ld人", merchantCouponModel.totalNum,merchantCouponModel.receive,merchantCouponModel.writeOff)
|
|
if merchantCouponModel.type == 2{
|
moneyL.attributedText = AttributedStringbuilder.build()
|
.add(string: "领取券", withFont: UIFont.init(name: Semibold, size: 30)!, withColor: UIColor.white).mutableAttributedString
|
useRuleL.text = merchantCouponModel.content.filterHTML()
|
}else{
|
moneyL.attributedText = AttributedStringbuilder.build()
|
.add(string: "¥", withFont: UIFont.init(name: Semibold, size: 18)!, withColor: UIColor.white)
|
.add(string: String(format: "%.2lf", merchantCouponModel.discount), withFont: UIFont.init(name: Semibold, size: 33)!, withColor: UIColor.white).mutableAttributedString
|
useRuleL.text = String(format: "店铺购买满%@元使用", merchantCouponModel.fullAmount.ld_formatFloat)
|
}
|
layoutSubviews()
|
}
|
}
|
|
var paymentCouponModel:PaymentCouponModel!{
|
didSet{
|
self.moneyL.attributedText = AttributedStringbuilder.build()
|
.add(string: "¥", withFont: UIFont.init(name: Semibold, size: 18)!, withColor: UIColor.white)
|
.add(string: String(format: "%.2lf", self.paymentCouponModel.money), withFont: UIFont.init(name: Semibold, size: 33)!, withColor: UIColor.white).mutableAttributedString
|
|
|
infoL.text = String(format: "有效期至 %@", paymentCouponModel.time)
|
recordBtn.isHidden = true
|
recordImg.isHidden = true
|
companyL.isHidden = false
|
companyL.text = paymentCouponModel.company
|
|
switch paymentCouponModel.userType.rawValue {
|
case 0:
|
nameL.text = "通用优惠券"
|
useRuleL.text = "快车/专车、出租车、跨城出行都可使用"
|
image_front_bg.image = UIImage.init(named: "bg_yellow_front")
|
break
|
case 1:
|
nameL.text = "快车/专车优惠券"
|
useRuleL.text = "仅限快车使用"
|
image_front_bg.image = UIImage.init(named: "bg_green_front")
|
break
|
case 2:
|
nameL.text = "出租车优惠券"
|
useRuleL.text = "仅限出租车使用"
|
image_front_bg.image = UIImage.init(named: "bg_blue_front")
|
break
|
case 3:
|
nameL.text = "跨城出行优惠券"
|
useRuleL.text = "仅限跨城出行使用"
|
image_front_bg.image = UIImage.init(named: "bg_red_front")
|
break
|
case 4:
|
nameL.text = "小件物流优惠券"
|
useRuleL.text = "仅限小件物流使用"
|
image_front_bg.image = UIImage.init(named: "bg_red_front")
|
break
|
default:
|
break
|
}
|
setNeedsLayout()
|
}
|
}
|
|
var myMerchantCouponModel:MyMerchantCouponModel!{
|
didSet{
|
nameL.text = myMerchantCouponModel.name
|
|
if !myMerchantCouponModel.endTime.isEmpty{
|
let days = DateClass.dateDifference(DateClass.timeStringToDate(myMerchantCouponModel.endTime), from:Date())
|
if days <= 0{
|
infoL.text = "已到期"
|
}else if days > 0 && days <= 1.0{
|
infoL.text = String(format: "距离到期仅剩1天")
|
}else{
|
infoL.text = String(format: "距离到期仅剩%.0lf天",days)
|
}
|
}
|
|
if myMerchantCouponModel.type == .goods{
|
useRuleL.text = myMerchantCouponModel.content.filterHTML()
|
moneyL.attributedText = AttributedStringbuilder.build()
|
.add(string: "领取券", withFont: UIFont.init(name: Semibold, size: 30)!, withColor: UIColor.white).mutableAttributedString
|
}else{
|
useRuleL.text = String(format: "店铺购买满%@元使用", myMerchantCouponModel.fullAmount.ld_formatFloat)
|
|
moneyL.attributedText = AttributedStringbuilder.build()
|
.add(string: "¥", withFont: UIFont.init(name: Semibold, size: 18)!, withColor: UIColor.white)
|
.add(string: String(format: "%.2lf", myMerchantCouponModel.discount), withFont: UIFont.init(name: Semibold, size: 33)!, withColor: UIColor.white).mutableAttributedString
|
}
|
layoutSubviews()
|
}
|
}
|
|
var type:ActiveStatus = .ongoing{
|
didSet{
|
if type == .ongoing{
|
image_front_bg.image = UIImage(named: "bg_yellow_front")
|
invaildImg.isHidden = true
|
}else{
|
image_front_bg.image = UIImage(named: "bg_gray_front")
|
invaildImg.isHidden = false
|
}
|
}
|
}
|
|
@IBOutlet weak var image_front_bg: UIImageView!
|
@IBOutlet weak var moneyL: UILabel!
|
@IBOutlet weak var nameL: UILabel!
|
@IBOutlet weak var infoL: UILabel!
|
@IBOutlet weak var useRuleL: UILabel!
|
@IBOutlet weak var recordBtn: UIButton!
|
@IBOutlet weak var recordImg: UIImageView!
|
@IBOutlet weak var checkImg: UIImageView!
|
@IBOutlet weak var invaildImg: UIImageView!
|
@IBOutlet weak var companyL: UILabel!
|
|
|
override func awakeFromNib() {
|
super.awakeFromNib()
|
selectionStyle = .none
|
}
|
|
override var isSelected: Bool{
|
didSet{
|
if isSelected{
|
checkImg.image = UIImage(named: "icon_raidobutton_selected")
|
}else{
|
checkImg.image = UIImage(named: "icon_raidobutton")
|
}
|
}
|
}
|
|
// @IBAction func recordAction(_ sender: UIButton) {
|
//
|
//
|
// }
|
}
|