package com.zj365.mime.vm

import androidx.lifecycle.MutableLiveData
import com.xty.base.vm.BaseVm
import com.xty.common.util.CommonToastUtils
import com.zj365.mime.R
import com.xty.network.model.RespBody

class ChangePhoneVm : BaseVm() {

    val codeLive by lazy{ MutableLiveData<RespBody<String>>() }
    val changePhone by lazy{ MutableLiveData<RespBody<String>>() }

    fun sendCodeForget(phone:String){
        startHttp {
            var code= apiInterface().sendCode(phone)
            code.getCodeStatus(codeLive,nowData)
        }
    }
    fun changeBindPhone(phone:String,code:String){
        if(phone.isEmpty()){
            CommonToastUtils.showToast(R.string.please_input_phone)
            return
        }
        if(code.isEmpty()){
            CommonToastUtils.showToast(R.string.please_input_code)
            return
        }

        startHttp {
            var response= apiInterface().changeBindPhone(phone,code)
            response.getCodeStatus(changePhone,nowData)
        }
    }
}