| | |
| | | // |
| | | |
| | | import UIKit |
| | | import JQTools |
| | | import QMUIKit |
| | | import HandyJSON |
| | | |
| | | struct WorldCupStudentSimpleInfoModel:HandyJSON{ |
| | | var id = 0 |
| | | var isStudent = 0 |
| | | } |
| | | |
| | | class WorldCupContentApplyInputVC: BaseVC { |
| | | |
| | | @IBOutlet weak var view_banner: UIView! |
| | | @IBOutlet weak var label_title: UILabel! |
| | | @IBOutlet weak var label_hot: UILabel! |
| | | @IBOutlet weak var label_duetime: UILabel! |
| | | @IBOutlet weak var label_starttime: UILabel! |
| | | @IBOutlet weak var label_endtime: UILabel! |
| | | @IBOutlet weak var label_ageScope: UILabel! |
| | | @IBOutlet weak var label_genderCond: UILabel! |
| | | @IBOutlet weak var label_city: UILabel! |
| | | @IBOutlet weak var label_address: UILabel! |
| | | @IBOutlet weak var label_matchPoint: UILabel! |
| | | @IBOutlet weak var label_pay_money: UILabel! |
| | | @IBOutlet weak var label_pay_coin: UILabel! |
| | | @IBOutlet weak var label_pay_course: UILabel! |
| | | @IBOutlet weak var btn_moreStore: UIButton! |
| | | @IBOutlet weak var tableView: UITableView! |
| | | @IBOutlet weak var btn_agreement: UIButton! |
| | | @IBOutlet weak var cons_tableHei: NSLayoutConstraint! |
| | | @IBOutlet weak var btn_addStudent: QMUIButton! |
| | | |
| | | |
| | | |
| | | private var students = [ActivityDetailPartModel]() |
| | | private var detailModel:WorldCupDetailModel! |
| | | |
| | | private lazy var bannerView:CommonBannerView = { |
| | | let v = CommonBannerView() |
| | | return v |
| | | }() |
| | | |
| | | init(_ model:WorldCupDetailModel) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.detailModel = model |
| | | } |
| | | |
| | | override func setUI() { |
| | | btn_addStudent.imagePosition = .right |
| | | btn_addStudent.spacingBetweenImageAndTitle = 4 |
| | | view_banner.addSubview(bannerView) |
| | | bannerView.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: JQ_ScreenW * 0.56) |
| | | tableView.delegate = self |
| | | tableView.dataSource = self |
| | | tableView.separatorStyle = .none |
| | | tableView.register(UINib(nibName: "StudentInfo_2_TCell", bundle: nil), forCellReuseIdentifier: "_StudentInfo_2_TCell") |
| | | } |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "社区世界杯" |
| | | let imgs = detailModel.infoImg.components(separatedBy: ",") |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | bannerView.setItems(items: items) |
| | | |
| | | // Do any additional setup after loading the view. |
| | | btn_moreStore.isHidden = detailModel.storeInfos.count > 1 |
| | | |
| | | label_title.text = detailModel.name |
| | | label_hot.text = "\(detailModel.heat)" |
| | | label_duetime.text = detailModel.registrationClosingTime |
| | | label_starttime.text = detailModel.startTime |
| | | label_endtime.text = detailModel.endTime |
| | | label_ageScope.text = detailModel.age + "岁" |
| | | switch detailModel.gender{ |
| | | case 1:label_genderCond.text = "男" |
| | | case 2:label_genderCond.text = "女" |
| | | default:label_genderCond.text = "全部" |
| | | } |
| | | label_city.text = "" |
| | | label_address.text = detailModel.address |
| | | label_matchPoint.text = detailModel.storeInfos.map({$0.name}).joined(separator: "、") |
| | | label_pay_money.text = "¥\(detailModel.cash)/人" |
| | | label_pay_coin.text = "\(detailModel.paiCoin)币/人" |
| | | label_pay_course.text = "\(detailModel.classHour)课时/人" |
| | | |
| | | } |
| | | |
| | | override func setRx() { |
| | | tableView.rx.observe(CGSize.self, "contentSize").subscribe(onNext: {[weak self] size in |
| | | self?.cons_tableHei.constant = size?.height ?? 0 |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | /* |
| | | // MARK: - Navigation |
| | | @IBAction func addStudentAction(_ sender: QMUIButton) { |
| | | StudentChooseView.show(itemType: .activity, defaultStu: students,isAuth: 1) { [weak self] studs in |
| | | self?.students = studs as! [ActivityDetailPartModel] |
| | | self?.cons_tableHei.constant = Double(self?.students.count ?? 0) * 100 |
| | | self?.tableView.reloadData() |
| | | } needAddClouse: {[weak self] () in |
| | | let vc = ActivityStudentListVC() |
| | | self?.push(vc: vc) |
| | | } |
| | | } |
| | | |
| | | // In a storyboard-based application, you will often want to do a little preparation before navigation |
| | | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { |
| | | // Get the new view controller using segue.destination. |
| | | // Pass the selected object to the new view controller. |
| | | } |
| | | */ |
| | | @IBAction func matchStoreAction(_ sender: UIButton) { |
| | | guard let detailModel = detailModel else{return} |
| | | AgreentView.show(type: .matchPoint, content: detailModel.storeInfos.map({$0.name}).joined(separator: "、")) |
| | | } |
| | | |
| | | |
| | | @IBAction func agreementAction(_ sender: UIButton) { |
| | | sender.isSelected = !sender.isSelected |
| | | |
| | | } |
| | | |
| | | @IBAction func webAction(_ sender: Any) { |
| | | let webVC = CommonWebVC(type: .matchStore,customTitle: "社区世界杯报名协议") |
| | | push(vc: webVC) |
| | | } |
| | | |
| | | |
| | | @IBAction func applyAction(_ sender: Any) { |
| | | guard btn_agreement.isSelected else { |
| | | alert(msg: "请先阅读并同意协议");return |
| | | } |
| | | |
| | | guard students.count > 0 else { |
| | | alert(msg: "请选择参赛人员");return |
| | | } |
| | | |
| | | |
| | | |
| | | StoresInfoView.show(detailModel.storeInfos.first ?? ActivityDetailStoreModel()) {[weak self] status in |
| | | guard let weakSelf = self else { return } |
| | | if status{ |
| | | var result = [Dictionary<String,Int>]() |
| | | for v in weakSelf.students{ |
| | | result.append(["id":v.id,"isStudent":v.isStudent]) |
| | | } |
| | | Services.worldCupPaymentCheck(id: weakSelf.detailModel.id, ids: result.jq_toJson1(), uid: nil).subscribe(onNext: {data in |
| | | if let model = data.data{ |
| | | |
| | | var money:Double? |
| | | var paiCoin:Int? |
| | | var classHour:Int? |
| | | |
| | | money = weakSelf.detailModel.cash.double |
| | | |
| | | if model.paiCoin == 1{ |
| | | paiCoin = weakSelf.detailModel.paiCoin |
| | | } |
| | | |
| | | if model.classHour == 1{ |
| | | classHour = weakSelf.detailModel.classHour |
| | | } |
| | | PaymentView.show(enumType: .worldCup, money: (ali: money, wx: money, coin: paiCoin, course:classHour, integral: nil)) {[weak self] payType in |
| | | guard let weakSelf = self else { return } |
| | | Services.worldCupPayment(id: weakSelf.detailModel.id, ids: result.jq_toJson1(), payType: payType, uid: nil).subscribe(onNext: {data in |
| | | if let m = data.data{ |
| | | switch payType { |
| | | case .aliPay: |
| | | YYPaymentManager.shared.sendPaymentRequest(YYAlipayRequest(orderString: m.orderString)) { result in |
| | | switch result { |
| | | case .success: |
| | | let vc = PaymentResultVC(result: .success, objType: .worldCup) |
| | | self?.push(vc: vc) |
| | | case .cancel: |
| | | alert(msg: "交易取消") |
| | | case .failure(_): |
| | | let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .worldCup) |
| | | self?.push(vc: vc) |
| | | } |
| | | } |
| | | case .coin,.free: |
| | | let vc = PaymentResultVC(result: .success, objType: .worldCup) |
| | | self?.push(vc: vc) |
| | | case .courseNum: |
| | | let vc = PaymentResultVC(result: .success, objType: .worldCup) |
| | | self?.push(vc: vc) |
| | | default:break |
| | | } |
| | | } |
| | | },onError: { error in |
| | | if let er = error as? NetworkRequest.NetRequestError{ |
| | | switch er { |
| | | case .Other(let code,let string): |
| | | let vc = PaymentResultVC(result: .fail(string,code), objType: .worldCup) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | default: |
| | | let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .worldCup) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | } |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | } |
| | | |
| | | extension WorldCupContentApplyInputVC:UITableViewDelegate{ |
| | | |
| | | } |
| | | |
| | | |
| | | extension WorldCupContentApplyInputVC:UITableViewDataSource{ |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let student = students[indexPath.row] |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_StudentInfo_2_TCell") as! StudentInfo_2_TCell |
| | | cell.indexPath = indexPath |
| | | cell.activityDetailPartModel = student |
| | | cell.btn_edit.isHidden = true |
| | | cell.img_radio.isHidden = true |
| | | cell.delClouse = {[weak self] index in |
| | | tableView.beginUpdates() |
| | | self?.students.remove(at: index.row) |
| | | tableView.deleteItemsAtIndexPaths([index], animationStyle: .automatic) |
| | | tableView.endUpdates() |
| | | tableView.reloadData() |
| | | } |
| | | return cell |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return students.count |
| | | } |
| | | } |