younger_times
2023-07-04 b01e1f8e597092fcaba5f5d7d3b472f3b6e95807
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
    //
    //  SearchStoreDetailVC.swift
    //  WanPai
    //
    //  Created by 无故事王国 on 2023/6/30.
    //
 
import UIKit
import JQTools
import QMUIKit
 
class SearchStoreDetailVC: BaseVC {
 
    lazy private var tableView:UITableView = {
        let table = UITableView(frame: .zero, style: .grouped)
        table.separatorStyle = .none
        table.delegate = self
        table.dataSource = self
        table.register(UINib(nibName: "YardTCell", bundle: nil), forCellReuseIdentifier: "_YardTCell")
        table.register(UINib(nibName: "SearchStoreDetail_1_TCell", bundle: nil), forCellReuseIdentifier: "_SearchStoreDetail_1_TCell")
        return table
    }()
 
    private let headView = SearchStoreDetailHeadView.jq_loadNibView()
 
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "门店详情"
 
        DispatchQueue.main.async {
            self.headView.layoutIfNeeded()
            self.headView.layoutSubviews()
            let height = self.headView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height
            self.headView.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: height)
            self.tableView.tableHeaderView = self.headView
        }
 
    }
 
    override func setUI() {
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
 
        tableView.layoutIfNeeded()
        tableView.tableHeaderView = headView
    }
}
 
extension SearchStoreDetailVC:UITableViewDelegate{
 
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if indexPath.section == 0{
            let vc = YardListVC()
            push(vc: vc)
        }else{
            let vc = CourseDetailVC()
            push(vc: vc)
        }
    }
 
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 40
    }
 
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        var headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "header")
        if headerView == nil{
            headerView = UITableViewHeaderFooterView()
            headerView!.contentView.backgroundColor = .white
            headerView!.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 40)
            let label = UILabel()
            label.textColor = .black.withAlphaComponent(0.8)
            label.font = UIFont.systemFont(ofSize: 16, weight: .semibold)
            label.tag = 1000
            headerView!.contentView.addSubview(label)
            label.snp.makeConstraints { make in
                make.left.equalTo(8)
                make.centerY.equalToSuperview()
            }
        }
 
        if let label = headerView!.viewWithTag(1000) as? UILabel{
            if section == 0{
                label.text = "场地列表"
            }else{
                label.text = "课程列表"
            }
        }
        return headerView
    }
 
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 40
    }
 
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        var footView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "footer")
        if footView == nil{
            footView = UITableViewHeaderFooterView()
            footView!.contentView.backgroundColor = .white
            footView!.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 40)
 
            let morebtn = QMUIButton(type: .custom)
            morebtn.setTitle("查看更多", for: .normal)
            morebtn.titleLabel?.font = UIFont.systemFont(ofSize: 12, weight: .medium)
            morebtn.setTitleColor(UIColor(hexStr: "#0048FF"), for: .normal)
            morebtn.setImage(UIImage(named: "btn_more"), for: .normal)
            morebtn.imagePosition = .right
            morebtn.spacingBetweenImageAndTitle = 3
 
            footView?.contentView.addSubview(morebtn)
            morebtn.snp.makeConstraints { make in
                make.center.equalToSuperview()
            }
        }
 
        return footView
    }
}
 
extension SearchStoreDetailVC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
 
    func numberOfSections(in tableView: UITableView) -> Int {
        return 2
    }
 
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if indexPath.section == 0{
            let cell = tableView.dequeueReusableCell(withIdentifier: "_YardTCell") as! YardTCell
            return cell
        }else {
            let cell = tableView.dequeueReusableCell(withIdentifier: "_SearchStoreDetail_1_TCell") as! SearchStoreDetail_1_TCell
            return cell
        }
    }
 
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.section == 0{
                return 80
        }else{
            return 180
        }
    }
}