package com.zxbw.modulemain.activity

import android.content.Intent
import android.content.Intent.ACTION_DIAL
import android.net.Uri
import android.text.Html
import android.view.View
import com.zxbw.modulemain.R
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.NetConfig
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.utils.JumpUtils
import kotlinx.android.synthetic.main.activity_layout_user_question.*
import me.jessyan.autosize.utils.ScreenUtils

/**
 * @author (wangXuewei)
 * @datetime 2022-06-21 15:40 GMT+8
 * @detail :
 */
class UserQuestionActivity : BaseActivity() {

    override fun layoutID(): Int {
        return R.layout.activity_layout_user_question
    }

    override fun init() {
        var statusBarHeight = ScreenUtils.getStatusBarHeight()
        if (statusBarHeight <= 0) {
            statusBarHeight = 40
        }
        id_sys_bar_view.layoutParams.height = statusBarHeight

        id_ll_question_1.setOnClickListener(this)
        id_ll_question_2.setOnClickListener(this)
        id_ll_question_3.setOnClickListener(this)
        id_ll_question_4.setOnClickListener(this)
        id_ll_question_5.setOnClickListener(this)
        id_ll_question_6.setOnClickListener(this)
        id_tv_answer_6.setOnClickListener(this)
        id_ll_kefu.setOnClickListener(this)
        id_img_back.setOnClickListener(this)
        id_tv_sqtk_btn.setOnClickListener(this)
//        id_tv_answer_5.text = Html.fromHtml(resources.getString(R.string.user_answer_5))
    }


    override fun onClick(v: View?) {
        when (v) {
            id_ll_question_1 -> {
                if (id_tv_answer_1.visibility == View.VISIBLE) {
                    id_check_question_1.isChecked = false
                    id_tv_answer_1.visibility = View.GONE
                } else {
                    id_check_question_1.isChecked = true
                    id_tv_answer_1.visibility = View.VISIBLE
                }
            }
            id_ll_question_2 -> {
                if (id_tv_answer_2.visibility == View.VISIBLE) {
                    id_check_question_2.isChecked = false
                    id_tv_answer_2.visibility = View.GONE
                } else {
                    id_check_question_2.isChecked = true
                    id_tv_answer_2.visibility = View.VISIBLE
                }
            }
            id_ll_question_3 -> {
                if (id_tv_answer_3.visibility == View.VISIBLE) {
                    id_check_question_3.isChecked = false
                    id_tv_answer_3.visibility = View.GONE
                } else {
                    id_check_question_3.isChecked = true
                    id_tv_answer_3.visibility = View.VISIBLE
                }
            }
            id_ll_question_4 -> {
                if (id_tv_answer_4.visibility == View.VISIBLE) {
                    id_check_question_4.isChecked = false
                    id_tv_answer_4.visibility = View.GONE
                } else {
                    id_check_question_4.isChecked = true
                    id_tv_answer_4.visibility = View.VISIBLE
                }
            }
            id_ll_question_5 -> {
                if (id_ll_answer_5.visibility == View.VISIBLE) {
                    id_check_question_5.isChecked = false
                    id_ll_answer_5.visibility = View.GONE
                } else {
                    id_check_question_5.isChecked = true
                    id_ll_answer_5.visibility = View.VISIBLE
                }
            }
            id_ll_question_6 -> {
                if (id_tv_answer_6.visibility == View.VISIBLE) {
                    id_check_question_6.isChecked = false
                    id_tv_answer_6.visibility = View.GONE
                } else {
                    id_check_question_6.isChecked = true
                    id_tv_answer_6.visibility = View.VISIBLE
                }
            }
            id_ll_kefu -> {
                if (Constant.Switch.isErrorKF){
                    JumpUtils.UDesk("在线客服", NetConfig.H5.WEB_URL_CUSTOMER_SERVICE)
                }else{
                    JumpUtils.UDesk("客服", NetConfig.H5.WEB_URL_CUSTOMER_SERVICE_ERROR)
                }
            }
            id_tv_sqtk_btn -> {
                JumpUtils.webJump("申请退款", "http://h5.zxhuichuan.com/xiaoxiang_refund")
            }
            id_img_back -> {
                finish()
            }
            id_tv_answer_6 -> {
                startActivity(Intent(ACTION_DIAL,Uri.parse("tel:4000033616")))
            }
        }

    }

}