From a141213b3234d2d83ffb6a5d2d42ede0e722d949 Mon Sep 17 00:00:00 2001 From: lmw <125975490@qq.com> Date: 星期二, 13 六月 2023 11:57:21 +0800 Subject: [PATCH] 公务出行开发完成 --- app/src/main/java/com/kuanzhai/user/ui/MainActivity.kt | 63 +++++++++++++++++++++++++------ 1 files changed, 51 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/kuanzhai/user/ui/MainActivity.kt b/app/src/main/java/com/kuanzhai/user/ui/MainActivity.kt index ec2bb7a..a6dba82 100644 --- a/app/src/main/java/com/kuanzhai/user/ui/MainActivity.kt +++ b/app/src/main/java/com/kuanzhai/user/ui/MainActivity.kt @@ -20,9 +20,10 @@ import cn.sinata.xldutils.utils.* import cn.sinata.xldutils.visible import com.flyco.tablayout.listener.OnTabSelectListener -import com.kuanzhai.user.OkApplication +import com.kuanzhai.user.KuanzhaiApplication import com.kuanzhai.user.R import com.kuanzhai.user.dialog.* +import com.kuanzhai.user.interfaces.StringCallback import com.kuanzhai.user.network.HttpManager import com.kuanzhai.user.network.entity.* import com.kuanzhai.user.network.entity.Function @@ -40,8 +41,11 @@ import com.kuanzhai.user.utils.PlaceHolderFragment import com.kuanzhai.user.utils.event.BaseEvent import com.tbruyelle.rxpermissions2.RxPermissions +import kotlinx.android.synthetic.main.activity_confirm_cross_order.* import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.drawer_mine.* +import kotlinx.android.synthetic.main.drawer_mine.tv_name +import kotlinx.android.synthetic.main.drawer_mine.tv_score import org.greenrobot.eventbus.EventBus import org.jetbrains.anko.sdk27.coroutines.onClick import org.jetbrains.anko.startActivity @@ -75,6 +79,8 @@ var phoneEmergency = "" //报警电话 var isTripping = false //是否有进行中的订单,如果没有 拖动地图才查询附近司机数量 + private var checkVoiceRecord = true //检查是否开起行程录音,1.首次进入检查2.切换账号检查 + private val menus = arrayListOf<NewFunBean>() private val adapter = MenuAdapter(menus) @@ -83,6 +89,8 @@ if (iv_mine.isSelected){ if (fragments[mViewPager.currentItem] is MapTripFragment){ taxiFragment.back() + }else if (fragments[mViewPager.currentItem] is OfficialFragment){ + officialFragment.back() }else{ logisticsFragment.back(false) } @@ -101,7 +109,7 @@ startActivity<OrderActivity>() } tv_setting.setOnClickListener { - startActivityForResult<SettingActivity>(500,"phone" to (userInfo?.phone?:"")) + startActivityForResult<SettingActivity>(500,"phone" to (userInfo?.phone?:""),"voice" to (userInfo?.soundSet?:"")) } tv_city.setOnClickListener { startActivityForResult<ChooseCityActivity>(501) @@ -117,8 +125,11 @@ } tv_company.setOnClickListener { HttpManager.queryCompany().request(this){_,data-> - startActivity<MyCompanyActivity>("data" to data,"orderPermission" to (userInfo?.approveOrder == 1)) + startActivity<MyCompanyActivity>("data" to data) } + } + tv_order_check.setOnClickListener { + startActivity<OrderCheckListActivity>() } tv_safe.setOnClickListener { userInfo?.let { @@ -172,7 +183,7 @@ } tv_join.setOnClickListener { if (businessInfo?.state == "2"){//冻结 - myToast("您的商家账号已冻结,请联系平台${OkApplication.phoneService}") + myToast("您的商家账号已冻结,请联系平台${KuanzhaiApplication.phoneService}") return@setOnClickListener } if (businessInfo?.auditStatus == "2") //已通过 @@ -238,7 +249,7 @@ private val fragments = arrayListOf<Fragment>() override fun initView() { titleBar.gone() - tv_city.text = OkApplication.chooseCityName + tv_city.text = KuanzhaiApplication.chooseCityName if (isOpen&&func.isNotEmpty()){ getPhone() getAgreement() @@ -430,6 +441,7 @@ Log.e(Const.Tag,"当前模块为:公务出行") mViewPager.currentItem = fragments.indexOf(officialFragment) taxiFragment.checkBack() + officialFragment.checkPermission() } Const.OrderType.TYPE_CALL-> { Log.e(Const.Tag,"当前模块为:电召") @@ -448,13 +460,13 @@ } private fun getPhone(){ - HttpManager.getPhone(OkApplication.chooseCityCode).request(this,false){_,data-> + HttpManager.getPhone(KuanzhaiApplication.chooseCityCode).request(this,false){ _, data-> data?.let { it.forEach { if (it.type == 1) phoneEmergency = it.phone else if (it.type == 2) - OkApplication.phoneService = it.phone + KuanzhaiApplication.phoneService = it.phone } } } @@ -494,13 +506,30 @@ HttpManager.queryUserInfo().request(this,false){_,data-> userInfo = data data?.run { - OkApplication.avatar = avatar + KuanzhaiApplication.avatar = avatar iv_header_home.setImageURI(avatar) tv_name.text = nickName tv_company.text = "企业认证($companyCount)" + tv_order_check.visibility = if (approveOrder == 1) View.VISIBLE else View.GONE + tv_order_check.text = "订单审核(${orderCount})" tv_score.text = String.format("当前积分%s",if (integral.isEmpty()) "0" else integral) - OkApplication.emergency = emergencyContactNumber - OkApplication.phone = phone + KuanzhaiApplication.emergency = emergencyContactNumber + KuanzhaiApplication.phone = phone + if (checkVoiceRecord&&userInfo?.soundSet == "0"){ + HttpManager.getH5(24).request(this@MainActivity,success = {_,data-> + data?.apply { + checkVoiceRecord = false + val h5Dialog = H5Dialog() + h5Dialog.arguments = bundleOf("ok" to "去开启","title" to "“宽窄优行”需要使用车内录音权限","content" to optString("content")) + h5Dialog.setCallback(object : StringCallback { + override fun onRlt(rlt: String) { + startActivity<VoiceRecordActivity>("voice" to false) + } + }) + h5Dialog.show(supportFragmentManager,"h5") + } + }) + } } } } @@ -543,7 +572,7 @@ } private fun updateTip(orderType:Int) { - if (orderType > Const.OrderType.TYPE_TAXI) + if (orderType > Const.OrderType.TYPE_TAXI&&orderType!=Const.OrderType.TYPE_OFFICIAL) tv_tip.gone() else tv_tip.visible() @@ -615,7 +644,7 @@ } private fun getAds(){ - HttpManager.getAds(1,OkApplication.chooseCityCode).request(this,false){_,data-> + HttpManager.getAds(1,KuanzhaiApplication.chooseCityCode).request(this,false){ _, data-> data?.let { if (it.isNotEmpty()){ val bannerDialog = BannerDialog() @@ -623,6 +652,12 @@ bannerDialog.show(supportFragmentManager,"banner") } } + } + } + + private fun getOfficialPermission(){ + HttpManager.validPermission().request(this,false){_,data-> + KuanzhaiApplication.officialPermission = data?.optBoolean("permission",false)?:false } } @@ -647,6 +682,7 @@ * 恢复未登录状态 */ fun resetLogin(){ + checkVoiceRecord = true drawer_main.closeDrawer(GravityCompat.START) isTripping = false if (fragments.contains(taxiFragment)) @@ -667,6 +703,7 @@ queryCoupon() if (menus.isEmpty()) getNewFun() + getOfficialPermission() } } @@ -675,6 +712,8 @@ drawer_main.closeDrawer(GravityCompat.START) else if (iv_mine.isSelected&&fragments[mViewPager.currentItem] is LogisticsFragment) logisticsFragment.back(false) + else if (iv_mine.isSelected&&fragments[mViewPager.currentItem] is OfficialFragment) + officialFragment.back() else if(taxiFragment.checkBack()) super.onBackPressed() } -- Gitblit v1.7.1