Kaynağa Gözat

交易优化

刘千军 10 ay önce
ebeveyn
işleme
6368f1decc

+ 115 - 5
Koala/Koala/Modular/Deal/V/Deal/DealView.swift

@@ -27,8 +27,11 @@ class DealView: BaseView {
         view.clickProBlock = {[weak self] btn in
             self?.VM?.isSimpleness = !self!.VM!.isSimpleness
             self?.navView.updateProBtn(isPro: self!.VM!.isSimpleness)
-            self?.VM?.isShowKline = true
-            self?.reloadTable()
+            if self!.VM!.isSimpleness {
+                self?.VM?.netGetSimPriceList()
+            }else{
+                self?.VM?.netGetPriceList()
+            }
         }
         return view
     }()
@@ -45,7 +48,7 @@ class DealView: BaseView {
             }
             
             pop.showPopupView(source: self.VM!.accountList) {index  in
-                if index > 0{
+                if index >= 0{
                     self.VM!.accountInfoModel = self.VM!.accountList[index]
                     self.topView.updateViewDataWith(model: self.VM!.accountInfoModel)
                     self.reloadTable()
@@ -264,7 +267,6 @@ class DealView: BaseView {
         VM?.getPriceListAction.values.observeValues({[weak self] (success) in
             guard let self = self else { return }
             if success {
-                self.VM?.isUpdateKline = true
                 self.reloadTable()
             }
         })
@@ -715,7 +717,115 @@ extension DealView:UITableViewDelegate,UITableViewDataSource{
     }
     
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-       
+        
+        if self.VM!.isChangeServer(){
+            if indexPath.section < 1  {
+                return
+            }
+        }else{
+            if indexPath.section < 2{
+                return
+            }
+        }
+        
+    
+        let accountModel:JDTradeAccountModel = JDTradeAccountModel.deserialize(from: self.VM?.accountInfoModel.toJSON())!
+        
+        if self.sectionView.segmentedControl.selectedSegmentIndex == 0{
+            let m = self.VM!.positionList[indexPath.row]
+            let model:JDPositionModel = JDPositionModel.deserialize(from:m.toJSON())!
+            let pop = JDTradeHoldAlertView()
+            pop.showPopupView(model: model, type: 0 ) { index in
+                if index == 1 {
+                    let closePop = JDClosePositionAlertView()
+                    closePop.showPopupView(model: model, accountModel: accountModel,deleteType: 0) { index in
+                        self.VM?.netOpenPosition()
+                    }
+                    
+                }else if index == 2{
+      
+                    let modifyPop = JDPositionModifyAlertView()
+                    modifyPop.showPopupView(model: model,accountModel: accountModel,modifyType: 0) { index in
+                        self.VM?.netOpenPosition()
+                    }
+                    
+                }else if index == 3 {
+                    if self.VM!.isChangeServer(){
+                        self.VM?.server = accountModel.server
+                    }
+                    self.VM?.updateSymbols(symbol: model.symbol)
+                    pop.dismissAlert()
+                    
+                }else{
+                    let vc = MarketDetailViewController()
+                    vc.symbolModel = m.SymbolModel
+                    currentVc()?.navigationController?.pushViewController(vc, animated: true)
+                    pop.dismissAlert()
+                }
+                
+            }
+        }
+        else if self.sectionView.segmentedControl.selectedSegmentIndex == 1{
+            let m = self.VM!.entrustList[indexPath.row]
+            let model:JDPositionModel = JDPositionModel.deserialize(from:m.toJSON())!
+            let pop = JDTradeHoldAlertView()
+            pop.showPopupView(model: model, type: 1 ) { index in
+                if index == 1 {
+                    let closePop = JDClosePositionAlertView()
+                    closePop.showPopupView(model: model, accountModel: accountModel,deleteType: 0) { index in
+                        self.VM?.netGetEntrustList()
+                    }
+                    
+                }else if index == 2{
+                    if self.VM!.isChangeServer(){
+                        self.VM?.server = accountModel.server
+                    }
+                    self.VM?.updateSymbols(symbol: model.symbol)
+                    pop.dismissAlert()
+                    
+                }else if index == 3 {
+                    let vc = MarketDetailViewController()
+                    vc.symbolModel = m.SymbolModel
+                    currentVc()?.navigationController?.pushViewController(vc, animated: true)
+                    pop.dismissAlert()
+                    
+                }else{
+                   
+                    let closePop = JDClosePositionAlertView()
+                    
+                    closePop.showPopupView(model: model,accountModel: accountModel,deleteType: 1) { index in
+                        self.VM?.netGetEntrustList()
+                    }
+                }
+                
+            }
+            
+        }else {
+            let m = self.VM!.closeOrderList[indexPath.row]
+            let model:JDPositionModel = JDPositionModel.deserialize(from:m.toJSON())!
+            let pop = JDTradeHoldAlertView()
+            pop.showPopupView(model: model, type: 2 ) { index in
+                
+                if index == 1{
+                    if self.VM!.isChangeServer(){
+                        self.VM?.server = accountModel.server
+                    }
+                    self.VM?.updateSymbols(symbol: model.symbol)
+                    pop.dismissAlert()
+                    
+                }else if index == 2{
+                    let vc = MarketDetailViewController()
+                    
+                    let symbolModel = KSymbolModel()
+                    vc.symbolModel = m.SymbolModel
+                    currentVc()?.navigationController?.pushViewController(vc, animated: true)
+                    pop.dismissAlert()
+                }
+                
+            }
+        }
+        
+      
        
     }
     

+ 15 - 11
Koala/Koala/Modular/Deal/VM/DealViewModel.swift

@@ -74,9 +74,13 @@ class DealViewModel: BaseViewModel {
     var selectSymbolModel:KSymbolModel = KSymbolModel(){
         didSet{
             self.netGetPriceDepth()
-            self.netGetSimPriceList()
             self.netGetTradesList()
-            self.netGetPriceList()
+            if self.isSimpleness {
+                self.netGetSimPriceList()
+            }else{
+                self.netGetPriceList()
+            }
+          
             self.updatePositionList()
             self.updateEntrustList()
             self.updateCloseOrderList()
@@ -414,13 +418,13 @@ extension DealViewModel{
         let endDate:String = currentTimeStamp()
         let p = KLinePeriod.minuteFor(kPeriod: KLinePeriod.getDefaultKLinePeriod())
         let startDate:String = String(format:"%d",conerData(currentTimeStamp(), .MyCLong).3! - 200*p*60)
-        
         let param = [
             "symbol":self.selectSymbolModel.symbol,
             "type":period,
             "startTime":startDate+"000",
-            "endTime":endDate+"000"
-        ]
+            "endTime":endDate+"000",
+            "count": 100
+        ] as [String : Any]
         ProgressHUD.showLoading()
         NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetPriceList,parameters:param , success: { (code, result) in
             ProgressHUD.hideHud()
@@ -713,14 +717,14 @@ extension DealViewModel{
     }
     
     func updateSymbols(symbol:String) -> Void {
-      
-        for (i,str) in self.symbols.enumerated(){
-            if symbol == str{
-                self.symbols.remove(at: i)
-                break
+        var arr:[String] = [String]()
+        for str in self.symbols{
+            if symbol != str{
+                arr.append(str)
             }
         }
-        self.symbols.append(symbol)
+        arr.append(symbol);
+        self.symbols = arr
     }
     
     func updatePositionList() -> Void {

+ 35 - 23
Koala/Koala/Modular/Market/V/MarketDetailView/MDAuoteView/MDAuoteDepthCell.xib

@@ -110,42 +110,54 @@
                                     <constraint firstItem="1T7-4c-odo" firstAttribute="trailing" secondItem="aPt-pp-Jrn" secondAttribute="trailing" id="vUs-vY-XcJ"/>
                                 </constraints>
                             </view>
-                            <stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yfI-Vy-nyJ">
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Htm-P6-py7">
                                 <rect key="frame" x="0.0" y="100" width="439" height="129"/>
                                 <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="Daf-rz-p6j">
-                                        <rect key="frame" x="0.0" y="0.0" width="217" height="129"/>
-                                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
-                                    </tableView>
-                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Lak-Ia-9jQ">
-                                        <rect key="frame" x="217" y="0.0" width="5" height="129"/>
+                                    <stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yfI-Vy-nyJ">
+                                        <rect key="frame" x="15" y="0.0" width="409" height="129"/>
                                         <subviews>
-                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="avr-Ft-KX2">
-                                                <rect key="frame" x="2" y="10" width="1" height="109"/>
+                                            <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="Daf-rz-p6j">
+                                                <rect key="frame" x="0.0" y="0.0" width="202" height="129"/>
+                                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                            </tableView>
+                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Lak-Ia-9jQ">
+                                                <rect key="frame" x="202" y="0.0" width="5" height="129"/>
+                                                <subviews>
+                                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="avr-Ft-KX2">
+                                                        <rect key="frame" x="2" y="10" width="1" height="109"/>
+                                                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="width" constant="1" id="8M5-wK-HM3"/>
+                                                        </constraints>
+                                                    </view>
+                                                </subviews>
                                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                                 <constraints>
-                                                    <constraint firstAttribute="width" constant="1" id="8M5-wK-HM3"/>
+                                                    <constraint firstAttribute="width" constant="5" id="0o4-Se-i10"/>
+                                                    <constraint firstItem="avr-Ft-KX2" firstAttribute="top" secondItem="Lak-Ia-9jQ" secondAttribute="top" constant="10" id="2Tr-fH-Gc7"/>
+                                                    <constraint firstItem="avr-Ft-KX2" firstAttribute="centerX" secondItem="Lak-Ia-9jQ" secondAttribute="centerX" id="8Db-OS-fNq"/>
+                                                    <constraint firstItem="avr-Ft-KX2" firstAttribute="centerY" secondItem="Lak-Ia-9jQ" secondAttribute="centerY" id="AXc-xl-ejU"/>
+                                                    <constraint firstAttribute="bottom" secondItem="avr-Ft-KX2" secondAttribute="bottom" constant="10" id="GCa-d4-Cc1"/>
                                                 </constraints>
                                             </view>
+                                            <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="BU0-qH-jzA">
+                                                <rect key="frame" x="207" y="0.0" width="202" height="129"/>
+                                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                            </tableView>
                                         </subviews>
-                                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                         <constraints>
-                                            <constraint firstAttribute="width" constant="5" id="0o4-Se-i10"/>
-                                            <constraint firstItem="avr-Ft-KX2" firstAttribute="top" secondItem="Lak-Ia-9jQ" secondAttribute="top" constant="10" id="2Tr-fH-Gc7"/>
-                                            <constraint firstItem="avr-Ft-KX2" firstAttribute="centerX" secondItem="Lak-Ia-9jQ" secondAttribute="centerX" id="8Db-OS-fNq"/>
-                                            <constraint firstItem="avr-Ft-KX2" firstAttribute="centerY" secondItem="Lak-Ia-9jQ" secondAttribute="centerY" id="AXc-xl-ejU"/>
-                                            <constraint firstAttribute="bottom" secondItem="avr-Ft-KX2" secondAttribute="bottom" constant="10" id="GCa-d4-Cc1"/>
+                                            <constraint firstItem="BU0-qH-jzA" firstAttribute="width" secondItem="Daf-rz-p6j" secondAttribute="width" id="4hY-3W-Lzp"/>
                                         </constraints>
-                                    </view>
-                                    <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="BU0-qH-jzA">
-                                        <rect key="frame" x="222" y="0.0" width="217" height="129"/>
-                                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
-                                    </tableView>
+                                    </stackView>
                                 </subviews>
+                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                 <constraints>
-                                    <constraint firstItem="BU0-qH-jzA" firstAttribute="width" secondItem="Daf-rz-p6j" secondAttribute="width" id="4hY-3W-Lzp"/>
+                                    <constraint firstAttribute="bottom" secondItem="yfI-Vy-nyJ" secondAttribute="bottom" id="3Fk-dY-F5U"/>
+                                    <constraint firstItem="yfI-Vy-nyJ" firstAttribute="leading" secondItem="Htm-P6-py7" secondAttribute="leading" constant="15" id="NR2-fH-IEf"/>
+                                    <constraint firstAttribute="trailing" secondItem="yfI-Vy-nyJ" secondAttribute="trailing" constant="15" id="ZiP-W6-vdF"/>
+                                    <constraint firstItem="yfI-Vy-nyJ" firstAttribute="top" secondItem="Htm-P6-py7" secondAttribute="top" id="uPU-7a-tck"/>
                                 </constraints>
-                            </stackView>
+                            </view>
                         </subviews>
                     </stackView>
                 </subviews>

+ 4 - 3
Koala/Koala/Modular/Market/V/MarketDetailView/MDAuoteView/MDAuoteDepthListCell.swift

@@ -42,8 +42,9 @@ class MDAuoteDepthListCell: BaseTableViewCell {
         // Configure the view for the selected state
     }
     
+    
     func updatePlan(plan:CGFloat) -> Void {
-        self.planWidthConstraint.constant = self.planBgView.frame.size.width * plan
+        self.planWidthConstraint.constant = (SCREEN_WIDTH-30-40-5)/2 * plan
     }
     
     func updateBuyCellWith(model:AsksOrBidsModel,digits:Int,plan:CGFloat,width:CGFloat,num:Int) -> Void {
@@ -55,7 +56,7 @@ class MDAuoteDepthListCell: BaseTableViewCell {
         
         self.updatePlan(plan: plan)
         
-        self.planView.backgroundColor = exchangeColorAndImage(increase: 1).0
+        self.planView.backgroundColor = exchangeColorAndImage(increase: 1).2
         self.numBtn.backgroundColor = exchangeColorAndImage(increase: 1).0
         self.priceLab.textColor = exchangeColorAndImage(increase: 1).0
         
@@ -71,7 +72,7 @@ class MDAuoteDepthListCell: BaseTableViewCell {
         
         self.updatePlan(plan: plan)
         
-        self.planView.backgroundColor = exchangeColorAndImage(increase: -1).0
+        self.planView.backgroundColor = exchangeColorAndImage(increase: -1).2
         self.numBtn.backgroundColor = exchangeColorAndImage(increase: -1).0
         self.priceLab.textColor = exchangeColorAndImage(increase: -1).0
         

+ 7 - 7
Koala/Koala/Modular/Market/V/MarketDetailView/MDAuoteView/MDAuoteDepthListCell.xib

@@ -26,10 +26,10 @@
                         <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
                     </button>
                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QfZ-qj-FSN">
-                        <rect key="frame" x="66.333333333333343" y="23.666666666666668" width="305.66666666666663" height="10.000000000000004"/>
+                        <rect key="frame" x="20" y="0.0" width="407" height="57"/>
                         <subviews>
-                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2lw-Fs-dxa">
-                                <rect key="frame" x="0.0" y="0.0" width="100" height="10"/>
+                            <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2lw-Fs-dxa">
+                                <rect key="frame" x="0.0" y="0.0" width="100" height="57"/>
                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="100" id="8d6-KX-dqn"/>
@@ -39,9 +39,7 @@
                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
                             <constraint firstAttribute="bottom" secondItem="2lw-Fs-dxa" secondAttribute="bottom" id="3nC-p5-ZvK"/>
-                            <constraint firstItem="2lw-Fs-dxa" firstAttribute="leading" secondItem="QfZ-qj-FSN" secondAttribute="leading" id="Iwy-sY-XXu"/>
                             <constraint firstItem="2lw-Fs-dxa" firstAttribute="top" secondItem="QfZ-qj-FSN" secondAttribute="top" id="Ro9-lh-4ag"/>
-                            <constraint firstAttribute="height" constant="10" id="Yy0-hb-VtT"/>
                         </constraints>
                     </view>
                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="d39-yE-fcD">
@@ -61,15 +59,17 @@
                     </label>
                 </subviews>
                 <constraints>
-                    <constraint firstItem="d39-yE-fcD" firstAttribute="leading" secondItem="QfZ-qj-FSN" secondAttribute="trailing" constant="5" id="9hl-s8-yCi"/>
+                    <constraint firstAttribute="bottom" secondItem="QfZ-qj-FSN" secondAttribute="bottom" id="0GZ-Bh-bXu"/>
+                    <constraint firstAttribute="trailing" secondItem="QfZ-qj-FSN" secondAttribute="trailing" id="5Fg-V1-BT1"/>
                     <constraint firstItem="Jur-eC-MpO" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="FSu-wv-Yl1"/>
+                    <constraint firstItem="QfZ-qj-FSN" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="Gsi-hz-SJP"/>
                     <constraint firstItem="Jur-eC-MpO" firstAttribute="leading" secondItem="fo8-x6-DN0" secondAttribute="trailing" constant="5" id="O7p-em-raQ"/>
                     <constraint firstItem="d39-yE-fcD" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="PNf-On-7IL"/>
                     <constraint firstItem="fo8-x6-DN0" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="TZK-Ye-7i7"/>
                     <constraint firstItem="QfZ-qj-FSN" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="Zll-Ib-y0j"/>
                     <constraint firstAttribute="trailing" secondItem="d39-yE-fcD" secondAttribute="trailing" id="ahk-MP-pNZ"/>
                     <constraint firstItem="fo8-x6-DN0" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="mow-Um-oez"/>
-                    <constraint firstItem="QfZ-qj-FSN" firstAttribute="leading" secondItem="Jur-eC-MpO" secondAttribute="trailing" constant="5" id="wj5-Ab-nBz"/>
+                    <constraint firstItem="QfZ-qj-FSN" firstAttribute="leading" secondItem="fo8-x6-DN0" secondAttribute="trailing" constant="5" id="o0y-5k-kaB"/>
                 </constraints>
             </tableViewCellContentView>
             <viewLayoutGuide key="safeArea" id="njF-e1-oar"/>

+ 15 - 0
Koala/Koala/Modular/Market/VM/MDAuoteViewModel.swift

@@ -62,6 +62,7 @@ class MDAuoteViewModel: BaseViewModel {
 extension MDAuoteViewModel {
     //获取行情数据
     func netGetPriceList() {
+        requestUpdateSubscribeAction()
         getPriceListAction.apply().start()
     }
     //获取行情数据
@@ -158,6 +159,20 @@ extension MDAuoteViewModel {
     }
     
     
+    func requestUpdateSubscribeAction() -> Void  {
+        let parame:[String:Any] = [
+            "symbols":getJSONStringFromArray(array:[self.symbolModel.symbol])
+        ]
+        NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netUpdateSubscribe, parameters: parame) { (code, result) in
+           
+          
+            
+        } failured: {  (code, result) in
+          
+    
+        }
+    }
+    
     
    
 }