From aaadcd1b0131392be5573a1fc6b3e92f08c5cb87 Mon Sep 17 00:00:00 2001
From: liugl <liugl@sinata.cn>
Date: 星期二, 29 十二月 2020 09:26:27 +0800
Subject: [PATCH] 1:新增上线
---
app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt | 255 ++++++++++++++++++++++++++++++++++++--------------
1 files changed, 181 insertions(+), 74 deletions(-)
diff --git a/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt b/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt
index d659f30..41bc491 100644
--- a/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt
+++ b/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt
@@ -11,10 +11,13 @@
import com.okgoincar.base.MyApplication
import com.okgoincar.bean.OrderBean
import com.okgoincar.bean.OrderSimpleData
+import com.okgoincar.bean.OrderStatueBean
import com.okgoincar.netUtls.Api
import com.okgoincar.netUtls.timeOver
+import com.okgoincar.slab.util.DialogUtil
import com.okgoincar.utils.MyUtils
import kotlinx.android.synthetic.main.activity_order_over.*
+import kotlinx.android.synthetic.main.dialog_sure_and_del_slab.view.*
import java.lang.Exception
class SlabOrderOverActivity : MySlabBaseActivity() {
@@ -27,7 +30,7 @@
intent.getStringExtra("orderId")
}
- var time:CountDownTimer? = null
+ var time: CountDownTimer? = null
lateinit var orderBean: OrderBean
@@ -42,72 +45,88 @@
override fun onPause() {
super.onPause()
- if (time != null){
+ if (time != null) {
time!!.cancel()
}
}
override fun setBlackMode(b: Boolean?) {
super.setBlackMode(b)
- if(b!!){ //晚上
+ if (b!!) { //晚上
rl_main_bg.setBackgroundResource(R.color.black)
ll_content_web.setBackgroundResource(R.drawable.bg_slab_main_8_black)
ll_order_top.setBackgroundResource(R.drawable.bg_slab_main_8_black_bottom)
// ll_pay_result.setBackgroundResource(R.drawable.bg_slab_main_8_shen_black)
iv_back_slab.setImageResource(R.mipmap.icon_back_slab)
- tv_title_slab.textColor(this,R.color.write)
- tv_name.textColor(this,R.color.write)
- tv_car_num.textColor(this,R.color.write)
- tv_phone.textColor(this,R.color.write)
- tv_time.textColor(this,R.color.write)
+ tv_title_slab.textColor(this, R.color.write)
+ tv_name.textColor(this, R.color.write)
+ tv_car_num.textColor(this, R.color.write)
+ tv_phone.textColor(this, R.color.write)
+ tv_time.textColor(this, R.color.write)
tv_time.setDrawableLeft(R.mipmap.icon_time_gray)
- tv_start_address.textColor(this,R.color.write)
- tv_end_address.textColor(this,R.color.write)
- tv_red_money.textColor(this,R.color.write)
- tv_pay_result_title.textColor(this,R.color.write)
- tv_order_type.textColor(this,R.color.write)
- tv_hive_small_money.textColor(this,R.color.write)
+ tv_start_address.textColor(this, R.color.write)
+ tv_end_address.textColor(this, R.color.write)
+ tv_red_money.textColor(this, R.color.write)
+ tv_pay_result_title.textColor(this, R.color.write)
+ tv_order_type.textColor(this, R.color.write)
+ tv_hive_small_money.textColor(this, R.color.write)
tv_phone.setDrawableLeft(R.mipmap.icon_dial_slab)
- }else{
+ } else {
rl_main_bg.setBackgroundResource(R.color.write)
ll_content_web.setBackgroundResource(R.drawable.write_top_10)
ll_order_top.setBackgroundResource(R.drawable.write_bottom_10)
// ll_pay_result.setBackgroundResource(R.drawable.bg_white_round5)
iv_back_slab.setImageResource(R.mipmap.icon_back_black)
- tv_title_slab.textColor(this,R.color.black)
- tv_name.textColor(this,R.color.black)
- tv_car_num.textColor(this,R.color.black)
- tv_phone.textColor(this,R.color.black)
- tv_time.textColor(this,R.color.black)
+ tv_title_slab.textColor(this, R.color.black)
+ tv_name.textColor(this, R.color.black)
+ tv_car_num.textColor(this, R.color.black)
+ tv_phone.textColor(this, R.color.black)
+ tv_time.textColor(this, R.color.black)
tv_time.setDrawableLeft(R.mipmap.icon_time_xiao)
- tv_start_address.textColor(this,R.color.black)
- tv_end_address.textColor(this,R.color.black)
- tv_red_money.textColor(this,R.color.black)
- tv_pay_result_title.textColor(this,R.color.black)
- tv_order_type.textColor(this,R.color.black)
- tv_hive_small_money.textColor(this,R.color.black)
+ tv_start_address.textColor(this, R.color.black)
+ tv_end_address.textColor(this, R.color.black)
+ tv_red_money.textColor(this, R.color.black)
+ tv_pay_result_title.textColor(this, R.color.black)
+ tv_order_type.textColor(this, R.color.black)
+ tv_hive_small_money.textColor(this, R.color.black)
tv_phone.setDrawableLeft(R.mipmap.icon_dial)
}
}
override fun initView() {
-
var map = getMapByAny()
map["orderId"] = orderId
map["orderType"] = orderType
callNet(this, Api.queryOrderInfo, map) {
orderBean = gson.fromJson(it, OrderBean::class.java)
showUi(orderBean)
- addSocketLisener()
-
+// addSocketLisener(orderBean)
+ checkOrderStatue()
}
}
+
+
private fun showUi(orderBean: OrderBean?) {
orderBean?.let {
+ MyApplication.getTTsManager()
+ .setVideoText("请确认乘客车内付款后,再点击返回首页")
+ time = timeOver(60000 * 6) {
+ tv_title_slab.text = "待支付($it)"
+ if (it == 0) {
+ if (time != null) {
+ time!!.cancel()
+ }
+ try {
+ finish()
+ } catch (e: Exception) {
+ }
+ }
+ }
tv_title_slab.text = "待支付"
tv_name.text = it.data.nickName
tv_car_num.text = it.data.historyNum.toString() + "次乘车"
+ tv_phone.text = it.data.phone
tv_phone.clickDelay {
MyUtils.getInstans().CallPhone(this, it.data.phone.toString())
}
@@ -143,64 +162,76 @@
}
}
- private fun addSocketLisener() {
- MyApplication.addOrderView(object : MyApplication.OrderStatueView {
- override fun orderInfo(data: OrderSimpleData?) {
- data?.let {
- if (it.status == 8||it.status == 7) {
- tv_pay_result_money.textColor(this@SlabOrderOverActivity,R.color.slab_green_over)
- Handler(Looper.getMainLooper()).post {
- time = timeOver (20000){
- tv_title_slab.text = "已完成($it)"
- if (it == 0){
- if (time != null){
- time!!.cancel()
- }
- try {
- onBackPressed()
- }catch (e:Exception){
- }
- }
- }
- }
-
-// android.os.Handler(Looper.getMainLooper()).post {
-// orderBean.data.orderState = 8
-// showUi(orderBean)
-// }
- }
- }
+ fun overOrder(){
+ callComplete() {
+ Handler(Looper.getMainLooper()).post {
+ time?.cancel()
+ time?.onFinish()
+ finish()
}
- })
-
-// if (handler == null) {
-// handler = android.os.Handler(mainLooper)
-// handler!!.postDelayed({
-// checkOrderStatue()
-// }, 3000)
-// }
+ }
}
- var handler: android.os.Handler? = null
+ var handler: Handler? = null
+ var isPlay = false
fun checkOrderStatue() {
+ if (handler == null) {
+ handler = Handler(mainLooper)
+ }
+ handler!!.postDelayed({
+ checkOrderStatue()
+ }, 3000)
var map = getMapByAny()
- map["orderId"] = orderId
- map["orderType"] = orderType
- callNet(false,Api.orderStateSocket, map) {
+// map["orderId"] = orderId
+// map["orderType"] = orderType
+ callNet(false, Api.orderStateSocket, map) {
val orderSimpleData =
Gson().fromJson(
it,
- OrderSimpleData::class.java
+ OrderStatueBean::class.java
)
- orderSimpleData?.let {
- if (orderSimpleData.status == 8) {
- orderBean.data.orderState = 8
- showUi(orderBean)
+ orderSimpleData?.data?.let {
+ var currentBean: OrderStatueBean.DataBean? = null
+ for (item in it) {
+ if (item.orderId == orderBean.data?.orderId) {
+ currentBean = item
+ }
+ }
+ if (it.size == 0 || currentBean == null) {
+ return@callNet
+ }
+ if (currentBean.state == 8) {
+ tv_pay_result_money.textColor(
+ this@SlabOrderOverActivity,
+ R.color.slab_green_over
+ )
+ Handler(Looper.getMainLooper()).post {
+ if (isPlay) {
+ return@post
+ }
+ isPlay = true
+ tv_complete.gone()
+ tv_to_main.visible()
+ MyApplication.getTTsManager()
+ .setVideoText("乘客已支付" + orderBean.data?.orderMoney.toString() + "元")
+ time?.cancel()
+ time = timeOver(20000) {
+ tv_title_slab.text = "已完成($it)"
+ if (it == 0) {
+ if (time != null) {
+ time!!.cancel()
+ }
+ try {
+ finish()
+ } catch (e: Exception) {
+ }
+ }
+ }
+ }
}
}
}
- handler?.postDelayed({ checkOrderStatue() }, 3000)
}
override fun onDestroy() {
@@ -235,5 +266,81 @@
tv_to_main.clickDelay {
onBackPressed()
}
+
+ tv_complete.clickDelay {
+ var pop = DialogUtil.getSlabDelAndSurePopWindow(this,"请确认是否收到乘客线下付款",{}){
+ overOrder()
+ }
+ pop.contentView.tv_close_base.text = "未收款"
+ pop.contentView.tv_sure_base.text = "已收款"
+ pop.showCenter(window.decorView)
+
+ }
}
+
+ override fun onBackPressed() {
+ overOrder()
+ }
+
+ private fun callComplete(function: () -> Unit) {
+ var map = getMapByAny()
+ map["orderId"] = orderId
+ map["orderType"] = orderType
+ callNet(Api.completeOrder,map,{
+ function()
+ }){
+ function()
+ }
+ }
+
+
+
+ private fun addSocketLisener(orderBean: OrderBean?) {
+ MyApplication.addOrderView(object : MyApplication.OrderStatueView {
+ override fun orderInfo(data: OrderSimpleData?) {
+ data?.let {
+ if (it.status == 8 || it.status == 7) {
+ tv_pay_result_money.textColor(
+ this@SlabOrderOverActivity,
+ R.color.slab_green_over
+ )
+ Handler(Looper.getMainLooper()).post {
+ if (isPlay) {
+ return@post
+ }
+ isPlay = true
+ MyApplication.getTTsManager()
+ .setVideoText("乘客已支付" + orderBean?.data?.orderMoney.toString() + "元")
+ time = timeOver(20000) {
+ tv_title_slab.text = "已完成($it)"
+ if (it == 0) {
+ if (time != null) {
+ time!!.cancel()
+ }
+ try {
+ finish()
+ } catch (e: Exception) {
+ }
+ }
+ }
+ }
+
+// android.os.Handler(Looper.getMainLooper()).post {
+// orderBean.data.orderState = 8
+// showUi(orderBean)
+// }
+ }
+ }
+ }
+ })
+
+
+// if (handler == null) {
+// handler = android.os.Handler(mainLooper)
+// handler!!.postDelayed({
+// checkOrderStatue()
+// }, 3000)
+// }
+ }
+
}
\ No newline at end of file
--
Gitblit v1.7.1