| | |
| | | import QMUIKit |
| | | |
| | | class SearchStoreDetailVC: BaseVC { |
| | | private var id:Int! |
| | | private var searchStoreDetailModel:SearchStoreDetailModel?{ |
| | | didSet{ |
| | | if let m = searchStoreDetailModel{ |
| | | headView.searchStoreDetailModel = m |
| | | tableView.reloadData() |
| | | } |
| | | } |
| | | } |
| | | |
| | | lazy private var tableView:UITableView = { |
| | | let table = UITableView(frame: .zero, style: .grouped) |
| | |
| | | |
| | | private let headView = SearchStoreDetailHeadView.jq_loadNibView() |
| | | |
| | | 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 = "门店详情" |
| | |
| | | self.tableView.tableHeaderView = self.headView |
| | | } |
| | | |
| | | Services.exploreStoreDetail(storeId: id).subscribe(onNext: {[weak self] data in |
| | | if let model = data.data{ |
| | | self?.searchStoreDetailModel = model |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | tableView.layoutIfNeeded() |
| | | tableView.tableHeaderView = headView |
| | | } |
| | | |
| | | @objc func moreAction(btn:UIButton){ |
| | | if btn.tag == 10{ |
| | | let vc = YardListVC() |
| | | push(vc: vc) |
| | | }else{ |
| | | let vc = CourseListVC() |
| | | push(vc: vc) |
| | | } |
| | | } |
| | | } |
| | | |
| | | extension SearchStoreDetailVC:UITableViewDelegate{ |
| | | |
| | | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| | | if indexPath.section == 0{ |
| | | let vc = YardListVC() |
| | | let model = searchStoreDetailModel!.venueList[indexPath.row] |
| | | let vc = YardDetailVC(id: model.siteId) |
| | | push(vc: vc) |
| | | }else{ |
| | | let vc = CourseDetailVC(id: 0) |
| | | let model = searchStoreDetailModel!.courseVoList[indexPath.row] |
| | | let vc = CourseDetailVC(id: model.courseId) |
| | | push(vc: vc) |
| | | } |
| | | } |
| | |
| | | |
| | | let morebtn = QMUIButton(type: .custom) |
| | | morebtn.setTitle("查看更多", for: .normal) |
| | | morebtn.tag = 10+section |
| | | 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 |
| | | morebtn.addTarget(self, action: #selector(moreAction), for: .touchUpInside) |
| | | |
| | | footView?.contentView.addSubview(morebtn) |
| | | morebtn.snp.makeConstraints { make in |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | return footView |
| | | } |
| | | } |
| | | |
| | | extension SearchStoreDetailVC:UITableViewDataSource{ |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return 10 |
| | | if section == 0{ |
| | | return searchStoreDetailModel?.venueList.count ?? 0 |
| | | }else{ |
| | | return searchStoreDetailModel?.courseVoList.count ?? 0 |
| | | } |
| | | } |
| | | |
| | | func numberOfSections(in tableView: UITableView) -> Int { |
| | |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | if indexPath.section == 0{ |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_YardTCell") as! YardTCell |
| | | let model = searchStoreDetailModel!.venueList[indexPath.row] |
| | | cell.venueModel = model |
| | | cell.label_distance.isHidden = true |
| | | return cell |
| | | }else { |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_SearchStoreDetail_1_TCell") as! SearchStoreDetail_1_TCell |
| | | let model = searchStoreDetailModel!.courseVoList[indexPath.row] |
| | | cell.detailCourseModel = model |
| | | return cell |
| | | } |
| | | } |