package com.dahe.gldriver.ui.account.authperson

import android.os.Bundle
import com.dahe.gldriver.R
import com.dahe.gldriver.bean.UpQualiInfoBean
import com.dahe.gldriver.bean.UpRoadInfoBean
import com.dahe.gldriver.databinding.ActivityAuthRoadBinding
import com.dahe.gldriver.net.BaseObserver
import com.dahe.gldriver.net.DataManager
import com.dahe.gldriver.net.RxHttpCallBack
import com.dahe.gldriver.oss.OssServiceUtil
import com.dahe.gldriver.ui.account.AuthSuccActivity
import com.dahe.gldriver.ui.account.SelectRoleActivity
import com.dahe.mylibrary.base.BaseActivity
import com.dahe.mylibrary.net.CommonResponseBean
import com.dahe.mylibrary.utils.ActivityUtils
import com.dahe.mylibrary.utils.ImageLoader
import com.dahe.mylibrary.utils.PickerUtils
import com.dahe.mylibrary.utils.PopsUtils
import com.github.gzuliyujiang.wheelpicker.contract.OnDatePickedListener
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers

/**
 * @ClassName AuthRoadActivity
 * @Author john
 * @Date 2024/1/25 16:02
 * @Description 道路运输许可证认证
 */
class AuthRoadActivity : BaseActivity<ActivityAuthRoadBinding>() {

    var ossServiceUtil: OssServiceUtil = OssServiceUtil.getInstance()
    var upRoad = UpRoadInfoBean()
    override fun initView(savedInstanceState: Bundle?) {
        setStatusBarColor(R.color.white)
        setTitleBar("实名认证",true)
        binding.run {
            btnOk.setOnClickListener {
                subMit()
            }

            tvDate.setOnClickListener {
                PickerUtils.getInstance().showDate(this@AuthRoadActivity){ date ->
//                    upRoad.roadLicenseValidity = date
                }
            }
            ivFront.setOnClickListener {
                PopsUtils.getInstance().showSimSelPic(mContext) {
                    ImageLoader.getInstance().loadRoundImage(mContext, it[0].path, 12, ivFront)
                }
            }
        }
    }

    override fun initDate() {
    }

    private fun subMit() {
        upRoad.run {
            roadLicense = binding.etID.text.trim().toString()
//            qualificationCertificateNo = binding.etId.text.toString()
//            qualificationCertificateEffectiveEnd = binding.tvDate.text.toString()

            DataManager.getInstance().setUpRoadLicense(upRoad)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
                    override fun onSuccess(t: CommonResponseBean<Any>) {
                        super.onSuccess(t)
                        ActivityUtils.startActivity(mContext, AuthSuccActivity::class.java)
                    }
                }))
        }
    }
}