//
//  QRCodeCallBackViewController.swift
//  MobilePortal
//
//  Created by caiyang on 2021/8/16.
//  Copyright © 2021 yin chen. All rights reserved.
//

import UIKit

class QRCodeCallBackViewController: BaseViewController,QRCodeSwiftViewDelegate {

    var bool = false
    var isHomePushType:IsHomePushType = .YesIsHomePushType
    var callBackBlock:passParameterBlock!
    
    lazy var qRCodeSwiftView: QRCodeSwiftOldView = {
        //let h = UIApplication.shared.statusBarFrame.size.height+(self.navigationController?.navigationBar.frame.size.height)!
        let qRCodeSwiftView = QRCodeSwiftOldView.init(frame: CGRect(x:0, y: 0, width:SCREEN_WHIDTH() , height:SCREEN_HEIGHT() ))
        qRCodeSwiftView.delegate = self
        return qRCodeSwiftView
    }()
    override func viewWillAppear(_ animated: Bool) {
        self.appViewsSstatistics(title: "扫码追溯", scope: AppClickType.OftenAppType.rawValue)
        if bool == true {
            dropOutVC()
        }
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        initTitleBar()
        self.title = "扫一扫"
        self.view.addSubview(qRCodeSwiftView)
        // Do any additional setup after loading the view.
    }
    
    func getQRCodeSwiftViewValue(_ value: String!) {
        bool = true
        print(value)
        self.callBackBlock(value)
//        self.navigationController?.popViewController(animated: true)
        self.dropOutVC()
    }
    func dropOutVC() {
        self.arrowResponse()
    }
    override func arrowResponse() {
        self.callBackBlock("")
//        self.qRCodeSwiftView.stopRunning()
        self.navigationController?.popViewController(animated: true)
    }
    override func gotoMessageVC(){
        self.actionGotoMessageWeb(messageId: AccountInfo.sharedInstance().messageId!, isHomePushType: .NOIsHomePushType)
    }
    /// 应用访问量
    func appViewsSstatistics(title:String,scope:String){
        let model = ClickRateModel()
        model.name = title
        model.belong = "门户"
        model.scope = scope
        model.type = "1"
        self.getClickRateHttpCmd(infoModel: model)
    }

}
