package com.yidian.shenghuoquan.bdemo.ui

import android.content.Intent
import android.os.Bundle
import com.yidian.bcommon.base.BaseActivity
import com.yidian.bcommon.constant.XRouterPathConstants
import com.yidian.bcommon.extensions.clickAntiShake
import com.yidian.shenghuoquan.bdemo.databinding.ActivityDemoTestBinding
import com.yidian.shenghuoquan.bdemo.dto.ConfirmOrderRequest
import com.yidian.shenghuoquan.bdemo.dto.Goods
import com.yidian.xpage.XPageManager


/**
 * 新车测试厂，地板油走起
 */
class DemoTestActivity : BaseActivity<ActivityDemoTestBinding>() {

  override fun createViewBinding(): ActivityDemoTestBinding {
    return ActivityDemoTestBinding.inflate(layoutInflater)
  }

  override fun getXPageName(): String {
    return XRouterPathConstants.DEMO_TEST_ACTIVITY
  }

  override fun init(savedInstanceState: Bundle?) {
    super.init(savedInstanceState)
    initClick()
  }

  private fun initClick() {
    testH5()
    testOrderConfirm()
  }

  private fun testH5() {
    viewBind.btnH5Test.clickAntiShake {
      startActivity(Intent(this, H5TestActivity::class.java))
    }
  }

  private fun testOrderConfirm() {
    val list = mutableListOf<Goods>()
    list.add(Goods(goodsSkuId = "04qbwzoazPixJUhfOppD", goodsSkuNum = 1, marketingId = 1, marketingType = 4))
    val confirmOrderReqDto = ConfirmOrderRequest(businessFrom = 2, goodsList = list, marketingId = "79")
    // 模拟h5进入确认订单的参数和逻辑
    viewBind.btnOrderConfirm.clickAntiShake {
      val hashMap = HashMap<String, Any?>()
      hashMap["business_from"] = "2"
      hashMap["marketing_id"] = "1"// 活动id
      hashMap["goods_list"] = list
      XPageManager.push(XRouterPathConstants.CONFIRM_ORDER_ACTIVITY, hashMap)
    }
  }
}
