|
@@ -20,6 +20,11 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
20
|
20
|
setUpUI()
|
21
|
21
|
}
|
22
|
22
|
|
|
23
|
+ override func viewDidAppear(_ animated: Bool) {
|
|
24
|
+ super.viewDidAppear(animated)
|
|
25
|
+ tableView.mj_header.beginRefreshing()
|
|
26
|
+ }
|
|
27
|
+
|
23
|
28
|
override func setUpUI() {
|
24
|
29
|
name = "订单"
|
25
|
30
|
view.addSubview(segView)
|
|
@@ -31,10 +36,28 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
31
|
36
|
seg.frame = CGRect.init(x: 12, y: 0, width: SCREEN_WIDTH-24, height: Fitesize(48))
|
32
|
37
|
seg.layer.cornerRadius = 8
|
33
|
38
|
seg.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.init(name: "PingFangSC-Light", size: Fitesize(17))!], for: .normal)
|
34
|
|
- seg.tintColor = UIColor.base()
|
|
39
|
+ seg.tintColor = UIColor.kxColor(withHex: 0xAD63FF)
|
|
40
|
+ seg.addTarget(self, action: #selector(segViewClick(sender:)), for: UIControl.Event.valueChanged)
|
|
41
|
+ seg.selectedSegmentIndex = 0
|
35
|
42
|
return seg
|
36
|
43
|
}()
|
37
|
44
|
|
|
45
|
+ @objc func segViewClick(sender: UISegmentedControl) -> Void {
|
|
46
|
+ switch sender.selectedSegmentIndex {
|
|
47
|
+ case 0:
|
|
48
|
+ module = "phone"
|
|
49
|
+ tableView.mj_header.beginRefreshing()
|
|
50
|
+ case 1:
|
|
51
|
+ module = "pad"
|
|
52
|
+ tableView.mj_header.beginRefreshing()
|
|
53
|
+ case 2:
|
|
54
|
+ module = "computer"
|
|
55
|
+ tableView.mj_header.beginRefreshing()
|
|
56
|
+ default:
|
|
57
|
+ break
|
|
58
|
+ }
|
|
59
|
+ }
|
|
60
|
+
|
38
|
61
|
lazy var tableView: UITableView = {
|
39
|
62
|
let table: UITableView = UITableView.init(frame: CGRect.init(x: 12, y: Fitesize(48), width: SCREEN_WIDTH-24, height: SCREEN_HEIGHT-NavHeight-Fitesize(48)), style: .grouped)
|
40
|
63
|
table.showsVerticalScrollIndicator = false
|
|
@@ -47,9 +70,32 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
47
|
70
|
table.estimatedSectionHeaderHeight = 0
|
48
|
71
|
table.estimatedSectionFooterHeight = 0
|
49
|
72
|
table.separatorStyle = .none
|
|
73
|
+ let header = MJRefreshNormalHeader.init()
|
|
74
|
+ header.setRefreshingTarget(self, refreshingAction: #selector(refreshWithHeader(header:)))
|
|
75
|
+ table.mj_header = header
|
|
76
|
+
|
|
77
|
+ let footer : MJRefreshBackNormalFooter = MJRefreshBackNormalFooter.init()
|
|
78
|
+ footer.setRefreshingTarget(self, refreshingAction: #selector(refreshFooter(footer:)))
|
|
79
|
+ table.mj_footer = footer
|
|
80
|
+
|
|
81
|
+ header.stateLabel.font = FontSize(14)
|
|
82
|
+ header.stateLabel.textColor = UIColor.detailTitle()
|
|
83
|
+ header.lastUpdatedTimeLabel.font = FontSize(14)
|
|
84
|
+ header.lastUpdatedTimeLabel.textColor = UIColor.detailTitle()
|
|
85
|
+ footer.stateLabel.textColor = UIColor.detailTitle()
|
50
|
86
|
return table
|
51
|
87
|
}()
|
52
|
88
|
|
|
89
|
+ @objc fileprivate func refreshWithHeader(header : MJRefreshHeader) {
|
|
90
|
+ page = 1
|
|
91
|
+ requestDataSourceWithPage(Page: page)
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ @objc fileprivate func refreshFooter (footer : MJRefreshAutoFooter) {
|
|
95
|
+ page += 1
|
|
96
|
+ requestDataSourceWithPage(Page: page)
|
|
97
|
+ }
|
|
98
|
+
|
53
|
99
|
func requestDataSourceWithPage(Page : Int) -> Void {
|
54
|
100
|
let urlString: String = KXURL + "/recycle/getList"
|
55
|
101
|
KXHTTP.post(urlString, params: ["page": Page, "module": module], success: { (json) in
|
|
@@ -58,9 +104,26 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
58
|
104
|
if Page == 1 {
|
59
|
105
|
self.dataSource.removeAllObjects()
|
60
|
106
|
}
|
61
|
|
- self.dataSource.addObjects(from: arr as! [Any])
|
|
107
|
+ arr.enumerateObjects({ (obj, index, bool) in
|
|
108
|
+ var dict = obj as! Dictionary<String, Any>
|
|
109
|
+ let jsonString: String = dict["content"] as! String
|
|
110
|
+ let jssonData: Data = jsonString.data(using: .utf8)!
|
|
111
|
+ let jsonDict = try? JSONSerialization.jsonObject(with: jssonData, options: .mutableContainers)
|
|
112
|
+ let mo: KXAssessViewModel = KXAssessViewModel.yy_model(withJSON: jsonDict!)!
|
|
113
|
+ dict["content"] = mo
|
|
114
|
+ let combineMo: KXSPOrderCombineModel = KXSPOrderCombineModel.yy_model(withJSON: dict)!
|
|
115
|
+ self.dataSource.add(combineMo)
|
|
116
|
+ })
|
|
117
|
+ self.tableView.mj_header.endRefreshing()
|
|
118
|
+ self.tableView.mj_footer.endRefreshing()
|
|
119
|
+ self.tableView.reloadData()
|
62
|
120
|
}) { (error) in
|
63
|
|
-
|
|
121
|
+ if Page == 1 {
|
|
122
|
+ self.dataSource.removeAllObjects()
|
|
123
|
+ }
|
|
124
|
+ self.tableView.mj_header.endRefreshing()
|
|
125
|
+ self.tableView.mj_footer.endRefreshing()
|
|
126
|
+ self.tableView.reloadData()
|
64
|
127
|
}
|
65
|
128
|
|
66
|
129
|
}
|
|
@@ -75,9 +138,18 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
75
|
138
|
|
76
|
139
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
77
|
140
|
let cell: KXSPOrderTableViewCell = tableView.dequeueReusableCell(withIdentifier: "KXSPOrderTableViewCell", for: indexPath) as! KXSPOrderTableViewCell
|
|
141
|
+ let model: KXSPOrderCombineModel = dataSource[indexPath.row] as! KXSPOrderCombineModel
|
|
142
|
+ cell.configTableViewCell(model: model, indexPath: indexPath as NSIndexPath)
|
78
|
143
|
return cell
|
79
|
144
|
}
|
80
|
145
|
|
|
146
|
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
147
|
+ let detail: KXSPOrderDetailViewController = KXSPOrderDetailViewController()
|
|
148
|
+ let model: KXSPOrderCombineModel = dataSource[indexPath.row] as! KXSPOrderCombineModel
|
|
149
|
+ detail.dataSource = NSMutableArray.init(object: model)
|
|
150
|
+ navigationController?.pushViewController(detail, animated: true)
|
|
151
|
+ }
|
|
152
|
+
|
81
|
153
|
}
|
82
|
154
|
|
83
|
155
|
class KXSPOrderTableViewCell: UITableViewCell {
|
|
@@ -156,7 +228,19 @@ class KXSPOrderTableViewCell: UITableViewCell {
|
156
|
228
|
}
|
157
|
229
|
|
158
|
230
|
override func configTableViewCell(model: AnyObject, indexPath: NSIndexPath) {
|
159
|
|
-
|
|
231
|
+ let mo: KXSPOrderCombineModel = model as! KXSPOrderCombineModel
|
|
232
|
+ iconImageView.image = UIImage(named: "icon_check_" + mo.module + "_" + mo.content.type)
|
|
233
|
+ let att: NSMutableAttributedString = NSMutableAttributedString()
|
|
234
|
+ att.append(NSAttributedString(string: "预估计:", attributes: [NSAttributedString.Key.foregroundColor: UIColor.kxColor(withHex: 0x666666), NSAttributedString.Key.font: UIFont(name: "PingFangSC-Regular", size: Fitesize(14))!]))
|
|
235
|
+ att.append(NSAttributedString(string: mo.content.price, attributes: [NSAttributedString.Key.foregroundColor: UIColor.kxColor(withHex: 0xAD63FF), NSAttributedString.Key.font: UIFont(name: "PingFangSC-Medium", size: Fitesize(18))!]))
|
|
236
|
+ nameLabel.text = mo.content.type
|
|
237
|
+ xinghao.text = "手机型号:" + mo.content.type
|
|
238
|
+ priceLabel.text = "预估计:" + mo.content.price
|
|
239
|
+ neicun.text = "内存:" + mo.content.memory
|
|
240
|
+ yanse.text = "颜色:" + mo.content.color
|
|
241
|
+ shijian.text = "购买时间:" + mo.content.time
|
|
242
|
+ chengse.text = "新旧成色:" + mo.content.quality
|
|
243
|
+ weixiu.text = "维修:" + mo.content.maintain
|
160
|
244
|
}
|
161
|
245
|
|
162
|
246
|
lazy var iconImageView: UIImageView = {
|
|
@@ -181,6 +265,7 @@ class KXSPOrderTableViewCell: UITableViewCell {
|
181
|
265
|
let label: UILabel = UILabel()
|
182
|
266
|
label.font = UIFont.init(name: "PingFangSC-Regular", size: Fitesize(14))
|
183
|
267
|
label.textColor = UIColor.kxColor(withHex: 0x666666)
|
|
268
|
+ label.text = "订单状态:进行中···"
|
184
|
269
|
return label
|
185
|
270
|
}()
|
186
|
271
|
|