Quellcode durchsuchen

交易下单模块

刘千军 vor 10 Monaten
Ursprung
Commit
3c4fdd009f

+ 8 - 3
Koala/Koala/FX/NetClass/Network.swift

@@ -147,11 +147,16 @@ extension NetWork {
                     var errno = json["return_code"].intValue
                     let status = json["status"].intValue
                     let code = json["code"].intValue
-      
-                    Dlog(json)
                     
+                    Dlog(json)
                     var data = json["data"]
                     
+                    if code == 0 && status == 0 && errno == 0{
+                        data = json
+                        errno = 200
+                    }
+                   
+                    
                     if json["pageInfo"].type != Type.null{
                         data = json["pageInfo"]
                     }
@@ -171,7 +176,7 @@ extension NetWork {
                         
                         var dict:[String: Any] = [String:Any]()
                         if data.dictionaryObject != nil{
-                            guard let dic = json["data"].dictionaryObject else {
+                            guard let dic = data.dictionaryObject else {
                                 failured(errno,"转字典失败" as AnyObject)
                                 return
                             }

+ 2 - 0
Koala/Koala/Modular/Deal/M/DealModel.swift

@@ -126,6 +126,7 @@ class CloseOrderListModel:BaseModel{
 }
 
 class PositionListModel:BaseModel{
+    public var mt_code: String! = ""
     public var tp: String! = ""
     public var volume: String! = ""
     public var symbol: String! = ""
@@ -143,6 +144,7 @@ class PositionListModel:BaseModel{
 }
 
 class EntrustListModel:BaseModel{
+    public var mt_code: String! = ""
     public var comment: String! = ""
     public var symbol: String! = ""
     public var open_time: String! = ""

+ 68 - 53
Koala/Koala/Modular/Deal/V/Deal/DealListCell.swift

@@ -103,11 +103,11 @@ class DealListCell: BaseTableViewCell {
         self.left1Lab.text = model.SymbolModel.title
         self.left2Lab.text = model.symbol
         
-        self.center1Lab.attributedText = self.setAttributes(title: switchLanguage("单位"), text: "1.00")
+        self.center1Lab.attributedText = self.setAttributes(title: switchLanguage("单位"), text: precisionString(with:model.volume, precision: "2"))
         
         self.center2Lab.attributedText = self.setAttributes(title: switchLanguage("现价"), text: precisionString(with: model.close_price, precision: "3"))
         
-        self.right1Lab.attributedText = self.setAttributes(title: switchLanguage("数量"), text: precisionString(with: model.volume, precision: "2"))
+        self.right1Lab.attributedText = self.setAttributes(title: switchLanguage("数量"), text: precisionString(with:decimalNumber(A: model.volume, B: model.SymbolModel.contract_size, type: .Multiply), precision: "2"))
         
         self.right2Lab.attributedText = self.setAttributes(title: switchLanguage("成本"), text: precisionString(with: model.open_price, precision: "2"))
         
@@ -225,67 +225,82 @@ class DealListCell: BaseTableViewCell {
     
     
     func updatePositionProfit(model:PositionListModel) -> Void {
-        
+       
         var profit = 0.00
-        let buy_price = conerData(model.SymbolModel.bid, .MyDouble).2!
-        let sell_price = conerData(model.SymbolModel.ask, .MyDouble).2!
-        let contract_size = conerData(model.SymbolModel.contract_size, .MyDouble).2!
-        let OPEN_PRICE = conerData(model.open_price as Any, .MyDouble).2!
-        let VOLUME = conerData(model.volume as Any, .MyDouble).2!
-        let isUSDSu = model.SymbolModel.symbol == model.SymbolModel.currency + "USD"//以USD结尾
-        let isUSD = model.SymbolModel.symbol == "USD" + model.SymbolModel.currency //以USD开头
-        
-        if model.SymbolModel.profit_mode == "1"{
-            if model.cmd == 0 || model.cmd == 2 || model.cmd == 4{
-                if isUSDSu {
-                    profit = (buy_price - OPEN_PRICE) * VOLUME * contract_size * (buy_price + sell_price)/2
-                }
-                else if isUSD{
-                    profit = (buy_price - OPEN_PRICE) * VOLUME * contract_size / (buy_price + sell_price)/2
-                }
-                else if model.SymbolModel.margin_currency == "USD" {
-                    profit = (buy_price - OPEN_PRICE) * VOLUME * contract_size
+        if model.mt_code == "CFD"{
+            let buy_price = conerData(model.SymbolModel.bid, .MyDouble).2!
+            let sell_price = conerData(model.SymbolModel.ask, .MyDouble).2!
+            let contract_size = conerData(model.SymbolModel.contract_size, .MyDouble).2!
+            let open_price = conerData(model.open_price as Any, .MyDouble).2!
+            let volume = conerData(model.volume as Any, .MyDouble).2!
+            let isUSDSu = model.SymbolModel.symbol == model.SymbolModel.currency + "USD"//以USD结尾
+            let isUSD = model.SymbolModel.symbol == "USD" + model.SymbolModel.currency //以USD开头
+            
+            if model.SymbolModel.profit_mode == "1"{
+                if model.cmd == 0 || model.cmd == 2 || model.cmd == 4{
+                    if isUSDSu {//以USD结尾
+                        profit = (buy_price - open_price) * volume * contract_size * (buy_price + sell_price)/2
+                    }
+                    else if isUSD{//以USD开头
+                        profit = (buy_price - open_price) * volume * contract_size / (buy_price + sell_price)/2
+                    }
+                    else if model.SymbolModel.margin_currency == "USD" {
+                        profit = (buy_price - open_price) * volume * contract_size
+                    }
+                   
+                }else{
+                    if isUSDSu {
+                        profit  = (open_price - sell_price) * volume * contract_size * (buy_price + sell_price)/2
+                    }
+                    else if isUSD{
+                        profit  = (open_price - sell_price) * volume * contract_size / (buy_price + sell_price)/2
+                    }
+                    else if model.SymbolModel.margin_currency == "USD" {
+                        profit = (open_price - sell_price) * volume * contract_size
+                    }
+                   
                 }
-               
+                
             }else{
-                if isUSDSu {
-                    profit  = (OPEN_PRICE - sell_price) * VOLUME * contract_size * (buy_price + sell_price)/2
-                }
-                else if isUSD{
-                    profit  = (OPEN_PRICE - sell_price) * VOLUME * contract_size / (buy_price + sell_price)/2
-                }
-                else if model.SymbolModel.margin_currency == "USD" {
-                    profit = (OPEN_PRICE - sell_price) * VOLUME * contract_size
+                if model.cmd == 0 || model.cmd == 2 || model.cmd == 4{
+                    if  isUSDSu {
+                        profit  = (buy_price - open_price) * volume * contract_size * ((buy_price + sell_price)/2 / buy_price)
+                    }
+                    else if isUSD{
+                        profit  = (buy_price - open_price) * volume * contract_size / ((buy_price + sell_price)/2 * buy_price)
+                    }
+                    else if model.SymbolModel.margin_currency == "USD" {
+                        profit = (buy_price - open_price) * volume * contract_size / buy_price
+                    }
+                   
+                }else{
+                    if isUSDSu {
+                        profit  = (open_price - sell_price) * volume * contract_size * ((buy_price + sell_price)/2/sell_price)
+                        
+                    }
+                    else if isUSD {
+                        profit  = (open_price - sell_price) * volume * contract_size / ((buy_price + sell_price)/2 * sell_price)
+                    }
+                    else if model.SymbolModel.margin_currency == "USD" {
+                        profit = (open_price - sell_price) * volume * contract_size / sell_price
+                    }
+                   
                 }
-               
             }
-            
         }else{
+            let volume = conerData(model.volume as Any, .MyDouble).2!
+            let size = conerData(model.SymbolModel.contract_size as Any, .MyDouble).2!
+            let open_price = conerData(model.open_price as Any, .MyDouble).2!
+            let buy_price = conerData(model.SymbolModel.bid, .MyDouble).2!
+            let sell_price = conerData(model.SymbolModel.ask, .MyDouble).2!
             if model.cmd == 0 || model.cmd == 2 || model.cmd == 4{
-                if  isUSDSu {
-                    profit  = (buy_price - OPEN_PRICE) * VOLUME * contract_size * ((buy_price + sell_price)/2 / buy_price)
-                }
-                else if isUSD{
-                    profit  = (buy_price - OPEN_PRICE) * VOLUME * contract_size / ((buy_price + sell_price)/2 * buy_price)
-                }
-                else if model.SymbolModel.margin_currency == "USD" {
-                    profit = (buy_price - OPEN_PRICE) * VOLUME * contract_size / buy_price
-                }
-               
+                profit = (buy_price - open_price)*size*volume
             }else{
-                if isUSDSu {
-                    profit  = (OPEN_PRICE - sell_price) * VOLUME * contract_size * ((buy_price + sell_price)/2/sell_price)
-                    
-                }
-                else if isUSD {
-                    profit  = (OPEN_PRICE - sell_price) * VOLUME * contract_size / ((buy_price + sell_price)/2 * sell_price)
-                }
-                else if model.SymbolModel.margin_currency == "USD" {
-                    profit = (OPEN_PRICE - sell_price) * VOLUME * contract_size / sell_price
-                }
-               
+                profit = (sell_price - open_price)*size*volume
             }
+            
         }
+       
         
         let value = precisionString(with: "\(profit)", precision: "2")
         let color = exchangeColorAndImage(increase: conerData(value, .MyFloat).1!).0

+ 1 - 1
Koala/Koala/Modular/Deal/V/Deal/DealProCell.swift

@@ -484,7 +484,7 @@ extension DealProCell{
     }
     
     func updateMax() -> Void {
-        self.amountLab.text = decimalNumber(A:self.VM.accountInfoModel.margin_free, B: self.VM.price, type: .Divid)
+        self.buyLab.text = decimalNumber(A:self.VM.accountInfoModel.margin_free, B: self.VM.price, type: .Divid)
     }
 }
 

+ 44 - 7
Koala/Koala/Modular/Deal/V/Deal/DealSectionView.swift

@@ -12,7 +12,10 @@ class DealSectionView: BaseView {
 
     @IBOutlet weak var topBgView: UIView!
     
-    var headerView: UIView!
+    @IBOutlet weak var bottomBgView: UIView!
+    
+    @IBOutlet weak var timerBgView: UIView!
+    var sectionView: UIView!
     var clickSelectBlock: ((_ index:Int) -> ())?
     
     lazy var segmentedControl:HMSegmentedControl = {
@@ -29,7 +32,26 @@ class DealSectionView: BaseView {
         segmentedControl.segmentEdgeInset = UIEdgeInsets.init(top: 0, left: 20, bottom: 0, right: 20)
         segmentedControl.indexChangeBlock = {[weak self](index) in
             self?.clickSelectBlock?(Int(index))
+            self?.updateLayer(index:Int(index))
+        }
+        return segmentedControl
+    }()
+    
+    lazy var timerControl:HMSegmentedControl = {
+        let segmentedControl:HMSegmentedControl = HMSegmentedControl.init(frame: CGRect(x:1, y: 1, width: 200-2, height: 28))
+        segmentedControl.selectedSegmentIndex = 0
+        segmentedControl.backgroundColor = .clear
+        segmentedControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor : MidTextColor,NSAttributedString.Key.font:_PFSM(12)]
+        segmentedControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor : TitleTextColor,NSAttributedString.Key.font:_PFSM(12)]
+        segmentedControl.selectionIndicatorBoxColor = ALLBackGroundColor
+        segmentedControl.selectionIndicatorBoxOpacity = 1
+        segmentedControl.selectionStyle = .box
+        segmentedControl.selectionIndicatorHeight = 0
+       
+        if let layer:CALayer = segmentedControl.value(forKey: "selectionIndicatorBoxLayer") as? CALayer{
+            layer.cornerRadius = 4
         }
+        segmentedControl.sectionTitles = [switchLanguage("日"),switchLanguage("周"),switchLanguage("月"),switchLanguage("自定义")]
         return segmentedControl
     }()
     
@@ -39,16 +61,17 @@ class DealSectionView: BaseView {
     
     override init(frame: CGRect) {
         super.init(frame: frame)
-        headerView = loadFromNib()
-        addSubview(headerView)
-        headerView.snp.makeConstraints { (make) in
+        sectionView = loadFromNib()
+        addSubview(sectionView)
+        
+        sectionView.snp.makeConstraints { (make) in
             make.edges.equalToSuperview()
         }
         mySwitchSkin()
         mySwitchLanguage()
         self.topBgView.addSubview(self.segmentedControl)
-        
-       
+        self.timerBgView.addSubview(timerControl)
+        self.updateLayer(index: 0)
     }
     
     required init?(coder aDecoder: NSCoder) {
@@ -63,13 +86,27 @@ class DealSectionView: BaseView {
        
         self.backgroundColor = .clear
         self.topBgView.backgroundColor = ALLBackGroundColor
-       
+        self.bottomBgView.backgroundColor = ALLBackGroundColor
+        self.timerBgView.backgroundColor = InputBackGroundColor
+        self.timerBgView.setViewLayerBorderColor(myColor: .clear, borderWidth: 0, maskBounds: 4)
+        timerControl.selectionIndicatorBoxColor = ALLBackGroundColor
+        //选中的盒子颜色
+        timerControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor : MidTextColor,NSAttributedString.Key.font:_PFSM(12)]
+        timerControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor : TitleTextColor,NSAttributedString.Key.font:_PFSM(12)]
         
     }
 
 }
 
 extension DealSectionView{
+    
+    func updateLayer(index:Int) -> Void {
+        if index == 2{
+            self.bottomBgView.isHidden = false
+        }else{
+            self.bottomBgView.isHidden = true
+        }
+    }
    
     func updateSectionTitles(position:Int,entrust:Int,closeOrder:Int) -> Void {
         var positionStr = switchLanguage("持仓")

+ 22 - 1
Koala/Koala/Modular/Deal/V/Deal/DealSectionView.xib

@@ -10,6 +10,8 @@
     <objects>
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="DealSectionView" customModule="Koala" customModuleProvider="target">
             <connections>
+                <outlet property="bottomBgView" destination="yCA-iV-o6x" id="1rO-aK-y6f"/>
+                <outlet property="timerBgView" destination="GWm-pI-kK2" id="i99-6K-xEz"/>
                 <outlet property="topBgView" destination="UxZ-QY-EJg" id="kOY-mY-Gor"/>
             </connections>
         </placeholder>
@@ -22,9 +24,28 @@
                     <rect key="frame" x="0.0" y="0.0" width="390" height="213"/>
                     <subviews>
                         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UxZ-QY-EJg">
-                            <rect key="frame" x="0.0" y="0.0" width="390" height="213"/>
+                            <rect key="frame" x="0.0" y="0.0" width="390" height="173"/>
                             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         </view>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yCA-iV-o6x">
+                            <rect key="frame" x="0.0" y="173" width="390" height="40"/>
+                            <subviews>
+                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GWm-pI-kK2">
+                                    <rect key="frame" x="95" y="5" width="200" height="30"/>
+                                    <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="200" id="KWh-Ll-PPv"/>
+                                    </constraints>
+                                </view>
+                            </subviews>
+                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            <constraints>
+                                <constraint firstItem="GWm-pI-kK2" firstAttribute="centerX" secondItem="yCA-iV-o6x" secondAttribute="centerX" id="Ao0-t9-lpR"/>
+                                <constraint firstAttribute="bottom" secondItem="GWm-pI-kK2" secondAttribute="bottom" constant="5" id="DYa-mK-Q8I"/>
+                                <constraint firstAttribute="height" constant="40" id="MWW-TX-NkI"/>
+                                <constraint firstItem="GWm-pI-kK2" firstAttribute="top" secondItem="yCA-iV-o6x" secondAttribute="top" constant="5" id="ejD-zn-cru"/>
+                            </constraints>
+                        </view>
                     </subviews>
                 </stackView>
             </subviews>

+ 1 - 1
Koala/Koala/Modular/Deal/V/Deal/DealSimCell.swift

@@ -420,7 +420,7 @@ extension DealSimCell{
     }
     
     func updateMax() -> Void {
-        self.amountLab.text = decimalNumber(A:self.VM.accountInfoModel.margin_free, B: self.VM.price, type: .Divid)
+        self.buyLab.text = decimalNumber(A:self.VM.accountInfoModel.margin_free, B: self.VM.price, type: .Divid)
     }
 }
 

+ 9 - 9
Koala/Koala/Modular/Deal/V/Deal/DealSimDataCell.swift

@@ -138,19 +138,19 @@ class DealSimDataCell: BaseTableViewCell {
             return
         }
         var buy:Double = 0
-        for model in vm.depthModel.bids {
+        for model in vm.depthModel.asks {
             buy += conerData(model.volume, .MyDouble).2!
         }
         var sell:Double = 0
-        for model in vm.depthModel.asks {
+        for model in vm.depthModel.bids {
             sell += conerData(model.volume, .MyDouble).2!
         }
         
         let buyRate = buy / (buy+sell)
         let sellRate = sell / (buy+sell)
         
-        self.buyRateLab.text = String(format: "%.2f", buyRate*100)
-        self.sellRateLab.text = String(format: "%.2f", sellRate*100)
+        self.buyRateLab.text = String(format: "%.2f%%", buyRate*100)
+        self.sellRateLab.text = String(format: "%.2f%%", sellRate*100)
         
         self.updatePlan(rate: buyRate)
         self.buyTableView.reloadData()
@@ -242,18 +242,18 @@ class DealSimDataListCell: BaseTableViewCell {
         view.addSubview(volumeLab)
         
         self.numLab.snp.makeConstraints { make in
-            make.left.equalTo(2)
+            make.left.equalTo(5)
             make.centerY.equalToSuperview()
             make.width.height.equalTo(10);
         }
         
         self.priceLab.snp.makeConstraints { make in
-            make.left.equalTo(self.priceLab.snp.right).offset(2)
+            make.left.equalTo(self.numLab.snp.right).offset(5)
             make.centerY.equalToSuperview()
         }
         
         self.volumeLab.snp.makeConstraints { make in
-            make.right.equalTo(-2)
+            make.right.equalTo(-5)
             make.centerY.equalToSuperview()
         }
         
@@ -295,7 +295,7 @@ class DealSimDataListCell: BaseTableViewCell {
     
     func updateBuyCellWith(model:AsksOrBidsModel,index:Int) -> Void {
         self.numLab.text = "\(index+1)"
-        self.priceLab.text = model.price
+        self.priceLab.text = precisionString(with: model.price, precision: "3")
         self.volumeLab.text = model.volume
         self.numLab.textColor = WhiteTextColor
         self.numLab.backgroundColor = exchangeColorAndImage(increase: 1).0
@@ -304,7 +304,7 @@ class DealSimDataListCell: BaseTableViewCell {
     
     func updateSellCellWith(model:AsksOrBidsModel,index:Int) -> Void {
         self.numLab.text = "\(index+1)"
-        self.priceLab.text = model.price
+        self.priceLab.text = precisionString(with: model.price, precision: "3")
         self.volumeLab.text = model.volume
         self.numLab.textColor = WhiteTextColor
         self.numLab.backgroundColor = exchangeColorAndImage(increase: -1).0

+ 6 - 6
Koala/Koala/Modular/Deal/V/Deal/DealSimDataCell.xib

@@ -106,7 +106,7 @@
                                                 <nil key="textColor"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
-                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LUK-Se-KIg">
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LUK-Se-KIg">
                                                 <rect key="frame" x="301" y="0.0" width="50" height="15"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="50" id="faK-e8-KlC"/>
@@ -150,14 +150,14 @@
                                         </constraints>
                                     </view>
                                     <stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Yu7-ED-2rR">
-                                        <rect key="frame" x="0.0" y="15" width="391" height="51"/>
+                                        <rect key="frame" x="20" y="15" width="351" height="51"/>
                                         <subviews>
                                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="qPb-XJ-cYt">
-                                                <rect key="frame" x="0.0" y="0.0" width="195.66666666666666" height="51"/>
+                                                <rect key="frame" x="0.0" y="0.0" width="175.66666666666666" height="51"/>
                                                 <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                             </tableView>
                                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="1Me-Om-60U">
-                                                <rect key="frame" x="195.66666666666663" y="0.0" width="195.33333333333337" height="51"/>
+                                                <rect key="frame" x="175.66666666666663" y="0.0" width="175.33333333333337" height="51"/>
                                                 <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                             </tableView>
                                         </subviews>
@@ -173,8 +173,8 @@
                                     <constraint firstItem="kZS-zi-y1P" firstAttribute="top" secondItem="ODx-Bi-S2n" secondAttribute="top" id="FGe-fm-WXG"/>
                                     <constraint firstAttribute="bottom" secondItem="Yu7-ED-2rR" secondAttribute="bottom" id="Se8-Fz-Qec"/>
                                     <constraint firstAttribute="trailing" secondItem="kZS-zi-y1P" secondAttribute="trailing" constant="20" id="VQF-Kx-ucJ"/>
-                                    <constraint firstAttribute="trailing" secondItem="Yu7-ED-2rR" secondAttribute="trailing" id="u9G-Ht-5IH"/>
-                                    <constraint firstItem="Yu7-ED-2rR" firstAttribute="leading" secondItem="ODx-Bi-S2n" secondAttribute="leading" id="x7E-86-U19"/>
+                                    <constraint firstAttribute="trailing" secondItem="Yu7-ED-2rR" secondAttribute="trailing" constant="20" id="u9G-Ht-5IH"/>
+                                    <constraint firstItem="Yu7-ED-2rR" firstAttribute="leading" secondItem="ODx-Bi-S2n" secondAttribute="leading" constant="20" id="x7E-86-U19"/>
                                 </constraints>
                             </view>
                         </subviews>

+ 6 - 3
Koala/Koala/Modular/Deal/V/Deal/DealTopView.swift

@@ -34,8 +34,11 @@ class DealTopView: BaseView {
         
         self.imgView.setViewLayerBorderColor(myColor: .clear, borderWidth: 0, maskBounds: 10)
         self.nameLab.setTextFont(.PFSM, 15)
+        self.nameLab.text = ""
         self.cashLab.setTextFont(.PFSR, 12)
+        self.cashLab.text = ""
         self.buyLab.setTextFont(.PFSR, 12)
+        self.buyLab.text = ""
         
         let tap = UITapGestureRecognizer(target: self, action: #selector(clickViewAction))
         self.addGestureRecognizer(tap)
@@ -61,7 +64,7 @@ class DealTopView: BaseView {
         self.cashLab.textColor = GrayTextColor
         self.buyLab.textColor = GrayTextColor
         
-        self.arrowsBtn.setImage(_image("Base_W_RightArrows&Base_W_RightArrows").imageWithTintColor(color: GrayTextColor), for: .normal)
+        self.arrowsBtn.setImage(_image("Base_W_RightArrows&Base_W_RightArrows").imageWithTintColor(color: LightTextColor), for: .normal)
         
     }
     
@@ -71,9 +74,9 @@ class DealTopView: BaseView {
         self.imgView.image = OperationalUserInfoData.getAccountName(model: model).1
         self.nameLab.text = String(format: "%@(%@)",OperationalUserInfoData.getAccountName(model: model).0,model.account)
         
-        self.cashLab.text = String(format: "%@:%@%@",switchLanguage("现金"),precisionString(with: model.margin_free, precision: "2"),OperationalUserInfoData.getAccountName(model: model).2)
+        self.cashLab.text = String(format: "%@: %@ %@",switchLanguage("现金"),precisionString(with: model.margin_free, precision: "2"),OperationalUserInfoData.getAccountName(model: model).2)
         
-        self.buyLab.text = String(format: "%@:%@%@",switchLanguage("最大购买力"),precisionString(with: model.margin_free, precision: "2"),OperationalUserInfoData.getAccountName(model: model).2)
+        self.buyLab.text = String(format: "%@: %@ %@",switchLanguage("最大购买力"),precisionString(with: model.margin_free, precision: "2"),OperationalUserInfoData.getAccountName(model: model).2)
     }
 
     

+ 58 - 56
Koala/Koala/Modular/Deal/V/Deal/DealView.swift

@@ -11,6 +11,7 @@ import UIKit
 class DealView: BaseView {
 
     var VM: DealViewModel?
+    var dateStr:(String,String) = ("","")
     
     lazy var navView:DealNavView = {
         let view = DealNavView()
@@ -101,6 +102,7 @@ class DealView: BaseView {
     lazy var sectionView:DealSectionView = {
         let view = DealSectionView.init(frame: CGRectMake(0, 0, SCREEN_WIDTH, 100))
         view.clickSelectBlock = {[weak self] index in
+            self?.reloadTable()
             guard OperationalUserInfoData.getLogin() else {
                 return
             }
@@ -114,6 +116,48 @@ class DealView: BaseView {
                 self?.VM?.netGetCloseOrderList()
             }
         }
+        
+        view.timerControl.indexChangeBlock = {[weak self](index) in
+            guard let self = self else{return}
+            if index == 0 {
+                self.VM?.startDate = dateToString(stmap: decimalNumber(A:currentTimeStamp(), B: "86400", type: .Subtract) , formatter: "yyyy-MM-dd")
+            }
+            else if index == 1{
+                self.VM?.startDate = dateToString(stmap: decimalNumber(A:currentTimeStamp(), B: "604800", type: .Subtract) , formatter: "yyyy-MM-dd")
+            }
+            else if index == 2{
+                self.VM?.startDate = dateToString(stmap: decimalNumber(A:currentTimeStamp(), B: "2592000", type: .Subtract) , formatter: "yyyy-MM-dd")
+            }else if index == 3{
+                let pop = PositionHistoryDatePopView()
+                if self.dateStr.0.length == 0 {
+                    self.dateStr.0 = dateToString(stmap:currentTimeStamp(),formatter: "yyyy-MM-dd")
+                    self.dateStr.1 = dateToString(stmap:currentTimeStamp(),formatter: "yyyy-MM-dd")
+                }
+                pop.showPopupView(date: self.dateStr) { dateStr in
+                    self.dateStr = dateStr
+                    self.VM?.endDate = dateStr.1
+                    self.VM?.startDate = dateStr.0
+                   
+                }
+            }
+        }
+        
+        view.timerControl.indexClickBlock = {[weak self](index) in
+            guard let self = self else{return}
+            if index == 3{
+                let pop = PositionHistoryDatePopView()
+                if self.dateStr.0.length == 0 {
+                    self.dateStr.0 = dateToString(stmap:currentTimeStamp(),formatter: "yyyy-MM-dd")
+                    self.dateStr.1 = dateToString(stmap:currentTimeStamp(),formatter: "yyyy-MM-dd")
+                }
+                pop.showPopupView(date: self.dateStr) { dateStr in
+                    self.dateStr = dateStr
+                    self.VM?.endDate = dateStr.1
+                    self.VM?.startDate = dateStr.0
+                   
+                }
+            }
+        }
         return view
     }()
     
@@ -439,63 +483,15 @@ extension DealView {
     func showPopupMenu() -> Void {
         let pop = KMenuPopupMenuView()
         var list:[(UIImage,String,Bool)] = [(UIImage,String,Bool)]()
-        if self.VM!.selectSymbolModel.isCollection {
-            list = [
-                (_image("Deal_W_Transfer&Deal_W_Transfer"),switchLanguage("资金划转"),true),
-                (_image("Deal_W_FC&Deal_W_FC"),switchLanguage("法币存款"),true),
-                (_image("Deal_W_Deposit&Deal_W_Deposit"),switchLanguage("充币"),true),
-                (_image("Deal_W_Finance&Deal_W_Finance"),switchLanguage("资金明细"),true),
-                (_image("Deal_W_Account&Deal_W_Account"),switchLanguage("模拟账户"),true),
-                (_image("Deal_W_Collection&Deal_W_Collection"),switchLanguage("取消自选"),true),
-            ]
-        }else{
-            list = [
-                (_image("Deal_W_Transfer&Deal_W_Transfer"),switchLanguage("资金划转"),true),
-                (_image("Deal_W_FC&Deal_W_FC"),switchLanguage("法币存款"),true),
-                (_image("Deal_W_Deposit&Deal_W_Deposit"),switchLanguage("充币"),true),
-                (_image("Deal_W_Finance&Deal_W_Finance"),switchLanguage("资金明细"),true),
-                (_image("Deal_W_Account&Deal_W_Account"),switchLanguage("模拟账户"),true),
-                (_image("Deal_W_Collection&Deal_W_Collection"),switchLanguage("添加自选"),true),
-            ]
-        }
-       
+        list = [
+            (_image("Deal_W_Lock&Deal_W_Lock"),switchLanguage("锁定交易"),true),
+            (_image("Deal_W_Set&Deal_W_Set"),switchLanguage("下单设置"),true),
+            (_image("Deal_W_Market&Deal_W_Market"),switchLanguage("我的行情"),true),
+            (_image("Deal_W_Help&Deal_W_Help"),switchLanguage("帮助中心"),true)
+        ]
         pop.showRelyPopupView(view: self.navView.menuBtn, source: list ,topB: -15,leftB: 80) {[weak self] index in
-            guard OperationalUserInfoData.getLogin() else {
-                currentVc()!.navigationController?.pushViewController(LoginViewController(), animated: true)
-                return
-            }
-            if index == 0{
-                let vc = ASelsectCurrencyViewController()
-                vc.type = .Transfer
-                currentVc()?.navigationController?.pushViewController(vc, animated: true)
-            }
-            else if index == 1{
-                let vc = AFiatDepositsViewController()
-                currentVc()?.navigationController?.pushViewController(vc, animated: true)
-            }
-            else if index == 2{
-                
-                let vc = ASelsectCurrencyViewController()
-                vc.type = .Deposit
-                currentVc()?.navigationController?.pushViewController(vc, animated: true)
-            }
-            else if index == 3{
-               
-               let vc = AssetsHistoryViewController()
-                vc.updateIndex(index: 0)
-                currentVc()!.navigationController?.pushViewController(vc, animated: true)
-            }
-            else if index == 4{
-                AssetsIndex = 2
-                 currentVc()?.tabBarController?.selectedIndex = TabbarAssetsIndex
-            }
-            else if index == 5{
-//                if self!.VM!.selectSymbolModel.isCollection {
-//                    self?.VM?.netDeleteProductUser(symbol: (self?.VM?.selectSymbolModel.symbol)!)
-//                }else{
-//                    self?.VM?.netInsertProductUser(symbol: (self?.VM?.selectSymbolModel.symbol)!)
-//                }
-            }
+           
+            
         }
     }
 }
@@ -687,10 +683,16 @@ extension DealView:UITableViewDelegate,UITableViewDataSource{
     func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
         if self.VM!.isChangeServer(){
             if section == 1 {
+                if self.sectionView.segmentedControl.selectedSegmentIndex == 2{
+                    return 80
+                }
                 return 40
             }
         }else{
             if section == 2 {
+                if self.sectionView.segmentedControl.selectedSegmentIndex == 2{
+                    return 80
+                }
                 return 40
             }
         }

+ 28 - 13
Koala/Koala/Modular/Deal/VM/DealViewModel.swift

@@ -92,6 +92,17 @@ class DealViewModel: BaseViewModel {
         }
     }
     
+    var startDate:String = dateToString(stmap: decimalNumber(A:currentTimeStamp(), B: "86400", type: .Subtract) , formatter: "yyyy-MM-dd"){
+        didSet{
+            self.netGetCloseOrderList()
+        }
+    }
+    var endDate:String = dateToString(stmap: currentTimeStamp(), formatter: "yyyy-MM-dd"){
+        didSet{
+            self.netGetCloseOrderList()
+        }
+    }
+    
     var symbols:[String] = []{
         didSet{
             netGetProductList()
@@ -111,7 +122,7 @@ class DealViewModel: BaseViewModel {
     var isSimpleness:Bool = true //是否
     var isSell:Bool = false //是否
     var isMarket:Bool = true //是否
-    var isShowKline:Bool = true //是否
+    var isShowKline:Bool = false //是否
     var isDayLimit:Bool = true //是否
     var num:String = "1"
     var profit:String = "0"
@@ -496,12 +507,12 @@ extension DealViewModel{
             observer.sendCompleted()
         }) { (code, result) in
             ProgressHUD.hideHud()
-            if code == 2007 {
-                observer.send(value: false)
-            }else{
-                ProgressHUD.showError(status: result as! String)
-            }
-            
+//            if code == 2007 {
+//                observer.send(value: false)
+//            }else{
+//                ProgressHUD.showError(status: result as! String)
+//            }
+            ProgressHUD.showError(status: result as! String)
             observer.sendCompleted()
         }
     }
@@ -533,11 +544,12 @@ extension DealViewModel{
             observer.sendCompleted()
         }) { (code, result) in
             ProgressHUD.hideHud()
-            if code == 2007 {
-                observer.send(value: false)
-            }else{
-                ProgressHUD.showError(status: result as! String)
-            }
+//            if code == 2007 {
+//                observer.send(value: false)
+//            }else{
+//                ProgressHUD.showError(status: result as! String)
+//            }
+            ProgressHUD.showError(status: result as! String)
             observer.sendCompleted()
         }
     }
@@ -634,8 +646,11 @@ extension DealViewModel{
     func requestGetCloseOrderList(observer: Signal< Bool, Never>.Observer) -> Void {
         ProgressHUD.showLoading()
         let param = [
+            "startDate":self.startDate,
+            "endDate":self.endDate,
             "account": self.accountInfoModel.account as Any,
-        ] as [String : Any]
+            "server": self.accountInfoModel.server as Any,
+        ]
         NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetCloseOrderList,parameters: param,success: { (code, result) in
             ProgressHUD.hideHud()
             if let dict:NSDictionary = result as? NSDictionary {

+ 21 - 0
Koala/Koala/Other/Assets.xcassets/Deal/Deal_W_Help.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "icon17.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
Koala/Koala/Other/Assets.xcassets/Deal/Deal_W_Help.imageset/icon17.png


+ 21 - 0
Koala/Koala/Other/Assets.xcassets/Deal/Deal_W_Lock.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "icon6.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
Koala/Koala/Other/Assets.xcassets/Deal/Deal_W_Lock.imageset/icon6.png


+ 21 - 0
Koala/Koala/Other/Assets.xcassets/Deal/Deal_W_Market.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "icon8.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
Koala/Koala/Other/Assets.xcassets/Deal/Deal_W_Market.imageset/icon8.png


+ 21 - 0
Koala/Koala/Other/Assets.xcassets/Deal/Deal_W_Set.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "icon7.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
Koala/Koala/Other/Assets.xcassets/Deal/Deal_W_Set.imageset/icon7.png