SalesmanComplementVC.swift 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //
  2. // SalesmanComplementVC.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/11/13.
  6. //
  7. import UIKit
  8. import RxSwift
  9. import RxCocoa
  10. class SalesmanComplementVC: ADHBaseVC {
  11. var shopType : String?{
  12. didSet{
  13. self.viewModel.salesmanCompleteModel.shopType = shopType
  14. }
  15. }
  16. @IBOutlet weak var topContent: NSLayoutConstraint!
  17. @IBOutlet weak var saveBtn: UIButton!
  18. @IBOutlet weak var nameTF: UITextField!
  19. @IBOutlet weak var phoneTF: UITextField!
  20. @IBOutlet weak var postCodeTF: UITextField!
  21. @IBOutlet weak var addressDetailTF: UITextView!
  22. @IBOutlet weak var streeTF: UITextField!
  23. @IBOutlet weak var startTimeLab: UILabel!
  24. @IBOutlet weak var endTimeLab: UILabel!
  25. var name : String?
  26. var phone : String?
  27. var postCode : String?
  28. var address : String?
  29. var street : String?
  30. var startTime : String?
  31. var endTime : String?
  32. let viewModel : HomeViewModel = HomeViewModel.init()
  33. let diposableBag = DisposeBag()
  34. override func viewDidLoad() {
  35. super.viewDidLoad()
  36. let navStyle = MCNavBarStyle()
  37. navStyle.styleForBackImage = UIImage.init(named: "黑色返回")!
  38. navStyle.styleForTitleColor = UIColor.black
  39. self.navBar = MCNavBarView.init(title: LanguagesUtil.createTextBy(Ctext: "客户信息", Etext: "Client information"), subTitle: nil,style: navStyle)
  40. self.topContent.constant = kNavAndStatuHeight + 1
  41. self.navBar?.backgroundColor = UIColor.white
  42. self.view.backgroundColor = UIColor.white
  43. self.nameTF.inputText(maxLength: 19) {
  44. self.name = self.nameTF.text
  45. }
  46. self.phoneTF.inputNumber(maxLength: 20) {
  47. self.phone = self.phoneTF.text
  48. }
  49. self.postCodeTF.inputNumber(maxLength: 20) {
  50. self.postCode = self.postCodeTF.text
  51. }
  52. self.addressDetailTF.inputText(maxLength: 300) {
  53. self.address = self.addressDetailTF.text
  54. }
  55. self.streeTF.inputText(maxLength: 40) {
  56. self.street = self.streeTF.text
  57. }
  58. }
  59. func saveSalesmanDetail(){
  60. if name.isEmptyStr{
  61. self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入姓名", Etext: "Please input your name"))
  62. return
  63. }
  64. if phone.isEmptyStr{
  65. self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入手机号", Etext: "Please input your phone number"))
  66. return
  67. }
  68. if phone?.count ?? 0 < 8{
  69. self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入正确的手机号", Etext: "Please input the correct phone number"))
  70. return
  71. }
  72. if postCode.isEmptyStr{
  73. self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入邮编", Etext: "Please input postal coder"))
  74. return
  75. }
  76. if street.isEmptyStr{
  77. self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入街道", Etext: "Please input street"))
  78. return
  79. }
  80. if address.isEmptyStr{
  81. self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入详细地址", Etext: "Please input the full address"))
  82. return
  83. }
  84. // if startTime.isEmptyStr{
  85. // self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请选择开始时间", Etext: "Please select a start time"))
  86. // return
  87. // }
  88. //
  89. // if endTime.isEmptyStr{
  90. // self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请选择结束时间", Etext: "Please select an end time"))
  91. // return
  92. // }
  93. self.hud.showLoading()
  94. self.viewModel.salesmanCompleteModel.receiving = name
  95. self.viewModel.salesmanCompleteModel.phoneNum = phone
  96. self.viewModel.salesmanCompleteModel.postcode = postCode
  97. self.viewModel.salesmanCompleteModel.detailAddress = address
  98. self.viewModel.salesmanCompleteModel.street = street
  99. self.viewModel.salesmanCompleteModel.startDate = "2023-11-14"
  100. self.viewModel.salesmanCompleteModel.endDate = "2023-11-20"
  101. self.viewModel.signalSalesmanComplete()?.on(success: { dd in
  102. self.hud.showSuccess()
  103. NotificationCenter.default.post(name: NSNotification.Name("刷新首页"), object: self, userInfo:nil)
  104. self.navigationController?.popViewController(animated: true)
  105. }, error: { error in
  106. self.hud.showFailure(error.msg ?? LanguagesUtil.createTextBy(Ctext: "网络错误", Etext: "network error"))
  107. })
  108. }
  109. @IBAction func jumpAction(_ sender: UIButton) {
  110. self.navigationController?.popViewController(animated: true)
  111. }
  112. @IBAction func saveAction(_ sender: UIButton) {
  113. self.saveSalesmanDetail()
  114. }
  115. }