liugl
2020-09-04 798c626c95adfa29cdb54a04a55e0776f3b22c80
app/src/main/java/com/okgoincar/slab/SlabLoginActivity.kt
@@ -4,6 +4,8 @@
import android.os.Handler
import android.os.Looper
import android.widget.Toast
import cn.sinata.xldutils.netstatus.NetUtils
import cn.sinata.xldutils.utils.DialogUtils
import cn.sinata.xldutils.utils.clickDelay
import cn.sinata.xldutils.utils.getContent
import com.google.gson.Gson
@@ -11,9 +13,12 @@
import com.okgoincar.netUtls.getMapByAny
import com.okgoincar.utils.Cache.CacheKey
import com.okgoincar.R
import com.okgoincar.base.BaseEvent
import com.okgoincar.bean.LoginBean
import com.okgoincar.netUtls.Api
import com.okgoincar.slab.util.DialogUtil
import kotlinx.android.synthetic.main.slab_activity_login.*
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
@@ -25,28 +30,40 @@
    override fun initView() {
        showTitle(false)
        showHeader(false)
    }
    override fun onResume() {
        super.onResume()
        if (!NetUtils.isNetworkConnected(this)){
           var dialog =  DialogUtil.getSlabSurePopWindow(this,"当前网络不通畅,请稍后再登录"){
                EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP))
            }
            dialog.showCenter(window.decorView)
        }
    }
    override fun setOnclick() {
        tv_login.clickDelay {
//            if (et_number.getContent().isNullOrEmpty()) {
//                toast("请输入工号")
//                return@clickDelay
//            }
//            var map = getMapByAny()
//            map["jobNum"] = et_number.getContent().trim()
//            callNet(true, Api.loginByJobNumber, map) {
//                toast("登录成功")
//                var bean = gson.fromJson<LoginBean>(it, LoginBean::class.java)
//                CacheKey.putKeyStr("appid", bean.data.appid)
//                CacheKey.putKeyStr("token", bean.data.token)
//                CacheKey.putKeyStr("userId", bean.data.id.toString())
//                CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
//                CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
//                finish()
//                startActivity<SlabMainActivity>()
//            }
            toLoginActivity(this,"452229198204010012")
            if (et_number.getContent().isNullOrEmpty()) {
                toast("请输入工号")
                return@clickDelay
            }
            var map = getMapByAny()
            map["jobNum"] = et_number.getContent().trim()
            callNet(true, Api.loginByJobNumber, map) {
                toast("登录成功")
                var bean = gson.fromJson<LoginBean>(it, LoginBean::class.java)
                CacheKey.putKeyStr("jobNum",et_number.getContent().trim())
                CacheKey.putKeyStr("appid", bean.data.appid)
                CacheKey.putKeyStr("token", bean.data.token)
                CacheKey.putKeyStr("userId", bean.data.id.toString())
                CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
                CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
                finish()
                startActivity<SlabMainActivity>()
            }
//            toLoginActivity(this,"452229198204010012")
        }
    }
@@ -73,7 +90,7 @@
                .show()
            mBackAppTime = System.currentTimeMillis()
        } else {
            closeAll()
            moveTaskToBack(true)
        }
    }