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

import android.os.Bundle
import com.yidian.bcommon.AppConfig
import com.yidian.bcommon.XRouterPathConstants
import com.yidian.bcommon.base.BaseActivity
import com.yidian.bcommon.extensions.clickAntiShake
import com.yidian.bcommon.extensions.hide
import com.yidian.bcommon.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)
    }
  }
}
