younger_times
2023-08-08 47a58a1a7d967464e93410e04791aaa4756c1cbd
WanPai/Root/Welfare/VC/CoinStoreCenterVC.swift
@@ -16,7 +16,7 @@
    let search = BehaviorRelay<String?>(value: nil)
    override func api() -> (Observable<BaseResponse<[MarketMdoel]>>)? {
        Services.mallList(goodsType: goodsType.value, rank: rank.value, search: search.value)
      Services.mallList(page:page,goodsType: goodsType.value, rank: rank.value, search: search.value)
    }
}
@@ -33,18 +33,21 @@
        flowLayout.minimumLineSpacing = 0
        flowLayout.minimumInteritemSpacing = 0
        flowLayout.itemSize = CGSize(width: CellW, height: CellH)
        flowLayout.headerReferenceSize = CGSize(width: JQ_ScreenW, height: JQ_ScreenW * 0.5564)
        flowLayout.sectionHeadersPinToVisibleBounds = true
        let collect = BaseCollectionView(frame: .zero, collectionViewLayout: flowLayout)
        collect.delegate = self
        collect.dataSource = self
        collect.contentInset = UIEdgeInsets(top: 0, left:0, bottom: 14, right: 0)
        collect.register(UINib(nibName: "CoinStoreCCell", bundle: nil), forCellWithReuseIdentifier: "_CoinStoreCCell")
        collect.register(UINib(nibName: "CoinStoreHeadView", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "_CoinStoreHeadView")
        collect.backgroundColor = .white
        return collect
    }()
   private var headView:CoinStoreHeadView = {
      let head = CoinStoreHeadView.jq_loadNibView()
      return head
   }()
    var benefitHomeModel:BenefitHomeModel?
@@ -52,15 +55,32 @@
        super.viewDidLoad()
        title = "积分商城"
        viewModel.configure(collectionView,needMore: false)
      headView.viewModel = viewModel
        viewModel.configure(collectionView)
        collectionView.jq_setEmptyView()
        viewModel.beginRefresh()
      if let model = benefitHomeModel{
         headView.label_coin.text = "\(model.userIntegral)积分"
         headView.label_username.text = model.userName
         headView.img_cover.sd_setImage(with: URL(string: model.userHeadImg))
         headView.tf_search.rx.text.orEmpty.bind(to: viewModel.search).disposed(by: disposeBag)
         headView.integral = model.userIntegral
      }
    }
    override func setUI() {
      view.addSubview(headView)
      headView.snp.makeConstraints { make in
         make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top)
         make.left.right.equalToSuperview()
         make.height.equalTo(JQ_ScreenW * 0.5564)
      }
        view.addSubview(collectionView)
        collectionView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
         make.top.equalTo(headView.snp.bottom)
         make.left.right.bottom.equalToSuperview()
        }
    }
}
@@ -74,18 +94,18 @@
        push(vc: vc)
    }
    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
        let headView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "_CoinStoreHeadView", for: indexPath) as! CoinStoreHeadView
        headView.innerView = self.view
        headView.viewModel = viewModel
        headView.label_coin.text = "\(benefitHomeModel?.userIntegral ?? 0)积分"
        headView.label_username.text = benefitHomeModel?.userName ?? ""
        headView.img_cover.sd_setImage(with: URL(string: benefitHomeModel?.userHeadImg))
        headView.tf_search.rx.text.orEmpty.bind(to: viewModel.search).disposed(by: disposeBag)
        headView.integral = benefitHomeModel?.userIntegral ?? 0
        return headView
    }
//    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
//        let headView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "_CoinStoreHeadView", for: indexPath) as! CoinStoreHeadView
//        headView.innerView = self.view
//        headView.viewModel = viewModel
//        headView.label_coin.text = "\(benefitHomeModel?.userIntegral ?? 0)积分"
//        headView.label_username.text = benefitHomeModel?.userName ?? ""
//        headView.img_cover.sd_setImage(with: URL(string: benefitHomeModel?.userHeadImg))
//        headView.tf_search.rx.text.orEmpty.bind(to: viewModel.search).disposed(by: disposeBag)
//        headView.integral = benefitHomeModel?.userIntegral ?? 0
//
//        return headView
//    }
}
extension CoinStoreCenterVC:UICollectionViewDataSource{