package com.xty.server.act

import com.alibaba.android.arouter.facade.annotation.Route
import com.xty.base.act.IBaseAct
import com.xty.common.R
import com.xty.common.TextUtils
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.getImageUrl
import com.xty.common.setImageUser
import com.xty.network.model.KeeperBean
import com.xty.server.databinding.ActHouseKeepInfoBinding


/**
 * 管家详情
 */
@Route(path = ARouterUrl.HOUSEKEEP_INFO)
class HousekeepInfoAct: IBaseAct() {
    val binding by lazy{ ActHouseKeepInfoBinding.inflate(layoutInflater) }
    override fun setLayout()=binding.root
    var bean :KeeperBean?=null
    override fun initData() {
        super.initData()
        val name = this
        intent.extras?.let {
            bean = it.getSerializable("bean") as KeeperBean
            bean?.let { it1 ->
                binding.mDocName.text = it1.realname
                if(it1.gender==1){
                    binding.mSex.text = "男"
                }else{
                    binding.mSex.text = "女"
                }
                binding.mPosition.text = it1.positionName
                binding.phone.text = it1.phone

                if (com.alibaba.android.arouter.utils.TextUtils.isEmpty(it1.experience) ){
                    binding.detail.text= "--"
                }else{
                    binding.detail.text = it1.experience
                }
                if (com.alibaba.android.arouter.utils.TextUtils.isEmpty(it1.intro) ){
                    binding.mTvLoc.text= "健康管家"
                }else{
                    binding.mTvLoc.text  = it1.intro
                }
//                binding.mTvLoc.text = if(it1.jobProverb!!.isBlank())"--"  else it1.jobProverb
//                binding.detail.text = if (it1.intro!!.isBlank()) "--" else it1.intro
                binding.mPhoto.apply {
                    setImageUser(  name , getImageUrl(it1.avatar)
                    )
                }
                binding.llLeft.setOnClickListener {
                   // TUIConversationUtils.startAYSingleChatActivity("man_"+it1.id, it1.realname, it1.avatar);
                }
            }


            binding.llRight.setOnClickListener {
                bundle.clear()
                bundle.putSerializable("bean", bean)
                RouteManager.goAct(ARouterUrl.ONLINE_MAKE, bundle)
            }

        }

    }

    override fun initView() {
        super.initView()
        statusBar(binding.title.mView)
        binding.title.mTvTitle.text=getString(R.string.server_1)
        binding.title.mIvBack.setOnClickListener { finish() }
    }
}