package com.hongyegroup.cpt_auths.ui

import android.content.Intent
import android.os.Bundle
import androidx.lifecycle.MutableLiveData
import com.guadou.cs_cptservices.base.activity.YYBaseVDBActivity
import com.guadou.cs_router.YYRouterService
import com.guadou.lib_baselib.base.vm.EmptyViewModel
import com.guadou.lib_baselib.bean.DataBindingConfig
import com.guadou.lib_baselib.utils.ActivityManage
import com.guadou.lib_baselib.utils.CommUtils
import com.guadou.lib_baselib.utils.KeyboardUtils
import com.guadou.lib_baselib.utils.StatusBarUtils
import com.hongyegroup.cpt_auths.BR
import com.hongyegroup.cpt_auths.R
import com.hongyegroup.cpt_auths.databinding.ActivityBusinessLoginBinding

/**
 * 用户的登录页面
 */
class BusinessLoginActivity : YYBaseVDBActivity<EmptyViewModel, ActivityBusinessLoginBinding>() {

    companion object {
        fun startInstance() {
            val context = CommUtils.getContext()
            val intent = Intent(context, BusinessLoginActivity::class.java)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            context.startActivity(intent)
        }
    }

    override fun getDataBindingConfig(): DataBindingConfig {
        return DataBindingConfig(R.layout.activity_business_login)
            .addBindingParams(BR.click, ClickProxy())
    }

    override fun startObserve() {

    }

    override fun init(savedInstanceState: Bundle?) {
        StatusBarUtils.immersive(this)

    }

    /**
     * DataBinding事件处理
     */
    inner class ClickProxy {

        //电话号码
        val mEmailLD: MutableLiveData<String> = MutableLiveData()

        //密码
        val mPasswordLD: MutableLiveData<String> = MutableLiveData()

        //返回按钮
        fun backPage() {
            finish()
        }

        //执行登录
        fun doLogin() {
            KeyboardUtils.hideSoftInput(mActivity)
            YYRouterService.businessComponentServer?.startBusinessMainActivity()
            ActivityManage.finishAllActivity()
        }

        //去忘记密码页面
        fun gotoForgotPasswordPage() {
            KeyboardUtils.hideSoftInput(mActivity)
            BusinessForgotPsdEmailActivity.startInstance()
        }


    }

}