|
@@ -1,20 +1,18 @@
|
|
package jx.cn.escort.ui.activity
|
|
package jx.cn.escort.ui.activity
|
|
|
|
|
|
|
|
|
|
-import android.annotation.SuppressLint
|
|
|
|
|
|
+
|
|
|
|
+
|
|
import android.content.Context
|
|
import android.content.Context
|
|
import android.content.SharedPreferences
|
|
import android.content.SharedPreferences
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
-import android.view.MotionEvent
|
|
|
|
-import android.view.View
|
|
|
|
import android.view.animation.Animation
|
|
import android.view.animation.Animation
|
|
-import android.view.animation.LinearInterpolator
|
|
|
|
import android.view.animation.RotateAnimation
|
|
import android.view.animation.RotateAnimation
|
|
-import android.view.animation.ScaleAnimation
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.lifecycle.lifecycleScope
|
|
import androidx.lifecycle.lifecycleScope
|
|
import com.xuexiang.xui.XUI
|
|
import com.xuexiang.xui.XUI
|
|
-import jx.cn.escort.R
|
|
|
|
|
|
+import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
|
|
|
|
+import com.xuexiang.xui.widget.toast.XToast
|
|
import jx.cn.escort.databinding.ActivityLoginBinding
|
|
import jx.cn.escort.databinding.ActivityLoginBinding
|
|
import jx.cn.escort.extension.ExtensionBinding.Companion.binding
|
|
import jx.cn.escort.extension.ExtensionBinding.Companion.binding
|
|
import jx.cn.escort.utils.ActivityUtils
|
|
import jx.cn.escort.utils.ActivityUtils
|
|
@@ -24,7 +22,7 @@ import org.koin.core.component.KoinComponent
|
|
import org.koin.core.component.inject
|
|
import org.koin.core.component.inject
|
|
|
|
|
|
|
|
|
|
-class LoginActivity : AppCompatActivity(), KoinComponent {
|
|
|
|
|
|
+ class LoginActivity : AppCompatActivity(), KoinComponent {
|
|
|
|
|
|
|
|
|
|
private val mContext: Context by inject()
|
|
private val mContext: Context by inject()
|
|
@@ -37,7 +35,6 @@ class LoginActivity : AppCompatActivity(), KoinComponent {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
XUI.initTheme(this@LoginActivity);
|
|
XUI.initTheme(this@LoginActivity);
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
@@ -46,10 +43,46 @@ class LoginActivity : AppCompatActivity(), KoinComponent {
|
|
|
|
|
|
|
|
|
|
mBinding.btnLoginAction.setOnClickListener {
|
|
mBinding.btnLoginAction.setOnClickListener {
|
|
|
|
+
|
|
|
|
+ val account: String = mBinding.loginAccount.text.toString().trim()
|
|
|
|
+ val password: String = mBinding.loginPassword.text.toString().trim()
|
|
|
|
+
|
|
|
|
+ if (account.isBlank()) {
|
|
|
|
+ XToast.info(this@LoginActivity, "请输入账号").show();
|
|
|
|
+ return@setOnClickListener
|
|
|
|
+ }
|
|
|
|
+ if (password.isBlank()) {
|
|
|
|
+ XToast.info(this@LoginActivity, "请输入密码").show();
|
|
|
|
+ return@setOnClickListener
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var isValidateAccount=false
|
|
|
|
+ accountRegex.forEach{ it->
|
|
|
|
+ if(!account.matches(it)){
|
|
|
|
+ isValidateAccount=true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!isValidateAccount) {
|
|
|
|
+ XToast.info(this@LoginActivity, "未开户").show();
|
|
|
|
+ return@setOnClickListener
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(password.length < 6) {
|
|
|
|
+ XToast.info(this@LoginActivity, "密码小于6位").show();
|
|
|
|
+ return@setOnClickListener
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!password.equals("123456", ignoreCase = true)) {
|
|
|
|
+ XToast.info(this@LoginActivity, "密码不正确").show();
|
|
|
|
+ return@setOnClickListener
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
lifecycleScope.launch {
|
|
lifecycleScope.launch {
|
|
mBinding.loginTitle.text = "加载中..."
|
|
mBinding.loginTitle.text = "加载中..."
|
|
var density=resources.displayMetrics.density
|
|
var density=resources.displayMetrics.density
|
|
- var drawable=resources.getDrawableForDensity(R.drawable.ic_login_loding,65*density.hashCode(),null)
|
|
|
|
|
|
+ var drawable=resources.getDrawableForDensity(jx.cn.escort.R.drawable.ic_login_loding,65*density.hashCode(),null)
|
|
|
|
|
|
mBinding.btnLoginAction.icon=drawable
|
|
mBinding.btnLoginAction.icon=drawable
|
|
|
|
|
|
@@ -61,6 +94,13 @@ class LoginActivity : AppCompatActivity(), KoinComponent {
|
|
|
|
|
|
delay(1000L)
|
|
delay(1000L)
|
|
defaultSharedPreferences.edit().putString("isAuth", "是").apply()
|
|
defaultSharedPreferences.edit().putString("isAuth", "是").apply()
|
|
|
|
+ defaultSharedPreferences.edit().putString("account", account).apply()
|
|
|
|
+ defaultSharedPreferences.edit().putString("password", password).apply()
|
|
|
|
+ if(account.matches(accountRegex[0])){
|
|
|
|
+ defaultSharedPreferences.edit().putString("role", "网点授权人员").apply()
|
|
|
|
+ }else{
|
|
|
|
+ defaultSharedPreferences.edit().putString("role", "押运授权人员").apply()
|
|
|
|
+ }
|
|
ActivityUtils.startActivity(this@LoginActivity,MainActivity::class.java)
|
|
ActivityUtils.startActivity(this@LoginActivity,MainActivity::class.java)
|
|
finish()
|
|
finish()
|
|
|
|
|
|
@@ -69,8 +109,22 @@ class LoginActivity : AppCompatActivity(), KoinComponent {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ companion object {
|
|
|
|
+ private val accountRegex:List<Regex>
|
|
|
|
+ get() {
|
|
|
|
+ return mutableListOf<Regex>(
|
|
|
|
+ Regex("^BOfficer\\d+"),
|
|
|
|
+ Regex("^EOfficer\\d+")
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @JvmStatic fun toAccountRegex():List<Regex>{
|
|
|
|
+
|
|
|
|
+ return accountRegex;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|