OrderDetailBottomView.swift 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. //
  2. // OrderDetailBottomView.swift
  3. // RainbowPlanet
  4. //
  5. // Created by 南鑫林 on 2019/5/16.
  6. // Copyright © 2019 RainbowPlanet. All rights reserved.
  7. //
  8. import UIKit
  9. class OrderDetailBottomView: BaseView {
  10. override func setupViews() {
  11. addSubview(oneButton)
  12. addSubview(twoButton)
  13. addSubview(threeButton)
  14. addSubview(leftButton)
  15. }
  16. override func setupLayouts() {
  17. oneButton.snp.remakeConstraints { (make) in
  18. make.centerY.equalToSuperview()
  19. make.height.equalTo(36)
  20. make.width.greaterThanOrEqualTo(90)
  21. make.right.equalTo(-14)
  22. }
  23. twoButton.snp.remakeConstraints { (make) in
  24. make.right.equalTo(oneButton.snp.left).offset(-12)
  25. make.centerY.equalToSuperview()
  26. make.height.equalTo(36)
  27. make.width.greaterThanOrEqualTo(90)
  28. }
  29. threeButton.snp.makeConstraints { (make) in
  30. make.right.equalTo(twoButton.snp.left).offset(-12)
  31. make.centerY.equalToSuperview()
  32. make.height.equalTo(36)
  33. make.width.greaterThanOrEqualTo(90)
  34. }
  35. leftButton.snp.makeConstraints { (make) in
  36. make.centerY.equalToSuperview()
  37. make.left.equalTo(20)
  38. }
  39. }
  40. private lazy var addressLabel: UILabel = {
  41. let addressLabel = UILabel()
  42. addressLabel.textColor = kfe352bColor
  43. addressLabel.font = kRegularFont13
  44. addressLabel.text = "自提地址:碑林区建设西路新城南门柜机"
  45. return addressLabel
  46. }()
  47. lazy var oneButton: UIButton = {
  48. let oneButton = UIButton(type: UIButton.ButtonType.custom)
  49. oneButton.cornerRadius = 18
  50. oneButton.masksToBounds = true
  51. oneButton.titleLabel?.font = kRegularFont15
  52. oneButton.isHidden = true
  53. return oneButton
  54. }()
  55. lazy var twoButton: UIButton = {
  56. let twoButton = UIButton(type: UIButton.ButtonType.custom)
  57. twoButton.cornerRadius = 18
  58. twoButton.masksToBounds = true
  59. twoButton.titleLabel?.font = kRegularFont15
  60. twoButton.isHidden = true
  61. return twoButton
  62. }()
  63. lazy var threeButton: UIButton = {
  64. let threeButton = UIButton(type: UIButton.ButtonType.custom)
  65. threeButton.cornerRadius = 18
  66. threeButton.masksToBounds = true
  67. threeButton.titleLabel?.font = kRegularFont15
  68. return threeButton
  69. }()
  70. lazy var leftButton: UIButton = {
  71. let leftButton = UIButton(type: UIButton.ButtonType.custom)
  72. leftButton.titleLabel?.font = kRegularFont15
  73. leftButton.isHidden = true
  74. return leftButton
  75. }()
  76. var orderModel: OrderModel? {
  77. didSet {
  78. switch orderModel?.status {
  79. case 0: //待付款
  80. leftButton.isHidden = false
  81. leftButton.setTitle("取消订单", for: UIControl.State.normal)
  82. leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
  83. setButton(isHidden: false, button: oneButton, title: "去付款", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  84. case 1://待发货
  85. if orderModel?.feedbackStatus == 0 {
  86. leftButton.isHidden = false
  87. leftButton.setTitle("申请退款", for: UIControl.State.normal)
  88. leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
  89. setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  90. }else {
  91. setButton(isHidden: false, button: oneButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  92. setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  93. }
  94. break
  95. case 2: //待收货
  96. if orderModel?.feedbackStatus == 0 {
  97. leftButton.isHidden = false
  98. leftButton.setTitle("申请退款", for: UIControl.State.normal)
  99. leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
  100. setButton(isHidden: false, button: oneButton, title: "确认收货", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  101. setButton(isHidden: false, button: twoButton, title: "查看物流", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  102. }else {
  103. setButton(isHidden: false, button: oneButton, title: "确认收货", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  104. setButton(isHidden: false, button: twoButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  105. setButton(isHidden: false, button: threeButton, title: "查看物流", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  106. }
  107. case 3: //配送中
  108. if orderModel?.feedbackStatus == 0 {
  109. leftButton.isHidden = false
  110. leftButton.setTitle("申请退款", for: UIControl.State.normal)
  111. leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
  112. setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  113. }else {
  114. setButton(isHidden: false, button: oneButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  115. setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  116. }
  117. case 4://待自提
  118. if orderModel?.feedbackStatus == 0 {
  119. leftButton.isHidden = false
  120. leftButton.setTitle("申请退款", for: UIControl.State.normal)
  121. leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
  122. setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  123. }else {
  124. setButton(isHidden: false, button: oneButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  125. setButton(isHidden: false, button: threeButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  126. }
  127. case 5: //已自提
  128. if orderModel?.feedbackStatus == 0 {
  129. leftButton.isHidden = false
  130. leftButton.setTitle("申请退款", for: UIControl.State.normal)
  131. leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
  132. if orderModel?.isComment == 0 {
  133. setButton(isHidden: false, button: oneButton, title: "去评价", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  134. setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  135. }else {
  136. setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  137. }
  138. }else {
  139. if orderModel?.isComment == 0 {
  140. setButton(isHidden: false, button: oneButton, title: "去评价", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  141. setButton(isHidden: false, button: twoButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  142. setButton(isHidden: false, button: threeButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  143. }else {
  144. setButton(isHidden: false, button: oneButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  145. setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  146. }
  147. }
  148. case 6: //已完成
  149. if orderModel?.isComment == 0 {
  150. setButton(isHidden: false, button: oneButton, title: "去评价", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  151. setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  152. setButton(isHidden: false, button: threeButton, title: "查看物流", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  153. }else {
  154. setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
  155. setButton(isHidden: false, button: twoButton, title: "查看物流", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
  156. }
  157. case 7: //已关闭
  158. setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: k333333Color)
  159. default:
  160. break
  161. }
  162. }
  163. }
  164. func setButton(isHidden:Bool,button:UIButton,title:String,titleColor:UIColor,backgroundColor:UIColor,borderColor:UIColor) {
  165. button.isHidden = isHidden
  166. button.setTitle(title, for: UIControl.State.normal)
  167. button.setTitleColor(titleColor, for: UIControl.State.normal)
  168. button.backgroundColor = backgroundColor
  169. button.layer.borderColor = borderColor.cgColor
  170. button.layer.borderWidth = 1
  171. }
  172. }