package com.yidian.shenghuoquan.border.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.yidian.bcommon.mvvm.BaseViewModel
import com.yidian.shenghuoquan.border.dto.OrderDetailDto
import com.yidian.shenghuoquan.border.http.OrderRemoteDataSource
import com.yidian.shenghuoquan.border.http.callback.IGetOrderDetailCallback

/**
 * author: yinjiacheng
 * date: 2021/8/21 09:31
 * description: 订单详情页
 */
class OrderDetailViewModel : BaseViewModel() {

  private val _orderDetailData = MutableLiveData<OrderDetailDto>()
  val orderDetailData: LiveData<OrderDetailDto> = _orderDetailData

  /**
   * 请求订单详情
   */
  fun requestOrderDetail(orderId: String) {
    OrderRemoteDataSource.getOrderDetail(object : IGetOrderDetailCallback {
      override fun getOrderDetailSuccess(result: OrderDetailDto?) {
        result?.let { _orderDetailData.value = it }
      }

      override fun getOrderDetailFailure(message: String?) {

      }
    }, hashMapOf("order_id" to orderId))
  }
}
