OderDetailHeadView.swift 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. //
  2. // OderDetailHeadView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/11/4.
  6. //
  7. import UIKit
  8. class OderDetailHeadView: UIView {
  9. /// 时间提示View
  10. @IBOutlet weak var timeView: UIView!
  11. /// 待支付View
  12. @IBOutlet weak var willPayView: UIView!
  13. /// 待接单
  14. @IBOutlet weak var pendingOrderView: UIView!
  15. /// 已完成
  16. @IBOutlet weak var finishView: UIView!
  17. /// 配送
  18. @IBOutlet weak var deliveryView: UIView!
  19. /// 超时取消
  20. @IBOutlet weak var timeOutView: UIView!
  21. /// 去支付BtnV
  22. @IBOutlet weak var payBtnView: UIView!
  23. /// 地址BtnV
  24. @IBOutlet weak var addressBtnView: UIView!
  25. /// 再次购买BtnV
  26. @IBOutlet weak var buyAgainBtnView: UIView!
  27. /// 确认收货BtnV
  28. @IBOutlet weak var receivingBtnView: UIView!
  29. /// 去评价BtnV
  30. @IBOutlet weak var evaluateBtnView: UIView!
  31. /// 联系商家BtnV
  32. @IBOutlet weak var callBtnView: UIView!
  33. /// 取消订单BtnV
  34. @IBOutlet weak var cancelBtnView: UIView!
  35. /// 订单状态
  36. @IBOutlet weak var typeLab: UILabel!
  37. /// 下单时间
  38. @IBOutlet weak var makeOrdrtTime: UILabel!
  39. /// 配送时间
  40. @IBOutlet weak var deliveryTme: UILabel!
  41. /// 地址
  42. @IBOutlet weak var addressLab: UILabel!
  43. /// 邮编
  44. @IBOutlet weak var postCodeLab: UILabel!
  45. /// 电话
  46. @IBOutlet weak var phoneLab: UILabel!
  47. /// 收货人
  48. @IBOutlet weak var nameLab: UILabel!
  49. /// 1去支付 2修改地址 3再来一单 4确认收货 5去评价 6联系商家 7取消订单
  50. var headBtnBlock : ((Int)->Void)?
  51. override func awakeFromNib() {
  52. super.awakeFromNib()
  53. }
  54. func configModel(model : OrderOutDetailModel){
  55. self.makeOrdrtTime.text = "\(model.createTime ?? "")"
  56. // self.makeOrdrtTime.text = "\(model. ?? "")"
  57. self.addressLab.text = "\(model.street ?? "")\(model.detailAddress ?? "")"
  58. // self.addressLab.sizeToFit()
  59. self.postCodeLab.text = "\(model.postcode ?? "")"
  60. self.phoneLab.text = "\(model.phoneNum ?? "")"
  61. self.nameLab.text = "\(model.receiving ?? "")"
  62. let labHeight : CGFloat = (self.addressLab.frame.size.height)
  63. self.timeView.isHidden = true
  64. self.willPayView.isHidden = true
  65. self.pendingOrderView.isHidden = true
  66. self.finishView.isHidden = true
  67. self.deliveryView.isHidden = true
  68. self.timeOutView.isHidden = true
  69. self.payBtnView.isHidden = true
  70. self.addressBtnView.isHidden = true
  71. self.buyAgainBtnView.isHidden = true
  72. self.receivingBtnView.isHidden = true
  73. self.evaluateBtnView.isHidden = true
  74. self.callBtnView.isHidden = true
  75. self.cancelBtnView.isHidden = true
  76. let status : String = "\(model.orderStatus ?? "")"
  77. if status === 1{
  78. //待付款
  79. self.timeView.isHidden = false
  80. self.willPayView.isHidden = false
  81. self.pendingOrderView.isHidden = true
  82. self.finishView.isHidden = true
  83. self.deliveryView.isHidden = true
  84. self.timeOutView.isHidden = true
  85. self.payBtnView.isHidden = false
  86. self.addressBtnView.isHidden = false
  87. self.buyAgainBtnView.isHidden = true
  88. self.receivingBtnView.isHidden = true
  89. self.evaluateBtnView.isHidden = true
  90. self.callBtnView.isHidden = true
  91. self.cancelBtnView.isHidden = false
  92. if self.addressLab.text.isNotEmptyStr{
  93. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:135 + labHeight + 30 + 100 + 100 + 100))
  94. }else{
  95. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:155 + 30 + 100 + 100 + 100))
  96. }
  97. self.typeLab.text = "待支付"
  98. }
  99. if status === 2{
  100. //待接单
  101. self.timeView.isHidden = true
  102. self.willPayView.isHidden = true
  103. self.pendingOrderView.isHidden = false
  104. self.finishView.isHidden = true
  105. self.deliveryView.isHidden = true
  106. self.timeOutView.isHidden = true
  107. self.payBtnView.isHidden = true
  108. self.addressBtnView.isHidden = false
  109. self.buyAgainBtnView.isHidden = true
  110. self.receivingBtnView.isHidden = true
  111. self.evaluateBtnView.isHidden = true
  112. self.callBtnView.isHidden = true
  113. self.cancelBtnView.isHidden = false
  114. if self.addressLab.text.isNotEmptyStr{
  115. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:135 + labHeight + 100 + 100 + 100))
  116. }else{
  117. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:155 + 100 + 100 + 100))
  118. }
  119. self.typeLab.text = LanguagesUtil.createTextBy(Ctext: "待商家接单", Etext: "Waiting fo accept the order")
  120. }
  121. if status === 3{
  122. //待配送
  123. self.timeView.isHidden = true
  124. self.willPayView.isHidden = true
  125. self.pendingOrderView.isHidden = true
  126. self.finishView.isHidden = true
  127. self.deliveryView.isHidden = false
  128. self.timeOutView.isHidden = true
  129. self.payBtnView.isHidden = true
  130. self.addressBtnView.isHidden = true
  131. self.buyAgainBtnView.isHidden = false
  132. self.receivingBtnView.isHidden = false
  133. self.evaluateBtnView.isHidden = true
  134. self.callBtnView.isHidden = false
  135. self.cancelBtnView.isHidden = true
  136. if self.addressLab.text.isNotEmptyStr{
  137. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:135 + labHeight + 100 + 100 + 100))
  138. }else{
  139. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:155 + 100 + 100 + 100))
  140. }
  141. self.typeLab.text = "订单待配送"
  142. }
  143. if status === 4{
  144. //已完成未评价
  145. self.timeView.isHidden = true
  146. self.willPayView.isHidden = true
  147. self.pendingOrderView.isHidden = true
  148. self.finishView.isHidden = false
  149. self.deliveryView.isHidden = true
  150. self.timeOutView.isHidden = true
  151. self.payBtnView.isHidden = true
  152. self.addressBtnView.isHidden = true
  153. self.buyAgainBtnView.isHidden = false
  154. self.receivingBtnView.isHidden = true
  155. self.evaluateBtnView.isHidden = false
  156. self.callBtnView.isHidden = true
  157. self.cancelBtnView.isHidden = false
  158. if self.addressLab.text.isNotEmptyStr{
  159. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:135 + labHeight + 100 + 100 + 100))
  160. }else{
  161. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:155 + 100 + 100 + 100))
  162. }
  163. self.typeLab.text = "订单已完成"
  164. }
  165. if status === 5{
  166. //已取消
  167. self.timeView.isHidden = true
  168. self.willPayView.isHidden = true
  169. self.pendingOrderView.isHidden = true
  170. self.finishView.isHidden = true
  171. self.deliveryView.isHidden = true
  172. self.timeOutView.isHidden = false //超时
  173. self.payBtnView.isHidden = true
  174. self.addressBtnView.isHidden = true
  175. self.buyAgainBtnView.isHidden = false
  176. self.receivingBtnView.isHidden = true
  177. self.evaluateBtnView.isHidden = true
  178. self.callBtnView.isHidden = false
  179. self.cancelBtnView.isHidden = true
  180. if self.addressLab.text.isNotEmptyStr{
  181. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:135 + labHeight + 50 + 100 + 100))
  182. }else{
  183. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:155 + 50 + 100 + 100))
  184. }
  185. self.typeLab.text = "订单已取消"
  186. }
  187. if status === 6{
  188. //退款中
  189. self.timeView.isHidden = true
  190. self.willPayView.isHidden = true
  191. self.pendingOrderView.isHidden = true
  192. self.finishView.isHidden = false
  193. self.deliveryView.isHidden = true
  194. self.timeOutView.isHidden = true
  195. self.payBtnView.isHidden = true
  196. self.addressBtnView.isHidden = true
  197. self.buyAgainBtnView.isHidden = false
  198. self.receivingBtnView.isHidden = true
  199. self.evaluateBtnView.isHidden = true
  200. self.callBtnView.isHidden = false
  201. self.cancelBtnView.isHidden = true
  202. if self.addressLab.text.isNotEmptyStr{
  203. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:135 + labHeight + 100 + 100 + 100))
  204. }else{
  205. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:155 + 100 + 100 + 100))
  206. }
  207. self.typeLab.text = "订单退款中"
  208. }
  209. if status === 7{
  210. //已退款
  211. self.timeView.isHidden = true
  212. self.willPayView.isHidden = true
  213. self.pendingOrderView.isHidden = true
  214. self.finishView.isHidden = false
  215. self.deliveryView.isHidden = true
  216. self.timeOutView.isHidden = true
  217. self.payBtnView.isHidden = true
  218. self.addressBtnView.isHidden = true
  219. self.buyAgainBtnView.isHidden = false
  220. self.receivingBtnView.isHidden = true
  221. self.evaluateBtnView.isHidden = true
  222. self.callBtnView.isHidden = false
  223. self.cancelBtnView.isHidden = true
  224. if self.addressLab.text.isNotEmptyStr{
  225. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:135 + labHeight + 100 + 100 + 100))
  226. }else{
  227. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:155 + 100 + 100 + 100))
  228. }
  229. self.typeLab.text = "订单已退款"
  230. }
  231. if status === 8{
  232. //完成已评价
  233. self.timeView.isHidden = true
  234. self.willPayView.isHidden = true
  235. self.pendingOrderView.isHidden = true
  236. self.finishView.isHidden = false
  237. self.deliveryView.isHidden = true
  238. self.timeOutView.isHidden = true
  239. self.payBtnView.isHidden = true
  240. self.addressBtnView.isHidden = true
  241. self.buyAgainBtnView.isHidden = false
  242. self.receivingBtnView.isHidden = true
  243. self.evaluateBtnView.isHidden = true
  244. self.callBtnView.isHidden = false
  245. self.cancelBtnView.isHidden = true
  246. if self.addressLab.text.isNotEmptyStr{
  247. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:135 + labHeight + 100 + 100 + 100))
  248. }else{
  249. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:155 + 100 + 100 + 100))
  250. }
  251. self.typeLab.text = "订单已完成"
  252. }
  253. }
  254. /// 去支付
  255. /// - Parameter sender: <#sender description#>
  256. @IBAction func goToPayAction(_ sender: UIButton) {
  257. if self.headBtnBlock != nil{
  258. self.headBtnBlock!(1)
  259. }
  260. }
  261. /// 修改地址
  262. /// - Parameter sender: <#sender description#>
  263. @IBAction func addressAction(_ sender: UIButton) {
  264. if self.headBtnBlock != nil{
  265. self.headBtnBlock!(2)
  266. }
  267. }
  268. /// 再来一单
  269. /// - Parameter sender: <#sender description#>
  270. @IBAction func oneMoreAgain(_ sender: UIButton) {
  271. if self.headBtnBlock != nil{
  272. self.headBtnBlock!(3)
  273. }
  274. }
  275. /// 确认收货
  276. /// - Parameter sender: <#sender description#>
  277. @IBAction func confirmReceipt(_ sender: UIButton) {
  278. if self.headBtnBlock != nil{
  279. self.headBtnBlock!(4)
  280. }
  281. }
  282. /// 去评价
  283. /// - Parameter sender: <#sender description#>
  284. @IBAction func goToEvaluate(_ sender: UIButton) {
  285. if self.headBtnBlock != nil{
  286. self.headBtnBlock!(5)
  287. }
  288. }
  289. /// 联系商家
  290. /// - Parameter sender: <#sender description#>
  291. @IBAction func phoneCall(_ sender: UIButton) {
  292. if self.headBtnBlock != nil{
  293. self.headBtnBlock!(6)
  294. }
  295. }
  296. /// 取消订单
  297. /// - Parameter sender: <#sender description#>
  298. @IBAction func cancelOrderAction(_ sender: UIButton) {
  299. if self.headBtnBlock != nil{
  300. self.headBtnBlock!(7)
  301. }
  302. }
  303. }