| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | var phoneEmergency = "" //报警电话 |
| | | var isTripping = false //是否有进行中的订单,如果没有 拖动地图才查询附近司机数量 |
| | | |
| | | private var checkVoiceRecord = true //检查是否开起行程录音,1.首次进入检查2.切换账号检查 |
| | | |
| | | private val menus = arrayListOf<NewFunBean>() |
| | | private val adapter = MenuAdapter(menus) |
| | | |
| | |
| | | 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) |
| | | } |
| | |
| | | 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) |
| | |
| | | } |
| | | 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 { |
| | |
| | | } |
| | | tv_join.setOnClickListener { |
| | | if (businessInfo?.state == "2"){//冻结 |
| | | myToast("您的商家账号已冻结,请联系平台${OkApplication.phoneService}") |
| | | myToast("您的商家账号已冻结,请联系平台${KuanzhaiApplication.phoneService}") |
| | | return@setOnClickListener |
| | | } |
| | | if (businessInfo?.auditStatus == "2") //已通过 |
| | |
| | | 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() |
| | |
| | | Log.e(Const.Tag,"当前模块为:公务出行") |
| | | mViewPager.currentItem = fragments.indexOf(officialFragment) |
| | | taxiFragment.checkBack() |
| | | officialFragment.checkPermission() |
| | | } |
| | | Const.OrderType.TYPE_CALL-> { |
| | | Log.e(Const.Tag,"当前模块为:电召") |
| | |
| | | } |
| | | |
| | | 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 |
| | | } |
| | | } |
| | | } |
| | |
| | | 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") |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | 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() |
| | |
| | | } |
| | | |
| | | 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() |
| | |
| | | bannerDialog.show(supportFragmentManager,"banner") |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private fun getOfficialPermission(){ |
| | | HttpManager.validPermission().request(this,false){_,data-> |
| | | KuanzhaiApplication.officialPermission = data?.optBoolean("permission",false)?:false |
| | | } |
| | | } |
| | | |
| | |
| | | * 恢复未登录状态 |
| | | */ |
| | | fun resetLogin(){ |
| | | checkVoiceRecord = true |
| | | drawer_main.closeDrawer(GravityCompat.START) |
| | | isTripping = false |
| | | if (fragments.contains(taxiFragment)) |
| | |
| | | queryCoupon() |
| | | if (menus.isEmpty()) |
| | | getNewFun() |
| | | getOfficialPermission() |
| | | } |
| | | } |
| | | |
| | |
| | | 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() |
| | | } |