Browse Source

flower order

xiaoxi 6 years ago
parent
commit
eabf087c96

+ 4 - 0
CAISHEN.xcodeproj/project.pbxproj

@@ -145,6 +145,7 @@
145 145
 		49B5CD241FB302F000F4A905 /* KXHouseCalculTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 49B5CD231FB302F000F4A905 /* KXHouseCalculTableViewCell.m */; };
146 146
 		7003017F2117F26C00D43106 /* KXSCRequestViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7003017E2117F26C00D43106 /* KXSCRequestViewModel.m */; };
147 147
 		700301822118175200D43106 /* KXSCDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 700301812118175200D43106 /* KXSCDataModel.m */; };
148
+		700EAFD521994E0F00E341EB /* KXSFMineFlowerOrderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 700EAFD421994E0F00E341EB /* KXSFMineFlowerOrderModel.swift */; };
148 149
 		7010C461217591E50075D458 /* KXMemoDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7010C460217591E50075D458 /* KXMemoDetailViewController.m */; };
149 150
 		701BE2F01FD651AA005B2046 /* KXNewMainPageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 701BE2EF1FD651AA005B2046 /* KXNewMainPageViewController.m */; };
150 151
 		702AA844217484B100151834 /* KXInvoiceDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 702AA843217484B100151834 /* KXInvoiceDetailViewController.m */; };
@@ -771,6 +772,7 @@
771 772
 		7003017E2117F26C00D43106 /* KXSCRequestViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KXSCRequestViewModel.m; sourceTree = "<group>"; };
772 773
 		700301802118175200D43106 /* KXSCDataModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KXSCDataModel.h; sourceTree = "<group>"; };
773 774
 		700301812118175200D43106 /* KXSCDataModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KXSCDataModel.m; sourceTree = "<group>"; };
775
+		700EAFD421994E0F00E341EB /* KXSFMineFlowerOrderModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KXSFMineFlowerOrderModel.swift; sourceTree = "<group>"; };
774 776
 		7010C45F217591E50075D458 /* KXMemoDetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KXMemoDetailViewController.h; sourceTree = "<group>"; };
775 777
 		7010C460217591E50075D458 /* KXMemoDetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KXMemoDetailViewController.m; sourceTree = "<group>"; };
776 778
 		701BE2EE1FD651AA005B2046 /* KXNewMainPageViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KXNewMainPageViewController.h; sourceTree = "<group>"; };
@@ -2494,6 +2496,7 @@
2494 2496
 			isa = PBXGroup;
2495 2497
 			children = (
2496 2498
 				7629ACD2219041A100CDCE02 /* KXSFMineAreaModel.swift */,
2499
+				700EAFD421994E0F00E341EB /* KXSFMineFlowerOrderModel.swift */,
2497 2500
 			);
2498 2501
 			path = model;
2499 2502
 			sourceTree = "<group>";
@@ -4342,6 +4345,7 @@
4342 4345
 				D11C725F2074D293006BB8A5 /* NSDictionary+AvoidCrash.m in Sources */,
4343 4346
 				40FB3BC5215C7FB100054D85 /* KXRobOrderSendDetailTableView.m in Sources */,
4344 4347
 				D19A3CA71F7B519700346A62 /* KXMD5Manager.m in Sources */,
4348
+				700EAFD521994E0F00E341EB /* KXSFMineFlowerOrderModel.swift in Sources */,
4345 4349
 				D11C725E2074D293006BB8A5 /* NSAttributedString+AvoidCrash.m in Sources */,
4346 4350
 				D186762A2112E4CB00A933E9 /* KXBillDocumentDetailViewController.m in Sources */,
4347 4351
 				76426E0F218AF06B0030C8B7 /* KXSFMGoodDetailViewController.swift in Sources */,

BIN
CAISHEN.xcworkspace/xcuserdata/xiaoxi.xcuserdatad/UserInterfaceState.xcuserstate


+ 1 - 1
CAISHEN/KXHeader.h

@@ -45,7 +45,7 @@
45 45
 
46 46
 #define KXSUPORTURL @"网址信息:http://sdjd.726p.com/"
47 47
 // 1 代表过审 0线上
48
-#define KXAPPSTATUS 1
48
+#define KXAPPSTATUS 0
49 49
 
50 50
 /****************************************************************/
51 51
 

+ 2 - 2
CAISHEN/KXPrefixHeader.pch

@@ -38,10 +38,10 @@
38 38
 #define KXWeakSelf __weak typeof(self) weakSelf = self;
39 39
 
40 40
 // 线上URL
41
-static NSString * const URL = @"https://newapi.henhaojie.com/user";
41
+//static NSString * const URL = @"https://newapi.henhaojie.com/user";
42 42
 
43 43
 // 测试URL
