刘千军 преди 11 месеца
родител
ревизия
c2973ce90f

+ 4 - 0
Koala/Koala.xcodeproj/project.pbxproj

@@ -569,6 +569,7 @@
 		6CA9FF31295DCEB90097ABA6 /* SecuritySettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA9FF30295DCEB80097ABA6 /* SecuritySettingsViewController.swift */; };
 		6CA9FF33295DCED70097ABA6 /* SecuritySettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA9FF32295DCED70097ABA6 /* SecuritySettingsViewModel.swift */; };
 		6CA9FF36295DCEF20097ABA6 /* SecuritySettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA9FF35295DCEF20097ABA6 /* SecuritySettingsView.swift */; };
+		6CBB62B82AD2F6540045A4C9 /* JDChartLineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBB62B52AD2F6540045A4C9 /* JDChartLineView.swift */; };
 		6CBDC8F32972F352003E068F /* ScriptMessageProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBDC8F22972F352003E068F /* ScriptMessageProxy.swift */; };
 		6CBDC8F52972F443003E068F /* WKWebViewConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBDC8F42972F443003E068F /* WKWebViewConfiguration.swift */; };
 		6CBDC8F72972FB69003E068F /* BaseWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBDC8F62972FB69003E068F /* BaseWebViewController.swift */; };
@@ -1313,6 +1314,7 @@
 		6CA9FF30295DCEB80097ABA6 /* SecuritySettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecuritySettingsViewController.swift; sourceTree = "<group>"; };
 		6CA9FF32295DCED70097ABA6 /* SecuritySettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecuritySettingsViewModel.swift; sourceTree = "<group>"; };
 		6CA9FF35295DCEF20097ABA6 /* SecuritySettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecuritySettingsView.swift; sourceTree = "<group>"; };
+		6CBB62B52AD2F6540045A4C9 /* JDChartLineView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JDChartLineView.swift; sourceTree = "<group>"; };
 		6CBDC8F22972F352003E068F /* ScriptMessageProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptMessageProxy.swift; sourceTree = "<group>"; };
 		6CBDC8F42972F443003E068F /* WKWebViewConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKWebViewConfiguration.swift; sourceTree = "<group>"; };
 		6CBDC8F62972FB69003E068F /* BaseWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseWebViewController.swift; sourceTree = "<group>"; };
@@ -2167,6 +2169,7 @@
 				6C7F44672955680600DC6771 /* HomeView.swift */,
 				04D38EB12AAB19E80047EF9C /* JDHomeMenuCell.swift */,
 				04D38EB32AAC164A0047EF9C /* JDHomeExponentCell.swift */,
+				6CBB62B52AD2F6540045A4C9 /* JDChartLineView.swift */,
 				6CA712FA2956D85F0047F450 /* HomeNavView.swift */,
 				6CA712FC2956D86B0047F450 /* HomeNavView.xib */,
 				04D38EB52AAC307E0047EF9C /* JDHomeHeaderView.swift */,
@@ -4288,6 +4291,7 @@
 				6CC8023A29954D3500C36373 /* ADepositViewController.swift in Sources */,
 				6CD200B329E6FB2100F0966D /* ASavingsDetailsListCell.swift in Sources */,
 				04CEE2812AB81D5300FAA760 /* JDTradeAccountDetailViewController.swift in Sources */,
+				6CBB62B82AD2F6540045A4C9 /* JDChartLineView.swift in Sources */,
 				6C00A8F6242D918D00CE9ADB /* ESTabBarItemContentView.swift in Sources */,
 				6C86531D29BB706900A2E7FB /* AssetsFinanceListCell.swift in Sources */,
 				6C4AFB4D29A9253E00508EA7 /* DealTalentCell.swift in Sources */,

+ 15 - 0
Koala/Koala/FX/Macro/PublicMethod.swift

@@ -310,6 +310,21 @@ func StringIsEmpty(value: AnyObject?) -> Bool {
     }
 }
 
