无故事王国
2023-10-24 e9474fe95f7f6c3e1652d6406c00804910cb44ad
WanPai/Root/Course/VC/CourseDetailApplyVC.swift
@@ -185,8 +185,7 @@
               //减去优惠
               let discountPrice = price - (weakSelf.selectCouponModel?.favorable ?? 0)
                    let coin = (model.playPaiCoin ?? 0) * weakSelf.studentModels.count
               let coin = model.playPaiCoin * weakSelf.studentModels.count
                    PaymentView.show(money: (ali:discountPrice,wx:discountPrice,coin:coin,course:nil,integral:nil)) { [weak self] payType in
                        guard let weakSelf = self else { return }
@@ -208,6 +207,7 @@
                                            switch result {
                                                case .success:
                                                    let vc = PaymentResultVC(result: .success, objType: .courseApply,handleVC: self,courseConfigId: model.id)
                                       vc.isExtend = self?.isExtend ?? false
                                       self?.push(vc: vc)
                                                case .cancel:
                                                    alert(msg: "已取消")
@@ -222,6 +222,7 @@
                                    case .coin:
//                              self?.navigationController?.popViewController(animated: false)
                              let vc = PaymentResultVC(result: .success, objType: .courseApply,handleVC: self,courseConfigId: model.id)
                              vc.isExtend = self?.isExtend ?? false
                              self?.push(vc: vc)
                           case .courseNum,.integral:break
                                }
@@ -260,33 +261,61 @@
            studentCount = Double(studentModels.count)
         }
         label_price.isHidden = subM.paymentPrice == 0
         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 == 0
                //原价
            if let originPrice =  subM.originalPrice{
                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
            }
         switch subM.payType {
            case .coin:
               label_price.text = ""
               label_price.isHidden = true
               label_originPrice.isHidden = true
               label_vipPrice.isHidden = true
                //玩湃币
            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 * studentModels.count)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313"))
                label_coin.attributedText = coinAttribute.mutableAttributedString
            }
                  //玩湃币
               label_coin.attributedText = AttributedStringbuilder.build()
                  .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
                  .add(string: "\(subM.playPaiCoin * studentModels.count)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")).mutableAttributedString
                //会员价
            if subM.vipPrice != 0{
                let vipAttribute = AttributedStringbuilder.build()
                    .add(string: "会员价:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
               .add(string: (subM.vipPrice * studentCount).currency(), withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313"))
                label_vipPrice.attributedText = vipAttribute.mutableAttributedString
            }
            case .cash:
               label_coin.isHidden = true;fallthrough
            case .cashCoin:
               if subM.originalPrice == 0{label_originPrice.isHidden = true}
                  //玩湃币
               label_coin.attributedText = AttributedStringbuilder.build()
                  .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
                  .add(string: "\(subM.playPaiCoin * studentModels.count)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")).mutableAttributedString
                  //原价
               let attribute = AttributedStringbuilder.build().add(string: (subM.originalPrice * 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
               if UserInfoModel.get()?.isVip == 1{
                     //会员
                  label_vipPrice.isHidden = true
                  if subM.paymentPrice < subM.vipPrice && subM.paymentPrice != 0{
                     label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency()
                  }else{
                     label_price.text = (subM.vipPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency()
                  }
               }else{
                     //非会员
                  label_vipPrice.isHidden = subM.vipPrice == 0 || subM.vipPrice == subM.paymentPrice
                  let vipAttribute = AttributedStringbuilder.build()
                     .add(string: "会员价:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
                     .add(string: (subM.vipPrice * studentCount).currency(), withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313"))
                  label_vipPrice.attributedText = vipAttribute.mutableAttributedString
                  if subM.originalPrice != 0 && subM.paymentPrice == 0{
                     label_price.text = (subM.originalPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency()
                  }else if subM.originalPrice == 0 && subM.paymentPrice != 0{
                     label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency()
                  }else{
                     var money = min(subM.originalPrice,subM.paymentPrice)
                     money = money - (selectCouponModel?.favorable ?? 0)
                     label_price.text = (money * studentCount).currency()
                  }
               }
         }
         if detailModel?.type == .experience{
            label_price.text = subM.paymentPrice.currency()
@@ -305,10 +334,11 @@
            var price:Double?
            switch subM.payType{
                case .cash:
                    price = subM.originalPrice == nil ? subM.vipPrice : subM.originalPrice
                    price = subM.originalPrice == 0 ? subM.vipPrice : subM.originalPrice
                case .coin:
                    if let coin = subM.playPaiCoin{price = Double(coin)}
            }
               price = Double(subM.playPaiCoin)
            case .cashCoin:break
         }
            guard price != nil else {
                LogError("会员优惠价格出现问题:nil");return