| | |
| | | private var page:Int = 1 |
| | | private var model:HuiminCardModel? |
| | | |
| | | // private var currentStuCode:HuiminCardItemModel? |
| | | private var cacheSet = [IndexPath:HuiminCardStuModel]() |
| | | |
| | | private var view_BgGradView:UIView = { |
| | | let bgView = UIView() |
| | | return bgView |
| | | }() |
| | | |
| | | override func viewDidAppear(_ animated: Bool) { |
| | | super.viewDidAppear(animated) |
| | | if let storeStr = UserDefaults.standard.object(forKey: "CurrentStore") as? String{ |
| | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "惠民卡" |
| | | view.backgroundColor = .clear |
| | | } |
| | | |
| | | override func setRx() { |
| | |
| | | |
| | | private func getData(){ |
| | | page = 1 |
| | | Services.getHuiminAgreementAndList(page: page, storeId: sotreId!).subscribe(onNext: {data in |
| | | guard let s = sotreId else {return} |
| | | |
| | | Services.getHuiminAgreementAndList(page: page, storeId: s).subscribe(onNext: {[unowned self]data in |
| | | self.model = data.data |
| | | |
| | | // for v in data.data?.cardList ?? []{ |
| | | // if !(v.qrCode?.isEmpty ?? true){ |
| | | // self.currentStuCode = v;break |
| | | // } |
| | | // } |
| | | |
| | | if data.data?.showType == 2{ |
| | | self.webView.isHidden = true |
| | | self.tableView.reloadData() |
| | |
| | | |
| | | override func setUI() { |
| | | |
| | | view.addSubview(view_BgGradView) |
| | | view_BgGradView.snp.makeConstraints { make in |
| | | make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top) |
| | | make.left.right.equalToSuperview() |
| | | make.height.equalTo(400) |
| | | } |
| | | |
| | | tableView = UITableView(frame: .zero, style: .plain) |
| | | tableView.showsVerticalScrollIndicator = false |
| | | tableView.separatorStyle = .none |
| | | tableView.backgroundColor = .clear |
| | | tableView.contentInset = UIEdgeInsets(top: 31, left: 0, bottom: 0, right: 0) |
| | | tableView.register(UINib(nibName: "CardCenterTCell", bundle: nil), forCellReuseIdentifier: "_CardCenterTCell") |
| | | tableView.register(UINib(nibName: "CardCenterTopQRCodeTCell", bundle: nil), forCellReuseIdentifier: "_CardCenterTopQRCodeTCell") |
| | | |
| | | tableView.delegate = self |
| | | tableView.dataSource = self |
| | | |
| | |
| | | webView.snp.makeConstraints { make in |
| | | make.edges.equalToSuperview() |
| | | } |
| | | let colors = [UIColor(hexStr: "#FD7202").cgColor, |
| | | UIColor.white.cgColor,] |
| | | view_BgGradView.jq_gradientColor(colorArr: colors, cornerRadius: 0, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 400), locations: nil, clear: false) |
| | | } |
| | | } |
| | | |
| | | extension CardCenterVC:UITableViewDelegate{ |
| | | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| | | guard indexPath.section == 1 else {return} |
| | | |
| | | let model = model!.cardList[indexPath.row] |
| | | let vc = CardCenterDetailVC(id:model.id,storeId: sotreId!) |
| | | push(vc: vc) |
| | |
| | | |
| | | extension CardCenterVC:UITableViewDataSource{ |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | if section == 0{ |
| | | return model?.cardList.count ?? 0 |
| | | } |
| | | return model?.cardList.count ?? 0 |
| | | } |
| | | |
| | | |
| | | func numberOfSections(in tableView: UITableView) -> Int { |
| | | return 2 |
| | | } |
| | | |
| | | |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let model = model!.cardList[indexPath.row] |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_CardCenterTCell") as! CardCenterTCell |
| | | cell.setHuiminCardItemModel(model) |
| | | return cell |
| | | |
| | | if indexPath.section == 0{ |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_CardCenterTopQRCodeTCell") as! CardCenterTopQRCodeTCell |
| | | cell.indexPath = indexPath |
| | | cell.setModel(model!.cardList[indexPath.row],cache: cacheSet[indexPath]) |
| | | cell.studentListClouse { list, index in |
| | | CommonAlertSheetView.show(items: list.map({$0.name})) {[unowned self] i in |
| | | if let m = model?.cardList[indexPath.row]{ |
| | | Services.getQRCodeByStuId(cardId: m.id, studentId: list[i].id).subscribe(onNext: {data in |
| | | self.cacheSet[indexPath] = data.data |
| | | self.tableView.reloadRows(at: [indexPath], with: .automatic) |
| | | }).disposed(by: self.disposeBag) |
| | | } |
| | | } |
| | | } |
| | | return cell |
| | | } |
| | | |
| | | if indexPath.section == 1{ |
| | | let model = model!.cardList[indexPath.row] |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_CardCenterTCell") as! CardCenterTCell |
| | | cell.setHuiminCardItemModel(model) |
| | | return cell |
| | | } |
| | | |
| | | return UITableViewCell() |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| | | return (JQ_ScreenW - 40) * 0.4841 + 20 |
| | | if indexPath.section == 0{ |
| | | let m = model?.cardList[indexPath.row] |
| | | if m?.qrCode?.isEmpty ?? true{ |
| | | return 0 |
| | | } |
| | | return 480 |
| | | }else{ |
| | | return (JQ_ScreenW - 40) * 0.4841 + 20 |
| | | } |
| | | } |
| | | } |