|
@@ -3,27 +3,24 @@ package com.quansu.heifengwuliu.vmodel
|
|
|
import android.Manifest
|
|
|
import android.annotation.SuppressLint
|
|
|
import android.app.Activity
|
|
|
-import android.app.Application
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.net.Uri
|
|
|
import android.os.Bundle
|
|
|
import android.text.TextUtils
|
|
|
-import android.util.Log
|
|
|
+import android.text.TextWatcher
|
|
|
import android.view.LayoutInflater
|
|
|
+import android.widget.EditText
|
|
|
import android.widget.FrameLayout
|
|
|
import android.widget.ImageView
|
|
|
import android.widget.LinearLayout
|
|
|
-import android.widget.TextView
|
|
|
import androidx.databinding.Bindable
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
import com.google.gson.Gson
|
|
|
import com.hwangjr.rxbus.RxBus
|
|
|
import com.qmuiteam.qmui.layout.QMUIFrameLayout
|
|
|
-import com.qmuiteam.qmui.skin.QMUISkinHelper
|
|
|
import com.qmuiteam.qmui.skin.QMUISkinValueBuilder
|
|
|
import com.qmuiteam.qmui.util.QMUIDisplayHelper
|
|
|
-import com.qmuiteam.qmui.util.QMUIResHelper
|
|
|
import com.qmuiteam.qmui.widget.dialog.QMUIDialog
|
|
|
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction
|
|
|
import com.qmuiteam.qmui.widget.popup.QMUIPopup
|
|
@@ -31,10 +28,9 @@ import com.qmuiteam.qmui.widget.popup.QMUIPopups
|
|
|
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
|
|
|
import com.quansu.heifengwuliu.BR
|
|
|
import com.quansu.heifengwuliu.R
|
|
|
+import com.quansu.heifengwuliu.activity.EachOtherActivity
|
|
|
import com.quansu.heifengwuliu.activity.EvaluateActivity
|
|
|
-import com.quansu.heifengwuliu.activity.VehicleListActivity
|
|
|
-import com.quansu.heifengwuliu.config.ConfigRx
|
|
|
-import com.quansu.heifengwuliu.model.DataInfoBean
|
|
|
+import com.quansu.heifengwuliu.config.MIntentAction
|
|
|
import com.quansu.heifengwuliu.model.WaybillDetails
|
|
|
import com.quansu.heifengwuliu.utils.ChosePhotoUtils
|
|
|
import com.quansu.heifengwuliu.utils.net.NetEngine
|
|
@@ -44,30 +40,34 @@ import com.yanzhenjie.permission.AndPermission
|
|
|
import com.ysnows.base.base.BRepository
|
|
|
import com.ysnows.base.base.BViewModel
|
|
|
import com.ysnows.base.utils.UiSwitch
|
|
|
-import java.util.HashMap
|
|
|
+import com.ysnows.base.utils.UiUtils
|
|
|
+import com.ysnows.base.view.BView
|
|
|
+import java.util.*
|
|
|
|
|
|
|
|
|
/*
|
|
|
*
|
|
|
* 订单状态 order_state:0->全部 10->待取货 20->运输中 30->待结算 40->待评价 50->已完成
|
|
|
*/
|
|
|
-open class WaybillDetailsVModel(application: Application) : BViewModel<BRepository>(application) {
|
|
|
+open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
|
|
|
val info: MutableLiveData<WaybillDetails> = MutableLiveData<WaybillDetails>()
|
|
|
-
|
|
|
//0货主端 2司机端
|
|
|
val type: MutableLiveData<Int> = MutableLiveData<Int>()
|
|
|
|
|
|
val tvTitle: MutableLiveData<String> = MutableLiveData<String>()
|
|
|
|
|
|
|
|
|
- var order_state: Int = 0
|
|
|
+ var order_state:Int=0
|
|
|
|
|
|
var img: MutableLiveData<String> = MutableLiveData("")//司机端
|
|
|
val isDialogShow: MutableLiveData<Boolean> = MutableLiveData<Boolean>(false)//司机端
|
|
|
|
|
|
val isButShow: MutableLiveData<Boolean> = MutableLiveData<Boolean>(true)
|
|
|
|
|
|
+ var ll: LinearLayout? =null
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Bindable
|
|
|
var number: String? = null
|
|
@@ -79,41 +79,55 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
|
|
|
|
|
|
fun getInfo(order_id: String) {
|
|
|
|
|
|
- if (type.value == 0) {//货主端-运单详情
|
|
|
+ if(type.value==0){//货主端-运单详情
|
|
|
|
|
|
- repository().rxLreq(NetEngine.service.orderGet(order_id))
|
|
|
+ repository().preq(NetEngine.service.orderGet(order_id))
|
|
|
.doOnNext() {
|
|
|
if (it.ok()) {
|
|
|
|
|
|
info.value = it.data() as WaybillDetails
|
|
|
- order_state = info.value!!.order.order_state
|
|
|
- when (info.value!!.order.order_state) {
|
|
|
- 10 -> tvTitle.value = "运输轨迹"
|
|
|
- 20 -> tvTitle.value = "运输轨迹"
|
|
|
- 30 -> tvTitle.value = "去结算"
|
|
|
- 40 -> tvTitle.value = "待评价"
|
|
|
- 50 -> tvTitle.value = "查看评价"
|
|
|
+ order_state= info.value!!.order.order_state
|
|
|
+ when(info.value!!.order.order_state){
|
|
|
+ 10->tvTitle.value="运输轨迹"
|
|
|
+ 20->tvTitle.value="运输轨迹"
|
|
|
+ 30->tvTitle.value="去结算"
|
|
|
+ 40->{
|
|
|
+ if(null!=info.value!!.eva.my_eva){
|
|
|
+ order_state=50
|
|
|
+ tvTitle.value = "查看评价"
|
|
|
+ }else {
|
|
|
+ tvTitle.value = "待评价"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 50->tvTitle.value="查看评价"
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
.subscribe()
|
|
|
|
|
|
- } else { //司机端-货主详情
|
|
|
+ }else{ //司机端-货主详情
|
|
|
|
|
|
- repository().rxLreq(NetEngine.service.orderGetDriver(order_id))
|
|
|
+ repository().preq(NetEngine.service.orderGetDriver(order_id))
|
|
|
.doOnNext() {
|
|
|
if (it.ok()) {
|
|
|
|
|
|
- info.value = it.data() as WaybillDetails
|
|
|
- order_state = info.value!!.order.order_state
|
|
|
- isButShow.value = order_state == 10 || order_state == 20 || order_state == 40 || order_state == 50
|
|
|
-
|
|
|
- when (info.value!!.order.order_state) {
|
|
|
- 10 -> tvTitle.value = "开始送货"
|
|
|
- 20 -> tvTitle.value = "已送达"
|
|
|
- 40 -> tvTitle.value = "待评价"
|
|
|
- 50 -> tvTitle.value = "查看评价"
|
|
|
+ info.value = it.data()as WaybillDetails
|
|
|
+ order_state= info.value!!.order.order_state
|
|
|
+ isButShow.value = order_state==10||order_state==20||order_state==40||order_state==50
|
|
|
+
|
|
|
+ when(info.value!!.order.order_state){
|
|
|
+ 10->tvTitle.value="开始送货"
|
|
|
+ 20->tvTitle.value="已送达"
|
|
|
+ 40->{
|
|
|
+ if(null!=info.value!!.eva.my_eva){
|
|
|
+ order_state=50
|
|
|
+ tvTitle.value = "查看评价"
|
|
|
+ }else {
|
|
|
+ tvTitle.value = "待评价"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 50->tvTitle.value="查看评价"
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -122,12 +136,14 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
- fun toStartShip(order_id: String) {
|
|
|
+ fun toStartShip(order_id:String){
|
|
|
|
|
|
- if (type.value == 0) {
|
|
|
+ if(type.value==0) {//货主端
|
|
|
//0->全部 10->待取货 20->运输中 30->待结算 40->待评价 50->已完成
|
|
|
// 10->tvTitle.value="运输轨迹"
|
|
|
// 20->tvTitle.value="运输轨迹"
|
|
@@ -144,23 +160,42 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
|
|
|
if (order_state == 30) {
|
|
|
|
|
|
|
|
|
+ showPayDialog(order_id)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if (order_state == 40) {
|
|
|
+ //货主给司机评价
|
|
|
+
|
|
|
+ UiSwitch.bundleRes(repository().context as Activity, EvaluateActivity::class.java, Bundle().apply {
|
|
|
+ putString("order_id",order_id)
|
|
|
+ putString("url", info.value!!.driver.avatar)
|
|
|
+ putString("sn", info.value!!.order.order_sn)
|
|
|
+ putString("time", info.value!!.order.create_time)
|
|
|
+ }, MIntentAction.REQUEST_CODE_COMMENT)
|
|
|
+
|
|
|
|
|
|
|
|
|
return
|
|
|
}
|
|
|
if (order_state == 50) {
|
|
|
+ //查看评价
|
|
|
+ UiSwitch.bundle(repository().context, EachOtherActivity::class.java,
|
|
|
+ Bundle().apply {
|
|
|
+ putString("order_id",order_id)
|
|
|
|
|
|
+ }
|
|
|
+ )
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- } else {//司机端
|
|
|
+ }else{//司机端
|
|
|
|
|
|
- if (order_state == 10) {
|
|
|
+ if(order_state==10) {
|
|
|
QMUIDialog.MessageDialogBuilder(repository().context)
|
|
|
.setTitle("提示")
|
|
|
.setMessage("确定要开始送货么")
|
|
@@ -174,42 +209,50 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
|
|
|
.show()
|
|
|
return
|
|
|
}
|
|
|
- if (order_state == 20) {//已完成
|
|
|
+ if(order_state==20){//已完成
|
|
|
|
|
|
- isDialogShow.value = true
|
|
|
- number = ""
|
|
|
+ isDialogShow.value=true
|
|
|
+ number=""
|
|
|
}
|
|
|
- if (order_state == 40) {//待评价--司机对货主的评价
|
|
|
+ if(order_state==40){//待评价--司机对货主的评价
|
|
|
|
|
|
- UiSwitch.bundle(repository().context, EvaluateActivity::class.java, Bundle().apply {
|
|
|
- putString("order_id", order_id)
|
|
|
- })
|
|
|
+ UiSwitch.bundleRes(repository().context as Activity, EvaluateActivity::class.java, Bundle().apply {
|
|
|
+ putString("order_id",order_id)
|
|
|
+ putString("url", "")
|
|
|
+ putString("sn", info.value!!.order.order_sn)
|
|
|
+ putString("time", info.value!!.order.create_time)
|
|
|
+ },MIntentAction.REQUEST_CODE_COMMENT)
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (order_state == 50) {//查看评价
|
|
|
-
|
|
|
+ if(order_state==50){//查看评价
|
|
|
|
|
|
+ UiSwitch.bundle(repository().context, EachOtherActivity::class.java,
|
|
|
+ Bundle().apply {
|
|
|
+ putString("order_id",order_id)
|
|
|
+ }
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
- fun setSureSend(order_id: String) {
|
|
|
+ fun setSureSend(order_id:String){
|
|
|
|
|
|
- var map = HashMap<String, String>()
|
|
|
+ var map= HashMap<String, String>()
|
|
|
map["order_id"] = order_id
|
|
|
map["state"] = "20"
|
|
|
- repository().rxLreq(NetEngine.service.setStatus(map))
|
|
|
+ repository().lreq(NetEngine.service.setStatus(map))
|
|
|
.doOnNext() {
|
|
|
if (it.ok()) {
|
|
|
- order_state = 20//变成运输中
|
|
|
- tvTitle.value = "已送达"
|
|
|
+ order_state=20//变成运输中
|
|
|
+ tvTitle.value="已送达"
|
|
|
}
|
|
|
}
|
|
|
.subscribe()
|
|
@@ -217,10 +260,11 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
@SuppressLint("WrongConstant")
|
|
|
- fun toCallPhone(mobile: String) {
|
|
|
+ fun toCallPhone(mobile:String){
|
|
|
//拨打电话
|
|
|
- if (TextUtils.isEmpty(mobile)) {
|
|
|
+ if(TextUtils.isEmpty(mobile)){
|
|
|
toast("未添加该公司的电话!!")
|
|
|
return
|
|
|
}
|
|
@@ -238,42 +282,40 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
|
|
|
|
|
|
}
|
|
|
|
|
|
- fun interceptClick() {
|
|
|
+ fun interceptClick(){
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
fun choseImg() {
|
|
|
//选择照片
|
|
|
ChosePhotoUtils.getChosePhoto(view()!!.context(), 1)
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- fun goOperation(type: Int, order_id: String, data_id: String) {
|
|
|
- if (type == 1) {
|
|
|
- isDialogShow.value = false
|
|
|
- } else {
|
|
|
+ fun goOperation(type:Int,order_id:String,data_id:String){
|
|
|
+ if(type==1){
|
|
|
+ isDialogShow.value=false
|
|
|
+ }else{
|
|
|
//确定
|
|
|
- if (TextUtils.isEmpty(number)) {
|
|
|
+ if(TextUtils.isEmpty(number)){
|
|
|
toast("输入运送数量")
|
|
|
return
|
|
|
}
|
|
|
- if (TextUtils.isEmpty(img.value)) {
|
|
|
+ if(TextUtils.isEmpty(img.value)){
|
|
|
toast("请上传凭证")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- var map = HashMap<String, String>()
|
|
|
+ var map= HashMap<String, String>()
|
|
|
map["order_id"] = order_id
|
|
|
map["state"] = "30"
|
|
|
- map["data_id"] = data_id
|
|
|
+ map["data_id"] =data_id
|
|
|
map["img"] = img.value.toString()
|
|
|
map["nums"] = number.toString()
|
|
|
- repository().rxLreq(NetEngine.service.setStatus(map))
|
|
|
+ repository().lreq(NetEngine.service.setStatus(map))
|
|
|
.doOnNext() {
|
|
|
if (it.ok(true)) {
|
|
|
- order_state = 30//变成待结算
|
|
|
- tvTitle.value = ""
|
|
|
- isDialogShow.value = false
|
|
|
+ order_state=30//变成待结算
|
|
|
+ tvTitle.value=""
|
|
|
+ isDialogShow.value=false
|
|
|
}
|
|
|
}
|
|
|
.subscribe()
|
|
@@ -282,7 +324,7 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
|
|
|
|
|
|
}
|
|
|
|
|
|
- fun getOrderStatus(order_state: Int): String {
|
|
|
+ fun getOrderStatus(order_state:Int):String {
|
|
|
//0->全部 10->待取货 20->运输中 30->待结算 40->待评价 50->已完成
|
|
|
if (type.value == 0) {//货主端
|
|
|
when (order_state) {
|
|
@@ -308,4 +350,120 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ fun showPayDialog(order_id: String){
|
|
|
+ var mNormalPopup = QMUIPopups.fullScreenPopup(repository().context)
|
|
|
+ val builder: QMUISkinValueBuilder = QMUISkinValueBuilder.acquire()
|
|
|
+ val frameLayout = QMUIFrameLayout(repository().context)
|
|
|
+
|
|
|
+ //自定义布局
|
|
|
+ val layoutInflater = repository().context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
|
|
+ var layout = layoutInflater.inflate(R.layout.item_apy_car, null)
|
|
|
+ val butCancel: ImageView = layout.findViewById(R.id.iv_close)
|
|
|
+ val etMoney: EditText = layout.findViewById(R.id.et_money)
|
|
|
+
|
|
|
+ val butSure: QMUIRoundButton =layout.findViewById(R.id.but_sure)
|
|
|
+
|
|
|
+ val payPwdEditText: PasswordView = layout.findViewById(R.id.ppet)
|
|
|
+ var password=""
|
|
|
+
|
|
|
+
|
|
|
+ payPwdEditText.setPasswordListener(object : PasswordView.PasswordListener {
|
|
|
+ override fun keyEnterPress(pwd: String?, isComplete: Boolean) {
|
|
|
+ password= pwd!!
|
|
|
+ if(!TextUtils.isEmpty(password)&&password.length==6){
|
|
|
+ var money=etMoney.text.toString().trim()
|
|
|
+ if(TextUtils.isEmpty(money)){
|
|
|
+ toast("请输入支付金额")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ getInfoPay(money,order_id,password)
|
|
|
+ mNormalPopup.dismiss()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ override fun passwordChange(changeText: String?) {
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun passwordComplete(pwd: String?) {
|
|
|
+ password=pwd!!
|
|
|
+ if(!TextUtils.isEmpty(password)&&password.length==6){
|
|
|
+
|
|
|
+ var money=etMoney.text.toString().trim()
|
|
|
+ if(TextUtils.isEmpty(money)){
|
|
|
+ toast("请输入支付金额")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ getInfoPay(money,order_id,password)
|
|
|
+ mNormalPopup.dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ butSure.setOnClickListener {
|
|
|
+ var money=etMoney.text.toString().trim()
|
|
|
+ if(TextUtils.isEmpty(money)){
|
|
|
+ toast("请输入支付金额")
|
|
|
+ return@setOnClickListener
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!TextUtils.isEmpty(password)&&password.length==6){
|
|
|
+ getInfoPay(money,order_id,password)
|
|
|
+ mNormalPopup.dismiss()
|
|
|
+ }else{
|
|
|
+ toast("请输入支付密码")
|
|
|
+ return@setOnClickListener
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ butCancel.setOnClickListener {
|
|
|
+ mNormalPopup.dismiss()
|
|
|
+ }
|
|
|
+ builder.release();
|
|
|
+
|
|
|
+ val size= QMUIDisplayHelper.getScreenWidth(repository().context)
|
|
|
+
|
|
|
+ val lp: FrameLayout.LayoutParams = FrameLayout.LayoutParams(size,
|
|
|
+ FrameLayout.LayoutParams.WRAP_CONTENT)
|
|
|
+ frameLayout.addView(layout, lp)
|
|
|
+
|
|
|
+ mNormalPopup.addView(frameLayout)
|
|
|
+ mNormalPopup.onDismiss() {
|
|
|
+ }
|
|
|
+
|
|
|
+ mNormalPopup.dismissIfOutsideTouch(false)
|
|
|
+ mNormalPopup.animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER)
|
|
|
+ mNormalPopup.show(ll)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ fun getInfoPay(money:String,order_id: String,pay_pwd:String) {
|
|
|
+ repository().lreq(NetEngine.service.carPay(money,order_id,pay_pwd))
|
|
|
+ .doOnNext() {
|
|
|
+ if (it.ok(true)) {
|
|
|
+ order_state=40
|
|
|
+ tvTitle.value= "待评价"
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ .subscribe()
|
|
|
+ }
|
|
|
+
|
|
|
+ fun changeComment(){//发表完评论改变状态
|
|
|
+ order_state=50
|
|
|
+ tvTitle.value="查看评价"
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|