Robert
58 分钟以前 c547797c9267e2f3e3c24c7acb31502517f3b6e6
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//
//  WelfareWeeklyDetailVC.swift
//  WanPai
//
//  Created by 无故事王国 on 2023/6/21.
//
 
import UIKit
import QMUIKit
import JQTools
import SDWebImage
 
class WelfareWeeklyDetailVC: BaseVC {
                @IBOutlet weak var view_banner: CommonBannerView!
                @IBOutlet weak var label_name: UILabel!
                @IBOutlet weak var label_address: UILabel!
                @IBOutlet weak var label_distance: UILabel!
                @IBOutlet weak var label_courseNum: UILabel!
                @IBOutlet weak var view_courseNum: UIView!
                @IBOutlet weak var label_giftCourseNum: UILabel!
                @IBOutlet weak var view_giftCourseNum: UIView!
                @IBOutlet weak var label_attendWeeks: UILabel!
                @IBOutlet weak var label_datetime: UILabel!
                @IBOutlet weak var img_intro: UIImageView!
                @IBOutlet weak var cons_imgIntroHei: NSLayoutConstraint!
                @IBOutlet weak var label_price: UILabel!
                @IBOutlet weak var label_originPrice: UILabel!
                @IBOutlet weak var label_coin: UILabel!
                @IBOutlet weak var label_vip: UILabel!
                @IBOutlet weak var btn_handle: UIButton!
                @IBOutlet weak var label_periodOfValidity: UILabel!
                @IBOutlet weak var view_periodOfValidity: UIView!
 
                private var id:Int!
                private var weeklyItemDetailModel:WeeklyItemDetailModel?
 
                required 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 = "运动营详情"
                                label_vip.isHidden = true
                                label_originPrice.isHidden = true
 
                                Services.weekBenefitDetail(id: id).subscribe(onNext: {[weak self] data in
                                                guard let weakSelf = self else { return }
                                                if let model = data.data{
                                                                weakSelf.weeklyItemDetailModel = model
                                                                weakSelf.label_name.text = model.coursePackageName
                                                                weakSelf.label_address.text = model.storeNameAddr
                                                                weakSelf.label_courseNum.text = "\(model.classHours)课时"
                                                                weakSelf.label_giftCourseNum.text = "\(model.freeClassHours)课时"
                                                                weakSelf.view_courseNum.isHidden = (model.classHours == 0 ||  model.type == 2)
                                                                weakSelf.view_giftCourseNum.isHidden = model.freeClassHours == 0
                                                                weakSelf.label_attendWeeks.text = model.weekTime
                                                                weakSelf.label_datetime.text = model.time
                                                                weakSelf.label_distance.text = String(format: "距离我%.2lfkm", model.distance)
                                                                //                weakSelf.label_coin.isHidden = model.wanpaiGold == 0
                                                                //                weakSelf.label_coin.text = String(format: "玩湃币:%ld", model.wanpaiGold)
                                                                //                weakSelf.label_originPrice.isHidden = model.costPrice == 0
                                                                //
                                                                //                weakSelf.label_originPrice.attributedText = AttributedStringbuilder.build().add(string: model.costPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).mutableAttributedString
 
                                                                weakSelf.label_price.text = model.discountPrice.currency()
                                                                weakSelf.label_periodOfValidity.text = model.holiTime
                                                                weakSelf.view_periodOfValidity.isHidden = model.holiTime.isEmpty
 
                                                                weakSelf.img_intro.sd_setImage(with: URL(string: model.introduceDrawing)) {[weak self] image, error, type, url in
                                                                                if let img = image{
                                                                                                self?.img_intro.image = img
                                                                                                let radio = img.size.width / img.size.height
                                                                                                self?.cons_imgIntroHei.constant = JQ_ScreenW / radio
                                                                                }
                                                                }
 
                                                                let imgs = model.detailDrawing.components(separatedBy: ",")
                                                                var items = [CommonBannerModel]()
                                                                for (index,img) in imgs.enumerated(){
                                                                                items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl))
                                                                }
                                                                self?.view_banner.setItems(items: items)
 
 
                                                                switch model.payType {
                                                                                case .cash:
                                                                                                weakSelf.label_coin.isHidden = true
                                                                                                weakSelf.label_price.text = model.discountPrice.currency()
 
                                                                                                if model.costPrice != 0 && model.costPrice > model.discountPrice{
                                                                                                                weakSelf.label_originPrice.isHidden = false
                                                                                                                weakSelf.label_originPrice.attributedText = AttributedStringbuilder.build().add(string: model.costPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).mutableAttributedString
                                                                                                }else{
                                                                                                                weakSelf.label_originPrice.isHidden = true
                                                                                                }
 
                                                                                                if model.costPrice > 0 && model.discountPrice < model.costPrice{
                                                                                                                weakSelf.label_originPrice.attributedText = AttributedStringbuilder.build().add(string: model.costPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).mutableAttributedString
                                                                                                }
 
 
                                                                                case .cashCoin:
                                                                                                weakSelf.label_coin.isHidden = false
                                                                                                weakSelf.label_coin.attributedText = AttributedStringbuilder.build()
                                                                                                                .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
                                                                                                                .add(string: "\(model.wanpaiGold)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")).mutableAttributedString
                                                                                                weakSelf.label_price.text = model.discountPrice.currency()
 
                                                                                                if model.costPrice > 0 && model.discountPrice < model.costPrice{
                                                                                                                weakSelf.label_originPrice.attributedText = AttributedStringbuilder.build().add(string: model.costPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).mutableAttributedString
                                                                                                }
 
 
                                                                                case .coin:
                                                                                                weakSelf.label_originPrice.isHidden = true
                                                                                                weakSelf.label_price.isHidden = true
                                                                                                weakSelf.label_coin.attributedText = AttributedStringbuilder.build()
                                                                                                                .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
                                                                                                                .add(string: "\(model.wanpaiGold)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")).mutableAttributedString
                                                                }
                                                }
                                }).disposed(by: disposeBag)
 
                }
                @IBAction func applyAction(_ sender: UIButton) {
                                guard let id = weeklyItemDetailModel?.coursePackageDiscountId else{return}
                                Services.queryCourseInfo(id: id).subscribe(onNext: {[weak self] data in
                                                if let m = data.data{
                                                                let vc = CourseDetailApplyVC(detailModel: m,classHours: self?.weeklyItemDetailModel?.classHours)
                                                                self?.push(vc: vc)
                                                }
                                }).disposed(by: disposeBag)
                }
}