package com.yidian.shenghuoquan.buserorder.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.yidian.bcommon.mvvm.BaseViewModel
import com.yidian.shenghuoquan.buserorder.dto.OrderDetailDto
import com.yidian.shenghuoquan.buserorder.http.OrderRemoteDataSource
import com.yidian.shenghuoquan.buserorder.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?) {
        _orderDetailData.value = result
      }

      override fun getOrderDetailFailure(message: String?) {
        _orderDetailData.value = null
      }
    }, hashMapOf("order_id" to orderId, "business_from" to "2"))
  }
}
