package com.zswc.creativity.adapter

import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.qmuiteam.qmui.kotlin.onClick
import com.ysnows.base.base.BAdapter
import com.ysnows.base.utils.B
import com.ysnows.base.utils.UiSwitch
import com.zswc.creativity.R
import com.zswc.creativity.activity.GiftOrderActivity
import com.zswc.creativity.activity.TibOrderActivity
import com.zswc.creativity.databinding.ItemOrderListBinding
import com.zswc.creativity.model.MyOrderInfo
import com.zswc.creativity.vmodel.OrderListFragmentVModel

class OrderListFragmentAdapter(val vm: OrderListFragmentVModel) : BAdapter<MyOrderInfo, BaseDataBindingHolder<ItemOrderListBinding>>(R.layout.item_order_list) {
    override fun convert(holder: BaseDataBindingHolder<ItemOrderListBinding>, item:MyOrderInfo) {
        holder.dataBinding?.vm=vm
        holder.dataBinding?.item = item
        holder.dataBinding?.ll?.onClick {
            if(item.status=="1"){//已购买

                UiSwitch.bundle(vm.repository().context, TibOrderActivity::class.java,
                        B().putString("orderid", item.order_no)
                                .putString("type","2")
                                .ok())
            }
            if(item.status=="2"){//已转赠

                UiSwitch.bundle(vm.repository().context, GiftOrderActivity::class.java,
                        B().putString("orderid", item.id)
                                .ok())

            }

        }

    }
}
