package com.yidian.shenghuoquan.bmanagercenter.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.yidian.shenghuoquan.bmanagercenter.R
import com.yidian.shenghuoquan.bmanagercenter.databinding.ViewLifeAccountPersonalAuthInfoBinding
import com.yidian.bcommon.utils.SensitiveInfoUtil

/**
 * author: yinjiacheng
 * date: 6/15/21 10:48 AM
 * description: 商户管理中心-基本信息-生活号个人认证信息
 */
class LifeAccountPersonalAuthInfoView @JvmOverloads constructor(
  context: Context,
  attrs: AttributeSet? = null,
  defStyle: Int = 0
) : ConstraintLayout(context, attrs, defStyle) {

  private val viewBinding by lazy {
    ViewLifeAccountPersonalAuthInfoBinding.bind(
      View.inflate(
        getContext(),
        R.layout.view_life_account_personal_auth_info,
        this
      )
    )
  }

  /**
   * 填充认证信息
   * @param lifeAccountName 生活号名称
   * @param occupation 职业
   * @param realName 真实姓名
   * @param idCardNo 身份证号
   * @param phoneNo 手机号
   */
  fun fillAuthInfo(lifeAccountName: String?, occupation: String?, realName: String?, idCardNo: String?, phoneNo: String?) {
    viewBinding.tvLifeAccountName.text = lifeAccountName
    viewBinding.tvContentOccupationLabel.text = occupation
    viewBinding.tvContentRealName.text = realName
    viewBinding.tvContentIdCardNo.text = idCardNo?.let { SensitiveInfoUtil.idCardNumEncrypt(it) }
    viewBinding.tvContentPhoneNo.text = phoneNo?.let { SensitiveInfoUtil.mobileEncrypt(it) }
  }
}
