// // SalesmanComplementVC.swift // ADHTuanCan // // Created by 敖德亨 on 2023/11/13. // import UIKit import RxSwift import RxCocoa class SalesmanComplementVC: ADHBaseVC { var shopType : String?{ didSet{ self.viewModel.salesmanCompleteModel.shopType = shopType } } @IBOutlet weak var topContent: NSLayoutConstraint! @IBOutlet weak var saveBtn: UIButton! @IBOutlet weak var nameTF: UITextField! @IBOutlet weak var phoneTF: UITextField! @IBOutlet weak var postCodeTF: UITextField! @IBOutlet weak var addressDetailTF: UITextView! @IBOutlet weak var streeTF: UITextField! @IBOutlet weak var startTimeLab: UILabel! @IBOutlet weak var endTimeLab: UILabel! var name : String? var phone : String? var postCode : String? var address : String? var street : String? var startTime : String? var endTime : String? let viewModel : HomeViewModel = HomeViewModel.init() let diposableBag = DisposeBag() override func viewDidLoad() { super.viewDidLoad() let navStyle = MCNavBarStyle() navStyle.styleForBackImage = UIImage.init(named: "黑色返回")! navStyle.styleForTitleColor = UIColor.black self.navBar = MCNavBarView.init(title: LanguagesUtil.createTextBy(Ctext: "客户信息", Etext: "Client information"), subTitle: nil,style: navStyle) self.topContent.constant = kNavAndStatuHeight + 1 self.navBar?.backgroundColor = UIColor.white self.view.backgroundColor = UIColor.white self.nameTF.inputText(maxLength: 19) { self.name = self.nameTF.text } self.phoneTF.inputNumber(maxLength: 20) { self.phone = self.phoneTF.text } self.postCodeTF.inputNumber(maxLength: 20) { self.postCode = self.postCodeTF.text } self.addressDetailTF.inputText(maxLength: 300) { self.address = self.addressDetailTF.text } self.streeTF.inputText(maxLength: 40) { self.street = self.streeTF.text } } func saveSalesmanDetail(){ if name.isEmptyStr{ self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入姓名", Etext: "Please input your name")) return } if phone.isEmptyStr{ self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入手机号", Etext: "Please input your phone number")) return } if phone?.count ?? 0 < 8{ self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入正确的手机号", Etext: "Please input the correct phone number")) return } if postCode.isEmptyStr{ self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入邮编", Etext: "Please input postal coder")) return } if street.isEmptyStr{ self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入街道", Etext: "Please input street")) return } if address.isEmptyStr{ self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入详细地址", Etext: "Please input the full address")) return } // if startTime.isEmptyStr{ // self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请选择开始时间", Etext: "Please select a start time")) // return // } // // if endTime.isEmptyStr{ // self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请选择结束时间", Etext: "Please select an end time")) // return // } self.hud.showLoading() self.viewModel.salesmanCompleteModel.receiving = name self.viewModel.salesmanCompleteModel.phoneNum = phone self.viewModel.salesmanCompleteModel.postcode = postCode self.viewModel.salesmanCompleteModel.detailAddress = address self.viewModel.salesmanCompleteModel.street = street self.viewModel.salesmanCompleteModel.startDate = "2023-11-14" self.viewModel.salesmanCompleteModel.endDate = "2023-11-20" self.viewModel.signalSalesmanComplete()?.on(success: { dd in self.hud.showSuccess() NotificationCenter.default.post(name: NSNotification.Name("刷新首页"), object: self, userInfo:nil) self.navigationController?.popViewController(animated: true) }, error: { error in self.hud.showFailure(error.msg ?? LanguagesUtil.createTextBy(Ctext: "网络错误", Etext: "network error")) }) } @IBAction func jumpAction(_ sender: UIButton) { self.navigationController?.popViewController(animated: true) } @IBAction func saveAction(_ sender: UIButton) { self.saveSalesmanDetail() } }