package com.zj365.mime.vm

import androidx.lifecycle.MutableLiveData
import com.xty.base.vm.BaseVm
import com.xty.common.Const
import com.xty.common.MMkvHelper
import com.xty.common.MMkvHelper.mmkv
import com.xty.common.util.CommonUtils
import com.xty.network.model.ProgrammeBean
import com.xty.network.model.ProgrammeDataBean
import com.xty.network.model.RespBody
import com.xty.network.model.SportBean
import org.json.JSONObject

class MyProgVm : BaseVm() {
    val progLive by lazy { MutableLiveData<RespBody<MutableList<ProgrammeBean>>>() }


    val sportLive by lazy { MutableLiveData<RespBody<MutableList<SportBean>>>() }
    fun getNesProg(id: String) {
        startHttp {
            var json = JSONObject()
            json.put("type", Const.PROGRAMME_1)
            json.put("id", id)
            var response = apiInterface().getProg(retrofits.getRequestBody(json.toString()))
            response.getCodeStatus(progLive, nowData)

        }
    }

    /**
     * 获取运动数据
     */
    fun getSportListNew(page: Int, userId: String?) {
        startHttp {
            val id = if (userId == "" || userId == null) {
                CommonUtils.getMyUserId()
            } else {
                userId
            }
            var json = JSONObject()
            json.put("userId", id)
            json.put("userType", 1)
            json.put("pageSize", Const.PAGE_SIZE)
            json.put("pageNum", page)
            var body = apiInterface().getSportListNew(retrofits.getRequestBody(json.toString()))
            body.getCodeStatus(sportLive, nowData)
        }
    }

}