younger_times
2023-06-13 47bc190ccc89050b2a15cc1a8fc4818ba440844d
WanPai/Root/Other/VC/PaymentResultVC.swift
@@ -11,6 +11,10 @@
class PaymentResultVC: BaseVC {
    
    enum PaymentResult{case success,fail}
    enum PaymentObjType{
        case member //会员
        case apply //报名
    }
    
    
    @IBOutlet weak var img_paymentState: UIImageView!
@@ -21,10 +25,12 @@
    @IBOutlet weak var btn_back: UIButton!
    
    private var result:PaymentResult!
    private var objType:PaymentObjType!
    
    required init(result:PaymentResult) {
    required init(result:PaymentResult,objType:PaymentObjType) {
        super.init(nibName: nil, bundle: nil)
        self.result = result
        self.objType = objType
    }
    
    required init?(coder: NSCoder) {
@@ -34,22 +40,43 @@
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "成为会员"
        
        btn_again.isHidden = result == .success
        btn_back.isHidden = result == .success
        btn_backHome.isHidden = result == .fail
        collectionView.isHidden =  result == .fail
        switch result {
        case .fail:
            img_paymentState.image = UIImage(named: "icon_fail")
            label_content.text = "支付失败,这是失败原因!"
        case .success:
            img_paymentState.image = UIImage(named: "icon_success")
            label_content.text = "支付成功,恭喜您成为玩湃会员!并获得优惠券!"
        switch objType{
        case .member:
            btn_again.isHidden = result == .success
            btn_back.isHidden = result == .success
            btn_backHome.isHidden = result == .fail
            collectionView.isHidden =  result == .fail
            switch result {
            case .fail:
                img_paymentState.image = UIImage(named: "icon_fail")
                label_content.text = "支付失败,这是失败原因!"
            case .success:
                img_paymentState.image = UIImage(named: "icon_success")
                label_content.text = "支付成功,恭喜您成为玩湃会员!并获得优惠券!"
            case .none:break
            }
        case .apply:
            btn_backHome.isHidden = true
            collectionView.isHidden =  true
            switch result {
            case .fail:
                btn_again.setTitle("再次支付", for: .normal)
                btn_back.setTitle("返回", for: .normal)
                img_paymentState.image = UIImage(named: "icon_fail")
                label_content.text = "报名失败,这是失败原因!"
            case .success:
                btn_again.setTitle("立即预约", for: .normal)
                btn_back.setTitle("返回首页", for: .normal)
                img_paymentState.image = UIImage(named: "icon_success")
                label_content.text = "报名成功,请及时预约课程上课!"
            case .none:break
            }
        case .none:break
        }
        
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.contentInset = UIEdgeInsets(top: 0, left: 14, bottom: 0, right: 14)