package com.zj365.dc.vm

import androidx.lifecycle.MutableLiveData
import com.xty.base.vm.BaseVm
import com.xty.network.model.FoodRecoginzeInfo
import com.xty.network.model.ImageUploadBean
import com.xty.network.model.RespBody
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.withContext
import okhttp3.MultipartBody
import org.json.JSONObject
import java.io.File

class DietManagementVm : BaseVm() {

    val foodRecoginzeInfoLiveData by lazy { MutableLiveData<RespBody<MutableList<FoodRecoginzeInfo>>>() }

    fun submit(type:String,path: String){
        startHttp {
            withContext(Dispatchers.IO) {
                var f = File(path)
                var fileRb =
                    MultipartBody.Part.createFormData("file", f.name, retrofits.getMultiPartFileRb(f))
                var body = apiInterface().foodRecognize(fileRb,retrofits.getRequestBody(type))

                body.getCodeStatus(foodRecoginzeInfoLiveData,nowData)

            }
        }
    }

}