无故事王国
2023-09-26 c86ac49db2969495ec21fae2a27956cad9499752
WanPai/Root/Course/VC/CourseDetailApplyVC.swift
@@ -39,6 +39,7 @@
   @IBOutlet weak var studentTableView: UITableView!
   @IBOutlet weak var view_packageList: UIView!
   @IBOutlet weak var btn_handleBtn: UIButton!
   @IBOutlet weak var view_teach: UIView!
    private var detailModel:CourseDetailModel?
    private var selectClassIndex:Int = 0
@@ -57,7 +58,7 @@
            img_cover.sd_setImage(with: URL(string: m.coverDrawing))
            label_title.text = m.name
            label_listenWeek.text = m.weeks.joined(separator: "、")
         label_listenTime.text = m.times.joined(separator: "|")
         label_listenTime.text = m.times.joined(separator: "|")
            label_store.text = m.storeName
            label_address.text = m.storeAddress
         label_vaild.text = m.time
@@ -75,7 +76,9 @@
               view_vaildTime.isHidden = true
         }
            if let stu = m.student{studentModels.append(stu)}
         if m.student?.id != 0{
            studentModels.append(m.student!)
         }
            cons_collHei.constant = ceil(Double(m.list.count) / 3.0) * CellH + floor(Double(m.list.count) / 3.0) * 21.0
            collectionView.reloadData()
@@ -172,10 +175,10 @@
                  }
                        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 let m = data.data{
                     if data.code == 200{
                                switch payType {
                                    case .aliPay:
                                        YYPaymentManager.shared.sendPaymentRequest(YYAlipayRequest(orderString: m.orderString)) { [weak self] result in
                              YYPaymentManager.shared.sendPaymentRequest(YYAlipayRequest(orderString: data.data!.orderString)) { [weak self] result in
                                            switch result {
                                                case .success:
//                                       self?.navigationController?.popViewController(animated: false)
@@ -213,14 +216,22 @@
    private func changePrice(_ index:Int){
        if let subM = detailModel?.list[index]{
         label_price.text = (subM.paymentPrice * Double(studentModels.count) - (selectCouponModel?.favorable ?? 0)).currency()
         var studentCount:Double = 0
         if studentModels.count == 0{
            studentCount = 1
         }else{
            studentCount = Double(studentModels.count)
         }
         label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).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 * Double(studentModels.count)).currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58))
                let attribute = AttributedStringbuilder.build().add(string: (originPrice * studentCount).currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58))
                label_originPrice.attributedText = attribute.mutableAttributedString
            }
@@ -236,12 +247,13 @@
            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 * Double(studentModels.count)).currency(), withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313"))
                    .add(string: (vipPrice * studentCount).currency(), withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313"))
                label_vipPrice.attributedText = vipAttribute.mutableAttributedString
            }
         if detailModel?.type == .experience{
            label_price.text = (subM.originalPrice ?? 0).currency()
            label_price.text = subM.paymentPrice.currency()
            view_teach.isHidden = true
            label_originPrice.isHidden = true
            label_vipPrice.isHidden = true
         }