//
|
// ExchangeRecordTCell.swift
|
// WanPai
|
//
|
// Created by 无故事王国 on 2023/6/29.
|
//
|
|
import UIKit
|
import JQTools
|
|
class ExchangeRecordTCell: UITableViewCell {
|
|
var recordsModel:RecordsModel!{
|
didSet{
|
label_title.text = recordsModel.goodName
|
label_state.text = recordsModel.useStatus.strTitle
|
label_duetime.text = String(format: "有效期:%@-%@", recordsModel.startTime,recordsModel.endTime)
|
label_type.text = recordsModel.goodType.strTitle
|
|
switch recordsModel.useStatus {
|
case .unUsed:
|
label_state.textColor = Def_ThemeColor
|
switch recordsModel.goodType {
|
case .ticket:
|
// rightQR.constant = 9
|
btn_qrCode.isHidden = false
|
default:
|
btn_qrCode.isHidden = true
|
}
|
case .expired,.used:
|
label_state.textColor = UIColor(hexStr: "#7A7A7A")
|
btn_qrCode.isHidden = true
|
}
|
lookDetails.isHidden = false
|
qrRight.constant = -9
|
switch recordsModel.exchangeType{
|
case.coin:
|
label_price.attributedText = AttributedStringbuilder.build().add(string: "\(recordsModel.integral)", withFont: UIFont.systemFont(ofSize: 18, weight: .medium), withColor: Def_ThemeColor)
|
.add(string: "积分", withFont: UIFont.systemFont(ofSize: 12, weight: .medium), withColor: Def_ThemeColor).mutableAttributedString
|
|
case .cashAndCoin:
|
var attribute = AttributedStringbuilder.build()
|
if recordsModel.integral != 0{
|
attribute = attribute.add(string: "\(recordsModel.integral)", withFont: UIFont.systemFont(ofSize: 18, weight: .medium), withColor: Def_ThemeColor)
|
attribute = attribute.add(string: "积分+", withFont: UIFont.systemFont(ofSize: 12, weight: .medium), withColor: Def_ThemeColor)
|
}
|
attribute = attribute.add(string: recordsModel.cash.currency(), withFont: UIFont.systemFont(ofSize: 12, weight: .medium), withColor: Def_ThemeColor)
|
label_price.attributedText = attribute.mutableAttributedString
|
case .cash:
|
label_price.attributedText = AttributedStringbuilder.build().add(string: recordsModel.cash.currency(), withFont: UIFont.systemFont(ofSize: 18, weight: .medium), withColor: Def_ThemeColor).mutableAttributedString
|
case .mpiao:
|
label_price.attributedText = AttributedStringbuilder.build().add(string: "会员赠送", withFont: UIFont.systemFont(ofSize: 18, weight: .medium), withColor: Def_ThemeColor).mutableAttributedString
|
lookDetails.isHidden = true
|
qrRight.constant = -90
|
}
|
}
|
}
|
@IBOutlet weak var label_title: UILabel!
|
@IBOutlet weak var label_state: UILabel!
|
@IBOutlet weak var label_duetime: UILabel!
|
@IBOutlet weak var label_price: UILabel!
|
@IBOutlet weak var label_type: UILabel!
|
@IBOutlet weak var btn_qrCode: UIButton!
|
|
@IBOutlet weak var qrRight: NSLayoutConstraint!
|
@IBOutlet weak var lookDetails: UIButton!
|
|
override func awakeFromNib() {
|
super.awakeFromNib()
|
selectionStyle = .none
|
}
|
|
|
@IBAction func QRCodeAction(_ sender: UIButton) {
|
var time = OpenDoorTimeModel()
|
|
if recordsModel.exchangeType == .mpiao && recordsModel.goodType == .ticket{
|
var timeCopy = OpenDoorTimeModelCopy()
|
timeCopy.start_time = recordsModel.startTime
|
timeCopy.end_time = recordsModel.endTime
|
let model = OpenDoorModelCopy(role: 1, time: [timeCopy], vipDetail: recordsModel.detailsId)
|
if let string = model.toJSONString(){
|
QRPreview.show(string)
|
}
|
}else{
|
time.start_time = Date.jq_StringToTimeInterval((recordsModel.startTime ), "yyyy-MM-dd HH:mm:ss")
|
time.end_time = Date.jq_StringToTimeInterval((recordsModel.endTime ), "yyyy-MM-dd HH:mm:ss")
|
let model = OpenDoorModel(sid: recordsModel.sid, rid: recordsModel.rid, uid: recordsModel.userId, time: [time], type: 2)
|
if let string = model.toJSONString(){
|
QRPreview.show(string)
|
}
|
}
|
|
}
|
}
|