做完车辆信息模块之后,又添加了一下预约加油模块的具体订单显示,核心代码如下:
// MARK: - lifecycle
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.gray
self.automaticallyAdjustsScrollViewInsets = false
if let navigationController = self.navigationController {
// 导航栏透明
navigationController.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController.navigationBar.shadowImage = UIImage()
navigationController.navigationBar.isTranslucent = true
let backButton = UIButton(frame: Rect(0, 0, 30, 30))
backButton.setImage(#imageLiteral(resourceName: "signup_button_back"), for: .normal)
backButton.addTarget(self, action: #selector(back), for: .touchUpInside)
let menuBarItem = UIBarButtonItem(customView: backButton)
navigationItem.leftBarButtonItem = menuBarItem
var contentInset = self.tableView.contentInset
contentInset.top = 200
self.tableView.contentInset = contentInset
}
initUI()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
UserManager.addObserver(observer: self, selector: .userDidGetOrderInfo, notification: .didGetOrderInfo)
UserManager.addObserver(observer: self, selector: .userDidGetOrderInfoFailure, notification: .didGetOrderInfoFailure)
let logInStatus = UserManager.shared.isLogIn
guard logInStatus == true else {
self.errorNotice("请先登录~")
return
}
getOrderInfo()
}
其实和之前的车辆模块写法类似,也是数据和界面的结合,我这里的主要工作量在于写界面,也是通过snapkit来搭建UI