|
@@ -8,15 +8,24 @@ import android.view.View
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
|
+import com.tencent.imsdk.v2.V2TIMConversation
|
|
|
+import com.tencent.qcloud.tuicore.TUIConstants
|
|
|
+import com.tencent.qcloud.tuicore.TUICore
|
|
|
+import com.tencent.qcloud.tuicore.TUILogin
|
|
|
+import com.tencent.qcloud.tuicore.interfaces.TUICallback
|
|
|
import com.yingyang.healthconsultation.R
|
|
|
import com.yingyang.healthconsultation.adapter.ConsultationDataAdapter
|
|
|
import com.yingyang.healthconsultation.databinding.ActivityPaidBinding
|
|
|
+import com.yingyang.healthconsultation.dialog.EvaluateDialog
|
|
|
import com.yingyang.healthconsultation.entity.PurchaseConsultationBean
|
|
|
+import com.yingyangfly.baselib.config.AccountConfig
|
|
|
+import com.yingyangfly.baselib.db.DoctorBean
|
|
|
import com.yingyangfly.baselib.dialog.TipsDialog
|
|
|
import com.yingyangfly.baselib.ext.*
|
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
import com.yingyangfly.baselib.utils.JumpUtil
|
|
|
+import com.yingyangfly.baselib.utils.User
|
|
|
|
|
|
/**
|
|
|
* 已支付
|
|
@@ -35,6 +44,7 @@ class PaidActivity : BaseMVVMActivity<ActivityPaidBinding, PaidViewModel>(),
|
|
|
private var sickTime: String = ""
|
|
|
private var images: String = ""
|
|
|
private var isConsultation: String = ""
|
|
|
+ private var doctor: DoctorBean? = null
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
id = intent.getStringExtra("id") ?: ""
|
|
@@ -132,18 +142,27 @@ class PaidActivity : BaseMVVMActivity<ActivityPaidBinding, PaidViewModel>(),
|
|
|
//1待接诊
|
|
|
binding {
|
|
|
tvStatus.text = "订单已支付,等待医生回复医生会在24小时内回复您"
|
|
|
+ orderBtnLayout.show(false)
|
|
|
+ btnConnection.show(true)
|
|
|
+ btnConnection.text = "取消订单"
|
|
|
}
|
|
|
}
|
|
|
"2" -> {
|
|
|
//2接诊中
|
|
|
binding {
|
|
|
tvStatus.text = "医生接诊中"
|
|
|
+ orderBtnLayout.show(false)
|
|
|
+ btnConnection.show(true)
|
|
|
+ btnConnection.text = "联系医生"
|
|
|
}
|
|
|
}
|
|
|
"3" -> {
|
|
|
//3已拒诊
|
|
|
binding {
|
|
|
tvStatus.text = "医生已取消"
|
|
|
+ orderBtnLayout.show(false)
|
|
|
+ btnConnection.show(true)
|
|
|
+ btnConnection.text = "重新问诊"
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -151,9 +170,11 @@ class PaidActivity : BaseMVVMActivity<ActivityPaidBinding, PaidViewModel>(),
|
|
|
//4已完成
|
|
|
binding {
|
|
|
tvStatus.text = "订单完成"
|
|
|
+ orderBtnLayout.show(false)
|
|
|
+ btnConnection.show(true)
|
|
|
+ btnConnection.text = "去评价"
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
"5" -> {
|
|
|
//5已取消
|
|
|
binding {
|
|
@@ -170,21 +191,6 @@ class PaidActivity : BaseMVVMActivity<ActivityPaidBinding, PaidViewModel>(),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取医生信息
|
|
|
- */
|
|
|
- private fun getDoctorDetail() {
|
|
|
- if (TextUtils.isEmpty(doctorId).not()) {
|
|
|
- viewModel.getDoctorDetail(doctorId, fail = {
|
|
|
- it.toast()
|
|
|
- }, success = {
|
|
|
- if (it != null) {
|
|
|
- binding.doctor = it
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
|
|
when (event.action) {
|
|
@@ -212,7 +218,7 @@ class PaidActivity : BaseMVVMActivity<ActivityPaidBinding, PaidViewModel>(),
|
|
|
} else if (v.id == R.id.btnContactDoctor) {
|
|
|
payOrder()
|
|
|
} else if (v.id == R.id.btnConnection) {
|
|
|
-
|
|
|
+ connectionOrder()
|
|
|
}
|
|
|
}
|
|
|
MotionEvent.ACTION_CANCEL -> {
|
|
@@ -226,6 +232,26 @@ class PaidActivity : BaseMVVMActivity<ActivityPaidBinding, PaidViewModel>(),
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 操作
|
|
|
+ */
|
|
|
+ private fun connectionOrder() {
|
|
|
+ when (status) {
|
|
|
+ "1", "3" -> {
|
|
|
+ showTipsDialog(id)
|
|
|
+ }
|
|
|
+ "2" -> {
|
|
|
+ getUserSign()
|
|
|
+ }
|
|
|
+ "4" -> {
|
|
|
+ evaluationOrder()
|
|
|
+ }
|
|
|
+ "5" -> {
|
|
|
+ reinterview()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 取消订单
|
|
|
*/
|
|
@@ -237,6 +263,9 @@ class PaidActivity : BaseMVVMActivity<ActivityPaidBinding, PaidViewModel>(),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 取消订单弹窗
|
|
|
+ */
|
|
|
private fun showTipsDialog(id: String) {
|
|
|
TipsDialog.TipDialogBuilder()
|
|
|
.title("提示")
|
|
@@ -269,4 +298,80 @@ class PaidActivity : BaseMVVMActivity<ActivityPaidBinding, PaidViewModel>(),
|
|
|
.withTransition(R.anim.leftin, R.anim.leftout)
|
|
|
.navigation(mContext)
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 去评价
|
|
|
+ */
|
|
|
+ private fun evaluationOrder() {
|
|
|
+ val diaslog = EvaluateDialog()
|
|
|
+ diaslog.setId(id)
|
|
|
+ diaslog.show(supportFragmentManager, "EvaluateDialog")
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重新问诊
|
|
|
+ */
|
|
|
+ private fun reinterview() {
|
|
|
+ JumpUtil.jumpActivityWithUrl(
|
|
|
+ RouterUrlCommon.consultationRequest,
|
|
|
+ doctorId,
|
|
|
+ mContext
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取密钥
|
|
|
+ */
|
|
|
+ private fun getUserSign() {
|
|
|
+ viewModel.getUserSign(doctor!!.id, fail = {
|
|
|
+ it.toast()
|
|
|
+ }, success = {
|
|
|
+ it?.let {
|
|
|
+ runOnUiThread {
|
|
|
+ loginIM(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 登录IM
|
|
|
+ */
|
|
|
+ private fun loginIM(sign: String) {
|
|
|
+ TUILogin.login(mContext, AccountConfig.TENCENT_IM_APPID, User.getUserId(), sign, object :
|
|
|
+ TUICallback() {
|
|
|
+ override fun onSuccess() {
|
|
|
+ runOnUiThread {
|
|
|
+ val param = Bundle()
|
|
|
+ param.putInt(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C)
|
|
|
+ param.putString(TUIConstants.TUIChat.CHAT_ID, doctor!!.id)
|
|
|
+ param.putString(TUIConstants.TUIChat.CHAT_NAME, doctor!!.userName)
|
|
|
+ param.putString(TUIConstants.TUIChat.FACE_URL, doctor!!.avatar)
|
|
|
+ TUICore.startActivity(TUIConstants.TUIChat.C2C_CHAT_ACTIVITY_NAME, param)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onError(errorCode: Int, errorMessage: String?) {
|
|
|
+ runOnUiThread {
|
|
|
+ "IM登陆失败".toast()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取医生信息
|
|
|
+ */
|
|
|
+ private fun getDoctorDetail() {
|
|
|
+ if (TextUtils.isEmpty(doctorId).not()) {
|
|
|
+ viewModel.getDoctorDetail(doctorId, fail = {
|
|
|
+ it.toast()
|
|
|
+ }, success = {
|
|
|
+ if (it != null) {
|
|
|
+ doctor = it
|
|
|
+ binding.doctor = it
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|