杨锴
2024-11-06 63f7ed967433acee3ae8764c7a077e15c29c41f2
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
//
//  PaymentOrderResultVC.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/15.
//
 
import UIKit
import JQTools
class PaymentOrderResultVC: BaseVC {
 
                var collectionView:UICollectionView!
                private let topView = PaymentOrderResultTopView.jq_loadNibView()
                private var id:Int!
    private var type:PaymentOrderVC.PaymentOrderType!
                private var price:Double!
                private var models = [Any]()
 
    init(type:PaymentOrderVC.PaymentOrderType,id:Int,price:Double) {
                                super.init(nibName: nil, bundle: nil)
                                self.id = id
        self.type = type
                                self.price = price
                }
                
                required init?(coder: NSCoder) {
                                fatalError("init(coder:) has not been implemented")
                }
                
                override func viewDidLoad() {
                                super.viewDidLoad()
                                title = "支付结果"
 
//        //如果从支付过来的,移除支付
//        navigationController!.viewControllers.removeAll { vc in
//            if vc is PaymentOrderResultVC || vc is PaymentOrderVC{
//                return true
//            }
//            return false
//        }
 
                                NotificationCenter.default.post(name: CourseRefresh_Noti, object: nil)
 
                                yy_popBlock = { [weak self] () in
                                                var toVC:UIViewController?
                                                for v in self?.navigationController?.viewControllers ?? []{
                                                                if v is CourseDetialVC{
                                                                                toVC = v;break
                                                                }
                                                }
                                                if toVC != nil{
                                                                self?.navigationController?.popToViewController(toVC!, animated: true)
                                                }else{
                                                                self?.navigationController?.popToRootViewController(animated: true)
                                                }
                                }
 
        topView.setPrice(type: type, id: id, price: price)
 
        if type == .course{
            Services.coursePaymentSuccess(courseId: id).subscribe(onNext: {data in
                self.models = data.data ?? []
                self.collectionView.reloadData()
            }).disposed(by: disposeBag)
        }
 
        if type == .muse{
            Services.musePaymentSuccess(meditationId: id).subscribe(onNext: {data in
                self.models = data.data ?? []
                self.collectionView.reloadData()
            }).disposed(by: disposeBag)
        }
                }
 
                override func setUI() {
                                super.setUI()
                                view.backgroundColor = .white
 
                                let layout = HoverHeaderFlowLayout()
                                let w = (JQ_ScreenW - 18 * 3) / 2
                                layout.itemSize = CGSize(width: w, height: w * 1.319)
                                layout.headerReferenceSize = CGSize(width: JQ_ScreenW, height: 59)
                                collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
                                collectionView.backgroundColor = .clear
                                collectionView.delegate = self
                                collectionView.delegate = self
                                collectionView.dataSource = self
                                collectionView.backgroundColor = .white
                                collectionView.contentInset = UIEdgeInsets(top: 298, left: 18, bottom: 0, right: 18)
                                collectionView.register(UINib(nibName: "HomeRelaxBanner_2_1_CCell", bundle: nil), forCellWithReuseIdentifier: "_HomeRelaxBanner_2_1_CCell")
                                collectionView.register(PaymentOrderResultHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "header")
                                view.addSubview(collectionView)
                                collectionView.snp.makeConstraints { make in
                                                make.edges.equalToSuperview()
                                }
 
 
                                view.addSubview(topView)
                                topView.backgroundColor = .clear
                                topView.snp.makeConstraints {[unowned self] make in
                                                make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(0)
                                                make.left.right.equalToSuperview()
                                                make.height.equalTo(278)
                                }
 
//                                view.addSubview(shadowView)
//                                shadowView.backgroundColor = .white
//                                shadowView.snp.makeConstraints {[unowned self] make in
//                                                make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(0)
//                                                make.left.right.equalToSuperview()
//                                                make.height.equalTo(30)
//                                }
 
                }
 
                override func viewDidLayoutSubviews() {
                                super.viewDidLayoutSubviews()
//                                shadowView.jq_gradientColor(colorArr: [UIColor(hexStr: "#F5F5F5").withAlphaComponent(0.15).cgColor,UIColor.clear.cgColor], cornerRadius: 0, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 30),locations: [0.1,0.9])
                }
}
 
 
extension PaymentOrderResultVC:UIScrollViewDelegate{
                func scrollViewDidScroll(_ scrollView: UIScrollView) {
                                let v = (scrollView.contentOffset.y) + 298
                                topView.y = -v
                                navigationController?.navigationBar.standardAppearance.backgroundColor = .white
                }
}
 
extension PaymentOrderResultVC:UICollectionViewDelegate & UICollectionViewDataSource{
                func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
                                return models.count
                }
 
                func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
 
        switch type {
            case .course:
                let model = models[indexPath.row] as! CourseModel
                if model.courseType == .online{
                    let vc = CourseDetialVC(courseId: model.id)
                    push(vc: vc)
                }else{
                    let vc = CourseDetialOfflineVC(courseId: model.id)
                    push(vc: vc)
                }
 
            case .muse:
                let model = models[indexPath.row] as! MeditationModel
                let vc = HomeItemDetailVC(id: model.id)
                push(vc: vc)
            case .none:break
        }
                }
 
                func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
                                let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_1_CCell", for: indexPath) as! HomeRelaxBanner_2_1_CCell
        let model = models[indexPath.row]
 
        if let m = model as? CourseModel{
            cell.setCourseModel(m)
        }
 
        if let m = model as? MeditationModel{
            cell.setMeditationModel(m)
        }
                                return cell
                }
 
                func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
                                if kind == UICollectionView.elementKindSectionHeader{
                                                let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "header", for: indexPath) as! PaymentOrderResultHeaderView
                                                return headerView
                                }
 
                                return UICollectionReusableView()
                }
}
 
class PaymentOrderResultHeaderView:UICollectionReusableView{
 
                override init(frame: CGRect) {
                                super.init(frame: frame)
                                setUI()
                }
 
                required init?(coder: NSCoder) {
                                fatalError("init(coder:) has not been implemented")
                }
 
                private func setUI(){
                                backgroundColor = .white
 
                                let lineView = UIView()
                                lineView.backgroundColor = UIColor(hexString: "#979797")?.withAlphaComponent(0.26)
                                addSubview(lineView)
                                lineView.snp.makeConstraints { make in
                                                make.left.equalTo(76)
                                                make.right.equalTo(-76)
                                                make.height.equalTo(1)
                                                make.centerY.equalToSuperview()
                                }
 
                                let lineLabel = UILabel()
                                lineLabel.text = "猜你喜欢"
                                lineLabel.backgroundColor = .white
                                lineLabel.textAlignment = .center
                                lineLabel.font = .systemFont(ofSize: 14, weight: .medium)
                                lineLabel.textColor = UIColor(hexString: "#3F4343")?.withAlphaComponent(0.79)
                                addSubview(lineLabel)
                                lineLabel.snp.makeConstraints { make in
                                                make.center.equalToSuperview()
                                                make.width.equalTo(71)
                                                make.height.equalTo(20)
                                }
                }
}