123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- //
- // OrderDetailBottomView.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/5/16.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- class OrderDetailBottomView: BaseView {
- override func setupViews() {
- addSubview(oneButton)
- addSubview(twoButton)
- addSubview(threeButton)
- addSubview(leftButton)
- }
-
- override func setupLayouts() {
- oneButton.snp.remakeConstraints { (make) in
- make.centerY.equalToSuperview()
- make.height.equalTo(36)
- make.width.greaterThanOrEqualTo(90)
- make.right.equalTo(-14)
- }
- twoButton.snp.remakeConstraints { (make) in
- make.right.equalTo(oneButton.snp.left).offset(-12)
- make.centerY.equalToSuperview()
- make.height.equalTo(36)
- make.width.greaterThanOrEqualTo(90)
- }
- threeButton.snp.makeConstraints { (make) in
- make.right.equalTo(twoButton.snp.left).offset(-12)
- make.centerY.equalToSuperview()
- make.height.equalTo(36)
- make.width.greaterThanOrEqualTo(90)
- }
- leftButton.snp.makeConstraints { (make) in
- make.centerY.equalToSuperview()
- make.left.equalTo(20)
- }
- }
-
- private lazy var addressLabel: UILabel = {
- let addressLabel = UILabel()
- addressLabel.textColor = kfe352bColor
- addressLabel.font = kRegularFont13
- addressLabel.text = "自提地址:碑林区建设西路新城南门柜机"
- return addressLabel
- }()
-
- lazy var oneButton: UIButton = {
- let oneButton = UIButton(type: UIButton.ButtonType.custom)
- oneButton.cornerRadius = 18
- oneButton.masksToBounds = true
- oneButton.titleLabel?.font = kRegularFont15
- oneButton.isHidden = true
- return oneButton
- }()
-
- lazy var twoButton: UIButton = {
- let twoButton = UIButton(type: UIButton.ButtonType.custom)
- twoButton.cornerRadius = 18
- twoButton.masksToBounds = true
- twoButton.titleLabel?.font = kRegularFont15
- twoButton.isHidden = true
- return twoButton
- }()
-
- lazy var threeButton: UIButton = {
- let threeButton = UIButton(type: UIButton.ButtonType.custom)
- threeButton.cornerRadius = 18
- threeButton.masksToBounds = true
- threeButton.titleLabel?.font = kRegularFont15
- return threeButton
- }()
-
- lazy var leftButton: UIButton = {
- let leftButton = UIButton(type: UIButton.ButtonType.custom)
- leftButton.titleLabel?.font = kRegularFont15
- leftButton.isHidden = true
- return leftButton
- }()
-
- var orderModel: OrderModel? {
- didSet {
- switch orderModel?.status {
- case 0: //待付款
- leftButton.isHidden = false
- leftButton.setTitle("取消订单", for: UIControl.State.normal)
- leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
-
- setButton(isHidden: false, button: oneButton, title: "去付款", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- case 1://待发货
- if orderModel?.feedbackStatus == 0 {
- leftButton.isHidden = false
- leftButton.setTitle("申请退款", for: UIControl.State.normal)
- leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
- setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }else {
- setButton(isHidden: false, button: oneButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }
- break
- case 2: //待收货
-
- if orderModel?.feedbackStatus == 0 {
- leftButton.isHidden = false
- leftButton.setTitle("申请退款", for: UIControl.State.normal)
- leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
- setButton(isHidden: false, button: oneButton, title: "确认收货", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: twoButton, title: "查看物流", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }else {
- setButton(isHidden: false, button: oneButton, title: "确认收货", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: twoButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: threeButton, title: "查看物流", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
-
- }
- case 3: //配送中
-
- if orderModel?.feedbackStatus == 0 {
- leftButton.isHidden = false
- leftButton.setTitle("申请退款", for: UIControl.State.normal)
- leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
- setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- }else {
- setButton(isHidden: false, button: oneButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }
- case 4://待自提
- if orderModel?.feedbackStatus == 0 {
- leftButton.isHidden = false
- leftButton.setTitle("申请退款", for: UIControl.State.normal)
- leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
- setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
-
- }else {
- setButton(isHidden: false, button: oneButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: threeButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }
- case 5: //已自提
-
- if orderModel?.feedbackStatus == 0 {
- leftButton.isHidden = false
- leftButton.setTitle("申请退款", for: UIControl.State.normal)
- leftButton.setTitleColor(k333333Color, for: UIControl.State.normal)
-
- if orderModel?.isComment == 0 {
- setButton(isHidden: false, button: oneButton, title: "去评价", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }else {
- setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }
- }else {
- if orderModel?.isComment == 0 {
- setButton(isHidden: false, button: oneButton, title: "去评价", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: twoButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: threeButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }else {
- setButton(isHidden: false, button: oneButton, title: "退款详情", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }
-
- }
- case 6: //已完成
- if orderModel?.isComment == 0 {
- setButton(isHidden: false, button: oneButton, title: "去评价", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: twoButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- setButton(isHidden: false, button: threeButton, title: "查看物流", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }else {
- setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: kffffffColor, backgroundColor: kFFA42FColor, borderColor: kFFA42FColor)
- setButton(isHidden: false, button: twoButton, title: "查看物流", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: kbfbfbfColor)
- }
- case 7: //已关闭
- setButton(isHidden: false, button: oneButton, title: "再次购买", titleColor: k333333Color, backgroundColor: UIColor.white, borderColor: k333333Color)
- default:
- break
- }
- }
- }
-
- func setButton(isHidden:Bool,button:UIButton,title:String,titleColor:UIColor,backgroundColor:UIColor,borderColor:UIColor) {
- button.isHidden = isHidden
- button.setTitle(title, for: UIControl.State.normal)
- button.setTitleColor(titleColor, for: UIControl.State.normal)
- button.backgroundColor = backgroundColor
- button.layer.borderColor = borderColor.cgColor
- button.layer.borderWidth = 1
- }
- }
|