+//数组转json
+func getJSONStringFromArray(array:NSArray) -> String {
+    if (!JSONSerialization.isValidJSONObject(array)) {
+        Dlog("无法解析出JSONString")
+        return ""
+    }
+    
+    let data : Data! = try? JSONSerialization.data(withJSONObject: array, options: [])
+    let JSONString = String(data: data, encoding: .utf8)
+    //        let JSONString = NSString(data:data as Data,encoding: String.Encoding.utf8.rawValue)
+    return JSONString!
+    
+}
+
+
 //字典转json
 func getJSONStringFromDictionary(dictionary:NSDictionary) -> String {
     if (!JSONSerialization.isValidJSONObject(dictionary)) {

+ 26 - 23
Koala/Koala/Modular/Home/V/HomeView.swift

@@ -111,20 +111,25 @@ class HomeView: BaseView {
             self?.headerView.showNoticeData((self?.VM?.noticeList)!)
         })
         
-//        VM?.symbolListAction.values.observeValues({[weak self] (success) in
-//            self?.reloadTable()
-//        })
+        VM?.symbolListAction.values.observeValues({[weak self] (success) in
+            self?.reloadTable()
+        })
+        
         
         VM?.newsListAction.values.observeValues({[weak self] (success) in
             self?.reloadTable()
         })
         
-//        VM?.signalSymbol.observeValues({ [weak self] (isSocket) in
-//            guard let self = self else { return }
-//            if isSocket {
-//                self.updateSocketCellData()
-//            }
-//        })
+        VM?.signalPrice.observeValues({ [weak self] (isSocket) in
+            self?.reloadTable()
+        })
+        
+        VM?.signalSymbol.observeValues({ [weak self] (isSocket) in
+            guard let self = self else { return }
+            if isSocket {
+                self.updateSocketCellData()
+            }
+        })
         
 
 
@@ -132,10 +137,8 @@ class HomeView: BaseView {
     }
     
     func updateSocketCellData() -> Void {
-        for (i,model) in self.VM!.symbolList.enumerated() {
-            if let cell:BaseCurrencyListCell = self.tableView.cellForRow(at: IndexPath(row: i, section: 1)) as? BaseCurrencyListCell{
-                cell.updateNewPrice(model: model)
-            }
+        if let cell:JDHomeExponentCell = self.tableView.cellForRow(at: IndexPath(row: 0, section: 1)) as? JDHomeExponentCell{
+            cell.updateCellDataWith(list: self.VM!.symbolList)
         }
     }
     
@@ -191,7 +194,7 @@ extension HomeView:UITableViewDelegate,UITableViewDataSource{
 //            return cell
             
             let cell = tableView.dequeueReusableCell(withIdentifier: JDHomeExponentCell.description()) as! JDHomeExponentCell
-            
+            cell.updateCellDataWith(list: self.VM!.symbolList)
             return cell
         }else {
             
@@ -213,7 +216,7 @@ extension HomeView:UITableViewDelegate,UITableViewDataSource{
             return 98//220 - 70
         }
         else if indexPath.section == 1{
-            return 310
+            return 330
         }else {
             return 100
         }
@@ -247,11 +250,7 @@ extension HomeView:UITableViewDelegate,UITableViewDataSource{
     
     
     func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
-        if section < 2{
-            let v = UIView(frame: CGRectMake(0, 0, SCREEN_WIDTH, 9))
-            v.backgroundColor = UIColor.pg_color(withHexString: "F7FAFE")
-            return v
-        }
+       
         return UIView()
     }
     
@@ -263,9 +262,7 @@ extension HomeView:UITableViewDelegate,UITableViewDataSource{
     }
     
     func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
-        if section < 2{
-            return 9
-        }
+      
         return 0
     }
     
@@ -278,6 +275,12 @@ extension HomeView:UITableViewDelegate,UITableViewDataSource{
             vc.viewModel.symbolModel = model!
             currentVc()?.navigationController?.pushViewController(vc, animated: true)
         }
+        else if indexPath.section == 2{
+            let model = self.VM!.newsList[indexPath.row]
+            let vc = InformationDetailViewController()
+            vc.id = model.id
+            currentVc()?.navigationController?.pushViewController(vc, animated: true)
+        }
        
     }
     

+ 132 - 0
Koala/Koala/Modular/Home/V/JDChartLineView.swift

@@ -0,0 +1,132 @@
+//
+//  JDChartLineView.swift
+//  Koala
+//
+//  Created by "" on 2020/4/30.
+//  Copyright © 2020 "". All rights reserved.
+//
+
+import UIKit
+import Charts
+class JDChartLineView: BaseView {
+    
+    var shadowSize: CGSize = CGSize(width: 0, height: 20)
+    
+    lazy var lineChartView: LineChartView = {
+        let lineChartView: LineChartView = LineChartView()
+        lineChartView.backgroundColor = .clear
+        lineChartView.delegate = self
+        return lineChartView
+    }()
+    
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        self.addSubview(lineChartView)
+        //设置交互样式
+        interactionStyle()
+        //添加(刷新数据)
+       // updataData()
+    }
+    
+    override func layoutSubviews() {
+        super.layoutSubviews()
+        self.lineChartView.frame = self.bounds
+    }
+    
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
+    }
+    
+}
+
+extension JDChartLineView {
+    
+    //设置样式
+    func interactionStyle(){
+        lineChartView.scaleYEnabled = false //取消Y轴缩放
+        lineChartView.doubleTapToZoomEnabled = true //双击缩放
+        lineChartView.dragEnabled = true //启用拖动手势
+        lineChartView.dragDecelerationEnabled = true //拖拽后是否有惯性效果
+        lineChartView.dragDecelerationFrictionCoef = 0.9 //拖拽后惯性效果摩擦系数(0~1)越小惯性越不明显
+        lineChartView.noDataText = switchLanguage("暂无数据") //如果没有数据会显示这个
+        lineChartView.drawBordersEnabled = false  //绘制图形区域边框
+        lineChartView.xAxis.enabled = false
+        lineChartView.leftAxis.enabled = false
+        lineChartView.rightAxis.enabled = false
+        lineChartView.xAxis.drawGridLinesEnabled = false
+        lineChartView.legend.enabled = false
+        
+    }
+    
+    
+}
+//MARK:-    数据加载和刷新
+extension JDChartLineView {
+   
+   
+    func updateHomeData(fillColor: UIColor, gradientColor: UIColor, data: [KSymbolKlineData]) -> Void {
+        var dataEntries = [ChartDataEntry]()
+        var maxEntry:ChartDataEntry = ChartDataEntry.init(x: 0, y: 0)
+        for i in 0..<data.count{
+            let model = data[(data.count-1)-i]
+            let entry = ChartDataEntry.init(x: Double(i), y: Double(model.close)!)
+            dataEntries.append(entry)
+            if maxEntry.y <  Double(model.close)!{
+                maxEntry =  ChartDataEntry.init(x: Double(i), y: Double(model.close)!*1.01)
+                
+            }
+        }
+        
+        //设置折线
+        let chartDataSet = LineChartDataSet(entries: dataEntries, label: "line")
+        chartDataSet.lineWidth = 1.5 //线条宽度
+        
+        //chartDataSet.calcMinMaxY(entry: maxEntry)
+        //chartDataSet.lineDashLengths = [3,1]
+        chartDataSet.mode = .cubicBezier
+        chartDataSet.setColors(fillColor)
+        //去掉阴影
+        chartDataSet.isShowShadow = false
+//        chartDataSet.shadowColor = modifyColorTransparency(color,alpha: 17)
+
+        chartDataSet.shadowSize = shadowSize
+        chartDataSet.shadowBlur = 10
+        chartDataSet.drawCirclesEnabled = false
+        chartDataSet.drawValuesEnabled = false
+        chartDataSet.drawFilledEnabled = true
+        //渐变颜色数组
+        let gradientColors = [fillColor.cgColor, gradientColor.cgColor] as CFArray
+        //每组颜色所在位置(范围0~1)
+        let colorLocations:[CGFloat] = [1.0, 0.0]
+        //生成渐变色
+        let gradient = CGGradient.init(colorsSpace: CGColorSpaceCreateDeviceRGB(),
+                                       colors: gradientColors, locations: colorLocations)
+        //将渐变色作为填充对象s
+        chartDataSet.fill = Fill.fillWithLinearGradient(gradient!, angle: 90.0)
+        
+        
+        let chartData = LineChartData(dataSets: [chartDataSet])
+        lineChartView.data = chartData
+    }
+    
+    
+}
+extension JDChartLineView: ChartViewDelegate {
+    //1.点击选中
+    func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) {
+        
+    }
+    //2.没有选中
+    func chartValueNothingSelected(_ chartView: ChartViewBase) {
+        
+    }
+    //3.捏合放大或缩小
+    func chartScaled(_ chartView: ChartViewBase, scaleX: CGFloat, scaleY: CGFloat) {
+    }
+    //4.拖拽图表
+    func chartTranslated(_ chartView: ChartViewBase, dX: CGFloat, dY: CGFloat) {
+        
+    }
+    
+}
+

