|
@@ -3,12 +3,12 @@ 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.text.TextWatcher
|
|
|
import android.view.LayoutInflater
|
|
|
import android.widget.EditText
|
|
|
import android.widget.FrameLayout
|
|
@@ -16,8 +16,6 @@ import android.widget.ImageView
|
|
|
import android.widget.LinearLayout
|
|
|
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.QMUISkinValueBuilder
|
|
|
import com.qmuiteam.qmui.util.QMUIDisplayHelper
|
|
@@ -40,8 +38,6 @@ import com.yanzhenjie.permission.AndPermission
|
|
|
import com.ysnows.base.base.BRepository
|
|
|
import com.ysnows.base.base.BViewModel
|
|
|
import com.ysnows.base.utils.UiSwitch
|
|
|
-import com.ysnows.base.utils.UiUtils
|
|
|
-import com.ysnows.base.view.BView
|
|
|
import java.util.*
|
|
|
|
|
|
|
|
@@ -49,24 +45,24 @@ import java.util.*
|
|
|
*
|
|
|
* 订单状态 order_state:0->全部 10->待取货 20->运输中 30->待结算 40->待评价 50->已完成
|
|
|
*/
|
|
|
-open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
+open class WaybillDetailsVModel(application: Application) : BViewModel<BRepository>(application) {
|
|
|
|
|
|
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
|
|
|
-
|
|
|
+ var ll: LinearLayout? = null
|
|
|
|
|
|
|
|
|
@Bindable
|
|
@@ -79,55 +75,55 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
|
|
|
fun getInfo(order_id: String) {
|
|
|
|
|
|
- if(type.value==0){//货主端-运单详情
|
|
|
+ if (type.value == 0) {//货主端-运单详情
|
|
|
|
|
|
- repository().preq(NetEngine.service.orderGet(order_id))
|
|
|
+ repository().rxPreq(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->{
|
|
|
- if(null!=info.value!!.eva.my_eva){
|
|
|
- order_state=50
|
|
|
+ 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 {
|
|
|
+ } else {
|
|
|
tvTitle.value = "待评价"
|
|
|
}
|
|
|
}
|
|
|
- 50->tvTitle.value="查看评价"
|
|
|
+ 50 -> tvTitle.value = "查看评价"
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
.subscribe()
|
|
|
|
|
|
- }else{ //司机端-货主详情
|
|
|
+ } else { //司机端-货主详情
|
|
|
|
|
|
- repository().preq(NetEngine.service.orderGetDriver(order_id))
|
|
|
+ repository().rxPreq(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->{
|
|
|
- if(null!=info.value!!.eva.my_eva){
|
|
|
- order_state=50
|
|
|
+ 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 {
|
|
|
+ } else {
|
|
|
tvTitle.value = "待评价"
|
|
|
}
|
|
|
}
|
|
|
- 50->tvTitle.value="查看评价"
|
|
|
+ 50 -> tvTitle.value = "查看评价"
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -136,14 +132,12 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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="运输轨迹"
|
|
@@ -171,7 +165,7 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
//货主给司机评价
|
|
|
|
|
|
UiSwitch.bundleRes(repository().context as Activity, EvaluateActivity::class.java, Bundle().apply {
|
|
|
- putString("order_id",order_id)
|
|
|
+ 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)
|
|
@@ -183,19 +177,19 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
}
|
|
|
if (order_state == 50) {
|
|
|
//查看评价
|
|
|
- UiSwitch.bundle(repository().context, EachOtherActivity::class.java,
|
|
|
- Bundle().apply {
|
|
|
- putString("order_id",order_id)
|
|
|
+ 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("确定要开始送货么")
|
|
@@ -209,28 +203,28 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
.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.bundleRes(repository().context as Activity, EvaluateActivity::class.java, Bundle().apply {
|
|
|
- putString("order_id",order_id)
|
|
|
+ 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)
|
|
|
+ }, 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)
|
|
|
+ putString("order_id", order_id)
|
|
|
}
|
|
|
)
|
|
|
}
|
|
@@ -239,20 +233,19 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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().lreq(NetEngine.service.setStatus(map))
|
|
|
+ repository().rxLreq(NetEngine.service.setStatus(map))
|
|
|
.doOnNext() {
|
|
|
if (it.ok()) {
|
|
|
- order_state=20//变成运输中
|
|
|
- tvTitle.value="已送达"
|
|
|
+ order_state = 20//变成运输中
|
|
|
+ tvTitle.value = "已送达"
|
|
|
}
|
|
|
}
|
|
|
.subscribe()
|
|
@@ -260,11 +253,10 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@SuppressLint("WrongConstant")
|
|
|
- fun toCallPhone(mobile:String){
|
|
|
+ fun toCallPhone(mobile: String) {
|
|
|
//拨打电话
|
|
|
- if(TextUtils.isEmpty(mobile)){
|
|
|
+ if (TextUtils.isEmpty(mobile)) {
|
|
|
toast("未添加该公司的电话!!")
|
|
|
return
|
|
|
}
|
|
@@ -282,40 +274,42 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
|
|
|
}
|
|
|
|
|
|
- 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().lreq(NetEngine.service.setStatus(map))
|
|
|
+ repository().rxLreq(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()
|
|
@@ -324,7 +318,7 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
|
|
|
}
|
|
|
|
|
|
- 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) {
|
|
@@ -350,8 +344,7 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- fun showPayDialog(order_id: String){
|
|
|
+ fun showPayDialog(order_id: String) {
|
|
|
var mNormalPopup = QMUIPopups.fullScreenPopup(repository().context)
|
|
|
val builder: QMUISkinValueBuilder = QMUISkinValueBuilder.acquire()
|
|
|
val frameLayout = QMUIFrameLayout(repository().context)
|
|
@@ -362,39 +355,40 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
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 butSure: QMUIRoundButton = layout.findViewById(R.id.but_sure)
|
|
|
|
|
|
val payPwdEditText: PasswordView = layout.findViewById(R.id.ppet)
|
|
|
- var password=""
|
|
|
+ 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)){
|
|
|
+ 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)
|
|
|
+ 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){
|
|
|
+ password = pwd!!
|
|
|
+ if (!TextUtils.isEmpty(password) && password.length == 6) {
|
|
|
|
|
|
- var money=etMoney.text.toString().trim()
|
|
|
- if(TextUtils.isEmpty(money)){
|
|
|
+ var money = etMoney.text.toString().trim()
|
|
|
+ if (TextUtils.isEmpty(money)) {
|
|
|
toast("请输入支付金额")
|
|
|
return
|
|
|
}
|
|
|
- getInfoPay(money,order_id,password)
|
|
|
+ getInfoPay(money, order_id, password)
|
|
|
mNormalPopup.dismiss()
|
|
|
}
|
|
|
}
|
|
@@ -403,16 +397,16 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
|
|
|
|
|
|
butSure.setOnClickListener {
|
|
|
- var money=etMoney.text.toString().trim()
|
|
|
- if(TextUtils.isEmpty(money)){
|
|
|
+ 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)
|
|
|
+ if (!TextUtils.isEmpty(password) && password.length == 6) {
|
|
|
+ getInfoPay(money, order_id, password)
|
|
|
mNormalPopup.dismiss()
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
toast("请输入支付密码")
|
|
|
return@setOnClickListener
|
|
|
}
|
|
@@ -424,7 +418,7 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
}
|
|
|
builder.release();
|
|
|
|
|
|
- val size= QMUIDisplayHelper.getScreenWidth(repository().context)
|
|
|
+ val size = QMUIDisplayHelper.getScreenWidth(repository().context)
|
|
|
|
|
|
val lp: FrameLayout.LayoutParams = FrameLayout.LayoutParams(size,
|
|
|
FrameLayout.LayoutParams.WRAP_CONTENT)
|
|
@@ -441,26 +435,25 @@ open class WaybillDetailsVModel : BViewModel<BRepository>() {
|
|
|
}
|
|
|
|
|
|
|
|
|
- fun getInfoPay(money:String,order_id: String,pay_pwd:String) {
|
|
|
- repository().lreq(NetEngine.service.carPay(money,order_id,pay_pwd))
|
|
|
+ fun getInfoPay(money: String, order_id: String, pay_pwd: String) {
|
|
|
+ repository().rxLreq(NetEngine.service.carPay(money, order_id, pay_pwd))
|
|
|
.doOnNext() {
|
|
|
if (it.ok(true)) {
|
|
|
- order_state=40
|
|
|
- tvTitle.value= "待评价"
|
|
|
+ order_state = 40
|
|
|
+ tvTitle.value = "待评价"
|
|
|
}
|
|
|
|
|
|
}
|
|
|
.subscribe()
|
|
|
}
|
|
|
|
|
|
- fun changeComment(){//发表完评论改变状态
|
|
|
- order_state=50
|
|
|
- tvTitle.value="查看评价"
|
|
|
+ fun changeComment() {//发表完评论改变状态
|
|
|
+ order_state = 50
|
|
|
+ tvTitle.value = "查看评价"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|