杨锴
2025-05-11 7453d2d0cef415b34323d1b91e6cfa4a6ba31178
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
//
//  MyCardItemVC.swift
//  WanPai
//
//  Created by 无故事王国 on 2025/3/28.
//
 
import UIKit
import WebKit
import JQTools
import Combine
 
class MyCardItemVC: BaseVC {
    @IBOutlet weak var label_item_title: UILabel!
    @IBOutlet weak var label_time: UILabel!
    @IBOutlet weak var imgCode: UIImageView!
    @IBOutlet weak var webView: WKWebView!
    @IBOutlet weak var cons_web_hei: NSLayoutConstraint!
    @IBOutlet weak var view_bg_grand: UIView!
    @IBOutlet weak var view_container: UIView!
    private var subscriptions = Set<AnyCancellable>()
    private var id:Int!
 
    init(id:Int) {
        super.init(nibName: nil, bundle: nil)
        self.id = id
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "我的玩湃惠民卡"
 
        Services.myHuiminCardDetail(id: id).subscribe(onNext: {data in
            if let m = data.data{
               let names = m.studentList.map({$0.name}).joined(separator: ",")
 
                self.label_item_title.text = String(format: "%@的玩湃惠民卡入场二维码", names)
 
                self.label_time.attributedText = AttributedStringbuilder.build().add(string: "该卡有效期至 ", withFont: .systemFont(ofSize: 16, weight: .medium), withColor: .black)
                    .add(string: m.endTime, withFont: .systemFont(ofSize: 16), withColor: UIColor(hexString: "#ff7300")!).mutableAttributedString
 
                self.imgCode.image = UIImage.jq_GenerateQRCode(with: m.qrCode, width: 250)
                self.webView.loadHTMLString(m.introduce.jq_wrapHtml(), baseURL: nil)
            }
        }).disposed(by: disposeBag)
    }
 
    override func setUI() {
        view.backgroundColor = UIColor.white
        view_container.jq_cornerRadius = 10
        let colors = [UIColor(hexStr: "#FD7202").cgColor,
                      UIColor.white.cgColor,]
        view_bg_grand.jq_gradientColor(colorArr: colors, cornerRadius: 0, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 400), locations: nil, clear: false)
    }
 
    override func setRx() {
        webView.publisher(for: \.scrollView.contentSize).sink {[unowned self] size in
            self.cons_web_hei.constant = size.height
        }.store(in: &subscriptions)
    }
    @IBAction func backAction(_ sender: UIButton) {
        navigationController?.popViewController()
    }
}