//
|
// WelfareWeeklyDetailVC.swift
|
// WanPai
|
//
|
// Created by 无故事王国 on 2023/6/21.
|
//
|
|
import UIKit
|
import QMUIKit
|
import JQTools
|
import SDWebImage
|
|
class WelfareWeeklyDetailVC: BaseVC {
|
@IBOutlet weak var view_banner: CommonBannerView!
|
@IBOutlet weak var label_name: UILabel!
|
@IBOutlet weak var label_address: UILabel!
|
@IBOutlet weak var label_distance: UILabel!
|
@IBOutlet weak var label_courseNum: UILabel!
|
@IBOutlet weak var view_courseNum: UIView!
|
@IBOutlet weak var label_giftCourseNum: UILabel!
|
@IBOutlet weak var view_giftCourseNum: UIView!
|
@IBOutlet weak var label_attendWeeks: UILabel!
|
@IBOutlet weak var label_datetime: UILabel!
|
@IBOutlet weak var img_intro: UIImageView!
|
@IBOutlet weak var cons_imgIntroHei: NSLayoutConstraint!
|
@IBOutlet weak var label_price: UILabel!
|
@IBOutlet weak var label_originPrice: UILabel!
|
@IBOutlet weak var label_coin: UILabel!
|
@IBOutlet weak var label_vip: UILabel!
|
@IBOutlet weak var btn_handle: UIButton!
|
@IBOutlet weak var label_periodOfValidity: UILabel!
|
@IBOutlet weak var view_periodOfValidity: UIView!
|
|
private var id:Int!
|
private var weeklyItemDetailModel:WeeklyItemDetailModel?
|
|
required init(id:Int) {
|
super.init(nibName: nil, bundle: nil)
|
self.id = id
|
}
|
|
required init?(coder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
title = "运动营详情"
|
label_vip.isHidden = true
|
label_originPrice.isHidden = true
|
|
Services.weekBenefitDetail(id: id).subscribe(onNext: {[weak self] data in
|
guard let weakSelf = self else { return }
|
if let model = data.data{
|
weakSelf.weeklyItemDetailModel = model
|
weakSelf.label_name.text = model.coursePackageName
|
weakSelf.label_address.text = model.storeNameAddr
|
weakSelf.label_courseNum.text = "\(model.classHours)课时"
|
weakSelf.label_giftCourseNum.text = "\(model.freeClassHours)课时"
|
weakSelf.view_courseNum.isHidden = (model.classHours == 0 || model.type == 2)
|
weakSelf.view_giftCourseNum.isHidden = model.freeClassHours == 0
|
weakSelf.label_attendWeeks.text = model.weekTime
|
weakSelf.label_datetime.text = model.time
|
weakSelf.label_distance.text = String(format: "距离我%.2lfkm", model.distance)
|
// weakSelf.label_coin.isHidden = model.wanpaiGold == 0
|
// weakSelf.label_coin.text = String(format: "玩湃币:%ld", model.wanpaiGold)
|
// weakSelf.label_originPrice.isHidden = model.costPrice == 0
|
//
|
// weakSelf.label_originPrice.attributedText = AttributedStringbuilder.build().add(string: model.costPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).mutableAttributedString
|
|
weakSelf.label_price.text = model.discountPrice.currency()
|
weakSelf.label_periodOfValidity.text = model.holiTime
|
weakSelf.view_periodOfValidity.isHidden = model.holiTime.isEmpty
|
|
weakSelf.img_intro.sd_setImage(with: URL(string: model.introduceDrawing)) {[weak self] image, error, type, url in
|
if let img = image{
|
self?.img_intro.image = img
|
let radio = img.size.width / img.size.height
|
self?.cons_imgIntroHei.constant = JQ_ScreenW / radio
|
}
|
}
|
|
let imgs = model.detailDrawing.components(separatedBy: ",")
|
var items = [CommonBannerModel]()
|
for (index,img) in imgs.enumerated(){
|
items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl))
|
}
|
self?.view_banner.setItems(items: items)
|
|
|
switch model.payType {
|
case .cash:
|
weakSelf.label_coin.isHidden = true
|
weakSelf.label_price.text = model.discountPrice.currency()
|
|
if model.costPrice != 0 && model.costPrice > model.discountPrice{
|
weakSelf.label_originPrice.isHidden = false
|
weakSelf.label_originPrice.attributedText = AttributedStringbuilder.build().add(string: model.costPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).mutableAttributedString
|
}else{
|
weakSelf.label_originPrice.isHidden = true
|
}
|
|
if model.costPrice > 0 && model.discountPrice < model.costPrice{
|
weakSelf.label_originPrice.attributedText = AttributedStringbuilder.build().add(string: model.costPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).mutableAttributedString
|
}
|
|
|
case .cashCoin:
|
weakSelf.label_coin.isHidden = false
|
weakSelf.label_coin.attributedText = AttributedStringbuilder.build()
|
.add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
|
.add(string: "\(model.wanpaiGold)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")).mutableAttributedString
|
weakSelf.label_price.text = model.discountPrice.currency()
|
|
if model.costPrice > 0 && model.discountPrice < model.costPrice{
|
weakSelf.label_originPrice.attributedText = AttributedStringbuilder.build().add(string: model.costPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).delLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).mutableAttributedString
|
}
|
|
|
case .coin:
|
weakSelf.label_originPrice.isHidden = true
|
weakSelf.label_price.isHidden = true
|
weakSelf.label_coin.attributedText = AttributedStringbuilder.build()
|
.add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F"))
|
.add(string: "\(model.wanpaiGold)币", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#F21313")).mutableAttributedString
|
}
|
}
|
}).disposed(by: disposeBag)
|
|
}
|
@IBAction func applyAction(_ sender: UIButton) {
|
guard let id = weeklyItemDetailModel?.coursePackageDiscountId else{return}
|
Services.queryCourseInfo(id: id).subscribe(onNext: {[weak self] data in
|
if let m = data.data{
|
let vc = CourseDetailApplyVC(detailModel: m,classHours: self?.weeklyItemDetailModel?.classHours)
|
self?.push(vc: vc)
|
}
|
}).disposed(by: disposeBag)
|
}
|
}
|