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.util.CommonUtils
import com.xty.network.model.RespBody
import com.xty.network.model.WatchData
import org.json.JSONArray
import org.json.JSONObject

class AddSportProgrammeVm: BaseVm() {

    val watchDataLive =MutableLiveData< RespBody<WatchData>>()
    val submitSuccess= MutableLiveData<RespBody<String>>()
    /**
     * 获取运动数据
     */
    fun beforeWatchData(time:String){
        startHttp {
            var json= JSONObject()
             json.put("userId", CommonUtils.getMyUserId())
             json.put("lessonStartTime",time)
            var body=apiInterface().beforeWatchData(retrofits.getRequestBody(json.toString()))
            body.getCodeStatus(watchDataLive,nowData)
        }
    }


    fun  addSportPlan(planName:String,lessonNumber:String,lessonStartTime:String,lessonEndTime:String ,beforeStamina:String,beforeSleep:String
    ,beforeDiet:String ,beforeWarmUp:String,beforeMusclePain:String ,beforeStretchArea:String ,beforeTargetMuscle:String , waitSend:String ,actionList:JSONArray){

        startHttp {
            var json= JSONObject()
            json.put("userId",CommonUtils.getMyUserId())
            json.put("planName",planName)
            json.put("lessonNumber",lessonNumber)
            json.put("lessonStartTime",lessonStartTime)
            json.put("lessonEndTime",lessonEndTime)
            json.put("beforeStamina",beforeStamina)
            json.put("beforeSleep",beforeSleep)
            json.put("beforeDiet",beforeDiet)
            json.put("beforeWarmUp",beforeWarmUp)
            json.put("beforeMusclePain",beforeMusclePain)
            json.put("beforeStretchArea",beforeStretchArea)
            json.put("beforeTargetMuscle",beforeTargetMuscle)
            json.put("waitSend",waitSend)  //0，暂存，1，发送
            json.put("actionList",actionList)
            var body=apiInterface().addSportPlan(retrofits.getRequestBody(json.toString()))
            body.getCodeStatus(submitSuccess,nowData)
        }

    }
    //{
    //  "userId": 3860,
    //  "planName": "增肌训练",
    //  "lessonNumber": "第1节",
    //  "lessonStartTime": "2023-09-01 17:00",
    //  "lessonEndTime": "2023-09-01 18:00",
    //  "beforeStamina": "课前体能",
    //  "beforeSleep": "睡眠情况",
    //  "beforeDiet": "饮食情况",
    //  "beforeWarmUp": "热身项目",
    //  "beforeMusclePain": "肌肉疼痛",
    //  "beforeStretchArea": "伸展部位",
    //  "beforeTargetMuscle": "目标肌群",
    //  "waitSend": 0,
    //  "actionList": [
    //    {
    //      "name": "动作名称",
    //      "time": "2023-09-01 17:20",
    //      "endTime": "2023-09-01 17:20",
    //      "groupList": [
    //        {
    //          "dataValue1": "",
    //          "dataValue2": ""
    //        }
    //      ]
    //    }
    //  ]
    //}
}