package com.zj365.health.vm

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

class SkinMeasurementVm: BaseVm() {
    val payGoodsObservable by lazy { MutableLiveData<RespBody<PayGoodsBean>>() }

    val payObservable by lazy { MutableLiveData<RespBody<PayBean>>() }



    fun getAIGoods(){
        startHttp {
            apiInterface().getTongueGoods()
            var response = apiInterface().getAISugarMedicineGoods()
            response.getCodeStatus(payGoodsObservable, nowData)
        }
    }


    //获取支付信息
    fun payAISugarMedicineOrder(goodsId:String,isWeChatPay:Boolean){
        startHttp {
            var json = JSONObject()
            json.put("goodsId",goodsId)
            json.put("channelName", if (isWeChatPay) "WEIXIN_APP" else "ALIPAY_APP")
            var response = apiInterface().payAISugarMedicineOrder(retrofits.getRequestBody(json.toString()))
            response.getCodeStatus(payObservable, nowData)
        }
    }
}