package com.yidian.shenghuoquan.newscontent.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.databinding.ViewLifeAccountPersonalAuthInfoBinding
import com.yidian.shenghuoquan.newscontent.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) }
  }
}
