//
//  SinglePointWeChatVC.swift
//  MobilePortal
//
//  Created by caiyang on 2020/8/24.
//  Copyright © 2020 yin chen. All rights reserved.
//

import UIKit

class SinglePointWeChatVC: BaseViewController,WXAuthDelegate,WXApiDelegate,UIAlertViewDelegate {

    lazy var loginView : LoginViewTwo = {
        let loginView = LoginViewTwo.init(frame: self.view.frame)
//        loginView.weixinQQView.weixinBtn.addTarget(self, action: #selector(sendAuthRequest), for: .touchUpInside)
        loginView.weixinQQView.weixinBtn.addTarget(self, action: #selector(getWeChatHttp), for: .touchUpInside)
        return loginView;
    }()
    var httpViewModel = WeChatViewModel()
    
//    var loginType:LoginType = .OldLoginType
    // 是否是按钮响应事件
    var loginInitType:LoginInitType = .LoginNomType
    var loginType:LoginType = .OldLoginType {
        didSet {
            if loginType == .OldLoginType {
               loginView.buttonAutoLogin.isHidden = true
            }else{
               loginView.buttonAutoLogin.isHidden = false
            }
        }
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.wr_setNavBarBackgroundAlpha(0)
        if #available(iOS 13.0, *) {
            if SCREEN_HEIGHT() >= 812 {
                self.wr_setNavBarShadowImageHidden(true)
            }
        } else {
            self.wr_setNavBarShadowImageHidden(true)
        }
        self.loginInitType = .LoginNomType
        NotificationCenter.default.addObserver(self, selector: #selector(gotoWeChatBinding), name: NSNotification.Name(rawValue: "gotoWeChatBinding"), object: nil)
        //        addNotificationCenter()
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        addInitLoginView()
        
        getNewVersionUpdateHttpCmd()
//        getScopeListHttpCmd()
        // Do any additional setup after loading the view.
    }
    // 视图即将消失
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: "gotoWeChatBinding"), object: nil)
        //        self.wr_setNavBarShadowImageHidden(false)
    }
    /// 微信绑定
    @objc func gotoWeChatBinding(){
        hidenHintView()
        let vc:WeChatBindingVC = WeChatBindingVC()
        self.pushViewController(viewController: vc, animated: true)
    }
    

}