+ 118 - 59
Koala/Koala/Modular/Home/V/JDHomeExponentCell.swift

@@ -11,16 +11,22 @@ import UIKit
 
 class JDHomeExponentCell: BaseTableViewCell {
     
+    lazy var listData:[KSymbolModel] = {
+        let arr:[KSymbolModel] = [KSymbolModel]()
+        return arr
+    }()
     
     lazy var collectionView : UICollectionView = {
         
         let layout = UICollectionViewFlowLayout.init()
         
 
-        let itemW = (SCREEN_WIDTH - 60)/3
+        let itemW = (SCREEN_WIDTH - 40)/3.0 - 1
+        
+        layout.minimumInteritemSpacing = 10
+        layout.minimumLineSpacing = 10
         
-        layout.minimumInteritemSpacing = 6
-        layout.itemSize = CGSizeMake(CGFloat(itemW), 133)
+        layout.itemSize = CGSizeMake(CGFloat(itemW), 150)
         layout.sectionInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 0)
         
         
@@ -37,13 +43,13 @@ class JDHomeExponentCell: BaseTableViewCell {
     
     override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
-        
+        contentView.backgroundColor = ALLBackGroundColor
         contentView.addSubview(collectionView)
         collectionView.snp.makeConstraints { make in
-            make.top.equalTo(contentView.snp.top).offset(15)
-            make.left.equalTo(contentView.snp.left).offset(18)
-            make.right.equalTo(contentView.snp.right).offset(-18)
-            make.bottom.equalTo(contentView.snp.bottom).offset(-19)
+            make.top.equalTo(contentView.snp.top).offset(10)
+            make.left.equalTo(contentView.snp.left).offset(10)
+            make.right.equalTo(contentView.snp.right).offset(-10)
+            make.bottom.equalTo(contentView.snp.bottom).offset(-10)
         }
         
     }
@@ -52,20 +58,26 @@ class JDHomeExponentCell: BaseTableViewCell {
         fatalError("init(coder:) has not been implemented")
     }
     
+    func updateCellDataWith(list:[KSymbolModel]) -> Void {
+        listData.removeAll()
+        self.listData = list
+        self.collectionView.reloadData()
+    }
+    
     
 }
 
 extension JDHomeExponentCell : UICollectionViewDataSource{
     
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        return 6
+        return self.listData.count
     }
     
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: JDHomeExponentItem.description(), for: indexPath) as! JDHomeExponentItem
-
+        cell.updateCellDataWith(model: self.listData[indexPath.row])
         return cell
     }
  
