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.ViewLifeAccountMerchantInfoBinding
import com.yidian.shenghuoquan.newscontent.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) }
  }
}
