Browse Source

1.修改自动跳转数据类,并添加参数

20241218TB223FC(测试jar包)
wangwanlei 9 months ago
parent
commit
b532c3124c

+ 1
- 1
app/src/main/java/com/xhly/manageapp/bean/scheme/AutoAppBean.kt View File

18
     /**
18
     /**
19
      * 认证类型:1账号2学号3手机号码4身份证号
19
      * 认证类型:1账号2学号3手机号码4身份证号
20
      */
20
      */
21
-    var singleType:String?=null
21
+    var authType:Int=0
22
 
22
 
23
 
23
 
24
 }
24
 }

+ 49
- 19
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

389
             //连接不为空,并且应用已安装则跳转应用
389
             //连接不为空,并且应用已安装则跳转应用
390
             if (it.authUrl!=null&&AppUtils.isAppInstalled(this,it.appPackage)){
390
             if (it.authUrl!=null&&AppUtils.isAppInstalled(this,it.appPackage)){
391
                 spUtils.saveJson(Const.AUTOAPPKEY,it)
391
                 spUtils.saveJson(Const.AUTOAPPKEY,it)
392
-                val launchIntent = Intent()
393
-                launchIntent.setComponent(
394
-                    ComponentName(
395
-                        it.appPackage!!,
396
-                        it.authUrl!!
397
-                    )
398
-                )
399
-                startActivity(launchIntent)
392
+                startAutoApp(it)
400
             }else{
393
             }else{
401
                try {
394
                try {
402
                    val autoAppBean = spUtils.getFromJson(Const.AUTOAPPKEY, AutoAppBean().javaClass) as AutoAppBean
395
                    val autoAppBean = spUtils.getFromJson(Const.AUTOAPPKEY, AutoAppBean().javaClass) as AutoAppBean
403
-                   if (it.authUrl!=null&&AppUtils.isAppInstalled(this,it.appPackage)){
404
-                       val launchIntent = Intent()
405
-                       launchIntent.setComponent(
406
-                           ComponentName(
407
-                               autoAppBean.appPackage!!,
408
-                               autoAppBean.authUrl!!
409
-                           )
410
-                       )
411
-                       startActivity(launchIntent)
396
+                   if (autoAppBean.authUrl!=null&&AppUtils.isAppInstalled(this,autoAppBean.appPackage)){
397
+                    startAutoApp(autoAppBean)
412
                    }else{
398
                    }else{
413
                        canClickFlag=true
399
                        canClickFlag=true
414
                    }
400
                    }
422
         updateAllStrategy()
408
         updateAllStrategy()
423
     }
409
     }
424
 
410
 
411
+    private fun startAutoApp(autoAppBean: AutoAppBean){
412
+        val launchIntent = Intent()
413
+        launchIntent.setComponent(
414
+            ComponentName(
415
+                autoAppBean.appPackage!!,
416
+                autoAppBean.authUrl!!
417
+            )
418
+        )
419
+        launchIntent.putExtra("authType",autoAppBean.authType)
420
+        userBean?.let {
421
+            when(autoAppBean.authType){
422
+                1->{
423
+                    val userid = it.userid
424
+                    launchIntent.putExtra("authData",userid.toString())
425
+                }
426
+                2->{
427
+                    val studentno = it.studentno
428
+                    launchIntent.putExtra("authData",studentno.toString())
429
+                }
430
+                3->{
431
+                    val userphone = it.userphone
432
+                    launchIntent.putExtra("authData",userphone.toString())
433
+                }
434
+                4->{
435
+                    val cardid = it.cardid
436
+                    launchIntent.putExtra("authData",cardid.toString())
437
+                }
438
+                else->{
439
+
440
+                }
441
+            }
442
+        }
443
+        startActivity(launchIntent)
444
+    }
425
     private fun showSucessToast() {
445
     private fun showSucessToast() {
426
         Toaster.show(R.string.updatetips)
446
         Toaster.show(R.string.updatetips)
427
         updateStrategyFlag = false
447
         updateStrategyFlag = false
484
             Const.backNum++
504
             Const.backNum++
485
             if (Const.backNum > Const.UPDATESTRATEGYNUM) {
505
             if (Const.backNum > Const.UPDATESTRATEGYNUM) {
486
                 Const.backNum = 0
506
                 Const.backNum = 0
487
-                Toaster.show(R.string.updatetips)
488
                 updateAllStrategy()
507
                 updateAllStrategy()
489
             }
508
             }
490
         }
509
         }
573
 
592
 
574
     override fun onResume() {
593
     override fun onResume() {
575
         super.onResume()
594
         super.onResume()
595
+        lifecycleScope.launch(Dispatchers.IO){
596
+            try {
597
+                val json = spUtils.getFromJson(Const.USERINFO, UserBean().javaClass)
598
+                if (json == null) {
599
+                    Toaster.show("用户信息为空")
600
+                } else {
601
+                    userBean = json as UserBean
602
+                }
603
+            }catch (e:Exception){
604
+
605
+            }
606
+        }
576
         Const.backNum++
607
         Const.backNum++
577
         userBean?.let {
608
         userBean?.let {
578
             viewModel.postAutoAppDetail(it.regionid)
609
             viewModel.postAutoAppDetail(it.regionid)
585
             //进入该页面20次或者点击返回键20次需要更新策略
616
             //进入该页面20次或者点击返回键20次需要更新策略
586
             lastTimeLong=System.currentTimeMillis()
617
             lastTimeLong=System.currentTimeMillis()
587
             Const.backNum = 0
618
             Const.backNum = 0
588
-            Toaster.show(R.string.updatetips)
589
             updateAllStrategy()
619
             updateAllStrategy()
590
         }else{
620
         }else{
591
             useTimeStrategy()
621
             useTimeStrategy()

Loading…
Cancel
Save