| | |
| | | // |
| | | // CourseDetailApplyVC.swift |
| | | // WanPai |
| | | // |
| | | // Created by 杨锴 on 2023/6/9. |
| | | // |
| | | // |
| | | // CourseDetailApplyVC.swift |
| | | // WanPai |
| | | // |
| | | // Created by 杨锴 on 2023/6/9. |
| | | // |
| | | |
| | | import UIKit |
| | | import JQTools |
| | |
| | | |
| | | class CourseDetailApplyVC: BaseVC { |
| | | |
| | | @IBOutlet weak var collectionView: UICollectionView! |
| | | @IBOutlet weak var cons_collectHei: NSLayoutConstraint! |
| | | @IBOutlet weak var btn_addStudent: QMUIButton! |
| | | @IBOutlet weak var tableView: UITableView! |
| | | @IBOutlet weak var cons_collHei: NSLayoutConstraint! |
| | | @IBOutlet weak var cons_tableHei: NSLayoutConstraint! |
| | | @IBOutlet weak var btn_coupon: TapBtn! |
| | | @IBOutlet weak var collectionView: UICollectionView! |
| | | @IBOutlet weak var cons_collectHei: NSLayoutConstraint! |
| | | @IBOutlet weak var btn_addStudent: QMUIButton! |
| | | @IBOutlet weak var tableView: UITableView! |
| | | @IBOutlet weak var cons_collHei: NSLayoutConstraint! |
| | | @IBOutlet weak var cons_tableHei: NSLayoutConstraint! |
| | | @IBOutlet weak var btn_coupon: TapBtn! |
| | | |
| | | @IBOutlet weak var view_banner: CommonBannerView! |
| | | @IBOutlet weak var label_title: UILabel! |
| | | @IBOutlet weak var label_listenWeek: UILabel! |
| | | @IBOutlet weak var label_listenTime: UILabel! |
| | | @IBOutlet weak var label_store: UILabel! |
| | | @IBOutlet weak var label_address: UILabel! |
| | | @IBOutlet weak var label_listenWeek: UILabel! |
| | | @IBOutlet weak var label_listenTime: UILabel! |
| | | @IBOutlet weak var label_store: UILabel! |
| | | @IBOutlet weak var label_address: UILabel! |
| | | |
| | | @IBOutlet weak var label_price: UILabel! |
| | | @IBOutlet weak var label_originPrice: UILabel! |
| | | @IBOutlet weak var label_vipPrice: UILabel! |
| | | @IBOutlet weak var label_coin: UILabel! |
| | | @IBOutlet weak var btn_hasCoupon: TapBtn! |
| | | @IBOutlet weak var btn_couponInfo: UIButton! |
| | | @IBOutlet weak var label_price: UILabel! |
| | | @IBOutlet weak var label_originPrice: UILabel! |
| | | @IBOutlet weak var label_vipPrice: UILabel! |
| | | @IBOutlet weak var label_coin: UILabel! |
| | | @IBOutlet weak var btn_hasCoupon: TapBtn! |
| | | @IBOutlet weak var btn_couponInfo: UIButton! |
| | | @IBOutlet weak var label_courseType: UILabel! |
| | | |
| | | @IBOutlet weak var view_vaildTime: UIView! |
| | |
| | | @IBOutlet weak var btn_handleBtn: UIButton! |
| | | @IBOutlet weak var view_teach: UIView! |
| | | |
| | | private var detailModel:CourseDetailModel? |
| | | private var selectClassIndex:Int = 0 |
| | | private var detailModel:CourseDetailModel? |
| | | private var selectClassIndex:Int = 0 |
| | | private var isExtend:Bool = false |
| | | private var CellW:Double! |
| | | private var CellH:Double! |
| | | private var studentModels = [CourseDetailStudentModel]() |
| | | private var couponModels = [CouponInfoModel]() |
| | | private var selectCouponModel:CouponInfoModel? |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "运动营详情" |
| | | private var CellW:Double! |
| | | private var CellH:Double! |
| | | private var studentModels = [CourseDetailStudentModel]() |
| | | private var couponModels = [CouponInfoModel]() |
| | | private var selectCouponModel:CouponInfoModel? |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "运动营详情" |
| | | |
| | | if let m = detailModel{ |
| | | label_title.text = m.name |
| | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | override func setUI() { |
| | | } |
| | | |
| | | btn_hasCoupon.isHidden = true |
| | | CellW = (JQ_ScreenW - 155) / 3.0 |
| | | CellH = CellW * 0.439 |
| | | |
| | | cons_tableHei.constant = 76 |
| | | |
| | | collectionView.delegate = self |
| | | collectionView.dataSource = self |
| | | collectionView.register(UINib(nibName: "Common_1_CCell", bundle: nil), forCellWithReuseIdentifier: "_Common_1_CCell") |
| | | |
| | | studentTableView.dataSource = self |
| | | studentTableView.separatorStyle = .none |
| | | studentTableView.register(UINib(nibName: "StudentInfoTCell", bundle: nil), forCellReuseIdentifier: "_StudentInfoTCell") |
| | | |
| | | btn_addStudent.imagePosition = .right |
| | | btn_addStudent.spacingBetweenImageAndTitle = 3 |
| | | } |
| | | override func setUI() { |
| | | |
| | | btn_hasCoupon.isHidden = true |
| | | CellW = (JQ_ScreenW - 155) / 3.0 |
| | | CellH = CellW * 0.439 |
| | | |
| | | cons_tableHei.constant = 76 |
| | | |
| | | collectionView.delegate = self |
| | | collectionView.dataSource = self |
| | | collectionView.register(UINib(nibName: "Common_1_CCell", bundle: nil), forCellWithReuseIdentifier: "_Common_1_CCell") |
| | | |
| | | studentTableView.dataSource = self |
| | | studentTableView.separatorStyle = .none |
| | | studentTableView.register(UINib(nibName: "StudentInfoTCell", bundle: nil), forCellReuseIdentifier: "_StudentInfoTCell") |
| | | |
| | | btn_addStudent.imagePosition = .right |
| | | btn_addStudent.spacingBetweenImageAndTitle = 3 |
| | | } |
| | | |
| | | init(detailModel:CourseDetailModel,isExtend:Bool = false) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.detailModel = detailModel |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.detailModel = detailModel |
| | | self.isExtend = isExtend |
| | | } |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | |
| | | override func setRx() { |
| | | NotificationCenter.default.rx.notification(StudentUpdate_Nofi).take(until: self.rx.deallocated).subscribe {[weak self] noti in |
| | | guard let weakSelf = self else { return } |
| | | //重新唤起添加学生 |
| | | //重新唤起添加学生 |
| | | weakSelf.studentAction(weakSelf.btn_addStudent) |
| | | }.disposed(by: disposeBag) |
| | | } |
| | | |
| | | @IBAction func couponAction(_ sender: TapBtn) { |
| | | CouponChooseView.show(couponModels,defaultModel: selectCouponModel) {[weak self] m in |
| | | @IBAction func couponAction(_ sender: TapBtn) { |
| | | CouponChooseView.show(couponModels,defaultModel: selectCouponModel) {[weak self] m in |
| | | guard let weakSelf = self else { return } |
| | | weakSelf.selectCouponModel = m |
| | | guard m != nil else { |
| | | guard m != nil else { |
| | | weakSelf.btn_couponInfo.setTitle("去选择", for: .normal);return |
| | | } |
| | | } |
| | | weakSelf.btn_couponInfo.setTitle("-\(m!.favorable.currency())", for: .normal) |
| | | weakSelf.changePrice(weakSelf.selectClassIndex) |
| | | } |
| | | } |
| | | |
| | | @IBAction func studentAction(_ sender: QMUIButton) { |
| | | StudentChooseView.show(itemType: .course, defaultStu: studentModels) { [weak self] studs in |
| | | guard let weakSelf = self else { return } |
| | | weakSelf.studentModels = studs as! [CourseDetailStudentModel] |
| | | weakSelf.tableView.reloadData() |
| | | weakSelf.cons_tableHei.constant = CGFloat((weakSelf.studentModels.count) * 87) |
| | | weakSelf.changePrice(weakSelf.selectClassIndex) |
| | | } needAddClouse: { [weak self] () in |
| | | let vc = AddStudentVC(type: .course) |
| | | self?.push(vc: vc) |
| | | } |
| | | } |
| | | |
| | | @IBAction func paymentAction(_ sender: UIButton) { |
| | | guard detailModel != nil else {return} |
| | | guard studentModels.count != 0 else {alertError(msg: "请选择运动营成员");return} |
| | | StoresInfoView.show(detailModel!) { [weak self] status in |
| | | guard let weakSelf = self else { return } |
| | | if status{ |
| | | if let model = weakSelf.detailModel?.list[weakSelf.selectClassIndex]{ |
| | | } |
| | | } |
| | | |
| | | @IBAction func studentAction(_ sender: QMUIButton) { |
| | | StudentChooseView.show(itemType: .course, defaultStu: studentModels) { [weak self] studs in |
| | | guard let weakSelf = self else { return } |
| | | weakSelf.studentModels = studs as! [CourseDetailStudentModel] |
| | | weakSelf.tableView.reloadData() |
| | | weakSelf.cons_tableHei.constant = CGFloat((weakSelf.studentModels.count) * 87) |
| | | weakSelf.changePrice(weakSelf.selectClassIndex) |
| | | } needAddClouse: { [weak self] () in |
| | | let vc = AddStudentVC(type: .course) |
| | | self?.push(vc: vc) |
| | | } |
| | | } |
| | | |
| | | @IBAction func paymentAction(_ sender: UIButton) { |
| | | guard detailModel != nil else {return} |
| | | guard studentModels.count != 0 else {alertError(msg: "请选择运动营成员");return} |
| | | StoresInfoView.show(detailModel!) { [weak self] status in |
| | | guard let weakSelf = self else { return } |
| | | if status{ |
| | | if let model = weakSelf.detailModel?.list[weakSelf.selectClassIndex]{ |
| | | |
| | | var price:Double = 0 |
| | | //是否是会员 |
| | | //是否是会员 |
| | | if weakSelf.detailModel?.isVip == 1 && model.vipPrice != 0{ |
| | | price = model.vipPrice |
| | | }else{ |
| | | price = model.paymentPrice |
| | | } |
| | | |
| | | //计算人数总价 |
| | | //计算人数总价 |
| | | price = price * Double(weakSelf.studentModels.count) |
| | | |
| | | //减去优惠 |
| | | //减去优惠 |
| | | let discountPrice = price - (weakSelf.selectCouponModel?.favorable ?? 0) |
| | | let coin = model.playPaiCoin * weakSelf.studentModels.count |
| | | |
| | | PaymentView.show(money: (ali:discountPrice,wx:discountPrice,coin:coin,course:nil,integral:nil)) { [weak self] payType in |
| | | guard let weakSelf = self else { return } |
| | | PaymentView.show(money: (ali:discountPrice,wx:discountPrice,coin:coin,course:nil,integral:nil)) { [weak self] payType in |
| | | guard let weakSelf = self else { return } |
| | | |
| | | var paymentPrice:Double = 0 |
| | | switch payType { |
| | |
| | | case .courseNum,.integral:break |
| | | } |
| | | |
| | | Services.courcePayment(conponId: weakSelf.selectCouponModel?.id, courseConfigId: model.id, id: weakSelf.detailModel!.id, price: paymentPrice, payType: payType, stuId: weakSelf.studentModels.map({$0.id})).subscribe(onNext: { data in |
| | | Services.courcePayment(conponId: weakSelf.selectCouponModel?.id, courseConfigId: model.id, id: weakSelf.detailModel!.id, price: paymentPrice, payType: payType, stuId: weakSelf.studentModels.map({$0.id})).subscribe(onNext: { data in |
| | | if data.code == 200{ |
| | | switch payType { |
| | | case .aliPay: |
| | | switch payType { |
| | | case .aliPay: |
| | | YYPaymentManager.shared.sendPaymentRequest(YYAlipayRequest(orderString: data.data!.orderString)) { [weak self] result in |
| | | switch result { |
| | | case .success: |
| | | let vc = PaymentResultVC(result: .success, objType: .courseApply,handleVC: self,courseConfigId: model.id) |
| | | switch result { |
| | | case .success: |
| | | let vc = PaymentResultVC(result: .success, objType: .courseApply,handleVC: self,courseConfigId: model.id) |
| | | vc.isExtend = self?.isExtend ?? false |
| | | self?.push(vc: vc) |
| | | case .cancel: |
| | | alert(msg: "已取消") |
| | | case .failure(_): |
| | | case .cancel: |
| | | alert(msg: "已取消") |
| | | case .failure(_): |
| | | let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .courseApply) |
| | | self?.push(vc: vc) |
| | | } |
| | | } |
| | | case .wechat: |
| | | } |
| | | } |
| | | case .wechat: |
| | | self?.navigationController?.popViewController(animated: false) |
| | | break |
| | | case .coin: |
| | | // self?.navigationController?.popViewController(animated: false) |
| | | case .coin: |
| | | // self?.navigationController?.popViewController(animated: false) |
| | | let vc = PaymentResultVC(result: .success, objType: .courseApply,handleVC: self,courseConfigId: model.id) |
| | | vc.isExtend = self?.isExtend ?? false |
| | | self?.push(vc: vc) |
| | | case .courseNum,.integral:break |
| | | } |
| | | }else{ |
| | | alertError(msg: data.msg) |
| | | } |
| | | } |
| | | }else{ |
| | | alertError(msg: data.msg) |
| | | } |
| | | },onError: { error in |
| | | if let er = error as? NetworkRequest.NetRequestError{ |
| | | switch er { |
| | |
| | | } |
| | | |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | } |
| | | }else{ |
| | | self?.navigationController?.popToRootViewController(animated: true) |
| | | } |
| | | } |
| | | }else{ |
| | | self?.navigationController?.popToRootViewController(animated: true) |
| | | NotificationCenter.default.post(name: ChooseHomeStore_Noti, object: nil) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //计算价格 |
| | | private func changePrice(_ index:Int){ |
| | | if let subM = detailModel?.list[index]{ |
| | | |
| | | //计算价格 |
| | | private func changePrice(_ index:Int){ |
| | | if let subM = detailModel?.list[index]{ |
| | | |
| | | var studentCount:Double = 0 |
| | | if studentModels.count == 0{ |
| | | studentCount = 1 |
| | |
| | | label_price.isHidden = true |
| | | label_originPrice.isHidden = true |
| | | label_vipPrice.isHidden = true |
| | | |
| | | //纯玩湃币没有优惠券项 |
| | | label_coin.isHidden = false |
| | | //纯玩湃币没有优惠券项 |
| | | btn_hasCoupon.isHidden = true |
| | | |
| | | label_coin.isHidden = false |
| | | //玩湃币 |
| | | label_coin.attributedText = AttributedStringbuilder.build() |
| | | .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F")) |
| | |
| | | }else{ |
| | | label_originPrice.isHidden = false |
| | | } |
| | | // label_originPrice.isHidden = (subM.paymentPrice == subM.originalPrice && subM.paymentPrice != 0 && subM.originalPrice != 0) |
| | | |
| | | // label_originPrice.isHidden = (subM.paymentPrice == subM.originalPrice && subM.paymentPrice != 0 && subM.originalPrice != 0) |
| | | label_coin.isHidden = false |
| | | //玩湃币 |
| | | label_coin.attributedText = AttributedStringbuilder.build() |
| | | .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F")) |
| | |
| | | label_originPrice.attributedText = attribute.mutableAttributedString |
| | | |
| | | if UserInfoModel.get()?.isVip == 1{ |
| | | //会员 |
| | | label_vipPrice.isHidden = true |
| | | if subM.paymentPrice < subM.vipPrice && subM.paymentPrice != 0{ |
| | | label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.vipPrice < subM.paymentPrice && subM.vipPrice != 0{ |
| | | label_price.text = (subM.vipPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.vipPrice != 0 && subM.paymentPrice != 0{ |
| | | let price = min(subM.vipPrice, subM.paymentPrice) |
| | | label_price.text = (price * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else{ |
| | | label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | |
| | | if subM.payType != .coin{ |
| | | //会员 |
| | | label_vipPrice.isHidden = true |
| | | if subM.paymentPrice < subM.vipPrice && subM.paymentPrice != 0{ |
| | | label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.vipPrice < subM.paymentPrice && subM.vipPrice != 0{ |
| | | label_price.text = (subM.vipPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.vipPrice != 0 && subM.paymentPrice != 0{ |
| | | let price = min(subM.vipPrice, subM.paymentPrice) |
| | | label_price.text = (price * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else{ |
| | | label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | } |
| | | } |
| | | |
| | | }else{ |
| | | //非会员 |
| | | label_vipPrice.isHidden = subM.vipPrice == 0 || subM.vipPrice == subM.paymentPrice |
| | | let vipAttribute = AttributedStringbuilder.build() |
| | | .add(string: "会员价:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F")) |
| | | .add(string: (subM.vipPrice * studentCount).currency(), withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")) |
| | | label_vipPrice.attributedText = vipAttribute.mutableAttributedString |
| | | if subM.payType != .coin{ |
| | | //非会员 |
| | | label_vipPrice.isHidden = subM.vipPrice == 0 || subM.vipPrice == subM.paymentPrice |
| | | let vipAttribute = AttributedStringbuilder.build() |
| | | .add(string: "会员价:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F")) |
| | | .add(string: (subM.vipPrice * studentCount).currency(), withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")) |
| | | label_vipPrice.attributedText = vipAttribute.mutableAttributedString |
| | | |
| | | |
| | | if subM.originalPrice != 0 && subM.paymentPrice == 0{ |
| | | label_price.text = (subM.originalPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.originalPrice == 0 && subM.paymentPrice != 0{ |
| | | label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.originalPrice != 0 && subM.paymentPrice != 0{ |
| | | var money = min(subM.originalPrice,subM.paymentPrice) |
| | | money = money - (selectCouponModel?.favorable ?? 0) |
| | | label_price.text = (money * studentCount).currency() |
| | | }else{ |
| | | label_price.text = (subM.originalPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | if subM.originalPrice != 0 && subM.paymentPrice == 0{ |
| | | label_price.text = (subM.originalPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.originalPrice == 0 && subM.paymentPrice != 0{ |
| | | label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.originalPrice != 0 && subM.paymentPrice != 0{ |
| | | var money = min(subM.originalPrice,subM.paymentPrice) |
| | | money = money - (selectCouponModel?.favorable ?? 0) |
| | | label_price.text = (money * studentCount).currency() |
| | | }else{ |
| | | label_price.text = (subM.originalPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if detailModel?.type == .experience{ |
| | | label_price.text = subM.paymentPrice.currency() |
| | | |
| | | if subM.paymentPrice != 0{ |
| | | label_price.text = subM.paymentPrice.currency() |
| | | label_price.isHidden = false |
| | | } |
| | | |
| | | view_teach.isHidden = true |
| | | label_originPrice.isHidden = true |
| | | label_vipPrice.isHidden = true |
| | | } |
| | | |
| | | if label_originPrice.isHidden && label_vipPrice.isHidden && label_coin.isHidden{ |
| | | label_coin.alpha = 0 |
| | | } |
| | | } |
| | | } |
| | | // if label_originPrice.isHidden && label_vipPrice.isHidden && label_coin.isHidden{ |
| | | // label_coin.alpha = 0 |
| | | // } |
| | | } |
| | | } |
| | | |
| | | //查询优惠券 |
| | | //查询优惠券 |
| | | private func queryCouponInfo(complete:(()->Void)? = nil){ |
| | | if let subM = detailModel?.list[selectClassIndex]{ |
| | | if let subM = detailModel?.list[selectClassIndex]{ |
| | | |
| | | var price:Double? |
| | | switch subM.payType{ |
| | | var price:Double? |
| | | switch subM.payType{ |
| | | case .cash,.cashCoin: |
| | | price = subM.originalPrice == 0 ? subM.vipPrice : subM.originalPrice |
| | | case .coin: |
| | | price = subM.originalPrice == 0 ? subM.vipPrice : subM.originalPrice |
| | | case .coin: |
| | | price = Double(subM.playPaiCoin) |
| | | } |
| | | |
| | | guard price != nil else { |
| | | LogError("会员优惠价格出现问题:nil");return |
| | | } |
| | | guard price != nil else { |
| | | LogError("会员优惠价格出现问题:nil");return |
| | | } |
| | | |
| | | Services.queryAvaiableCopons(id: detailModel!.id, price: price!).subscribe(onNext: { [weak self] data in |
| | | Services.queryAvaiableCopons(id: detailModel!.id, price: price!).subscribe(onNext: { [weak self] data in |
| | | guard let weakSelf = self else { return } |
| | | self?.btn_hasCoupon.isHidden = (data.data?.count ?? 0) == 0 |
| | | self?.couponModels = data.data ?? [] |
| | | self?.btn_hasCoupon.isHidden = (data.data?.count ?? 0) == 0 |
| | | self?.couponModels = data.data ?? [] |
| | | |
| | | //重新获取优惠券,在切换套餐时触发 |
| | | //重新获取优惠券,在切换套餐时触发 |
| | | if let selectCoupon = self?.selectCouponModel{ |
| | | if !weakSelf.couponModels.contains(where: {$0.id == selectCoupon.id}){ |
| | | weakSelf.selectCouponModel = nil |
| | |
| | | } |
| | | } |
| | | complete?() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | |
| | | override func viewDidLayoutSubviews() { |
| | | super.viewDidLayoutSubviews() |
| | |
| | | } |
| | | |
| | | extension CourseDetailApplyVC:UICollectionViewDelegate{ |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | selectClassIndex = indexPath.row |
| | | collectionView.reloadData() |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | selectClassIndex = indexPath.row |
| | | collectionView.reloadData() |
| | | queryCouponInfo {[weak self] () in |
| | | self?.changePrice(indexPath.row) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | extension CourseDetailApplyVC:UICollectionViewDataSource{ |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | let m = detailModel!.list[indexPath.row] |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_Common_1_CCell", for: indexPath) as! Common_1_CCell |
| | | cell.isSelected = indexPath.row == selectClassIndex |
| | | cell.courseDetailListModel = m |
| | | return cell |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | return detailModel?.list.count ?? 0 |
| | | } |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | let m = detailModel!.list[indexPath.row] |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_Common_1_CCell", for: indexPath) as! Common_1_CCell |
| | | cell.isSelected = indexPath.row == selectClassIndex |
| | | cell.courseDetailListModel = m |
| | | return cell |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | return detailModel?.list.count ?? 0 |
| | | } |
| | | } |
| | | |
| | | extension CourseDetailApplyVC:UICollectionViewDelegateFlowLayout{ |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { |
| | | return 21 |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { |
| | | return 21 |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
| | | return CGSize(width: CellW, height: CellH) |
| | | } |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { |
| | | return 21 |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { |
| | | return 21 |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
| | | return CGSize(width: CellW, height: CellH) |
| | | } |
| | | } |
| | | |
| | | extension CourseDetailApplyVC:UITableViewDataSource{ |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return studentModels.count |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_StudentInfoTCell") as! StudentInfoTCell |
| | | cell.indexPath = indexPath |
| | | cell.studentModel = studentModels[indexPath.row] |
| | | cell.deleClouse = { [weak self] index in |
| | | guard let weakSelf = self else { return } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return studentModels.count |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_StudentInfoTCell") as! StudentInfoTCell |
| | | cell.indexPath = indexPath |
| | | cell.studentModel = studentModels[indexPath.row] |
| | | cell.deleClouse = { [weak self] index in |
| | | guard let weakSelf = self else { return } |
| | | if weakSelf.studentModels.count > 1{ |
| | | tableView.beginUpdates() |
| | | weakSelf.studentModels.remove(at: index) |
| | |
| | | }else{ |
| | | alert(msg: "至少选择一位运动营成员") |
| | | } |
| | | } |
| | | } |
| | | cell.btn_handle.isHidden = isExtend |
| | | return cell |
| | | } |
| | | return cell |
| | | } |
| | | } |