//
|
// MineCouponsDetailVC.swift
|
// OKProject
|
//
|
// Created by 无故事王国 on 2022/2/15.
|
// Copyright © 2022 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
import RxCocoa
|
import RxSwift
|
|
class MineCouponsDetailVC: YYViewController {
|
|
@IBOutlet weak var priceL: UILabel!
|
@IBOutlet weak var nameL: UILabel!
|
@IBOutlet weak var infoL: UILabel!
|
@IBOutlet weak var info1L: UILabel!
|
@IBOutlet weak var merchantImg: UIImageView!
|
@IBOutlet weak var merchantNameL: UILabel!
|
@IBOutlet weak var merchantAddressL: UILabel!
|
@IBOutlet weak var userNameL: UILabel!
|
@IBOutlet weak var phoneL: UILabel!
|
@IBOutlet weak var qrCodeImg: UIImageView!
|
@IBOutlet weak var couponBgImg: UIImageView!
|
|
var couponState:CouponStateType = .overdue
|
|
public var myMerchantCouponModel:MyMerchantCouponModel?
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
title = "我的优惠券"
|
|
priceL.adjustsFontSizeToFitWidth = true
|
priceL.minimumScaleFactor = 0.5
|
view.backgroundColor = UIColor(hexString: "#F3F4F5")
|
|
if myMerchantCouponModel != nil{
|
|
if myMerchantCouponModel!.type == .goods{
|
priceL.attributedText = AttributedStringbuilder.build()
|
.add(string: "领取券", withFont: UIFont.init(name: Semibold, size: 30)!, withColor: UIColor.white).mutableAttributedString
|
info1L.text = myMerchantCouponModel!.content.filterHTML()
|
}else{
|
info1L.text = String(format: "店铺购买满%@元使用", myMerchantCouponModel!.fullAmount.ld_formatFloat)
|
|
priceL.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
|
}
|
|
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)
|
}
|
}
|
|
merchantImg.load(url: myMerchantCouponModel!.headImg)
|
merchantNameL.text = myMerchantCouponModel!.merchantName
|
merchantAddressL.text = "商家地址:\(myMerchantCouponModel!.address)"
|
userNameL.text = "姓名:\(myMerchantCouponModel!.contactName)"
|
phoneL.text = "电话:\(myMerchantCouponModel!.contactPhone)"
|
qrCodeImg.image = createQRForString(qrString: "merchantCoupon:\(myMerchantCouponModel!.code)", qrImageName: nil)
|
}
|
|
switch couponState{
|
case .unuse:
|
couponBgImg.image = UIImage(named: "coupon_bg_front")
|
case .overdue,.used:
|
couponBgImg.image = UIImage(named: "bg_gray_front")
|
}
|
}
|
}
|