package com.zj365.mime.adapter

import android.text.TextUtils
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.zj365.mime.R
import com.xty.network.model.ScoreBean

class NewScroeAdapter : BaseAdapter<ScoreBean.Records>(R.layout.item_score_new) {

    private val maps by lazy {
        mapOf(
            1 to "签到",
            2 to "查看日报",
            3 to "阅读健康科普",
            4 to "分享",
            5 to "日常打卡",
            6 to "电子化验单上传",
            7 to "完善个人资料",
            8 to "查看服务板块—操作指南",
            9 to "登录App同步数据"
        )
    }

    override fun convert(holder: BaseViewHolder, item: ScoreBean.Records) {
        holder.setText(R.id.mTime, item.createTime)
//            .setText(R.id.tvType,maps[item.type])
            .setText(R.id.mAllScore, if (item.num >= 0) "+${item.num}" else item.num.toString())
            .setText(R.id.tvType, item.typeName)

        when (item.type) {
            16, 17 -> {
                holder.setGone(R.id.tvNamePhone, false)
                val str = if (!TextUtils.isEmpty(item.inviteUserName)) {
                    if (!TextUtils.isEmpty(item.inviteUserPhone)) {
                        "${item.inviteUserName} | ${item.inviteUserPhone}"
                    } else {
                        item.inviteUserName
                    }
                } else {
                    if (!TextUtils.isEmpty(item.inviteUserPhone)) {
                        item.inviteUserPhone
                    } else {
                        holder.setGone(R.id.tvNamePhone, true)
                        ""
                    }
                }
                holder.setText(R.id.tvNamePhone, str)
            }

            18 -> {
                holder.setText(R.id.tvType, "${item.typeName}-${item.remark}")
                holder.setGone(R.id.tvNamePhone, true)
            }

            else -> {
                holder.setGone(R.id.tvNamePhone, true)
            }
        }
    }
}