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.ViewLifeAccountMerchantInfoBinding
import com.yidian.bcommon.utils.SensitiveInfoUtil

/**
 * author: yinjiacheng
 * date: 6/17/21 00:10 AM
 * description: 生活号创建成功-商户信息
 */
class LifeAccountMerchantInfoView @JvmOverloads constructor(
  context: Context,
  attrs: AttributeSet? = null,
  defStyle: Int = 0
) : ConstraintLayout(context, attrs, defStyle) {

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

  /**
   * 填充商户信息
   * @param lifeAccountName 生活号名称
   * @param manager 管理员
   * @param phoneNum 手机号
   */
  fun fillAuthInfo(lifeAccountName: String?, manager: String?, phoneNum: String?) {
    viewBinding.tvLifeAccountName.text = lifeAccountName
    viewBinding.tvContentManager.text = manager
    viewBinding.tvContentPhoneNumber.text = phoneNum?.let { SensitiveInfoUtil.mobileEncrypt(it) }
  }
}
