| | |
| | | @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 studentTableView: UITableView! |
| | | |
| | |
| | | private var CellH:Double! |
| | | private var studentModels = [CourseDetailStudentModel]() |
| | | private var couponModels = [CouponInfoModel]() |
| | | private var selectCouponModel:CouponInfoModel? |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | |
| | | label_store.text = m.storeName |
| | | label_address.text = m.storeAddress |
| | | |
| | | changePrice(selectClassIndex) |
| | | if let stu = m.student{studentModels.append(stu)} |
| | | |
| | | cons_collHei.constant = ceil(Double(m.list.count) / 3.0) * CellH + floor(Double(m.list.count) / 3.0) * 21.0 |
| | |
| | | |
| | | cons_tableHei.constant = CGFloat(studentModels.count * 87) |
| | | tableView.reloadData() |
| | | changePrice(selectClassIndex) |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @IBAction func couponAction(_ sender: TapBtn) { |
| | | guard couponModels.count != 0 else { |
| | | alertError(msg: "暂无优惠券");return |
| | | CouponChooseView.show(couponModels,defaultModel: selectCouponModel) { m in |
| | | self.selectCouponModel = m |
| | | guard m != nil else { |
| | | self.btn_couponInfo.setTitle("去选择", for: .normal);return |
| | | } |
| | | self.btn_couponInfo.setTitle("-\(m!.favorable)", for: .normal) |
| | | } |
| | | |
| | | CouponChooseView.show() |
| | | } |
| | | |
| | | @IBAction func studentAction(_ sender: QMUIButton) { |
| | | StudentChooseView.show(itemType:.course,defaultStu: detailModel?.student) { |
| | | |
| | | StudentChooseView.show(itemType: .course, defaultStu: studentModels) { [weak self] studs in |
| | | guard let weakSelf = self else { return } |
| | | weakSelf.studentModels = studs |
| | | weakSelf.tableView.reloadData() |
| | | weakSelf.cons_tableHei.constant = CGFloat((weakSelf.studentModels.count) * 87) |
| | | weakSelf.changePrice(weakSelf.selectClassIndex) |
| | | } needAddClouse: { [weak self] () in |
| | | let vc = AddStudentVC() |
| | | self?.push(vc: vc) |
| | |
| | | } |
| | | |
| | | @IBAction func paymentAction(_ sender: UIButton) { |
| | | PaymentView.show { status in |
| | | let paymentState:PaymentResultVC.PaymentResult = status ? .success:.fail |
| | | let vc = PaymentResultVC(result: paymentState, objType: .courseApply) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | self.present(vc, animated: true) |
| | | 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]{ |
| | | let price = model.vipPrice == nil ? model.originalPrice : model.vipPrice |
| | | let coin = model.playPaiCoin |
| | | PaymentView.show(money: (ali:price,wx:price,coin:coin,course:nil)) { [weak self] payType in |
| | | guard let weakSelf = self else { return } |
| | | Services.courcePayment(conponId: weakSelf.selectCouponModel?.id, courseConfigId: model.id, id: weakSelf.detailModel!.id, price: model.paymentPrice, payType: payType, stuId: weakSelf.studentModels.map({$0.id})).subscribe(onNext: { data in |
| | | if let m = data.data{ |
| | | switch payType { |
| | | case .aliPay: |
| | | YYPaymentManager.shared.sendPaymentRequest(YYAlipayRequest(orderString: m.orderString)) { [weak self] result in |
| | | switch result { |
| | | case .success: |
| | | let vc = PaymentResultVC(result: .success, objType: .courseApply) |
| | | self?.present(vc, animated: true) |
| | | case .cancel: |
| | | let vc = PaymentResultVC(result: .fail, objType: .courseApply) |
| | | self?.present(vc, animated: true) |
| | | case .failure(let error): |
| | | let vc = PaymentResultVC(result: .fail, objType: .courseApply) |
| | | self?.present(vc, animated: true) |
| | | } |
| | | } |
| | | case .wechat:break |
| | | case .coin:break |
| | | case .courseNum:break |
| | | } |
| | | }else{ |
| | | alertError(msg: data.msg) |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | } |
| | | }else{ |
| | | self?.navigationController?.popToRootViewController(animated: true) |
| | | } |
| | | } |
| | | } |
| | | |
| | | private func changePrice(_ index:Int){ |
| | | if let subM = detailModel?.list[index]{ |
| | | label_price.text = subM.paymentPrice.currency() |
| | | label_originPrice.isHidden = subM.originalPrice == nil |
| | | label_coin.isHidden = subM.playPaiCoin == nil |
| | | label_vipPrice.isHidden = subM.vipPrice == nil |
| | | |
| | | label_price.text = (subM.paymentPrice * Double(studentModels.count)).currency() |
| | | label_originPrice.isHidden = subM.originalPrice == nil || subM.originalPrice == 0 |
| | | label_coin.isHidden = subM.playPaiCoin == nil || subM.playPaiCoin == 0 |
| | | label_vipPrice.isHidden = subM.vipPrice == nil || subM.vipPrice == 0 |
| | | |
| | | //原价 |
| | | if let originPrice = subM.originalPrice{ |
| | | let attribute = AttributedStringbuilder.build().add(string: originPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).underLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)) |
| | | let attribute = AttributedStringbuilder.build().add(string: (originPrice * Double(studentModels.count)).currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).underLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)) |
| | | label_originPrice.attributedText = attribute.mutableAttributedString |
| | | } |
| | | |
| | | |
| | | //玩湃币 |
| | | if let paiCoin = subM.playPaiCoin{ |
| | | let coinAttribute = AttributedStringbuilder.build() |
| | | .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F")) |
| | | .add(string: "\(paiCoin)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")) |
| | | .add(string: "\(paiCoin * studentModels.count)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")) |
| | | label_coin.attributedText = coinAttribute.mutableAttributedString |
| | | } |
| | | |
| | |
| | | if let vipPrice = subM.vipPrice{ |
| | | let vipAttribute = AttributedStringbuilder.build() |
| | | .add(string: "会员价:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F")) |
| | | .add(string: vipPrice.currency(), withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")) |
| | | .add(string: (vipPrice * Double(studentModels.count)).currency(), withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")) |
| | | label_vipPrice.attributedText = vipAttribute.mutableAttributedString |
| | | } |
| | | } |
| | |
| | | LogError("会员优惠价格出现问题:nil");return |
| | | } |
| | | |
| | | Services.queryAvaiableCopons(id: subM.id, price: price!).subscribe(onNext: { [weak self] data in |
| | | Services.queryAvaiableCopons(id: detailModel!.id, price: price!).subscribe(onNext: { [weak self] data in |
| | | self?.btn_hasCoupon.isHidden = (data.data?.count ?? 0) == 0 |
| | | self?.couponModels = data.data ?? [] |
| | | }).disposed(by: disposeBag) |
| | |
| | | |
| | | 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 } |
| | | tableView.beginUpdates() |
| | | weakSelf.studentModels.remove(at: index) |
| | | tableView.deleteRows(at: [IndexPath(row: index, section: 0)], with: .right) |
| | | tableView.endUpdates() |
| | | weakSelf.cons_tableHei.constant = CGFloat((weakSelf.studentModels.count) * 87) |
| | | tableView.reloadData() |
| | | weakSelf.changePrice(weakSelf.selectClassIndex) |
| | | } |
| | | return cell |
| | | } |
| | | |
| | | } |