r
2025-09-19 8c309ff419690cc77c9b178096878e18d4849fc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
//  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)
            }
        }
        
    }
}