| | |
| | | |
| | | import UIKit |
| | | import QMUIKit |
| | | import SDWebImage |
| | | import JQTools |
| | | |
| | | class ActivityDetailApplyVC: BaseVC { |
| | | |
| | | |
| | | @IBOutlet weak var img_profile: UIImageView! |
| | | @IBOutlet weak var label_storeName: UILabel! |
| | | @IBOutlet weak var label_title: UILabel! |
| | | @IBOutlet weak var label_joinCondition: UILabel! |
| | | @IBOutlet weak var label_address: 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_city: UILabel! |
| | | @IBOutlet weak var label_money: UILabel! |
| | | @IBOutlet weak var label_coin: UILabel! |
| | | @IBOutlet weak var label_courseNum: UILabel! |
| | | @IBOutlet weak var label_introducion: UILabel! |
| | | @IBOutlet weak var btn_enroll: UIButton! |
| | | @IBOutlet weak var tableView: UITableView! |
| | | @IBOutlet weak var btn_addStudent: QMUIButton! |
| | | @IBOutlet weak var cons_tableHei: NSLayoutConstraint! |
| | | |
| | | var activityDetailModel:ActivityDetailModel! |
| | | private var students = [ActivityDetailPartModel]() |
| | | |
| | | required init(model:ActivityDetailModel) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.activityDetailModel = model |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | |
| | | |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "活动详情" |
| | | |
| | | img_profile.sd_setImage(with: URL(string: activityDetailModel.storeCoverDrawing)!) |
| | | label_storeName.text = activityDetailModel.storeName + "(\(activityDetailModel.storeAddress))" |
| | | label_title.text = activityDetailModel.name |
| | | label_joinCondition.text = activityDetailModel.registerCondition.strTitle |
| | | label_address.text = activityDetailModel.address |
| | | label_duetime.text = activityDetailModel.registerEndTime |
| | | label_starttime.text = activityDetailModel.startTime |
| | | label_endtime.text = activityDetailModel.endTime |
| | | label_ageScope.text = activityDetailModel.age |
| | | label_introducion.text = activityDetailModel.introduction |
| | | label_city.text = activityDetailModel.province + "|" + activityDetailModel.city |
| | | label_money.text = String(format: "%@/人", activityDetailModel.cashPrice.currency()) |
| | | label_coin.text = String(format: "%ld币/人", activityDetailModel.playPaiCoin) |
| | | label_courseNum.text = String(format: "%ld课时/人", activityDetailModel.classPrice) |
| | | |
| | | students.append(contentsOf: activityDetailModel.participant) |
| | | cons_tableHei.constant = Double(students.count) * 100 |
| | | tableView.reloadData() |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | } |
| | | |
| | | @IBAction func addStudentAction(_ sender: QMUIButton) { |
| | | StudentChooseView.show(itemType: .activity) { studs in |
| | | |
| | | StudentChooseView.show(itemType: .activity, defaultStu: students) { [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) |
| | |
| | | |
| | | @IBAction func applyAction(_ sender: UIButton) { |
| | | |
| | | StoresInfoView.show(CourseDetailModel()) { status in |
| | | |
| | | guard students.count != 0 else { |
| | | alertError(msg: "请至少选择一位参赛人员");return |
| | | } |
| | | |
| | | // StoresInfoView.show(CourseDetailModel() { status in |
| | | // if status{ |
| | | // PaymentView.show(money: (ali:1,wx:2,coin:2,course:2)) { stat in |
| | | // let result:PaymentResultVC.PaymentResult = status ? .success:.fail |
| | | // let vc = PaymentResultVC(result: result, objType: .activityApply) |
| | | // vc.modalPresentationStyle = .fullScreen |
| | | // self.present(vc, animated: true) |
| | | // } |
| | | // } |
| | | // } |
| | | StoresInfoView.show(activityDetailModel) { [weak self] status in |
| | | guard let weakSelf = self else { return } |
| | | |
| | | let price = weakSelf.activityDetailModel.cashPrice * Double(weakSelf.activityDetailModel.participant.count) |
| | | let coin = weakSelf.activityDetailModel.playPaiCoin * weakSelf.activityDetailModel.participant.count |
| | | let course = weakSelf.activityDetailModel.classPrice * weakSelf.activityDetailModel.participant.count |
| | | |
| | | if status{ |
| | | PaymentView.show(money: (ali:price,wx:price,coin:coin,course:course)) { [weak self] type in |
| | | guard let weakSelf = self else { return } |
| | | let ids = weakSelf.students.map({"\($0.id)"}).joined(separator: ",") |
| | | Services.paymentCompetition(id: weakSelf.activityDetailModel.id, userIds: ids, payType: type).subscribe(onNext: {data in |
| | | if let m = data.data{ |
| | | switch type { |
| | | case .aliPay: |
| | | let req = YYAlipayRequest(orderString: m.orderString) |
| | | YYPaymentManager.shared.sendPaymentRequest(req) { result in |
| | | switch result { |
| | | case .success: |
| | | let vc = PaymentResultVC(result: .success, objType: .activityApply) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | case .cancel: |
| | | let vc = PaymentResultVC(result: .fail, objType: .activityApply) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | case .failure(_): |
| | | let vc = PaymentResultVC(result: .fail, objType: .activityApply) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | } |
| | | } |
| | | case .wechat:break |
| | | case .coin:break |
| | | case .courseNum:break |
| | | } |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | extension ActivityDetailApplyVC: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() |
| | | self?.cons_tableHei.constant = Double(self?.students.count ?? 0) * 100 |
| | | } |
| | | |
| | | return cell |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return 2 |
| | | return students.count |
| | | } |
| | | |
| | | |
| | | } |