package com.abbidot.tracker.deprecated.ui.activity.vm

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.abbidot.baselibrary.constant.MMKVKey
import com.abbidot.baselibrary.util.MMKVUtil
import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.bean.RechargeDeviceBean
import com.abbidot.tracker.retrofit2.NetworkApi
import kotlinx.coroutines.launch

/**
 *Created  by .yzq on 2022/3/25/025.
 * @link
 * @description:可以充值的设备
 */
class RechargeDeviceViewModel : ViewModel() {
    val mDeviceCardLiveData = MutableLiveData<Result<MutableList<RechargeDeviceBean>>>()

    fun getCards(activity: BaseActivity<*>) {
        activity.showLoading(true)
        val userId = MMKVUtil.getString(MMKVKey.UserId)
        viewModelScope.launch {
            val result = NetworkApi.getCards(userId)
            mDeviceCardLiveData.value = result
        }
    }
}