package com.yidian.shenghuoquan.border.ui

import androidx.activity.viewModels
import com.yidian.bcommon.mvvm.BaseMvvmActivity
import com.yidian.shenghuoquan.border.R
import com.yidian.shenghuoquan.border.databinding.BorderActivityOrderDetailBinding
import com.yidian.shenghuoquan.border.manager.OrderStatusManager
import com.yidian.shenghuoquan.border.viewmodel.OrderDetailViewModel

/**
 * author: yinjiacheng
 * date: 2021/8/21 09:29
 * description: 订单详情页
 */
class OrderDetailActivity : BaseMvvmActivity<BorderActivityOrderDetailBinding, OrderDetailViewModel>() {

  override val layoutId: Int = R.layout.border_activity_order_detail
  override val vm: OrderDetailViewModel by viewModels()

  override fun initView() {
    vm.orderDetailData.observe(this, {
      // 获取当前订单状态
      val status = OrderStatusManager.getOrderStatus(it.orderStatus)
      binding.svOrderStatus.setOrderStatus(status, it)
      binding.pvPickupPointInfo.setPickupPoint(it.placeList)
      binding.ivConsigneeInfo.setConsigneeInfo(status, it.orderShippingInfo)
      binding.ivCommodityInfo.setCommodityInfo(status, it)
      binding.ivOrderInfo.setOrderInfo(status, it)
    })
    // Test
    vm.requestOrderDetail("21082017225320101002")
  }
}
