|
@@ -13,12 +13,39 @@ class JDTradeAccountDetailViewController: BaseViewController {
|
|
|
|
|
|
var accountModel : JDTradeAccountModel = JDTradeAccountModel()
|
|
|
|
|
|
+
|
|
|
+ var JXTableHeaderViewHeight: Int = 400
|
|
|
+ var JXheightForHeaderInSection: Int = 50
|
|
|
+
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
self.myNavigationBar.isHidden = true
|
|
|
self.setup()
|
|
|
}
|
|
|
|
|
|
+ lazy var holdVC : JDTradeAccountHoldViewController = {
|
|
|
+ let vc = JDTradeAccountHoldViewController()
|
|
|
+ vc.accountModel = self.accountModel
|
|
|
+ return vc
|
|
|
+
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var positionVC : JDTradeAccountPositionViewController = {
|
|
|
+
|
|
|
+ let vc = JDTradeAccountPositionViewController()
|
|
|
+ vc.accountModel = self.accountModel
|
|
|
+
|
|
|
+ return vc
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var historyVC : JDTradeAccountHistoryOrderViewController = {
|
|
|
+
|
|
|
+ let vc = JDTradeAccountHistoryOrderViewController()
|
|
|
+ vc.accountModel = self.accountModel
|
|
|
+ return vc
|
|
|
+ }()
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
lazy var accountHeaderView: JDTradeAccountInfoHeaderView = {
|
|
@@ -28,29 +55,24 @@ class JDTradeAccountDetailViewController: BaseViewController {
|
|
|
return v
|
|
|
}()
|
|
|
|
|
|
+ var pagingView: JXPagingView!
|
|
|
|
|
|
var segmentedDataSource: JXSegmentedBaseDataSource?
|
|
|
- let segmentedView = JXSegmentedView()
|
|
|
+ let segmentedView = JXSegmentedView(frame: CGRectMake(0, 0, 200, 50)) //JXSegmentedView()
|
|
|
|
|
|
|
|
|
- let titles = ["持仓","挂单","历史订单"]
|
|
|
-
|
|
|
- lazy var listContainerView: JXSegmentedListContainerView! = {
|
|
|
- return JXSegmentedListContainerView(dataSource: self)
|
|
|
- }()
|
|
|
+ let titles = [switchLanguage("持仓"),switchLanguage("挂单"),switchLanguage("历史订单")]
|
|
|
|
|
|
fileprivate func setup(){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
view.addSubview(accountHeaderView)
|
|
|
|
|
|
|
|
|
- listContainerView.frame = CGRect(x: 0, y: 450, width: view.bounds.size.width, height: view.bounds.size.height - 50 - 450 )
|
|
|
+// listContainerView.frame = CGRect(x: 0, y: 450, width: view.bounds.size.width, height: view.bounds.size.height - 50 - 450 )
|
|
|
|
|
|
let dataSource = JXSegmentedTitleDataSource()
|
|
|
dataSource.isTitleColorGradientEnabled = true
|
|
|
- dataSource.titleNormalColor = UIColor.pg_color(withHexString: "333333") //UIColor.init(hexString: "333333") ?? .black
|
|
|
+ dataSource.titleNormalColor = _color("#333333񑘕") //UIColor.init(hexString: "333333") ?? .black
|
|
|
dataSource.titleSelectedColor = .black//UIColor.pg_color(withHexString: "FF6F30") // UIColor.init(hexString: "DC3C23") ?? .black
|
|
|
dataSource.titleNormalFont = UIFont.systemFont(ofSize: 16)
|
|
|
dataSource.titleSelectedFont = UIFont.boldSystemFont(ofSize: 18)
|
|
@@ -58,86 +80,194 @@ class JDTradeAccountDetailViewController: BaseViewController {
|
|
|
dataSource.titles = titles
|
|
|
segmentedDataSource = dataSource
|
|
|
|
|
|
- //配置指示器
|
|
|
-// let indicator = JXSegmentedIndicatorLineView()
|
|
|
-// indicator.indicatorWidth = JXSegmentedViewAutomaticDimension
|
|
|
-//
|
|
|
-// indicator.indicatorColor = UIColor.pg_color(withHexString: "FF6F30") //UIColor.init(hexString: "DC3C23") ?? .black
|
|
|
-// segmentedView.indicators = [indicator]
|
|
|
-
|
|
|
segmentedView.dataSource = self.segmentedDataSource
|
|
|
|
|
|
- segmentedView.delegate = self
|
|
|
segmentedView.backgroundColor = .white //UIColor.init(hexString: "E5E5E5")
|
|
|
|
|
|
- view.addSubview(segmentedView)
|
|
|
- segmentedView.snp.makeConstraints { make in
|
|
|
- make.left.equalTo(self.view)
|
|
|
- make.width.equalTo(200)
|
|
|
- make.top.equalTo(self.accountHeaderView.snp.bottom)
|
|
|
- make.height.equalTo(50)
|
|
|
+
|
|
|
+ pagingView = JXPagingView(delegate: self)
|
|
|
+ self.view.addSubview(pagingView)
|
|
|
+ pagingView.snp.makeConstraints { make in
|
|
|
+ make.edges.equalTo(self.view)
|
|
|
}
|
|
|
|
|
|
- segmentedView.listContainer = listContainerView
|
|
|
- listContainerView.scrollView.isScrollEnabled = true
|
|
|
- view.addSubview(listContainerView)
|
|
|
+ segmentedView.listContainer = pagingView.listContainerView
|
|
|
+
|
|
|
+// view.addSubview(segmentedView)
|
|
|
+// segmentedView.snp.makeConstraints { make in
|
|
|
+// make.left.equalTo(self.view)
|
|
|
+// make.width.equalTo(200)
|
|
|
+// make.top.equalTo(self.accountHeaderView.snp.bottom)
|
|
|
+// make.height.equalTo(50)
|
|
|
+// }
|
|
|
+
|
|
|
+// segmentedView.listContainer = listContainerView
|
|
|
+// listContainerView.scrollView.isScrollEnabled = true
|
|
|
+// view.addSubview(listContainerView)
|
|
|
+//
|
|
|
+// segmentedView.reloadData()
|
|
|
|
|
|
- segmentedView.reloadData()
|
|
|
+ self.requestEntrustList()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-extension JDTradeAccountDetailViewController: JXSegmentedViewDelegate {
|
|
|
- public func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
|
|
|
- if let dotDataSource = segmentedDataSource as? JXSegmentedDotDataSource {
|
|
|
- //先更新数据源的数据
|
|
|
- dotDataSource.dotStates[index] = false
|
|
|
- //再调用reloadItem(at: index)
|
|
|
- segmentedView.reloadItem(at: index)
|
|
|
- }
|
|
|
+extension JDTradeAccountDetailViewController {
|
|
|
+
|
|
|
+
|
|
|
+ func requestEntrustList() ->Void {
|
|
|
+
|
|
|
|
|
|
- self.navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
|
|
|
+ let param = [
|
|
|
+ "account": self.accountModel.account ?? "" ,
|
|
|
+ "server" : self.accountModel.server ?? ""
|
|
|
+
|
|
|
+ ] as [String : Any]
|
|
|
+
|
|
|
+
|
|
|
+ NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetPositionList,parameters: param,success: { (code, result) in
|
|
|
+
|
|
|
+ ProgressHUD.hideHud()
|
|
|
+
|
|
|
+ if let dict: NSDictionary = result as? NSDictionary {
|
|
|
+
|
|
|
+ if let list: [NSDictionary] = dict["list"] as? [NSDictionary]{
|
|
|
+
|
|
|
+ var totalYk : CGFloat = 0.0
|
|
|
+ var totalSz : CGFloat = 0.0
|
|
|
+
|
|
|
+ for dic in list {
|
|
|
+
|
|
|
+ let model = JDPositionModel.deserialize(from: dic)!
|
|
|
+
|
|
|
+ let ykDecNumber: NSDecimalNumber = NSDecimalNumber.init(string: model.profit)
|
|
|
+ let ykNumber = ykDecNumber.doubleValue
|
|
|
+
|
|
|
+ totalYk += ykNumber
|
|
|
+
|
|
|
+
|
|
|
+ let szDecNumber: NSDecimalNumber = NSDecimalNumber.init(string: model.close_price)
|
|
|
+ let szNumber = szDecNumber.doubleValue
|
|
|
+
|
|
|
+ totalSz += szNumber
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ self.accountHeaderView.ykLb.text = precisionString(with: "\(totalYk)", precision: "2")
|
|
|
+ self.accountHeaderView.szLb.text = precisionString(with: "\(totalSz)", precision: "2")
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }) { (code, result) in
|
|
|
+ ProgressHUD.showError(status: result as! String)
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-extension JDTradeAccountDetailViewController: JXSegmentedListContainerViewDataSource {
|
|
|
- public func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
|
|
|
- if let titleDataSource = segmentedView.dataSource as? JXSegmentedBaseDataSource {
|
|
|
- return titleDataSource.dataSource.count
|
|
|
- }
|
|
|
- return 0 //titles.count
|
|
|
+extension JDTradeAccountDetailViewController : JXPagingViewDelegate {
|
|
|
+ func tableHeaderViewHeight(in pagingView: JXPagingView) -> Int {
|
|
|
+ return JXTableHeaderViewHeight
|
|
|
}
|
|
|
|
|
|
- public func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
|
|
|
+ func tableHeaderView(in pagingView: JXPagingView) -> UIView {
|
|
|
+ return self.accountHeaderView
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ func heightForPinSectionHeader(in pagingView: JXPagingView) -> Int {
|
|
|
+ return JXheightForHeaderInSection
|
|
|
+ }
|
|
|
+
|
|
|
+ func viewForPinSectionHeader(in pagingView: JXPagingView) -> UIView {
|
|
|
+ let v = UIView(frame: CGRectMake(0, 0, SCREEN_WIDTH, 50))
|
|
|
+ v.addSubview(segmentedView)
|
|
|
+
|
|
|
+ return v
|
|
|
+ }
|
|
|
+
|
|
|
+ func numberOfLists(in pagingView: JXPagingView) -> Int {
|
|
|
+ return titles.count
|
|
|
+ }
|
|
|
+
|
|
|
+ func pagingView(_ pagingView: JXPagingView, initListAtIndex index: Int) -> JXPagingViewListViewDelegate {
|
|
|
|
|
|
if index == 0 {
|
|
|
-
|
|
|
- let vc = JDTradeAccountHoldViewController()
|
|
|
- vc.accountModel = self.accountModel
|
|
|
- return vc
|
|
|
-
|
|
|
+ return holdVC
|
|
|
} else if index == 1 {
|
|
|
-
|
|
|
- let vc = JDTradeAccountPositionViewController()
|
|
|
- vc.accountModel = self.accountModel
|
|
|
- return vc
|
|
|
-
|
|
|
+ return positionVC
|
|
|
}else {
|
|
|
-
|
|
|
- let vc = JDTradeAccountHistoryOrderViewController()
|
|
|
- vc.accountModel = self.accountModel
|
|
|
-
|
|
|
- return vc
|
|
|
-
|
|
|
+ return historyVC
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ func pagingView(_ pagingView: JXPagingView, mainTableViewDidScroll scrollView: UIScrollView) {
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+extension JXPagingListContainerView : JXSegmentedViewListContainer{}
|
|
|
+
|
|
|
+//
|
|
|
+//extension JDTradeAccountDetailViewController: JXSegmentedViewDelegate {
|
|
|
+// public func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
|
|
|
+// if let dotDataSource = segmentedDataSource as? JXSegmentedDotDataSource {
|
|
|
+// //先更新数据源的数据
|
|
|
+// dotDataSource.dotStates[index] = false
|
|
|
+// //再调用reloadItem(at: index)
|
|
|
+// segmentedView.reloadItem(at: index)
|
|
|
+// }
|
|
|
+//
|
|
|
+// self.navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
|
|
|
+//
|
|
|
+// }
|
|
|
+//}
|
|
|
+
|
|
|
+
|
|
|
+//extension JDTradeAccountDetailViewController: JXSegmentedListContainerViewDataSource {
|
|
|
+// public func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
|
|
|
+// if let titleDataSource = segmentedView.dataSource as? JXSegmentedBaseDataSource {
|
|
|
+// return titleDataSource.dataSource.count
|
|
|
+// }
|
|
|
+// return 0 //titles.count
|
|
|
+// }
|
|
|
+//
|
|
|
+// public func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
|
|
|
+//
|
|
|
+// if index == 0 {
|
|
|
+//
|
|
|
+// let vc = JDTradeAccountHoldViewController()
|
|
|
+// vc.accountModel = self.accountModel
|
|
|
+// return vc
|
|
|
+//
|
|
|
+// } else if index == 1 {
|
|
|
+//
|
|
|
+// let vc = JDTradeAccountPositionViewController()
|
|
|
+// vc.accountModel = self.accountModel
|
|
|
+// return vc
|
|
|
+//
|
|
|
+// }else {
|
|
|
+//
|
|
|
+// let vc = JDTradeAccountHistoryOrderViewController()
|
|
|
+// vc.accountModel = self.accountModel
|
|
|
+//
|
|
|
+// return vc
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//}
|
|
|
+
|
|
|
extension JDTradeAccountDetailViewController: JXSegmentedListContainerViewListDelegate {
|
|
|
func listView() -> UIView {
|
|
|
return view
|