package com.yidian.shenghuoquan.newscontent.wallet.ui

import android.os.Bundle
import androidx.core.content.ContextCompat
import com.yidian.common.AppConfig
import com.yidian.common.XRouterPathConstants
import com.yidian.common.base.BaseActivity
import com.yidian.common.extensions.clickAntiShake
import com.yidian.common.extensions.hide
import com.yidian.common.extensions.show
import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.databinding.ActivityMyWalletBinding
import com.yidian.shenghuoquan.newscontent.ui.ProtocolActivity
import com.yidian.xpage.XPageManager


/**
 * 我的钱包
 */
class MyWalletActivity : BaseActivity<ActivityMyWalletBinding>() {

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

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

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

  private fun initClick() {
    // 交易明细
    viewBind.tvTransactionDetails.clickAntiShake {
      XPageManager.push(XRouterPathConstants.TRANSACTION_LIST, null)
    }
    // todo 提现(仅管理员可以发起提现)
    viewBind.tvWithdraw.clickAntiShake {
//      XPageManager.push(XRouterPathConstants.VERIFY_IDENTITY, null)
      // todo 测试代码
      XPageManager.push(XRouterPathConstants.WECHAT_AUTH, null)
    }
  }

  private fun initTitle() {
    viewBind.include.tvTitle.text = "我的钱包"
    viewBind.include.ivBack.setOnClickListener {
      XPageManager.pop(null)
    }
    viewBind.include.tvMenu.hide()
    viewBind.include.ivMenu.show()
    viewBind.include.ivMenu.setImageResource(R.drawable.icon_faq)
    viewBind.include.ivMenu.setOnClickListener {
      val urlMap = HashMap<String, String>()
      urlMap[ProtocolActivity.ProtocolUrlKey] = AppConfig.commonProblem
      XPageManager.push(XRouterPathConstants.COMMON_PROBLEM, urlMap)
    }
  }
}
