package com.rdiot.yx485.ui.login.model

import androidx.databinding.ObservableField
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
 * 登录ViewModel
 * @author mR2hao
 * @date 2022/11/15
 */
class LoginViewModel : ViewModel() {
    /** 手机号 */
    var phone: ObservableField<String> = ObservableField("")

    /** 短信验证码 */
    var smsCode: ObservableField<String> = ObservableField("")

    /** 密码 */
    var pwd: ObservableField<String> = ObservableField("")

    /** 获取验证码剩余秒数 */
    val lessTimeSecond: MutableLiveData<Int> by lazy { MutableLiveData(0) }

    /** 已阅隐私政策 */
    val isRead: MutableLiveData<Boolean> by lazy { MutableLiveData(false) }

    /** 是否重置密码  true重置密码 false忘记密码 */
    var isResetPwd: ObservableField<Boolean> = ObservableField(false)

    /**
     * 清空数据
     * @param clearPhone Boolean 是否清空手机号码
     */
    fun clear(clearPhone: Boolean) {
        if (clearPhone) {
            phone.set(null)
        }
        smsCode.set(null)
    }
}