|
@@ -11,6 +11,9 @@ import JXSegmentedView
|
|
|
|
|
|
class OrderListViewController: UIViewController {
|
|
|
|
|
|
+ var orderVCType : OrderVCType?
|
|
|
+ var orderModelArray = Array<OrderModel>()
|
|
|
+
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
setupViews()
|
|
@@ -29,16 +32,233 @@ class OrderListViewController: UIViewController {
|
|
|
}
|
|
|
|
|
|
func setupData() {
|
|
|
+ orderListView.tableView.addHeaderWithHeader(withBeginRefresh: true, animation: false) {
|
|
|
+ [weak self] (page) in
|
|
|
+ self?.orderPurchaseOrderListApi(page: page)
|
|
|
+ }
|
|
|
+ orderListView.tableView.addFooterWithWithHeader(withAutomaticallyRefresh: true) {
|
|
|
+ [weak self] (page) in
|
|
|
+ self?.orderPurchaseOrderListApi(page: page)
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
+ func orderPurchaseOrderListApi(page:Int = 1) {
|
|
|
+ SwiftMoyaNetWorkServiceOrder.shared().orderPurchaseOrderListApi(page: page, status: orderVCType.map { $0.rawValue } ?? -1) {
|
|
|
+ [weak self] (orderListModel) -> (Void) in
|
|
|
+ let orderListModel = orderListModel as? OrderListModel
|
|
|
+ if orderListModel?.pagination?.currentPage ?? 1 <= orderListModel?.pagination?.totalPages ?? 1 {
|
|
|
+ if orderListModel?.pagination?.currentPage == 1{
|
|
|
+ self?.orderModelArray.removeAll()
|
|
|
+ self?.orderListView.tableView.resetNoMoreData()
|
|
|
+ }
|
|
|
+ self?.orderModelArray = (self?.orderModelArray)! + (orderListModel?.data!)!
|
|
|
+ self?.orderListView.tableView.reloadData()
|
|
|
+ }else {
|
|
|
+ self?.orderListView.tableView.endFooterNoMoreData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private lazy var orderListView: OrderListView = {
|
|
|
let orderListView = OrderListView()
|
|
|
+ orderListView.tableView.dataSource = self
|
|
|
+ orderListView.tableView.delegate = self
|
|
|
return orderListView
|
|
|
}()
|
|
|
+}
|
|
|
|
|
|
+extension OrderListViewController : UITableViewDelegate, UITableViewDataSource {
|
|
|
+ func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
+
|
|
|
+ return orderModelArray.isEmpty ? 0 : orderModelArray.count
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
+ let orderModel = orderModelArray[section]
|
|
|
+
|
|
|
+
|
|
|
+ if !(orderModel.detail?.isEmpty ?? true) {
|
|
|
+ switch orderModel.deliverType {
|
|
|
+ case 1: //自提
|
|
|
+ if orderModel.feedbackStatus == 0 { //未维权
|
|
|
+ switch orderModel.status {
|
|
|
+ case 0: //待付款
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 1: //待发货
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 2: //已发货/待收货
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 3: //配送中
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 4: //待自提
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 5: //已自提
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 6: //已完成
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 7: //已关闭
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+
|
|
|
+ default:
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ switch orderModel.feedbackStatus {
|
|
|
+ case 1: //1-退款处理中
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 2: //2-退款完成
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 3: //3-拒绝退款
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ default:
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ case 2: //快递
|
|
|
+ if orderModel.feedbackStatus == 0 { //未维权
|
|
|
+ switch orderModel.status {
|
|
|
+ case 0: //待付款
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 1: //待发货
|
|
|
+ return 3 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 2: //已发货/待收货
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 3: //配送中
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 4: //待自提
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 5: //已自提
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 6: //已完成
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 7: //已关闭
|
|
|
+ return 3 + (orderModel.detail?.count ?? 0)
|
|
|
+ default:
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ switch orderModel.feedbackStatus {
|
|
|
+ case 1: //1-退款处理中
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 2: //2-退款完成
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ case 3: //3-拒绝退款
|
|
|
+ return 4 + (orderModel.detail?.count ?? 0)
|
|
|
+ default:
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
+ switch indexPath.row {
|
|
|
+ case 0:
|
|
|
+ let cell = OrderShopAndStatusTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ cell.orderModel = orderModelArray[indexPath.section]
|
|
|
+ return cell
|
|
|
+ case 1:
|
|
|
+ let cell = OrderDeliveryModeAndTimeTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ cell.orderModel = orderModelArray[indexPath.section]
|
|
|
+ return cell
|
|
|
+ case orderModelArray.count + 2:
|
|
|
+ let cell = OrderTotalAmountTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ cell.orderModel = orderModelArray[indexPath.section]
|
|
|
+ return cell
|
|
|
+ case orderModelArray.count + 3:
|
|
|
+ let orderModel = orderModelArray[indexPath.section]
|
|
|
+ switch orderModel.deliverType {
|
|
|
+ case 1: //自提
|
|
|
+ if orderModel.feedbackStatus == 0 { //未维权
|
|
|
+ switch orderModel.status {
|
|
|
+ case 0,5: //待付款/已自提/已完成
|
|
|
+ let cell = OrderDeliveryModeAndButtonTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ case 1,4,7: //待发货/待自提/已关闭
|
|
|
+ let cell = OrderDeliveryModeTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ case 2,3: //待收货/配送中
|
|
|
+ let cell = OrderButtonTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ default:
|
|
|
+ return UITableViewCell()
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ let cell = OrderDeliveryModeAndButtonTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ }
|
|
|
+
|
|
|
+ case 2: //快递
|
|
|
+ if orderModel.feedbackStatus == 0 { //未维权
|
|
|
+ switch orderModel.status {
|
|
|
+ case 0,2,3,6: //待付款/待收货//配送中
|
|
|
+ let cell = OrderButtonTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ case 1,4,5,7: //待发货//待自提//已自提/已关闭
|
|
|
+ return UITableViewCell()
|
|
|
+ default:
|
|
|
+ return UITableViewCell()
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ let cell = OrderButtonTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return UITableViewCell()
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ let cell = OrderProductTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ let orderModel = orderModelArray[indexPath.section]
|
|
|
+ if !(orderModel.detail?.isEmpty ?? true) {
|
|
|
+ cell.orderModelDetailModel = orderModel.detail?[indexPath.row-2]
|
|
|
+ }
|
|
|
+ return cell
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
|
+ switch indexPath.row {
|
|
|
+ case 0:
|
|
|
+ return 48
|
|
|
+ case 1:
|
|
|
+ return 40
|
|
|
+ case orderModelArray.count + 2:
|
|
|
+ return 40
|
|
|
+ case orderModelArray.count + 3:
|
|
|
+ return UITableView.automaticDimension
|
|
|
+ default:
|
|
|
+ return 108
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
|
+ return 10
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
extension OrderListViewController : JXSegmentedListContainerViewListDelegate {
|
|
|
func listView() -> UIView {
|
|
|
return view
|