|
|
@@ -3,29 +3,33 @@ package com.yingyang.healthconsultation.consultationsheet
|
|
|
import android.annotation.SuppressLint
|
|
|
import android.app.Activity
|
|
|
import android.content.Intent
|
|
|
+import android.os.Bundle
|
|
|
import android.os.Environment
|
|
|
import android.text.TextUtils
|
|
|
import android.view.MotionEvent
|
|
|
import android.view.View
|
|
|
import android.widget.ImageView
|
|
|
-import android.widget.LinearLayout
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
+import com.alibaba.android.arouter.launcher.ARouter
|
|
|
import com.donkingliang.imageselector.utils.ImageSelector
|
|
|
import com.yingyang.healthconsultation.R
|
|
|
import com.yingyang.healthconsultation.adapter.SickTimeAdapter
|
|
|
import com.yingyang.healthconsultation.databinding.ActivityConsultationSheetBinding
|
|
|
import com.yingyang.healthconsultation.dialog.SelectPicDialog
|
|
|
+import com.yingyang.healthconsultation.entity.PurchaseConsultationBean
|
|
|
import com.yingyang.healthconsultation.entity.UploadImgBean
|
|
|
import com.yingyang.healthconsultation.utils.CommonUtils
|
|
|
import com.yingyangfly.baselib.adapter.XBaseAdapter
|
|
|
import com.yingyangfly.baselib.dialog.TipsDialog
|
|
|
-import com.yingyangfly.baselib.ext.*
|
|
|
+import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
+import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
|
+import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
+import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
-import com.yingyangfly.baselib.utils.GlideImgUtil
|
|
|
import com.yingyangfly.baselib.utils.LogUtil
|
|
|
import com.yingyangfly.baselib.utils.img.ImgUtil
|
|
|
import top.zibin.luban.Luban
|
|
|
@@ -40,15 +44,21 @@ class ConsultationSheetActivity :
|
|
|
BaseMVVMActivity<ActivityConsultationSheetBinding, ConsultationSheetViewModel>(),
|
|
|
View.OnTouchListener {
|
|
|
|
|
|
- private val REQUEST_MEDICALRECORDS_CAMERA = 1
|
|
|
- private val REQUEST_MEDICALRECORDS_IMG = 2
|
|
|
- var imageList = mutableListOf<UploadImgBean>()
|
|
|
+ private var id: String = ""
|
|
|
+ private val requestMedicalRecordsCamera = 1
|
|
|
+ private val requestMedicalRecordsImg = 2
|
|
|
+ private var imageList = mutableListOf<UploadImgBean>()
|
|
|
private lateinit var emptyUploadImgBean: UploadImgBean
|
|
|
private lateinit var imageAdapter: XBaseAdapter<UploadImgBean>
|
|
|
-
|
|
|
+ private val purchaseConsultationBean = PurchaseConsultationBean()
|
|
|
private val sickTimes = mutableListOf<String>()
|
|
|
private val sickTimeAdapter by lazy { SickTimeAdapter() }
|
|
|
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ id = intent.getStringExtra("url") ?: ""
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ }
|
|
|
+
|
|
|
override fun initViews() {
|
|
|
binding {
|
|
|
sickTimes.clear()
|
|
|
@@ -59,6 +69,9 @@ class ConsultationSheetActivity :
|
|
|
val layoutManager = LinearLayoutManager(mContext, RecyclerView.HORIZONTAL, false)
|
|
|
rvSickTime.layoutManager = layoutManager
|
|
|
rvSickTime.adapter = sickTimeAdapter
|
|
|
+ sickTimeAdapter.onClickListener = {
|
|
|
+ purchaseConsultationBean.sickTime = it
|
|
|
+ }
|
|
|
sickTimeAdapter.setData(sickTimes)
|
|
|
}
|
|
|
initImageRv()
|
|
|
@@ -67,7 +80,6 @@ class ConsultationSheetActivity :
|
|
|
/**
|
|
|
* 初始化问诊单图片
|
|
|
*/
|
|
|
- @SuppressLint("NotifyDataSetChanged")
|
|
|
private fun initImageRv() {
|
|
|
emptyUploadImgBean = UploadImgBean()
|
|
|
imageList.add(emptyUploadImgBean)
|
|
|
@@ -96,7 +108,7 @@ class ConsultationSheetActivity :
|
|
|
imgDelete.visibility = View.VISIBLE
|
|
|
val params = img.layoutParams
|
|
|
params.height = params.width
|
|
|
- if (bean.remotePath.isNullOrEmpty()) {
|
|
|
+ if (bean.remotePath.isEmpty()) {
|
|
|
upLoadImg(i, img)
|
|
|
} else {
|
|
|
if (bean.localPaht.isEmpty()) {
|
|
|
@@ -126,6 +138,7 @@ class ConsultationSheetActivity :
|
|
|
/**
|
|
|
* 删除图片
|
|
|
*/
|
|
|
+ @SuppressLint("NotifyDataSetChanged")
|
|
|
private fun delect(i: Int) {
|
|
|
TipsDialog.TipDialogBuilder()
|
|
|
.title("提示")
|
|
|
@@ -156,14 +169,14 @@ class ConsultationSheetActivity :
|
|
|
.setSingle(false) //设置是否单选
|
|
|
.canPreview(true) //是否点击放大图片查看,,默认为true
|
|
|
.setMaxSelectCount(if (getImgLocalPaths().size > 0) 9 - getImgLocalPaths().size else 9) // 图片的最大选择数量,小于等于0时,不限数量
|
|
|
- .start(this, REQUEST_MEDICALRECORDS_IMG) // 打开相册
|
|
|
+ .start(this, requestMedicalRecordsImg) // 打开相册
|
|
|
} else {
|
|
|
ImageSelector.builder()
|
|
|
.useCamera(true)
|
|
|
.onlyTakePhoto(true)
|
|
|
.setCrop(false)
|
|
|
.setSelected(getImgLocalPaths())
|
|
|
- .start(this, REQUEST_MEDICALRECORDS_CAMERA)
|
|
|
+ .start(this, requestMedicalRecordsCamera)
|
|
|
}
|
|
|
}
|
|
|
dialog.show(supportFragmentManager, "SelectPicDialog")
|
|
|
@@ -172,7 +185,7 @@ class ConsultationSheetActivity :
|
|
|
private fun getImgLocalPaths(): ArrayList<String> {
|
|
|
val localList = arrayListOf<String>()
|
|
|
imageList.forEach {
|
|
|
- if (it.localPaht.isNullOrEmpty().not())
|
|
|
+ if (it.localPaht.isEmpty().not())
|
|
|
localList.add(it.localPaht)
|
|
|
}
|
|
|
return localList
|
|
|
@@ -184,11 +197,18 @@ class ConsultationSheetActivity :
|
|
|
binding {
|
|
|
backLayout.setOnTouchListener(this@ConsultationSheetActivity)
|
|
|
btnSubmit.setOnTouchListener(this@ConsultationSheetActivity)
|
|
|
+ radioBeenHospital.setOnCheckedChangeListener { group, checkedId ->
|
|
|
+ if (checkedId == R.id.radioYes) {
|
|
|
+ purchaseConsultationBean.isConsultation = "0"
|
|
|
+ } else if (checkedId == R.id.radioNo) {
|
|
|
+ purchaseConsultationBean.isConsultation = "1"
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun initData() {
|
|
|
- getUserInfo()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
@@ -206,7 +226,9 @@ class ConsultationSheetActivity :
|
|
|
finish()
|
|
|
}
|
|
|
R.id.btnSubmit -> {
|
|
|
-
|
|
|
+ if (judge()) {
|
|
|
+ saveData()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -219,28 +241,15 @@ class ConsultationSheetActivity :
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取患者信息
|
|
|
- */
|
|
|
- private fun getUserInfo() {
|
|
|
- viewModel.getUserInfo(fail = {
|
|
|
- it.toast()
|
|
|
- }, success = {
|
|
|
- if (it != null) {
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
super.onActivityResult(requestCode, resultCode, data)
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
|
|
- if (requestCode == REQUEST_MEDICALRECORDS_CAMERA) {//拍照
|
|
|
+ if (requestCode == requestMedicalRecordsCamera) {//拍照
|
|
|
val images = data?.getStringArrayListExtra(ImageSelector.SELECT_RESULT)
|
|
|
images?.let {
|
|
|
withLs(it)
|
|
|
}
|
|
|
- } else if (requestCode == REQUEST_MEDICALRECORDS_IMG) {//选择图片
|
|
|
+ } else if (requestCode == requestMedicalRecordsImg) {//选择图片
|
|
|
val images = data?.getStringArrayListExtra(ImageSelector.SELECT_RESULT)
|
|
|
images?.let {
|
|
|
withLs(it)
|
|
|
@@ -258,7 +267,7 @@ class ConsultationSheetActivity :
|
|
|
.ignoreBy(100)
|
|
|
.setTargetDir(getPath())
|
|
|
.setFocusAlpha(false)
|
|
|
- .filter { path -> !(TextUtils.isEmpty(path) || path.toLowerCase().endsWith(".gif")) }
|
|
|
+ .filter { path -> !(TextUtils.isEmpty(path) || path.lowercase().endsWith(".gif")) }
|
|
|
.setCompressListener(
|
|
|
object : OnCompressListener {
|
|
|
override fun onStart() {
|
|
|
@@ -303,7 +312,7 @@ class ConsultationSheetActivity :
|
|
|
|
|
|
override fun onDestroy() {
|
|
|
val path = getPath()
|
|
|
- if (path.isNullOrEmpty().not()) {
|
|
|
+ if (path.isEmpty().not()) {
|
|
|
CommonUtils.deleteDirectory(path)
|
|
|
}
|
|
|
super.onDestroy()
|
|
|
@@ -348,4 +357,62 @@ class ConsultationSheetActivity :
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 购买问诊服务
|
|
|
+ */
|
|
|
+ private fun saveData() {
|
|
|
+ val stringBuffer = StringBuffer()
|
|
|
+ getImgRemotePathPaths().forEach {
|
|
|
+ stringBuffer.append(it).append(",")
|
|
|
+ }
|
|
|
+ purchaseConsultationBean.let {
|
|
|
+ it.remark = binding.editCondition.text.toString()
|
|
|
+ it.sysUserId = id
|
|
|
+ it.images = stringBuffer.toString()
|
|
|
+ }
|
|
|
+ ARouter.getInstance().build(RouterUrlCommon.payment)
|
|
|
+ .withString("id", id)
|
|
|
+ .withSerializable("purchaseConsultationBean", purchaseConsultationBean)
|
|
|
+ .withTransition(R.anim.leftin, R.anim.leftout)
|
|
|
+ .navigation(mContext)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 非空判断
|
|
|
+ */
|
|
|
+ private fun judge(): Boolean {
|
|
|
+ if (binding.editCondition.text.toString().isEmpty()) {
|
|
|
+ "请输入病情描述".toast()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (purchaseConsultationBean.sickTime.isNullOrEmpty()) {
|
|
|
+ "请选择患病多久了".toast()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (purchaseConsultationBean.isConsultation.isNullOrEmpty()) {
|
|
|
+ "请选择此次病情是否去医院就诊过".toast()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (getImgRemotePathPaths().isEmpty()) {
|
|
|
+ "请上传病历资料".toast()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (binding.agreementBox.isChecked.not()) {
|
|
|
+ "请您阅读相关协议及隐私政策".toast()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 问诊图片地址
|
|
|
+ */
|
|
|
+ private fun getImgRemotePathPaths(): ArrayList<String> {
|
|
|
+ val localList = arrayListOf<String>()
|
|
|
+ imageList.forEach {
|
|
|
+ if (it.remotePath.isEmpty().not()) localList.add(it.remotePath)
|
|
|
+ }
|
|
|
+ return localList
|
|
|
+ }
|
|
|
}
|