//
//  MembershipVC.swift
//  SwiftProject
//
//  Created by aaa on 2024/4/1.
//

import Foundation
import UIKit
import Firebase

class MembershipVC: BaseController {
    var pvView:MembershipProductView?
    var pcenterView:UIView?
    var psubscribeBtn:UIButton?
    var selectedItem:MemberShipModelItem?
    lazy var mTopImgView:UIImageView = {
        //393*236
//        let view = UIImageView(frame: CGRect(x: 0, y: 0, width: SCREEN_Width, height: SCREEN_Height * 236/393))
        let view = UIImageView(frame: CGRect(x: 0, y: 0, width: SCREEN_Width, height: SCREEN_Height))
        view.image = UIImage.init(named: "vippage_bg")
        return view
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.configureUI()
        self.configureData()
        
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        if UserInfo.sharedInstance.isMemberShip {//统计
            
            Analytics.logEvent("iap_isvip_pv", parameters: nil)
        }
        else {
            Analytics.logEvent("iap_unvip_pv", parameters: nil)
        }
    }
    
    //用户vip身份改变
    @objc override func userVipStateChangeNotification(noti:Notification) {
        print("子类收到通知收到的vip通知...")
        if UserInfo.sharedInstance.isMemberShip {
            if let h = pcenterView?.isHidden, h == false {
                pcenterView?.snp.updateConstraints({ make in
                    make.height.equalTo(0)
                })
                pcenterView?.superview?.layoutIfNeeded()
                pcenterView?.isHidden = true
                rightBtn1?.isHidden = true
                psubscribeBtn?.setBackgroundImage(UIImage(named: NSLocalizedString("vip_alreadybuybtn", comment: "")), for: .normal)
                psubscribeBtn?.isEnabled = false
            }
            
            FeedbackView.show {//好评
                
            } negativeCallback: {//差评
                
            }
            
        }
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
    }
    
    deinit {
        print("MembershipVC...deinit")
    }
    
}

