|
@@ -15,6 +15,23 @@ class JDTradeAccountHistoryOrderViewController: BaseViewController {
|
|
|
|
|
|
var accountModel : JDTradeAccountModel?
|
|
|
var dateStr:(String,String) = ("","")
|
|
|
+
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ lazy var orderList:[JDPositionModel] = {
|
|
|
+ let arr:[JDPositionModel] = [JDPositionModel]()
|
|
|
+ return arr
|
|
|
+ }()
|
|
|
+
|
|
|
lazy var tableView : UITableView = {
|
|
|
|
|
|
let v = UITableView(frame: .zero, style: .plain)
|
|
@@ -28,6 +45,21 @@ class JDTradeAccountHistoryOrderViewController: BaseViewController {
|
|
|
|
|
|
}()
|
|
|
|
|
|
+ lazy var totalLrLb : UILabel = {
|
|
|
+ let v = UILabel()
|
|
|
+ v.setTextFont(.PFSR, 15)
|
|
|
+ v.textColor = _color("#333333񑘕")
|
|
|
+ v.text = "0"
|
|
|
+ return v
|
|
|
+ }()
|
|
|
+ lazy var totalJyLb : UILabel = {
|
|
|
+ let v = UILabel()
|
|
|
+ v.setTextFont(.PFSR, 15)
|
|
|
+ v.textColor = _color("#333333񑘕")
|
|
|
+ v.text = "0"
|
|
|
+ return v
|
|
|
+ }()
|
|
|
+
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
|
|
@@ -41,41 +73,47 @@ class JDTradeAccountHistoryOrderViewController: BaseViewController {
|
|
|
make.edges.equalTo(self.view)
|
|
|
}
|
|
|
|
|
|
- self.requestEntrustList()
|
|
|
+ self.netGetCloseOrderList()
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
extension JDTradeAccountHistoryOrderViewController {
|
|
|
|
|
|
- func requestEntrustList() ->Void {
|
|
|
+ func netGetCloseOrderList() ->Void {
|
|
|
|
|
|
|
|
|
let param = [
|
|
|
+
|
|
|
+ "pageNum" : "1",
|
|
|
+ "startDate" : self.startDate,
|
|
|
+ "endDate" : self.endDate,
|
|
|
"account": self.accountModel?.account ?? "" ,
|
|
|
"server" : self.accountModel?.server ?? ""
|
|
|
|
|
|
] as [String : Any]
|
|
|
|
|
|
|
|
|
- NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetEntrustList,parameters: param,success: { (code, result) in
|
|
|
-
|
|
|
+ NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetCloseOrderList,parameters: param,success: { (code, result) in
|
|
|
+
|
|
|
ProgressHUD.hideHud()
|
|
|
-// if let dict:NSDictionary = result as? NSDictionary {
|
|
|
-// if let list:[NSDictionary] = dict["list"] as? [NSDictionary]{
|
|
|
-// self.entrustList.removeAll()
|
|
|
-// for dic in list {
|
|
|
-// let model = EntrustListModel.deserialize(from: dic)!
|
|
|
-// self.entrustList.append(model)
|
|
|
-// }
|
|
|
-// observer.send(value: true)
|
|
|
-// }else{
|
|
|
-// observer.send(value: false)
|
|
|
-// }
|
|
|
-// }else{
|
|
|
-// observer.send(value: false)
|
|
|
-// }
|
|
|
-// observer.sendCompleted()
|
|
|
+
|
|
|
+ if let dict: NSDictionary = result as? NSDictionary {
|
|
|
+
|
|
|
+ if let list: [NSDictionary] = dict["list"] as? [NSDictionary]{
|
|
|
+ self.orderList.removeAll()
|
|
|
+
|
|
|
+ for dic in list {
|
|
|
+
|
|
|
+ let model = JDPositionModel.deserialize(from: dic)!
|
|
|
+
|
|
|
+ self.orderList.append(model)
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ self.tableView.reloadData()
|
|
|
+ }
|
|
|
}) { (code, result) in
|
|
|
ProgressHUD.showError(status: result as! String)
|
|
|
}
|
|
@@ -100,13 +138,15 @@ extension JDTradeAccountHistoryOrderViewController: UITableViewDelegate,UITableV
|
|
|
dateView.segmentedControl.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")
|
|
|
+ self.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")
|
|
|
+ self.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")
|
|
|
+ self.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 {
|
|
@@ -115,11 +155,14 @@ extension JDTradeAccountHistoryOrderViewController: UITableViewDelegate,UITableV
|
|
|
}
|
|
|
pop.showPopupView(date: self.dateStr) { dateStr in
|
|
|
self.dateStr = dateStr
|
|
|
-// self.VM?.endDate = dateStr.1
|
|
|
-// self.VM?.startDate = dateStr.0
|
|
|
+ self.endDate = dateStr.1
|
|
|
+ self.startDate = dateStr.0
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ self.netGetCloseOrderList()
|
|
|
+
|
|
|
}
|
|
|
headerView.addSubview(dateView)
|
|
|
|
|
@@ -177,12 +220,76 @@ extension JDTradeAccountHistoryOrderViewController: UITableViewDelegate,UITableV
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
|
|
|
- return 54
|
|
|
+ return 54 + 80
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
|
|
|
|
|
|
- let v = UIView(frame: CGRectMake(0, 0, SCREEN_WIDTH, 54))
|
|
|
+ let v = UIView(frame: CGRectMake(0, 0, SCREEN_WIDTH, 54 + 80))
|
|
|
+
|
|
|
+ let lrView = UIView()
|
|
|
+ v.addSubview(lrView)
|
|
|
+ lrView.snp.makeConstraints { make in
|
|
|
+ make.left.top.right.equalTo(v)
|
|
|
+ make.height.equalTo(40)
|
|
|
+ }
|
|
|
+
|
|
|
+ let lrLb = UILabel()
|
|
|
+ lrLb.setTextFont(.PFSR, 15)
|
|
|
+ lrLb.textColor = _color("#7C7C7CC7C7C")
|
|
|
+ lrLb.text = switchLanguage("利润")
|
|
|
+
|
|
|
+ lrView.addSubview(lrLb)
|
|
|
+ lrLb.snp.makeConstraints { make in
|
|
|
+ make.centerY.equalTo(lrView)
|
|
|
+ make.left.equalTo(lrView.snp.left).offset(17)
|
|
|
+ }
|
|
|
+
|
|
|
+ lrView.addSubview(totalLrLb)
|
|
|
+ totalLrLb.snp.makeConstraints { make in
|
|
|
+ make.centerY.equalTo(lrView)
|
|
|
+ make.right.equalTo(lrView.snp.right).offset(-17)
|
|
|
+ }
|
|
|
+
|
|
|
+ let lineView = UIView()
|
|
|
+
|
|
|
+ lineView.backgroundColor = _color("#F0F0F0&#F0F0F0")
|
|
|
+ v.addSubview(lineView)
|
|
|
+ lineView.snp.makeConstraints { make in
|
|
|
+ make.left.right.equalTo(v)
|
|
|
+ make.top.equalTo(lrView.snp.bottom)
|
|
|
+ make.height.equalTo(1)
|
|
|
+ }
|
|
|
+
|
|
|
+ let jyView = UIView()
|
|
|
+ v.addSubview(jyView)
|
|
|
+ jyView.snp.makeConstraints { make in
|
|
|
+ make.top.equalTo(lineView.snp.bottom)
|
|
|
+ make.left.right.equalTo(v)
|
|
|
+ make.height.equalTo(40)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let jyLb = UILabel()
|
|
|
+ jyLb.setTextFont(.PFSR, 15)
|
|
|
+ jyLb.textColor = _color("#7C7C7CC7C7C")
|
|
|
+ jyLb.text = switchLanguage("结余")
|
|
|
+
|
|
|
+ jyView.addSubview(jyLb)
|
|
|
+ jyLb.snp.makeConstraints { make in
|
|
|
+ make.centerY.equalTo(jyView)
|
|
|
+ make.left.equalTo(jyView.snp.left).offset(17)
|
|
|
+ }
|
|
|
+
|
|
|
+ jyView.addSubview(totalJyLb)
|
|
|
+ totalJyLb.snp.makeConstraints { make in
|
|
|
+ make.centerY.equalTo(jyView)
|
|
|
+ make.right.equalTo(jyView.snp.right).offset(-17)
|
|
|
+ }
|
|
|
+
|
|
|
+ totalJyLb.text = precisionString(with: self.accountModel?.balance ?? "0.00", precision: "2")
|
|
|
+
|
|
|
let tipLb = UILabel()
|
|
|
tipLb.font = .systemFont(ofSize: 12)
|
|
|
tipLb.textColor = UIColor.pg_color(withHexString: "B1B9C1")
|
|
@@ -190,42 +297,27 @@ extension JDTradeAccountHistoryOrderViewController: UITableViewDelegate,UITableV
|
|
|
tipLb.textAlignment = .center
|
|
|
v.addSubview(tipLb)
|
|
|
tipLb.snp.makeConstraints { make in
|
|
|
- make.center.equalTo(v)
|
|
|
+ make.top.equalTo(jyView.snp.bottom).offset(15)
|
|
|
+ make.centerX.equalTo(v)
|
|
|
}
|
|
|
return v
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
- 1
|
|
|
+ return orderList.count
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
-// let cell:DealListCell = tableView.dequeueReusableCell(withIdentifier: "DealListCell") as! DealListCell
|
|
|
-// if self.headerView.segmentedControl.selectedSegmentIndex == 0 {
|
|
|
-// let model = self.VM?.positionList[indexPath.row]
|
|
|
-// cell.updatePositionCellWith(model: model!)
|
|
|
-// }
|
|
|
-// else if self.headerView.segmentedControl.selectedSegmentIndex == 1{
|
|
|
-// let model = self.VM?.entrustList[indexPath.row]
|
|
|
-// cell.updateEntrustCellWith(model: model!)
|
|
|
-// }else{
|
|
|
-// let model = self.VM?.closeOrderList[indexPath.row]
|
|
|
-// cell.updateCloseOrderCellWith(model: model!)
|
|
|
-// }
|
|
|
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: JDTradeDealListCell.description()) as! JDTradeDealListCell
|
|
|
-
|
|
|
+ cell.setupCellByPositionModel(model: self.orderList[indexPath.row])
|
|
|
return cell
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
|
return 62
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
extension JDTradeAccountHistoryOrderViewController: JXSegmentedListContainerViewListDelegate {
|