无故事王国
2023-10-24 e9474fe95f7f6c3e1652d6406c00804910cb44ad
WanPai/Root/Course/VC/CourseDetailVC.swift
@@ -12,7 +12,6 @@
class CourseDetailVC: BaseVC {
   @IBOutlet weak var view_banner: CommonBannerView!
      //    @IBOutlet weak var img_cover: UIImageView!
    @IBOutlet weak var label_title: UILabel!
    @IBOutlet weak var label_local: UILabel!
    @IBOutlet weak var label_distance: UILabel!
@@ -20,9 +19,7 @@
   @IBOutlet weak var view_listen: UIView!
   @IBOutlet weak var label_listenTime: UILabel!
    @IBOutlet weak var img_1: UIImageView!
//    @IBOutlet weak var img_2: UIImageView!
    @IBOutlet weak var cons_img1Height: NSLayoutConstraint!
//    @IBOutlet weak var cons_img2Height: NSLayoutConstraint!
   @IBOutlet weak var label_courseType: UILabel!
   @IBOutlet weak var label_vaildTime: UILabel!
   @IBOutlet weak var view_vaildTime: UIView!
@@ -52,7 +49,7 @@
            label_courseType.text = m.type.strTitle
            label_courseType.isHidden = m.type == .none
            view_vaildTime.isHidden = m.type == .normal
            label_price.isHidden = (m.list.first?.paymentPrice ?? 0) == 0
//            label_price.isHidden = (m.list.first?.paymentPrice ?? 0) == 0
            let w = String.jq_getWidth(text: m.type.strTitle, height: 25, font: 14)
            label_courseType.jq_cornerPartWithNib(byRoundingCorners: [.topLeft,.bottomLeft], radii: 8, size: CGSize(width: w, height: 25))
@@ -67,32 +64,58 @@
            }
            label_price.text = m.list.first!.paymentPrice.currency()
            if let subM = m.list.first {
               label_originPrice.isHidden = subM.originalPrice == nil || subM.originalPrice == 0
               label_coin.isHidden = subM.playPaiCoin == nil || subM.playPaiCoin == 0
               label_vipPrice.isHidden =  subM.vipPrice == 0
               switch subM.payType {
                  case .coin:
                     label_price.text = ""
                     label_price.isHidden = true
                     label_originPrice.isHidden = true
                     label_vipPrice.isHidden = true
                  //原价
               if let originPrice =  subM.originalPrice{
                  let attribute = AttributedStringbuilder.build().add(string: originPrice.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
               }
                     //玩湃币
                     label_coin.attributedText = AttributedStringbuilder.build()
                        .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
                        .add(string: "\(subM.playPaiCoin )币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")).mutableAttributedString
                  //玩湃币
               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)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313"))
                  label_coin.attributedText = coinAttribute.mutableAttributedString
               }
                  case .cash:
                     label_coin.isHidden = true;fallthrough
                  case .cashCoin:
                     if subM.originalPrice == 0{label_originPrice.isHidden = true}
                  //会员价
               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.currency(), withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313"))
                  label_vipPrice.attributedText = vipAttribute.mutableAttributedString
                        //玩湃币
                     label_coin.attributedText = AttributedStringbuilder.build()
                        .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
                        .add(string: "\(subM.playPaiCoin )币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")).mutableAttributedString
                        //原价
                     let attribute = AttributedStringbuilder.build().add(string: subM.originalPrice.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.currency()
                        }else{
                           label_price.text = subM.vipPrice.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.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.currency()
                        }else if subM.originalPrice == 0 && subM.paymentPrice != 0{
                           label_price.text = subM.paymentPrice.currency()
                        }else{
                           label_price.text = min(subM.originalPrice,subM.paymentPrice).currency()
                        }
                     }
               }
            }