无故事王国
2023-10-23 29ca792f9cd6216f5618cf8706d35a51b57b1376
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
    //
    //  StudentReportVC.swift
    //  WanPai
    //
    //  Created by 无故事王国 on 2023/6/26.
    //
 
import UIKit
import JQTools
import QMUIKit
import SDWebImage
 
class StudentReportVC: BaseVC {
 
    @IBOutlet weak var label_stu_hei: UILabel!
    @IBOutlet weak var label_stu_wei: UILabel!
    @IBOutlet weak var label_stu_BMI: UILabel!
    @IBOutlet weak var stackView: UIStackView!
    @IBOutlet weak var view_line: UIView!
    private let zoomImageView = QMUIZoomImageView()
 
    private var stuId:Int!
 
    init(stuId:Int){
        super.init(nibName: nil, bundle: nil)
        self.stuId = stuId
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
 
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "测试报告"
 
        Services.queryPhysical(stuId: stuId).subscribe(onNext: { [weak self] data in
            if let m = data.data{
                self?.label_stu_hei.attributedText = self?.setAttribute(t1: "\(m.height)", t2: "cm")
                self?.label_stu_wei.attributedText = self?.setAttribute(t1: "\(m.weight)", t2: "kg")
                self?.label_stu_BMI.attributedText = self?.setAttribute(t1: "\(m.bmi)", t2:m.bodyStatus)
 
                SDWebImageDownloader.shared.downloadImage(with: URL(string: m.url)) {[weak self] image, data, error, status in
                    if let image{
                        self?.zoomImageView.image = image
                        self?.zoomImageView.hideEmpty()
                    }
                }
            }
        }).disposed(by: disposeBag)
    }
 
    override func setUI() {
        label_stu_hei.attributedText = setAttribute(t1: "0", t2: "cm")
        label_stu_wei.attributedText = setAttribute(t1: "0", t2: "kg")
        label_stu_BMI.attributedText = setAttribute(t1: "0.0", t2: "正常")
 
 
        view.addSubview(zoomImageView)
        zoomImageView.showEmpty(withText: "暂无报告")
        zoomImageView.snp.makeConstraints { make in
            make.top.equalTo(view_line.snp.bottom).offset(30)
            make.left.right.bottom.equalToSuperview()
        }
    }
 
    private func setAttribute(t1:String,t2:String)->NSMutableAttributedString{
        let color:UIColor = UIColor(hexStr: "#2F5264")
        let a1 = AttributedStringbuilder()
        a1.add(string: t1, withFont: UIFont.systemFont(ofSize: 26), withColor: color)
            .add(string: t2, withFont: UIFont.systemFont(ofSize: 16), withColor: color)
        return a1.mutableAttributedString
    }
 
}