|
@@ -17,6 +17,7 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
17
|
17
|
|
18
|
18
|
override func viewDidLoad() {
|
19
|
19
|
super.viewDidLoad()
|
|
20
|
+ setNav()
|
20
|
21
|
setUpUI()
|
21
|
22
|
}
|
22
|
23
|
|
|
@@ -25,6 +26,15 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
25
|
26
|
tableView.mj_header.beginRefreshing()
|
26
|
27
|
}
|
27
|
28
|
|
|
29
|
+ func setNav() -> Void {
|
|
30
|
+ navigationController?.navigationBar.shadowImage = UIImage()
|
|
31
|
+ navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
|
|
32
|
+ navigationController?.navigationBar.barTintColor = UIColor.gradientHeight(from: UIColor.kxColor(withHex: 0xDB8DFF), to: UIColor.kxColor(withHex: 0xE9C4FA), withHeight: Int32(NavHeight))
|
|
33
|
+ let navView: UIView = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 44))
|
|
34
|
+ navView.backgroundColor = UIColor.gradientHeight(from: UIColor.kxColor(withHex: 0xE9C4FA), to: UIColor.kxColor(withHex: 0xf5f5f5), withHeight: 44)
|
|
35
|
+ view.addSubview(navView)
|
|
36
|
+ }
|
|
37
|
+
|
28
|
38
|
override func setUpUI() {
|
29
|
39
|
name = "订单"
|
30
|
40
|
view.addSubview(segView)
|
|
@@ -32,7 +42,7 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
32
|
42
|
}
|
33
|
43
|
|
34
|
44
|
lazy var segView: UISegmentedControl = {
|
35
|
|
- let seg: UISegmentedControl = UISegmentedControl.init(items: ["手机","平板","电脑"])
|
|
45
|
+ let seg: UISegmentedControl = UISegmentedControl.init(items: ["手机","电脑","平板"])
|
36
|
46
|
seg.frame = CGRect.init(x: 12, y: 0, width: SCREEN_WIDTH-24, height: Fitesize(48))
|
37
|
47
|
seg.layer.cornerRadius = 8
|
38
|
48
|
seg.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.init(name: "PingFangSC-Light", size: Fitesize(17))!], for: .normal)
|
|
@@ -48,10 +58,10 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
48
|
58
|
module = "phone"
|
49
|
59
|
tableView.mj_header.beginRefreshing()
|
50
|
60
|
case 1:
|
51
|
|
- module = "pad"
|
|
61
|
+ module = "computer"
|
52
|
62
|
tableView.mj_header.beginRefreshing()
|
53
|
63
|
case 2:
|
54
|
|
- module = "computer"
|
|
64
|
+ module = "pad"
|
55
|
65
|
tableView.mj_header.beginRefreshing()
|
56
|
66
|
default:
|
57
|
67
|
break
|
|
@@ -59,7 +69,7 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
59
|
69
|
}
|
60
|
70
|
|
61
|
71
|
lazy var tableView: UITableView = {
|
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)
|
|
72
|
+ let table: UITableView = UITableView.init(frame: CGRect.init(x: 12, y: Fitesize(48), width: SCREEN_WIDTH-24, height: SCREEN_HEIGHT-NavHeight-Fitesize(48)-TabbarHeight), style: .grouped)
|
63
|
73
|
table.showsVerticalScrollIndicator = false
|
64
|
74
|
table.showsHorizontalScrollIndicator = false
|
65
|
75
|
table.delegate = self
|
|
@@ -70,6 +80,8 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
70
|
80
|
table.estimatedSectionHeaderHeight = 0
|
71
|
81
|
table.estimatedSectionFooterHeight = 0
|
72
|
82
|
table.separatorStyle = .none
|
|
83
|
+ table.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: table.frame.width, height: 0.1))
|
|
84
|
+ table.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: table.frame.width, height: 0.1))
|
73
|
85
|
let header = MJRefreshNormalHeader.init()
|
74
|
86
|
header.setRefreshingTarget(self, refreshingAction: #selector(refreshWithHeader(header:)))
|
75
|
87
|
table.mj_header = header
|
|
@@ -97,33 +109,35 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
97
|
109
|
}
|
98
|
110
|
|
99
|
111
|
func requestDataSourceWithPage(Page : Int) -> Void {
|
100
|
|
- let urlString: String = KXURL + "/recycle/getList"
|
101
|
|
- KXHTTP.post(urlString, params: ["page": Page, "module": module], success: { (json) in
|
102
|
|
- let response: NSDictionary = json as! NSDictionary
|
103
|
|
- let arr: NSArray = response["data"] as! [NSDictionary] as NSArray
|
104
|
|
- if Page == 1 {
|
105
|
|
- self.dataSource.removeAllObjects()
|
106
|
|
- }
|
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()
|
120
|
|
- }) { (error) in
|
121
|
|
- if Page == 1 {
|
122
|
|
- self.dataSource.removeAllObjects()
|
|
112
|
+ if KXLoginManager.shareInstance()?.isLogin() == true {
|
|
113
|
+ let urlString: String = KXURL + "/recycle/getList"
|
|
114
|
+ KXHTTP.post(urlString, params: ["page": Page, "module": module], success: { (json) in
|
|
115
|
+ let response: NSDictionary = json as! NSDictionary
|
|
116
|
+ let arr: NSArray = response["data"] as! [NSDictionary] as NSArray
|
|
117
|
+ if Page == 1 {
|
|
118
|
+ self.dataSource.removeAllObjects()
|
|
119
|
+ }
|
|
120
|
+ arr.enumerateObjects({ (obj, index, bool) in
|
|
121
|
+ var dict = obj as! Dictionary<String, Any>
|
|
122
|
+ let jsonString: String = dict["content"] as! String
|
|
123
|
+ let jssonData: Data = jsonString.data(using: .utf8)!
|
|
124
|
+ let jsonDict = try? JSONSerialization.jsonObject(with: jssonData, options: .mutableContainers)
|
|
125
|
+ let mo: KXAssessViewModel = KXAssessViewModel.yy_model(withJSON: jsonDict!)!
|
|
126
|
+ dict["content"] = mo
|
|
127
|
+ let combineMo: KXSPOrderCombineModel = KXSPOrderCombineModel.yy_model(withJSON: dict)!
|
|
128
|
+ self.dataSource.add(combineMo)
|
|
129
|
+ })
|
|
130
|
+ self.tableView.mj_header.endRefreshing()
|
|
131
|
+ self.tableView.mj_footer.endRefreshing()
|
|
132
|
+ self.tableView.reloadData()
|
|
133
|
+ }) { (error) in
|
|
134
|
+ if Page == 1 {
|
|
135
|
+ self.dataSource.removeAllObjects()
|
|
136
|
+ }
|
|
137
|
+ self.tableView.mj_header.endRefreshing()
|
|
138
|
+ self.tableView.mj_footer.endRefreshing()
|
|
139
|
+ self.tableView.reloadData()
|
123
|
140
|
}
|
124
|
|
- self.tableView.mj_header.endRefreshing()
|
125
|
|
- self.tableView.mj_footer.endRefreshing()
|
126
|
|
- self.tableView.reloadData()
|
127
|
141
|
}
|
128
|
142
|
|
129
|
143
|
}
|
|
@@ -150,6 +164,22 @@ class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITabl
|
150
|
164
|
navigationController?.pushViewController(detail, animated: true)
|
151
|
165
|
}
|
152
|
166
|
|
|
167
|
+ func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
|
168
|
+ return UIView()
|
|
169
|
+ }
|
|
170
|
+
|
|
171
|
+ func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
172
|
+ return 10
|
|
173
|
+ }
|
|
174
|
+
|
|
175
|
+ func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
|
|
176
|
+ return UIView()
|
|
177
|
+ }
|
|
178
|
+
|
|
179
|
+ func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
|
|
180
|
+ return 0.1
|
|
181
|
+ }
|
|
182
|
+
|
153
|
183
|
}
|
154
|
184
|
|
155
|
185
|
class KXSPOrderTableViewCell: UITableViewCell {
|
|
@@ -230,17 +260,26 @@ class KXSPOrderTableViewCell: UITableViewCell {
|
230
|
260
|
override func configTableViewCell(model: AnyObject, indexPath: NSIndexPath) {
|
231
|
261
|
let mo: KXSPOrderCombineModel = model as! KXSPOrderCombineModel
|
232
|
262
|
iconImageView.image = UIImage(named: "icon_check_" + mo.module + "_" + mo.content.type)
|
|
263
|
+ nameLabel.text = mo.content.type
|
233
|
264
|
let att: NSMutableAttributedString = NSMutableAttributedString()
|
234
|
265
|
att.append(NSAttributedString(string: "预估计:", attributes: [NSAttributedString.Key.foregroundColor: UIColor.kxColor(withHex: 0x666666), NSAttributedString.Key.font: UIFont(name: "PingFangSC-Regular", size: Fitesize(14))!]))
|
235
|
266
|
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
|
|
267
|
+ priceLabel.attributedText = att
|
|
268
|
+ xinghao.text = "型号:" + mo.content.type
|
239
|
269
|
neicun.text = "内存:" + mo.content.memory
|
240
|
|
- yanse.text = "颜色:" + mo.content.color
|
241
|
|
- shijian.text = "购买时间:" + mo.content.time
|
242
|
270
|
chengse.text = "新旧成色:" + mo.content.quality
|
243
|
271
|
weixiu.text = "维修:" + mo.content.maintain
|
|
272
|
+ if mo.module == "phone" {
|
|
273
|
+ yanse.text = "颜色:" + mo.content.color
|
|
274
|
+ shijian.text = "购买时间:" + mo.content.time
|
|
275
|
+ } else if mo.module == "pad" {
|
|
276
|
+ yanse.text = "网络模式:" + mo.content.netModel
|
|
277
|
+ shijian.text = "购买时间:" + mo.content.time
|
|
278
|
+ } else {
|
|
279
|
+ yanse.text = "硬盘:" + mo.content.hardDisk
|
|
280
|
+ shijian.text = "处理器:" + mo.content.cpu
|
|
281
|
+ }
|
|
282
|
+
|
244
|
283
|
}
|
245
|
284
|
|
246
|
285
|
lazy var iconImageView: UIImageView = {
|