无故事王国
2023-11-21 58405a369e73cca7bd5ef2cef948e1944907c2c7
WanPai/Root/Course/VC/CourseDetailApplyVC.swift
@@ -43,14 +43,14 @@
   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?
   private var classHours:Int?
   private var signUpCourseModel:SignUpCourseItemModel?
//   private var signUpCourseModel:SignUpCourseItemModel?
   private var signUpModel:SignUpCourseItemDetailModel?
   override func viewDidLoad() {
      super.viewDidLoad()
@@ -108,17 +108,17 @@
         view_banner.setItems(items: items)
      }
      if let m = signUpModel{
         classHours = m.chooseHours
         if m.payStatus == .unPayment{
            btn_handleBtn.setTitle("待支付", for: .normal)
            btn_addStudent.isHidden = true
         }
      btn_addStudent.isHidden = isExtend
      if isExtend{
         btn_handleBtn.setTitle("续课", for: .normal)
      }else{
         btn_handleBtn.setTitle("立即报名", for: .normal)
      }
      if signUpCourseModel?.payStatus == .unPayment{
         btn_handleBtn.setTitle("待支付", for: .normal)
         btn_addStudent.isHidden = true
         if m.payStatus == .paymented{
            btn_handleBtn.setTitle("续课", for: .normal)
            btn_addStudent.isHidden = true
         }
      }
   }
@@ -142,12 +142,11 @@
      btn_addStudent.spacingBetweenImageAndTitle = 3
   }
   init(detailModel:CourseDetailModel,isExtend:Bool = false,classHours:Int? = nil,signUpCourseModel:SignUpCourseItemModel? = nil) {
   init(detailModel:CourseDetailModel,signUpModel:SignUpCourseItemDetailModel? = nil,classHours:Int? = nil) {
      super.init(nibName: nil, bundle: nil)
      self.detailModel = detailModel
      self.isExtend = isExtend
      self.signUpModel = signUpModel
      self.classHours = classHours
      self.signUpCourseModel = signUpCourseModel
   }
   required init?(coder: NSCoder) {
@@ -193,7 +192,13 @@
      StoresInfoView.show(detailModel!) { [weak self] status in
         guard let weakSelf = self else { return }
         if status{
            if let model = weakSelf.detailModel?.list[weakSelf.selectClassIndex]{
            if var model = weakSelf.detailModel?.list[weakSelf.selectClassIndex]{
               //续课时价格
               if let list = weakSelf.signUpModel?.list{
                  model = list[weakSelf.selectClassIndex]
               }
               var price:Double = 0
                  //是否是会员
@@ -213,16 +218,16 @@
               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
                  var resultPayPrice:Double = 0
                  switch payType {
                     case .aliPay,.wechat:
                        paymentPrice = discountPrice
                        resultPayPrice = price
                     case .coin:
                        paymentPrice = Double(coin)
                        resultPayPrice = Double(coin)
                     case .courseNum,.integral:break
                  }
                  Services.courcePayment(conponId: weakSelf.selectCouponModel?.id, courseConfigId: model.id, id: weakSelf.detailModel!.id, price: price, 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: resultPayPrice, payType: payType, stuId: weakSelf.studentModels.map({$0.id})).subscribe(onNext: { data in
                     if data.code == 200{
                        switch payType {
                           case .aliPay:
@@ -230,7 +235,7 @@
                                 switch result {
                                    case .success:
                                       let vc = PaymentResultVC(result: .success, objType: .courseApply,handleVC: self,courseConfigId: model.id)
                                       vc.isExtend = self?.isExtend ?? false
                                       vc.isExtend = self?.signUpModel?.payStatus == .paymented
                                       self?.push(vc: vc)
                                    case .cancel:
                                       alert(msg: "已取消")
@@ -243,9 +248,8 @@
                              self?.navigationController?.popViewController(animated: false)
                              break
                           case .coin:
                                 //                              self?.navigationController?.popViewController(animated: false)
                              let vc = PaymentResultVC(result: .success, objType: .courseApply,handleVC: self,courseConfigId: model.id)
                              vc.isExtend = self?.isExtend ?? false
                              vc.isExtend = self?.signUpModel?.payStatus == .paymented
                              self?.push(vc: vc)
                           case .courseNum,.integral:break
                        }
@@ -482,7 +486,7 @@
            alert(msg: "至少选择一位运动营成员")
         }
      }
      cell.btn_handle.isHidden = isExtend
      cell.btn_handle.isHidden = signUpModel != nil
      return cell
   }
}