@@ -83,61 +95,60 @@ class JDHomeExponentItem: UICollectionViewCell {
 
     lazy var bgView : UIView = {
         let v = UIView()
-        v.backgroundColor = UIColor.pg_color(withHexString: "E4FFF6")
-        
-        v.layer.masksToBounds = true
-        v.layer.cornerRadius = 6
+        v.backgroundColor = ALLBackGroundColor
+        v.setViewLayerBorderColor(myColor: ViewBorderColor, borderWidth: 1, maskBounds: 4)
         
         return v
     }()
     
     lazy var nameLb : UILabel = {
         let v = UILabel()
-        v.textColor = .black
-        v.font = .systemFont(ofSize: 14)
-        v.textAlignment = .center
-        v.text = "上证指数"
+        v.setTextFont(.PFSR, 12)
+        v.textAlignment = .left
         return v
     }()
     
     lazy var priceLb : UILabel = {
         let v = UILabel()
-        v.textColor = UIColor.pg_color(withHexString: "1BB570")
-        v.textAlignment = .center
-        v.font = .boldSystemFont(ofSize: 19)
-        v.text = "2363.91"
+        v.textAlignment = .left
+        v.setTextFont(.PFSM, 14)
+        v.text = "0.00"
         return v
     }()
     
     lazy var todayRateLb : UILabel = {
         let v = UILabel()
-        v.textColor = UIColor.pg_color(withHexString: "1BB570")
-        v.textAlignment = .center
-        v.font = .systemFont(ofSize: 11)
-        v.text = "-16.27"
+        v.textColor = MidTextColor
+        v.textAlignment = .left
+        v.setTextFont(.PFSR, 9)
+        v.text = "0.00"
         return v
     }()
     
     lazy var totalRateLb : UILabel = {
         let v = UILabel()
-        v.textColor = UIColor.pg_color(withHexString: "1BB570")
-        v.textAlignment = .center
-        v.font = .systemFont(ofSize: 11)
-        v.text = "-14.26"
+        v.textColor = MidTextColor
+        v.textAlignment = .left
+        v.setTextFont(.PFSR, 9)
+        v.text = "0.00"
         return v
     }()
     
+    lazy var lineView:JDChartLineView = {
+        let view:JDChartLineView = JDChartLineView()
+        view.lineChartView.minOffset = 0
+        view.shadowSize = CGSize(width: 0, height: 3)
+        view.isUserInteractionEnabled = false
+        view.lineChartView.isUserInteractionEnabled = false
+        return view
+    }()
+    
     lazy var buyBtn : UIButton = {
         
         let v = UIButton(type: .custom)
-        v.setTitle("买入", for: .normal)
-        v.setTitleColor( UIColor.pg_color(withHexString: "FF6F30"), for: .normal)
-        v.titleLabel?.font = .systemFont(ofSize: 12)
-        
+        v.setTextFont(.PFSR, 10)
         v.layer.masksToBounds = true
-        v.layer.cornerRadius = 12.5
-        v.layer.borderColor = UIColor.pg_color(withHexString: "FE6F30").cgColor
-        v.layer.borderWidth = 1
+        v.setViewLayerBorderColor(myColor: .clear, borderWidth: 0, maskBounds: 4)
         return v
     }()
     
@@ -145,14 +156,9 @@ class JDHomeExponentItem: UICollectionViewCell {
     lazy var sellBtn : UIButton = {
         
         let v = UIButton(type: .custom)
-        v.setTitle("卖出", for: .normal)
-        v.setTitleColor( UIColor.pg_color(withHexString: "62D585"), for: .normal)
-        v.titleLabel?.font = .systemFont(ofSize: 12)
-        
+        v.setTextFont(.PFSR, 10)
         v.layer.masksToBounds = true
-        v.layer.cornerRadius = 12.5
-        v.layer.borderColor = UIColor.pg_color(withHexString: "62D585").cgColor
-        v.layer.borderWidth = 1
+        v.setViewLayerBorderColor(myColor: .clear, borderWidth: 0, maskBounds: 4)
         return v
     }()
     
@@ -169,47 +175,100 @@ class JDHomeExponentItem: UICollectionViewCell {
         
         bgView.addSubview(nameLb)
         nameLb.snp.makeConstraints { make in
-            make.centerX.equalTo(bgView)
-            make.top.equalTo(bgView.snp.top).offset(14)
+            make.left.equalTo(5)
+            make.right.equalTo(-5)
+            make.top.equalTo(10)
         }
         
         bgView.addSubview(priceLb)
         priceLb.snp.makeConstraints { make in
-            make.top.equalTo(nameLb.snp.bottom).offset(12)
-            make.centerX.equalTo(bgView)
+            make.top.equalTo(nameLb.snp.bottom).offset(10)
+            make.left.equalTo(5)
+            make.right.equalTo(-5)
         }
         
         bgView.addSubview(todayRateLb)
         todayRateLb.snp.makeConstraints { make in
-            make.top.equalTo(priceLb.snp.bottom).offset(7)
-            make.left.equalTo(bgView.snp.left).offset(16)
+            make.top.equalTo(priceLb.snp.bottom).offset(5)
+            make.left.equalTo(5)
         }
         
         bgView.addSubview(totalRateLb)
         totalRateLb.snp.makeConstraints { make in
             make.centerY.equalTo(todayRateLb)
-            make.left.equalTo(todayRateLb.snp.right).offset(6)
+            make.left.equalTo(todayRateLb.snp.right).offset(5)
+            
         }
         
-        bgView.addSubview(buyBtn)
-        buyBtn.snp.makeConstraints { make in
-            make.bottom.equalTo(bgView.snp.bottom).offset(-12)
-            make.right.equalTo(bgView.snp.centerX).offset(-2)
-            make.size.equalTo(CGSizeMake(44, 22))
+        bgView.addSubview(self.lineView)
+        self.lineView.snp.makeConstraints { make in
+            make.top.equalTo(self.todayRateLb.snp.bottom).offset(15)
+            make.left.equalTo(10)
+            make.right.equalTo(-10)
+            make.bottom.equalTo(-35)
         }
         
         bgView.addSubview(sellBtn)
         sellBtn.snp.makeConstraints { make in
-            make.centerY.equalTo(buyBtn)
-            make.left.equalTo(bgView.snp.centerX).offset(2)
-            make.size.equalTo(CGSizeMake(44, 22))
+            make.bottom.equalTo(0)
+            make.left.equalTo(0)
+            make.height.equalTo(20)
+        }
+        
+        bgView.addSubview(buyBtn)
+        buyBtn.snp.makeConstraints { make in
+            make.bottom.equalTo(0)
+            make.right.equalTo(0)
+            make.left.equalTo(sellBtn.snp.right).offset(2)
+            make.width.equalTo(sellBtn.snp.width)
+            make.height.equalTo(20)
         }
+        
+      
     }
     
     required init?(coder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
     
+    func updateCellDataWith(model:KSymbolModel) -> Void {
+        
+       
+        self.nameLb.textColor = TitleTextColor
+        
+        self.todayRateLb.textColor = MidTextColor
+        self.totalRateLb.textColor = MidTextColor
+        
+        self.sellBtn.setTitle(switchLanguage("卖出"), for: .normal)
+        self.sellBtn.setTitleColor(MidTextColor, for: .normal)
+        self.sellBtn.backgroundColor = MidBackGroundColor;
+        
+        self.buyBtn.setTitle(switchLanguage("买入"), for: .normal)
+        self.buyBtn.setTitleColor(MidTextColor, for: .normal)
+        self.buyBtn.backgroundColor = MidBackGroundColor;
+        
+        self.nameLb.text = model.title
+        
+        self.priceLb.text = precisionString(with: model.newPrice, precision: model.digits) 
+        
+        let today:Double = conerData(model.newPrice, .MyDouble).2! - conerData(model.open, .MyDouble).2!
+        if today > 0 {
+            self.todayRateLb.text = String(format: "+%.2f", today)
+        }else{
+            self.todayRateLb.text = String(format: "%.2f", today)
+        }
+        
+        let increase = conerData(model.increase as Any, .MyFloat).1!
+        if increase > 0 {
+            self.totalRateLb.text = "+" + precisionString(with: model.increase, precision: "2")  + "%"
+        }else{
+            self.totalRateLb.text = precisionString(with: model.increase, precision: "2")  + "%"
+        }
+        
+        self.priceLb.textColor = exchangeColorAndImage(increase: increase).0
+        
+        self.lineView.updateHomeData(fillColor: self.priceLb.textColor , gradientColor: ALLBackGroundColor , data: model.data)
+    }
     
 }
 

+ 1 - 1
Koala/Koala/Modular/Home/V/JDHomeMenuCell.swift

@@ -45,7 +45,7 @@ class JDHomeMenuCell: UITableViewCell {
         
         contentView.addSubview(collectionView)
         
-       // collectionView.setViewLayerBorderColor(myColor: .red, borderWidth: 1, maskBounds: 4)
+
         collectionView.layer.borderColor = ViewBorderColor.cgColor
         collectionView.layer.borderWidth = 1
         collectionView.layer.cornerRadius = 4

+ 2 - 1
Koala/Koala/Modular/Home/VC/HomeViewController.swift

@@ -64,7 +64,8 @@ class HomeViewController: BaseViewController  {
         
         self.viewModel.netHomeBanner()
         self.viewModel.netHomeNotice()
-//        self.viewModel.netSymbolList()
+        self.viewModel.netSymbolList()
+        self.viewModel.netPriceList()
         self.viewModel.netNewsList()
                 
         let menu = SideMenuNavigationController(rootViewController: MineViewController())

+ 72 - 6
Koala/Koala/Modular/Home/VM/HomeViewModel.swift

@@ -30,17 +30,29 @@ class HomeViewModel: BaseViewModel {
         return arr
     }()
     
+    lazy var priceDict:[String:[KSymbolKlineData]] = {
+        let arr:[String:[KSymbolKlineData]] = [String:[KSymbolKlineData]]()
+        return arr
+    }()
+    
     lazy var newsList : [JDNewsModel] = {   //首页新闻
        
         let arr: [JDNewsModel] = [JDNewsModel]()
         return arr
     }()
     
+    lazy var netParamList:[String] = {
+        let arr:[String] = ["000001.SH","HK50","US30","DXY","XAUUSD","BTCUSD"];
+        return arr
+    }()
+    
     let (signalSymbol, observeSymbol) = Signal<Bool, Never>.pipe()
+    let (signalPrice, observePrice) = Signal<Bool, Never>.pipe()
     //netForSymbolList
     var homeBannerAction: Action <(),(Bool),Never>!
     var homeNoticeAction: Action <(),(Bool),Never>!
     var symbolListAction: Action <(),(Bool),Never>!
+  
     
     var newsListAction: Action <(),(Bool),Never>!
     
@@ -64,6 +76,7 @@ class HomeViewModel: BaseViewModel {
             }
         }
         
+        
         newsListAction = Action<(),(Bool),Never> { [weak self] _ in
             return SignalProducer<(Bool), Never>{ observer, _ in
                 
@@ -144,9 +157,9 @@ extension HomeViewModel {
     }
     //
     func requestSymbolList(observer: Signal< Bool, Never>.Observer) -> Void {
+       
         let parame:[String:Any] = [
-            "hot":"1",
-            "index":"1"
+            "symbol":getJSONStringFromArray(array: self.netParamList as NSArray)
         ]
         NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForHomeSymbolList,parameters: parame, success: { (code, result) in
             if let list:[NSDictionary] = result?["list"] as? [NSDictionary] {
@@ -160,11 +173,12 @@ extension HomeViewModel {
                         }
                         model?.newPrice = precisionString(with: ask, precision: model!.digits)
                         let np = decimalNumber(A: model!.newPrice, B: model!.open, type: .Subtract, scale:model!.digits)
-                        model?.increase = decimalNumber(A: np, B: model!.open, type: .Divid)
-                        model?.increase = decimalNumber(A: model!.increase, B: "100", type: .Multiply)
+                        let increase = (conerData(np, .MyDouble).2!/conerData(model!.open, .MyDouble).2!)*100
+                        model?.increase = String(format: "%.2f",increase)
                         self.symbolList.append(model!)
                     }
                 }
+                self.updatePriceList()
                 observer.send(value: true)
             }else{
                 observer.send(value: false)
@@ -178,6 +192,45 @@ extension HomeViewModel {
         }
     }
     
+    //获取交易对
+    func netPriceList() {
+        for symbol in self.netParamList{
+            requestPriceList(symbol: symbol)
+        }
+    }
+    
+    //
+    func requestPriceList(symbol:String) -> Void {
+        let endDate:String = currentTimeStamp()
+        let parame:[String:Any] = [
+            "symbol":symbol,
+            "type":"1",
+            "count":"100",
+            "endTime":endDate+"000"
+        ]
+    
+        NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetPriceList,parameters: parame, success: { (code, result) in
+            if let list:[NSDictionary] = result as? [NSDictionary] {
+                var arr:[KSymbolKlineData] = [KSymbolKlineData]()
+                for dic in list {
+                    let model = KSymbolKlineData.deserialize(from: dic)
+                    arr.append(model!)
+                }
+                self.priceDict.add([symbol:arr])
+                self.updatePriceList()
+            }else{
+                ProgressHUD.showError(status:DataTypeErrorPrompt)
+            }
+           
+        }) { (code, result) in
+            ProgressHUD.showError(status: result as! String)
+        }
+    }
+    
+    
+    
+    
+    
     //获取首页新闻
     
     func netNewsList(){
@@ -219,6 +272,19 @@ extension HomeViewModel {
 }
 
 extension HomeViewModel{
+    func updatePriceList() -> Void {
+        if (self.symbolList.count > 0){
+            for model in self.symbolList{
+                if let arr:[KSymbolKlineData] = self.priceDict[model.symbol] as? [KSymbolKlineData]{
+                    model.data = arr
+                }
+            }
+            self.observePrice.send(value: true)
+        }
+    }
+}
+
+extension HomeViewModel{
     func getHomeInfoListData() ->Void {
         guard self.data.count == 0 else {
             return
@@ -272,8 +338,8 @@ extension HomeViewModel{
                         if model.symbol == symbol {
                             model.newPrice = String(format:"%@",currentSocket["ask"] as! CVarArg)
                             let np = decimalNumber(A: model.newPrice, B: model.open, type: .Subtract, scale:model.digits)
-                            model.increase = decimalNumber(A: np, B: model.open, type: .Divid)
-                            model.increase = decimalNumber(A: model.increase, B: "100", type: .Multiply)
+                            let increase = (conerData(np, .MyDouble).2!/conerData(model.open, .MyDouble).2!)*100
+                            model.increase = String(format: "%.2f",increase)
                             isReload = true
                             break
                         }

+ 61 - 65
Koala/Koala/Modular/Information/V/InfomationCell.swift

@@ -17,11 +17,10 @@ class InfomationCell: BaseTableViewCell {
         
         let v = UILabel()
         
-        v.textColor = UIColor.pg_color(withHexString: "333333")
-        v.font = .systemFont(ofSize: 15)
+        v.setTextFont(.PFSM, 14)
         v.numberOfLines = 2
         
-        v.text = "2023年中报每股收益1.65美元,净利润52.16亿美元,长-6.47%"
+        v.text = ""
         return v
         
     }()
@@ -30,7 +29,7 @@ class InfomationCell: BaseTableViewCell {
         
         let v = UIImageView()
         
-        v.backgroundColor = UIColor.pg_color(withHexString: "E4FFF6")
+       // v.backgroundColor = UIColor.pg_color(withHexString: "E4FFF6")
         v.layer.masksToBounds = true
         v.layer.cornerRadius = 6
         return v
@@ -39,27 +38,25 @@ class InfomationCell: BaseTableViewCell {
     lazy var nickNameLb : UILabel = {
         
         let v = UILabel()
-        v.textColor = UIColor.pg_color(withHexString: "A2A2A2")
-        v.font = .systemFont(ofSize: 11)
-        v.text = "STELLANTIS"
+        v.setTextFont(.PFSR, 10)
+        v.text = ""
         return v
     }()
     
     lazy var rateLb : UILabel = {
         
         let v = UILabel()
-        v.textColor = UIColor.pg_color(withHexString: "141415")
-        v.font = .systemFont(ofSize: 11)
-        v.text = "28%"
+        v.setTextFont(.PFSR, 10)
+        v.text = ""
         return v
     }()
     
     lazy var timeLb : UILabel = {
         
         let v = UILabel()
-        v.textColor = UIColor.pg_color(withHexString: "A2A2A2")
-        v.font = .systemFont(ofSize: 11)
-        v.text = "今天 19:83"
+      
+        v.setTextFont(.PFSR, 10)
+        v.text = ""
         return v
     }()
     
@@ -67,7 +64,7 @@ class InfomationCell: BaseTableViewCell {
     
     override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
-        
+        contentView.backgroundColor = ALLBackGroundColor
         contentView.addSubview(picIv)
         picIv.snp.makeConstraints { make in
             make.centerY.equalTo(contentView)
@@ -111,27 +108,32 @@ class InfomationCell: BaseTableViewCell {
 
 extension InfomationCell {
     
-        func updateNewsCellWith(model:JDNewsModel) -> Void {
-            
-            self.titleLb.text = model.title
-            self.nickNameLb.text = model.origin
-            self.rateLb.text = ""
-            
-            self.timeLb.text = model.created_at
-            
-            if model.img.length == 0 {
-                
-                self.picIv.snp.updateConstraints { make in
-                    make.size.equalTo(CGSize(width: 0, height: 71))
-                }
-            }
+    func updateNewsCellWith(model:JDNewsModel) -> Void {
+        contentView.backgroundColor = ALLBackGroundColor
+        self.titleLb.textColor = TitleTextColor
+        self.nickNameLb.textColor = MidTextColor
+        self.timeLb.textColor = MidTextColor
+        self.rateLb.textColor = MidTextColor
+        
+        self.titleLb.text = model.title
+        self.nickNameLb.text = model.origin
+        self.rateLb.text = ""
+        
+        self.timeLb.text = model.created_at
+        
+        if model.img.length == 0 {
             
-            if let url = URL.init(string: model.img) {
-                
-                self.picIv.kf.setImage(with: url)
+            self.picIv.snp.updateConstraints { make in
+                make.size.equalTo(CGSize(width: 0, height: 71))
             }
+        }
+        
+        if let url = URL.init(string: model.img) {
             
-            
+            self.picIv.kf.setImage(with: url)
+        }
+        
+        
     }
 }
 
@@ -151,9 +153,9 @@ class MarketTopicCell: BaseTableViewCell {
     lazy var contentLb : UILabel = {
         let v = UILabel()
         v.textColor = UIColor.pg_color(withHexString: "333333")
-        v.font = .systemFont(ofSize: 12)
+        v.setTextFont(.PFSM, 14)
         v.numberOfLines = 2
-        v.text = "2023年中报每股收益1.65美元,净利润52.16亿美同比去年增长-6.47%"
+       
         return v
     }()
     
@@ -180,12 +182,12 @@ class MarketTopicCell: BaseTableViewCell {
     required init?(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
-
+    
 }
 
 
 extension MarketTopicCell {
-   
+    
     func updateNewsCellWith(model:JDNewsModel) -> Void {
         self.newsModel = model
         self.contentLb.text = model.title
@@ -248,11 +250,11 @@ extension ReadInfoCell : UICollectionViewDataSource{
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ReadItemCell.description(), for: indexPath) as! ReadItemCell
-
-//        let randModel = hotAry?[indexPath.item]
-//
-//        cell.titleLb.text = randModel?.title
-
+        
+        //        let randModel = hotAry?[indexPath.item]
+        //
+        //        cell.titleLb.text = randModel?.title
+        
         return cell
     }
     
@@ -264,19 +266,19 @@ extension ReadInfoCell : UICollectionViewDelegate{
     
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         
-//        guard let strongSelf = self else {
-//            return
-//        }
-
-//        let controller = CricListDetailViewController(context: self.context, id:randomModel?.id )
-//        controller.navigationPresentation = .master
-//
-//        if let navigationController = self.context.sharedContext.mainWindow?.viewController as? NavigationController {
-//            navigationController.pushViewController(controller, completion: {
-//
-//            })
-//        }
-
+        //        guard let strongSelf = self else {
+        //            return
+        //        }
+        
+        //        let controller = CricListDetailViewController(context: self.context, id:randomModel?.id )
+        //        controller.navigationPresentation = .master
+        //
+        //        if let navigationController = self.context.sharedContext.mainWindow?.viewController as? NavigationController {
+        //            navigationController.pushViewController(controller, completion: {
+        //
+        //            })
+        //        }
+        
     }
 }
 
@@ -287,10 +289,8 @@ class ReadItemCell: UICollectionViewCell {
     lazy var titleLb : UILabel = {
         
         let v  = UILabel()
-        
-        v.font = .boldSystemFont(ofSize: 14)
-        v.textColor = UIColor.pg_color(withHexString: "7D43F6")
-        v.text = "ETF周报"
+        v.setTextFont(.PFSM, 14)
+        v.text = ""
         return v
         
     }()
@@ -298,9 +298,7 @@ class ReadItemCell: UICollectionViewCell {
     lazy var timeLb : UILabel = {
         
         let v = UILabel()
-        v.font = .systemFont(ofSize: 11)
-        v.textColor = UIColor.pg_color(withHexString: "A2A2A2")
-        v.text = "今天 19:83"
+        v.setTextFont(.PFSR, 10)
         v.textAlignment = .right
         return v
         
@@ -309,9 +307,7 @@ class ReadItemCell: UICollectionViewCell {
     lazy var contentLb : UILabel = {
         
         let v = UILabel()
-        v.font = .systemFont(ofSize: 12)
-        v.textColor = UIColor.pg_color(withHexString: "333333")
-        v.text = "2023年中报每股收益1.65美元,净利润52.16亿美…"
+        v.setTextFont(.PFSR, 10)
         v.textAlignment = .left
         v.numberOfLines = 2
         return v
@@ -321,7 +317,7 @@ class ReadItemCell: UICollectionViewCell {
     lazy var bgView : UIView = {
         
         let v = UIView()
-        v.backgroundColor = UIColor.pg_color(withHexString: "F9F7FE")
+        v.backgroundColor = .clear
         v.layer.masksToBounds = true
         v.layer.cornerRadius = 5
         

+ 11 - 0
Koala/Koala/Modular/Public/Model/PublicModel.swift

@@ -87,8 +87,19 @@ class KSymbolModel: BaseModel {
     var timeList:[KSymbolTimeModel] = [KSymbolTimeModel]()
     var isCollection:Bool = false
     
+    var data:[KSymbolKlineData] = [KSymbolKlineData]()
+
+}
 
 
+class KSymbolKlineData:BaseModel{
+    var volume: String = ""
+    var datetime: String = ""
+    var high: String = ""
+    var low: String = ""
+    var close: String = ""
+    var turnover: String = ""
+    var open: String = ""
 }
 
 class KSymbolTimeModel: BaseModel {