package com.zj365.health.vm

import androidx.lifecycle.MutableLiveData
import com.xty.base.vm.BaseVm
import com.xty.network.model.AnswerBean
import com.xty.network.model.QuestDetailBean
import com.xty.network.model.RespBody
import org.json.JSONObject

class RiskAssessVm: BaseVm() {


    val timeOut by lazy{MutableLiveData<RespBody<Boolean>>()}
    val answerLive by lazy{MutableLiveData<RespBody<MutableList<AnswerBean>>>()}
    val detail by lazy{MutableLiveData<RespBody<QuestDetailBean>>()}
    fun getAnswerList(id:String){
        startHttp {
            var json=JSONObject()
            json.put("id",id)
            var response=apiInterface().getAnswerList(retrofits.getRequestBody(json.toString()))
            response.getCodeStatus(answerLive,nowData)
        }
    }

    fun getQuestTime(){
        startHttp {
            var body=apiInterface().getQuestTime()
            body.getCodeStatus(timeOut,nowData)
        }
    }

    fun getQuestDetail(position:Int,data:String){
        startHttp {
            var json=JSONObject()
            json.put("type",position+1)
            json.put("date",data)
            var body=apiInterface().getQuestDetail(retrofits.getRequestBody(json.toString()))

            body.getCodeStatus(detail,nowData)
        }
    }


}