     }
     
     deinit {
+        UserModel.share().currentUser?.removeObserver(self, forKeyPath: "balance")
         NotificationCenter.default.removeObserver(self)
     }
     

        register.dk_setTitleColorPicker(DKColorTable.shared().picker(withKey: AppConst.Color.auxiliary), for: .normal)
        logoutButton.layer.borderWidth = 0.7
        logoutButton.layer.borderColor = UIColor(hexString: "#cccccc").cgColor
        
        registerNotify()
        //更新token
        AppDataHelper.instance().checkTokenLogin()
        requstTotalHistroy()
        initReceiveBalanceBlock()
        if checkLogin() {
            loginSuccessIs(bool: true)
            
            memberImageView.isHidden = UserModel.share().getCurrentUser()?.type == 0
            if UserModel.share().getCurrentUser() == nil {
                memberImageView.isHidden = true
            }

            guard UserModel.share().currentUser != nil else {return}
            let str = numberFormatter.string(from: NSNumber(value: UserModel.share().currentUser!.balance))
            nameLabel.text = str?.components(separatedBy: "￥").last?.components(separatedBy: "¥").last?.components(separatedBy: "$").last
            if UserModel.share().getCurrentUser()!.balance > 999999.0 {
                nameLabel.adjustsFontSizeToFitWidth = true
            }

        
      
    }
    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
        
        if keyPath == "balance" {
            guard UserModel.share().currentUser != nil else { return }
            setBalanceText(balance: (UserModel.share().currentUser?.balance)!)
        }
        
    }
    
    func formatMoneyString(balance:Double) -> String? {
       let str = numberFormatter.string(from: NSNumber(value: balance))
        return str?.components(separatedBy: "￥").last?.components(separatedBy: "¥").last?.components(separatedBy: "$").last
    }
    
    func setBalanceText(balance:Double) {
        nameLabel.text = formatMoneyString(balance: balance)
        if balance > 999999.0 {
            nameLabel.adjustsFontSizeToFitWidth = true
        }
        ShareModel.share().userMoney = balance
        DispatchQueue.main.async {
            UserModel.updateUser(info: { (result)-> ()? in
                UserModel.share().currentUser?.balance = balance
            })
        }
    }
    

    func initReceiveBalanceBlock() {
        SocketRequestManage.shared.receiveBalanceBlock = { (response) in
