| | |
| | | private var layout:WaterFallFlowLayout! |
| | | @IBOutlet weak var label_store: UILabel! |
| | | private var items = Array<HomeStoreConfigModel>() |
| | | // private var storeModel:HomeStoreModel? |
| | | private var storeModel:HomeStoreModel? |
| | | var viewModel = HomeViewModel() |
| | | |
| | | override func viewDidAppear(_ animated: Bool) { |
| | | super.viewDidAppear(animated) |
| | | if storeModel == nil{ |
| | | startLocation() |
| | | } |
| | | } |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | viewModel.configure(collectionView,needMore: false) |
| | | |
| | | locationTool.startLocation { [weak self] local in |
| | | locationTool.stopLocation() |
| | | self?.getStoreInfo() |
| | | } errorClouse: { [weak self] error in |
| | | alertError(msg: "定位获取失败") |
| | | self?.label_store.text = "定位获取失败" |
| | | self?.getStoreInfo() |
| | | } |
| | | startLocation() |
| | | |
| | | viewModel.dataSource.subscribe(onNext: {[weak self] data in |
| | | guard let weakSelf = self else { return } |
| | |
| | | let courseInfoVC = CourseInfoVC() |
| | | courseInfoVC.startClouseHomeModel = model |
| | | let clouseNav = BaseNav(rootViewController: courseInfoVC) |
| | | clouseNav.tabBarItem = UITabBarItem(title: "开始上课", image: UIImage(named: "tabbar_course"), selectedImage: UIImage(named: "tabbar_course_s")) |
| | | clouseNav.tabBarItem = UITabBarItem(title: "开始上课", image: UIImage(named: "tabbar_course"), selectedImage: UIImage(named: "tabbar_course_s")?.withRenderingMode(.alwaysOriginal)) |
| | | self?.tabBarController?.viewControllers![1] = clouseNav |
| | | }else { |
| | | if let vc = (self?.tabBarController?.viewControllers?[1] as? BaseNav)?.topViewController as? CourseVC{ |
| | |
| | | private func getStoreInfo(){ |
| | | Services.homeInfo().subscribe(onNext: {[weak self] data in |
| | | if let m = data.data{ |
| | | self?.storeModel = m |
| | | self?.label_store.text = m.name.isEmpty ? "门店获取失败":m.name |
| | | var text = "欢迎来到 快乐运动俱乐部" |
| | | if m.isVip == 0{text.append("\n加入我们 成为会员")} |
| | |
| | | } |
| | | collectionView.reloadData() |
| | | } |
| | | |
| | | private func startLocation(){ |
| | | locationTool.startLocation { [weak self] local in |
| | | locationTool.stopLocation() |
| | | self?.getStoreInfo() |
| | | } errorClouse: { [weak self] error in |
| | | alertError(msg: "定位获取失败") |
| | | self?.label_store.text = "定位获取失败" |
| | | self?.getStoreInfo() |
| | | } |
| | | } |
| | | |
| | | @IBAction func joinMemberAction(_ sender: UIButton) { |
| | | let joinMemberVC = JoinMemberIntroduceVC() |
| | |
| | | |
| | | |
| | | @IBAction func chooseStoresAction(_ sender: TapBtn) { |
| | | StoresChooseView.show { [weak self] storeId in |
| | | StoresChooseView.show { [weak self] storeId,storeName in |
| | | self?.viewModel.storeId.accept(storeId) |
| | | self?.label_store.text = storeName |
| | | self?.viewModel.beginRefresh() |
| | | } |
| | | } |
| | |
| | | let vc = WelfareWeeklyListVC() |
| | | push(vc: vc) |
| | | case .wisdomCourt: |
| | | let vc = WelfareWeeklyListVC() |
| | | push(vc: vc) |
| | | break |
| | | // let vc = WelfareWeeklyListVC() |
| | | // push(vc: vc) |
| | | case .welfare: |
| | | if viewModel.storeId.value != 0{ |
| | | Services.queryStoreFreeBenefit(id: viewModel.storeId.value).subscribe(onNext: {[weak self] data in |
| | |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeCCell", for: indexPath) as! HomeCCell |
| | | let item = items[indexPath.row] |
| | | cell.img.sd_setImage(with: URL(string: item.backgroundImage), placeholderImage: item.type.defaultImg, options: .highPriority) |
| | | cell.img.cornerRadius = 10 |
| | | return cell |
| | | } |
| | | |
| | |
| | | func waterFlowLayout(_ waterFlowLayout: WaterFallFlowLayout, itemHeight indexPath: IndexPath) -> CGFloat { |
| | | let item = items[indexPath.row] |
| | | |
| | | if (item.radio ?? 0) >= 0.8{ |
| | | if indexPath.row % 2 != 0{ |
| | | return 185 |
| | | }else{ |
| | | return 288 |