|
@@ -8,23 +8,236 @@
|
8
|
8
|
|
9
|
9
|
import UIKit
|
10
|
10
|
|
11
|
|
-class KXSPOrderViewController: KXBaseViewController {
|
|
11
|
+class KXSPOrderViewController: KXBaseViewController, UITableViewDelegate, UITableViewDataSource {
|
12
|
12
|
|
|
13
|
+ var dataSource: NSMutableArray = NSMutableArray.init()
|
|
14
|
+ var page = 1
|
|
15
|
+ var module: String = "phone"
|
|
16
|
+
|
|
17
|
+
|
13
|
18
|
override func viewDidLoad() {
|
14
|
19
|
super.viewDidLoad()
|
15
|
|
-
|
16
|
|
- // Do any additional setup after loading the view.
|
|
20
|
+ setUpUI()
|
17
|
21
|
}
|
18
|
22
|
|
|
23
|
+ override func setUpUI() {
|
|
24
|
+ name = "订单"
|
|
25
|
+ view.addSubview(segView)
|
|
26
|
+ view.addSubview(tableView)
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ lazy var segView: UISegmentedControl = {
|
|
30
|
+ let seg: UISegmentedControl = UISegmentedControl.init(items: ["手机","平板","电脑"])
|
|
31
|
+ seg.frame = CGRect.init(x: 12, y: 0, width: SCREEN_WIDTH-24, height: Fitesize(48))
|
|
32
|
+ seg.layer.cornerRadius = 8
|
|
33
|
+ seg.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.init(name: "PingFangSC-Light", size: Fitesize(17))!], for: .normal)
|
|
34
|
+ seg.tintColor = UIColor.base()
|
|
35
|
+ return seg
|
|
36
|
+ }()
|
|
37
|
+
|
|
38
|
+ lazy var tableView: UITableView = {
|
|
39
|
+ 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
|
+ table.showsVerticalScrollIndicator = false
|
|
41
|
+ table.showsHorizontalScrollIndicator = false
|
|
42
|
+ table.delegate = self
|
|
43
|
+ table.dataSource = self
|
|
44
|
+ table.register(KXSPOrderTableViewCell.classForCoder(), forCellReuseIdentifier: "KXSPOrderTableViewCell")
|
|
45
|
+ table.rowHeight = Fitesize(234)
|
|
46
|
+ table.estimatedRowHeight = 0
|
|
47
|
+ table.estimatedSectionHeaderHeight = 0
|
|
48
|
+ table.estimatedSectionFooterHeight = 0
|
|
49
|
+ table.separatorStyle = .none
|
|
50
|
+ return table
|
|
51
|
+ }()
|
|
52
|
+
|
|
53
|
+ func requestDataSourceWithPage(Page : Int) -> Void {
|
|
54
|
+ let urlString: String = KXURL + "/recycle/getList"
|
|
55
|
+ KXHTTP.post(urlString, params: ["page": Page, "module": module], success: { (json) in
|
|
56
|
+ let response: NSDictionary = json as! NSDictionary
|
|
57
|
+ let arr: NSArray = response["data"] as! [NSDictionary] as NSArray
|
|
58
|
+ if Page == 1 {
|
|
59
|
+ self.dataSource.removeAllObjects()
|
|
60
|
+ }
|
|
61
|
+ self.dataSource.addObjects(from: arr as! [Any])
|
|
62
|
+ }) { (error) in
|
|
63
|
+
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ func numberOfSections(in tableView: UITableView) -> Int {
|
|
69
|
+ return dataSource.count
|
|
70
|
+ }
|
19
|
71
|
|
20
|
|
- /*
|
21
|
|
- // MARK: - Navigation
|
22
|
|
-
|
23
|
|
- // In a storyboard-based application, you will often want to do a little preparation before navigation
|
24
|
|
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
25
|
|
- // Get the new view controller using segue.destination.
|
26
|
|
- // Pass the selected object to the new view controller.
|
|
72
|
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
73
|
+ return 1
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
77
|
+ let cell: KXSPOrderTableViewCell = tableView.dequeueReusableCell(withIdentifier: "KXSPOrderTableViewCell", for: indexPath) as! KXSPOrderTableViewCell
|
|
78
|
+ return cell
|
27
|
79
|
}
|
28
|
|
- */
|
|
80
|
+
|
|
81
|
+}
|
29
|
82
|
|
|
83
|
+class KXSPOrderTableViewCell: UITableViewCell {
|
|
84
|
+
|
|
85
|
+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
86
|
+ super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
87
|
+ selectionStyle = .none
|
|
88
|
+ layer.cornerRadius = 10
|
|
89
|
+ contentView.addSubview(iconImageView)
|
|
90
|
+ contentView.addSubview(nameLabel)
|
|
91
|
+ contentView.addSubview(priceLabel)
|
|
92
|
+ contentView.addSubview(statusLabel)
|
|
93
|
+ contentView.addSubview(line)
|
|
94
|
+ contentView.addSubview(canshu)
|
|
95
|
+ contentView.addSubview(xinghao)
|
|
96
|
+ contentView.addSubview(yanse)
|
|
97
|
+ contentView.addSubview(chengse)
|
|
98
|
+ contentView.addSubview(neicun)
|
|
99
|
+ contentView.addSubview(shijian)
|
|
100
|
+ contentView.addSubview(weixiu)
|
|
101
|
+ iconImageView.mas_makeConstraints { (make) in
|
|
102
|
+ make?.left.mas_equalTo()(contentView)?.offset()(Fitesize(14))
|
|
103
|
+ make?.top.mas_equalTo()(contentView)?.offset()(Fitesize(17))
|
|
104
|
+ make?.size.mas_equalTo()(CGSize.init(width: Fitesize(70), height: Fitesize(70)))
|
|
105
|
+ }
|
|
106
|
+ nameLabel.mas_makeConstraints { (make) in
|
|
107
|
+ make?.left.mas_equalTo()(iconImageView.mas_right)?.offset()(Fitesize(20))
|
|
108
|
+ make?.top.mas_equalTo()(contentView)?.offset()(Fitesize(14))
|
|
109
|
+ }
|
|
110
|
+ priceLabel.mas_makeConstraints { (make) in
|
|
111
|
+ make?.left.mas_equalTo()(nameLabel)
|
|
112
|
+ make?.top.mas_equalTo()(nameLabel.mas_bottom)?.offset()(5)
|
|
113
|
+ }
|
|
114
|
+ statusLabel.mas_makeConstraints { (make) in
|
|
115
|
+ make?.left.mas_equalTo()(priceLabel)
|
|
116
|
+ make?.top.mas_equalTo()(priceLabel.mas_bottom)?.offset()(2)
|
|
117
|
+ }
|
|
118
|
+ line.mas_makeConstraints { (make) in
|
|
119
|
+ make?.left.mas_equalTo()(contentView)?.offset()(Fitesize(15))
|
|
120
|
+ make?.right.mas_equalTo()(contentView)?.offset()(-Fitesize(15))
|
|
121
|
+ make?.top.mas_equalTo()(statusLabel.mas_bottom)?.offset()(Fitesize(14))
|
|
122
|
+ make?.height.mas_equalTo()(0.5)
|
|
123
|
+ }
|
|
124
|
+ canshu.mas_makeConstraints { (make) in
|
|
125
|
+ make?.left.mas_equalTo()(contentView)?.offset()(Fitesize(17))
|
|
126
|
+ make?.top.mas_equalTo()(line.mas_bottom)?.offset()(Fitesize(13))
|
|
127
|
+ }
|
|
128
|
+ xinghao.mas_makeConstraints { (make) in
|
|
129
|
+ make?.left.mas_equalTo()(canshu)
|
|
130
|
+ make?.top.mas_equalTo()(canshu.mas_bottom)?.offset()(Fitesize(10))
|
|
131
|
+ }
|
|
132
|
+ yanse.mas_makeConstraints { (make) in
|
|
133
|
+ make?.left.mas_equalTo()(xinghao)
|
|
134
|
+ make?.top.mas_equalTo()(xinghao.mas_bottom)?.offset()(2)
|
|
135
|
+ }
|
|
136
|
+ chengse.mas_makeConstraints { (make) in
|
|
137
|
+ make?.left.mas_equalTo()(yanse)
|
|
138
|
+ make?.top.mas_equalTo()(yanse.mas_bottom)?.offset()(2)
|
|
139
|
+ }
|
|
140
|
+ neicun.mas_makeConstraints { (make) in
|
|
141
|
+ make?.left.mas_equalTo()(contentView)?.offset()(Fitesize(182))
|
|
142
|
+ make?.top.mas_equalTo()(xinghao)
|
|
143
|
+ }
|
|
144
|
+ shijian.mas_makeConstraints { (make) in
|
|
145
|
+ make?.left.mas_equalTo()(neicun)
|
|
146
|
+ make?.top.mas_equalTo()(yanse)
|
|
147
|
+ }
|
|
148
|
+ weixiu.mas_makeConstraints { (make) in
|
|
149
|
+ make?.left.mas_equalTo()(shijian)
|
|
150
|
+ make?.top.mas_equalTo()(chengse)
|
|
151
|
+ }
|
|
152
|
+ }
|
|
153
|
+
|
|
154
|
+ required init?(coder aDecoder: NSCoder) {
|
|
155
|
+ fatalError("init(coder:) has not been implemented")
|
|
156
|
+ }
|
|
157
|
+
|
|
158
|
+ override func configTableViewCell(model: AnyObject, indexPath: NSIndexPath) {
|
|
159
|
+
|
|
160
|
+ }
|
|
161
|
+
|
|
162
|
+ lazy var iconImageView: UIImageView = {
|
|
163
|
+ let imageView:UIImageView = UIImageView()
|
|
164
|
+ imageView.layer.cornerRadius = 7
|
|
165
|
+ return imageView
|
|
166
|
+ }()
|
|
167
|
+
|
|
168
|
+ lazy var nameLabel: UILabel = {
|
|
169
|
+ let label: UILabel = UILabel()
|
|
170
|
+ label.font = UIFont.init(name: "PingFangSC-Medium", size: Fitesize(18))
|
|
171
|
+ label.textColor = UIColor.title()
|
|
172
|
+ return label
|
|
173
|
+ }()
|
|
174
|
+
|
|
175
|
+ lazy var priceLabel: UILabel = {
|
|
176
|
+ let label: UILabel = UILabel()
|
|
177
|
+ return label
|
|
178
|
+ }()
|
|
179
|
+
|
|
180
|
+ lazy var statusLabel: UILabel = {
|
|
181
|
+ let label: UILabel = UILabel()
|
|
182
|
+ label.font = UIFont.init(name: "PingFangSC-Regular", size: Fitesize(14))
|
|
183
|
+ label.textColor = UIColor.kxColor(withHex: 0x666666)
|
|
184
|
+ return label
|
|
185
|
+ }()
|
|
186
|
+
|
|
187
|
+ lazy var line: UIView = {
|
|
188
|
+ let view: UIView = UIView()
|
|
189
|
+ view.backgroundColor = UIColor.kxColor(withHex: 0xd8d8d8)
|
|
190
|
+ return view
|
|
191
|
+ }()
|
|
192
|
+
|
|
193
|
+ lazy var canshu: UILabel = {
|
|
194
|
+ let label: UILabel = UILabel()
|
|
195
|
+ label.font = UIFont.init(name: "PingFangSC-Medium", size: Fitesize(16))
|
|
196
|
+ label.textColor = UIColor.title()
|
|
197
|
+ label.text = "评估参数"
|
|
198
|
+ return label
|
|
199
|
+ }()
|
|
200
|
+
|
|
201
|
+ lazy var xinghao: UILabel = {
|
|
202
|
+ let label: UILabel = UILabel()
|
|
203
|
+ label.font = UIFont.init(name: "PingFangSC-Regular", size: Fitesize(14))
|
|
204
|
+ label.textColor = UIColor.kxColor(withHex: 0x666666)
|
|
205
|
+ return label
|
|
206
|
+ }()
|
|
207
|
+
|
|
208
|
+ lazy var yanse: UILabel = {
|
|
209
|
+ let label: UILabel = UILabel()
|
|
210
|
+ label.font = UIFont.init(name: "PingFangSC-Regular", size: Fitesize(14))
|
|
211
|
+ label.textColor = UIColor.kxColor(withHex: 0x666666)
|
|
212
|
+ return label
|
|
213
|
+ }()
|
|
214
|
+
|
|
215
|
+ lazy var chengse: UILabel = {
|
|
216
|
+ let label: UILabel = UILabel()
|
|
217
|
+ label.font = UIFont.init(name: "PingFangSC-Regular", size: Fitesize(14))
|
|
218
|
+ label.textColor = UIColor.kxColor(withHex: 0x666666)
|
|
219
|
+ return label
|
|
220
|
+ }()
|
|
221
|
+
|
|
222
|
+ lazy var neicun: UILabel = {
|
|
223
|
+ let label: UILabel = UILabel()
|
|
224
|
+ label.font = UIFont.init(name: "PingFangSC-Regular", size: Fitesize(14))
|
|
225
|
+ label.textColor = UIColor.kxColor(withHex: 0x666666)
|
|
226
|
+ return label
|
|
227
|
+ }()
|
|
228
|
+
|
|
229
|
+ lazy var shijian: UILabel = {
|
|
230
|
+ let label: UILabel = UILabel()
|
|
231
|
+ label.font = UIFont.init(name: "PingFangSC-Regular", size: Fitesize(14))
|
|
232
|
+ label.textColor = UIColor.kxColor(withHex: 0x666666)
|
|
233
|
+ return label
|
|
234
|
+ }()
|
|
235
|
+
|
|
236
|
+ lazy var weixiu: UILabel = {
|
|
237
|
+ let label: UILabel = UILabel()
|
|
238
|
+ label.font = UIFont.init(name: "PingFangSC-Regular", size: Fitesize(14))
|
|
239
|
+ label.textColor = UIColor.kxColor(withHex: 0x666666)
|
|
240
|
+ return label
|
|
241
|
+ }()
|
|
242
|
+
|
30
|
243
|
}
|