左晓为主开发手持机充值管理机
zuoxiao
2025-03-31 bd4891e2fd6b773cbb0ec387f6db4bc944fdf51a
generallibrary/src/main/java/com/dayu/general/activity/MyFragment.kt
@@ -5,6 +5,9 @@
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.dayu.baselibrary.business.BusinessProvider
import com.dayu.baselibrary.view.ConfirmDialog
import com.dayu.general.BaseApplication
import com.dayu.general.databinding.FragmentMyBinding
class MyFragment : Fragment() {
@@ -15,6 +18,47 @@
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentMyBinding.inflate(inflater, container, false)
        binding?.logoutRL?.setOnClickListener {
            ConfirmDialog(requireContext(), "提示", "确定要退出登录吗?") {
                logout()
            }.show()
        }
        return binding?.root
    }
    override fun onResume() {
        super.onResume()
        if (BaseApplication.userName.isNotEmpty()) {
            binding?.myName?.text = BaseApplication.userName
        } else {
            binding?.myName?.text = "未登录"
        }
        if (BaseApplication.userPhone.isNotEmpty()) {
            binding?.myPhone?.text = BaseApplication.userPhone
        } else {
            binding?.myPhone?.text = "未登录"
        }
        if (BaseApplication.blockName.isNotEmpty()) {
            binding?.myAdName?.text = BaseApplication.blockName
        } else {
            binding?.myAdName?.text = "未登录"
        }
    }
    fun logout() {
        BaseApplication.userId = ""
        BaseApplication.userName = ""
        BaseApplication.userPhone = ""
        BaseApplication.blockId = ""
        BaseApplication.blockName = ""
        binding?.myName?.text = "未登录"
        binding?.myPhone?.text = "未登录"
        binding?.myAdName?.text = "未登录"
        // 使用路由管理器跳转到登录页面
        context?.let {
            BusinessProvider.getBusinessProvider().startLoginNavigotor.navigateToLogin(context)
        }
    }
}