         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()
+        UserModel.share().currentUser?.addObserver(self, forKeyPath: "balance", options: .new, context: nil)
         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
+            nameLabel.text = formatMoneyString(balance: UserModel.share().currentUser!.balance)
             if UserModel.share().getCurrentUser()!.balance > 999999.0 {
                 nameLabel.adjustsFontSizeToFitWidth = true
             }


            if let object = result as? Dictionary<String,Any> {
                if let  money =  object["balance"] as? Double {
                    let str = self?.numberFormatter.string(from: NSNumber(value: money))
                    self?.nameLabel.text = str?.components(separatedBy: "￥").last?.components(separatedBy: "¥").last?.components(separatedBy: "$").last
                    if money > 999999.0 {
                        self?.nameLabel.adjustsFontSizeToFitWidth = true
                    }
                    ShareModel.share().userMoney = money
                    UserModel.updateUser(info: { (result)-> ()? in
                        UserModel.share().currentUser?.balance = money
                    })
                } else {
                    self?.nameLabel.text =  "0.00"
                }

        
      
    }
    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
