From 31b6be2dfcc5a7e9300c90b2216dbd579153c3b0 Mon Sep 17 00:00:00 2001
From: younger_times <841720330@qq.com>
Date: 星期一, 10 七月 2023 19:22:00 +0800
Subject: [PATCH] 新增

---
 WanPai/Root/Course/VC/CourseDetailVC.swift |   84 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/WanPai/Root/Course/VC/CourseDetailVC.swift b/WanPai/Root/Course/VC/CourseDetailVC.swift
index 64232f5..7e3a6b3 100644
--- a/WanPai/Root/Course/VC/CourseDetailVC.swift
+++ b/WanPai/Root/Course/VC/CourseDetailVC.swift
@@ -7,13 +7,94 @@
 
 import UIKit
 import QMUIKit
+import JQTools
 
 class CourseDetailVC: BaseVC {
 
+    @IBOutlet weak var img_cover: UIImageView!
+    @IBOutlet weak var label_title: UILabel!
     @IBOutlet weak var btn_local: QMUIButton!
+    @IBOutlet weak var label_distance: UILabel!
+    @IBOutlet weak var label_listenWeek: UILabel!
+    @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_price: UILabel!
+    @IBOutlet weak var label_originPrice: UILabel!
+    @IBOutlet weak var label_vipPrice: UILabel!
+    @IBOutlet weak var label_coin: UILabel!
+
+    private var id = 0
+    private var detailModel:CourseDetailModel!{
+        didSet{
+            img_cover.sd_setImage(with: URL(string: detailModel.coverDrawing))
+            label_title.text = detailModel.name
+            label_distance.text = String(format: "距离我%.2lfkm", detailModel.distance)
+            btn_local.setTitle(detailModel.storeAddress, for: .normal)
+            label_listenWeek.text = detailModel.weeks.joined(separator: "、")
+            label_listenTime.text = detailModel.times
+            img_1.sd_setImage(with: URL(string: detailModel.introduceDrawing)) { image, error, type, url in
+                let radio = image!.size.width / image!.size.height
+                self.cons_img1Height.constant = JQ_ScreenH * radio
+
+            }
+
+            img_2.sd_setImage(with: URL(string: detailModel.detailDrawing)) { image, error, type, url in
+                let radio = image!.size.width / image!.size.height
+                self.cons_img2Height.constant = JQ_ScreenH * radio
+            }
+
+            label_price.text = detailModel.list.first!.paymentPrice.currency()
+
+
+            if let subM = detailModel.list.first {
+                label_originPrice.isHidden = subM.originalPrice == 0
+                label_coin.isHidden = subM.playPaiCoin == 0
+                label_vipPrice.isHidden = subM.vipPrice == 0
+
+                //原价
+                let attribute = AttributedStringbuilder.build().add(string: subM.originalPrice.currency(), withFont: UIFont.systemFont(ofSize: 16, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58)).underLine(color: UIColor(hexStr: "#3F3F3F").withAlphaComponent(0.58))
+                label_originPrice.attributedText = attribute.mutableAttributedString
+
+                //玩湃币
+                let coinAttribute = 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"))
+                label_coin.attributedText = coinAttribute.mutableAttributedString
+
+                //会员价
+                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
+            }
+
+
+        }
+    }
+
+    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 = "课程详情"
+
+        Services.queryCourseInfo(id: id).subscribe(onNext: { data in
+            if let m = data.data{
+                self.detailModel = m
+            }
+        }).disposed(by: disposeBag)
     }
     
     override func setUI() {
@@ -28,7 +109,6 @@
     
     
     @IBAction func localAction(_ sender: QMUIButton) {
-        
+        JQ_MapNavigationTool.startNav(CLLocationCoordinate2D(latitude: detailModel.lat.toDouble, longitude: detailModel.lon.toDouble), distanceName: detailModel.storeAddress, scheme: "weparklife")
     }
-    
 }

--
Gitblit v1.7.1