package com.cheng.bole.ui.fragment.mine.order.list

import androidx.lifecycle.MutableLiveData
import com.cheng.bole.bean.OrderEntity
import com.cheng.bole.net.ApiFactory
import com.example.base.extensions.toast
import com.example.base.utils.L
import com.example.base.viewmodel.BaseViewModel

class OrderListViewModel : BaseViewModel() {
    val orderLiveData = MutableLiveData<List<OrderEntity>>()

    fun getOrderList(status: String) {
        showDialog()
        launchOnUiTryCatch({
            val response = ApiFactory.apiService.getOrderList(status)
            if (response.status) {
                orderLiveData.postValue(response.data)
            } else toast(response.message, true)
            dismissDialog()
        }, {
            dismissDialog()
            setError(it)
            L.d(it)
        })
    }
}