44
-//static NSString * const URL = @"http://bw.quyaqu.com/user";
44
+static NSString * const URL = @"http://bw.quyaqu.com/user";
45 45
 
46 46
 
47 47
 

+ 194 - 19
CAISHEN/SellFlowers/Mine/controllers/KXSFMineOrderViewController.swift

@@ -8,9 +8,16 @@
8 8
 
9 9
 import UIKit
10 10
 
11
-class KXSFMineOrderViewController: KXBaseViewController ,UITableViewDelegate,UITableViewDataSource {
12
- 
11
+protocol KXSFFlowerFooterViewDelegate: NSObjectProtocol {
12
+    func kxsf_FlowerFooterViewAction(section: Int)
13
+}
14
+
15
+class KXSFMineOrderViewController: KXBaseViewController,UITableViewDelegate,UITableViewDataSource,KXSFFlowerFooterViewDelegate {
16
+    
13 17
     let tabCellID = "tableCellID"
18
+    var dataSource: NSMutableArray = NSMutableArray.init()
19
+    var page = 1
20
+    var status = 1
14 21
     
15 22
     override func viewDidLoad() {
16 23
         super.viewDidLoad()
@@ -26,9 +33,46 @@ class KXSFMineOrderViewController: KXBaseViewController ,UITableViewDelegate,UIT
26 33
         view.addSubview(tableView)
27 34
     }
28 35
     
29
-    lazy var headerLineView : KXHeaderLineView = {
30
-        var headerView : KXHeaderLineView = KXHeaderLineView.init(items: ["代发货","待收货","已完成"])!
31
-        headerView.frame = CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 50)
36
+    fileprivate func requestConfirmOrder(id: String) {
37
+        let urlString: String = KXURL + "/trial/confirmFlowerBill"
38
+        KXHTTP.post(urlString, params: ["id": id], success: { (json) in
39
+            self.tableView.mj_header.beginRefreshing()
40
+        }) { (error) in
41
+            
42
+        }
43
+        
44
+    }
45
+    
46
+    fileprivate func requestDataSourceWithPage(Page: Int) {
47
+        let urlString: String = KXURL + "/trial/myFlowerBillList"
48
+        KXHTTP.post(urlString, params: ["page": Page, "status": status], success: { (json) in
49
+            let responseJson: NSDictionary = json as! NSDictionary
50
+            let array = responseJson["data"] as! [NSDictionary]
51
+            
52
+            let dataArr = NSArray.yy_modelArray(with: KXSFMineFlowerOrderModel.self, json: array) as! [KXSFMineFlowerOrderModel]
53
+            if Page == 1 {
54
+                self.dataSource.removeAllObjects()
55
+                self.dataSource.addObjects(from: dataArr)
56
+                self.tableView.mj_header.endRefreshing()
57
+                self.tableView.mj_footer.endRefreshing()
58
+                self.tableView.reloadData()
59
+            } else {
60
+                self.dataSource.addObjects(from: dataArr)
61
+                self.tableView.mj_header.endRefreshing()
62
+                self.tableView.mj_footer.endRefreshing()
63
+                self.tableView.reloadData()
64
+            }
65
+            
66
+        }) { (error) in
67
+            self.tableView.mj_header.endRefreshing()
68
+            self.tableView.mj_footer.endRefreshing()
69
+        }
70
+        
71
+    }
72
+    
73
+    lazy var headerLineView: KXHeaderLineView = {
74
+        var headerView: KXHeaderLineView = KXHeaderLineView.init(items: ["待发货","待收货","已完成"])!
75
+        headerView.frame = CGRect(x: 10, y: 14, width: SCREEN_WIDTH-20, height: 38)
32 76
         headerView.selectedIndex = 1
33 77
         headerView.lineColor = UIColor.base()
34 78
         headerView.buttonNormalColor = UIColor.detailTitle()
@@ -38,34 +82,60 @@ class KXSFMineOrderViewController: KXBaseViewController ,UITableViewDelegate,UIT
38 82
         return headerView
39 83
     }()
40 84
     
41
-    lazy var tableView : UITableView = {
42
-        var table = UITableView.init(frame: CGRect.init(x: 0, y: 50, width: SCREEN_WIDTH, height: SCREEN_HEIGHT-NavHeight - 50), style: .plain)
85
+    lazy var tableView: UITableView = {
86
+        var table = UITableView.init(frame: CGRect.init(x: 10, y: 52, width: SCREEN_WIDTH-20, height: SCREEN_HEIGHT-NavHeight - 52), style: .grouped)
43 87
         table.delegate = self
44 88
         table.dataSource = self
45 89
         table.separatorStyle = .none
46
-        table.tableFooterView = UIView.init(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 0.1))
47
-        table.tableHeaderView = UIView.init(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 0.1))
48
-        table.rowHeight = 190
49
-        table.register(UINib.init(nibName: "KXSFMineOrderTableViewCell", bundle: Bundle.main), forCellReuseIdentifier: tabCellID)
90
+        table.tableFooterView = UIView.init(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH-20, height: 0.1))
91
+        table.tableHeaderView = UIView.init(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH-20, height: 0.1))
92
+        table.rowHeight = 150
93
+        table.register(KXSFBuySubmitOrderTableCell.classForCoder(), forCellReuseIdentifier: tabCellID)
94
+        let header = MJRefreshNormalHeader.init()
95
+        header.setRefreshingTarget(self, refreshingAction: #selector(refreshWithHeader(header:)))
96
+        table.mj_header = header
97
+
98
+        let footer : MJRefreshBackNormalFooter = MJRefreshBackNormalFooter.init()
99
+        footer.setRefreshingTarget(self, refreshingAction: #selector(refreshFooter(footer:)))
100
+        table.mj_footer = footer
101
+
102
+        header.stateLabel.font = FontSize(14)
103
+        header.stateLabel.textColor = UIColor.detailTitle()
104
+        header.lastUpdatedTimeLabel.font = FontSize(14)
105
+        header.lastUpdatedTimeLabel.textColor = UIColor.detailTitle()
106
+        footer.stateLabel.textColor = UIColor.detailTitle()
107
+        header.beginRefreshing()
50 108
         return table
51 109
     }()
52 110
     
111
+    @objc fileprivate func refreshWithHeader(header : MJRefreshHeader) {
112
+        page = 1
113
+        requestDataSourceWithPage(Page: page)
114
+    }
115
+    
116
+    @objc fileprivate func refreshFooter (footer : MJRefreshAutoFooter) {
117
+        page += 1
118
+        requestDataSourceWithPage(Page: page)
119
+    }
53 120
     
54 121
     @objc func headerViewClick(button : UIButton)  {
55
-        switch button.tag - 2000 {
122
+        switch button.tag - 1000 {
56 123
         case 0:
57 124
             do{
58
-                
125
+                status = 1
126
+                tableView.mj_header.beginRefreshing()
59 127
             }
60 128
             break
61 129
         case 1:
62 130
             do{
63
-                
131
+                status = 2
132
+                tableView.mj_header.beginRefreshing()
64 133
             }
65 134
             break
66 135
         case 2:
67 136
             do{
68
-                
137
+                status = 3
138
+                tableView.mj_header.beginRefreshing()
69 139
             }
70 140
             break
71 141
         default:
@@ -76,15 +146,120 @@ class KXSFMineOrderViewController: KXBaseViewController ,UITableViewDelegate,UIT
76 146
 }
77 147
 
78 148
 extension KXSFMineOrderViewController{
149
+    
150
+    func kxsf_FlowerFooterViewAction(section: Int) {
151
+        let mo: KXSFMineFlowerOrderModel = dataSource[section] as! KXSFMineFlowerOrderModel
152
+        requestConfirmOrder(id: mo.id ?? "0")
153
+    }
154
+    
155
+    func numberOfSections(in tableView: UITableView) -> Int {
156
+        return dataSource.count 
157
+    }
158
+    
79 159
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
80
-        return 10
160
+        let mo: KXSFMineFlowerOrderModel = dataSource[section] as! KXSFMineFlowerOrderModel
161
+        return mo.product?.count ?? 0
81 162
     }
82 163
     
83 164
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
84
-        let cell : KXSFMineOrderTableViewCell = tableView.dequeueReusableCell(withIdentifier: tabCellID)! as! KXSFMineOrderTableViewCell
165
+        let cell : KXSFBuySubmitOrderTableCell = tableView.dequeueReusableCell(withIdentifier: tabCellID)! as! KXSFBuySubmitOrderTableCell
166
+        let mo: KXSFMineFlowerOrderModel = dataSource[indexPath.section] as! KXSFMineFlowerOrderModel
167
+        let subMo: KXSFMListModel = mo.product?[indexPath.row] as! KXSFMListModel
168
+        cell.configTableViewCell(model: subMo, indexPath: indexPath as NSIndexPath)
169
+        cell.selectionStyle = .none
85 170
         return cell
86 171
     }
87
-    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
88
-        
172
+    
173
+    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
174
+        return 6
175
+    }
176
+    
177
+    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
178
+        return UIView()
179
+    }
180
+    
181
+    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
182
+        return 66
183
+    }
184
+    
185
+    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
186
+        let view : KXSFFlowerFooterView = KXSFFlowerFooterView.init(frame: CGRect(x: 0, y: 0, width: tableView.width, height: 66))
187
+        let mo: KXSFMineFlowerOrderModel = dataSource[section] as! KXSFMineFlowerOrderModel
188
+        var isHidden: Bool = true
189
+        if status == 2 {
190
+            isHidden = false
191
+        }
192
+        view.configFooterView(model: mo, section: section, hidden: isHidden)
193
+        return view
194
+    }
195
+}
196
+
197
+class KXSFFlowerFooterView: UIView {
198
+    
199
+    weak var delegate: KXSFFlowerFooterViewDelegate?
200
+    
201
+    override init(frame: CGRect) {
202
+        super.init(frame: frame)
203
+        backgroundColor = UIColor.white
204
+        addSubview(countLabel)
205
+        addSubview(accountLabel)
206
+        addSubview(nextButton)
207
+        countLabel.mas_makeConstraints { (make) in
208
+            make?.left.equalTo()(self)?.offset()(18)
209
+            make?.centerY.equalTo()(self)
210
+        }
211
+        accountLabel.mas_makeConstraints { (make) in
212
+            make?.left.equalTo()(countLabel.mas_right)?.offset()(20)
213
+            make?.centerY.equalTo()(countLabel)
214
+        }
215
+        nextButton.mas_makeConstraints { (make) in
216
+            make?.right.equalTo()(self)?.offset()(-18)
217
+            make?.centerY.equalTo()(self)
218
+            make?.size.equalTo()(CGSize(width: 99, height: 32))
219
+        }
220
+    }
221
+    
222
+    required init?(coder aDecoder: NSCoder) {
223
+        fatalError("init(coder:) has not been implemented")
224
+    }
225
+    
226
+    func configFooterView(model: AnyObject, section: Int, hidden: Bool) {
227
+        let mo: KXSFMineFlowerOrderModel = model as! KXSFMineFlowerOrderModel
228
+        countLabel.text = String.init(format: "共%@件商品", mo.total_num ?? 0)
229
+        let atts: NSMutableAttributedString = NSMutableAttributedString()
230
+        atts.append(NSAttributedString.ppInit(title: "合计:", foregroundColor: UIColor.kxColor(withHex: 0x63D273), font: UIFont.init(name: "PingFangSC-Regular", size: 14)))
231
+        atts.append(NSAttributedString.ppInit(title: String(format: "¥%@", mo.total_price ?? 0), foregroundColor: UIColor.kxColor(withHex: 0x208C2B), font: UIFont.init(name: "PingFangSC-Semibold", size: 14)))
232
+        accountLabel.attributedText = atts
233
+        nextButton.isHidden = hidden
234
+        if hidden == false {
235
+            nextButton.tag = section
236
+            nextButton.addTarget(self, action: #selector(submitAction(button:)), for: UIControl.Event.touchUpInside)
237
+        }
238
+    }
239
+    
240
+    lazy var countLabel: UILabel = {
241
+        var countLabel: UILabel = UILabel.init()
242
+        countLabel.font = UIFont.init(name: "PingFangSC-Regular", size: 15)
243
+        countLabel.textColor = UIColor.title()
244
+        return countLabel
245
+    }()
246
+    
247
+    lazy var accountLabel: UILabel = {
248
+        var accountLabel: UILabel = UILabel.init()
249
+        return accountLabel
250
+    }()
251
+    
252
+    lazy var nextButton: UIButton = {
253
+        var nextButton: UIButton = UIButton.init(type: UIButton.ButtonType.custom)
254
+        nextButton.layer.cornerRadius = 16
255
+        nextButton.layer.masksToBounds = true
256
+        let normalAtt = NSAttributedString.ppInit(title: "确认订单", foregroundColor: UIColor.white, font: FontSize(14))
257
+        nextButton.backgroundColor = UIColor.base()
258
+        nextButton.setAttributedTitle(normalAtt, for: UIControl.State.normal)
259
+        return nextButton
260
+    }()
261
+    
262
+    @objc func submitAction(button: UIButton) {
263
+        delegate?.kxsf_FlowerFooterViewAction(section: button.tag)
89 264
     }
90 265
 }

+ 23 - 0
CAISHEN/SellFlowers/Mine/model/KXSFMineFlowerOrderModel.swift

@@ -0,0 +1,23 @@
1
+//
2
+//  KXSFMineFlowerOrderModel.swift
3
+//  CAISHEN
4
+//
5
+//  Created by xiaoxi on 2018/11/12.
6
+//  Copyright © 2018 kuxuan. All rights reserved.
7
+//
8
+
9
+import UIKit
10
+
11
+class KXSFMineFlowerOrderModel: NSObject, YYModel {
12
+    @objc var id: String?
13
+    @objc var total_price: String?
14
+    @objc var total_num: String?
15
+    @objc var product: Array<KXSFMListModel>?
16
+    @objc var delivery_time: String?
17
+    @objc var message: String?
18
+    @objc var address_id: String?
19
+    
20
+    @objc static func modelContainerPropertyGenericClass() -> [String : Any]? {
21
+        return ["product": KXSFMListModel.self]
22
+    }
23
+}