[1.0.7]1.医生卡片点击接口对接

This commit is contained in:
zhanglei
2025-12-11 15:51:06 +08:00
parent ca2bff5149
commit ca0e318bd0
7 changed files with 141 additions and 61 deletions
@@ -23,6 +23,7 @@ import com.tencent.qcloud.tuicore.TUICore
import com.tencent.qcloud.tuikit.tuichat.TUIChatService import com.tencent.qcloud.tuikit.tuichat.TUIChatService
import com.tencent.qcloud.tuikit.tuichat.classicui.event.IMChatEvent import com.tencent.qcloud.tuikit.tuichat.classicui.event.IMChatEvent
import com.xjjk.healthyclients.base.BaseVMBActivity import com.xjjk.healthyclients.base.BaseVMBActivity
import com.xjjk.healthyclients.bean.CardInfoBean
import com.xjjk.healthyclients.bottomtab.HomeBottomTabLayout import com.xjjk.healthyclients.bottomtab.HomeBottomTabLayout
import com.xjjk.healthyclients.databinding.ActivityMainBinding import com.xjjk.healthyclients.databinding.ActivityMainBinding
import com.xjjk.healthyclients.event.RefreshEvent import com.xjjk.healthyclients.event.RefreshEvent
@@ -241,6 +242,26 @@ class MainActivity : BaseVMBActivity<MainViewModel, ActivityMainBinding>(R.layou
} }
} }
//全科医生校验
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.CREATED) {
mViewModel.cardInfoString.collectLatest {
if (it.type == 0) {//卡片未过期
val bundle = Bundle()
bundle.putString("doctorId", mIMChatEvent?.getDoctor())
TUICore.startActivity(
TUIChatService.getAppContext(),
"DoctorHomepageActivity",
bundle
)
} else {
CustomToast.makeText(CustomActivityManager.getInstance().currentActivity(),it.msg,Toast.LENGTH_SHORT).show()
}
}
}
}
} }
override fun onPause() { override fun onPause() {
@@ -364,7 +385,14 @@ class MainActivity : BaseVMBActivity<MainViewModel, ActivityMainBinding>(R.layou
if (event.getType()==0) { if (event.getType()==0) {
mIMChatEvent=event mIMChatEvent=event
mViewModel.initIMDialog() mViewModel.initIMDialog()
mViewModel.selectDoctorCardExpireTime(event.time) mViewModel.postCardInfo(
CardInfoBean(
event.fromAccount,
event.groupId,
event.msgId,
DataStoreManager.getUserId()
)
)
}else if (event.getType()==1){ }else if (event.getType()==1){
if (event.message.isNotEmpty()) { if (event.message.isNotEmpty()) {
CustomToast.makeText(CustomActivityManager.getInstance().TopActivity(), event.message, Toast.LENGTH_SHORT).show() CustomToast.makeText(CustomActivityManager.getInstance().TopActivity(), event.message, Toast.LENGTH_SHORT).show()
@@ -22,8 +22,8 @@ import com.orhanobut.logger.Logger
import com.sw.healthyclients.utils.StatusbarUtil import com.sw.healthyclients.utils.StatusbarUtil
import com.sw.healthyclients.view.CustomToast import com.sw.healthyclients.view.CustomToast
import com.sw.healthyclients.view.LoadingDialog import com.sw.healthyclients.view.LoadingDialog
import com.xjjk.healthyclients.R
import com.xjjk.healthyclients.BR import com.xjjk.healthyclients.BR
import com.xjjk.healthyclients.R
import com.xjjk.healthyclients.base.viewmodel.BaseViewModel import com.xjjk.healthyclients.base.viewmodel.BaseViewModel
import com.xjjk.healthyclients.base.viewmodel.BaseViewModel.Companion.LOADING_STATE_HIDE import com.xjjk.healthyclients.base.viewmodel.BaseViewModel.Companion.LOADING_STATE_HIDE
import com.xjjk.healthyclients.base.viewmodel.BaseViewModel.Companion.LOADING_STATE_SHOW import com.xjjk.healthyclients.base.viewmodel.BaseViewModel.Companion.LOADING_STATE_SHOW
@@ -50,14 +50,14 @@ import java.sql.SQLException
*/ */
abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private val contentViewResId: Int) : abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private val contentViewResId: Int) :
Fragment(), View.OnClickListener { Fragment(), View.OnClickListener {
var mRootView: RelativeLayout?=null var mRootView: RelativeLayout? = null
/** 是否第一次加载 */ /** 是否第一次加载 */
private var mIsFirstLoading = true private var mIsFirstLoading = true
var dialog: LoadingDialog? = null var dialog: LoadingDialog? = null
protected lateinit var mViewModel: VM protected lateinit var mViewModel: VM
lateinit var mBinding: B lateinit var mBinding: B
var mEmpty: View?=null var mEmpty: View? = null
var mIsVisible: Boolean=false
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
@@ -129,30 +129,33 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
} }
} }
open fun onDrawFinish(){ open fun onDrawFinish() {
mRootView=mBinding.root.findViewById<RelativeLayout>(R.id.rl_empty_root_view) mRootView = mBinding.root.findViewById<RelativeLayout>(R.id.rl_empty_root_view)
mRootView?.let{ mRootView?.let {
mEmpty=LayoutInflater.from(context) mEmpty = LayoutInflater.from(context)
.inflate(R.layout.layout_empty, it, false).apply { .inflate(R.layout.layout_empty, it, false).apply {
findViewById<TextView>(R.id.tv_empty).text = "暂无数据" findViewById<TextView>(R.id.tv_empty).text = "暂无数据"
} }
var layoutParams = var layoutParams =
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT) RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT
)
layoutParams.addRule(RelativeLayout.BELOW, R.id.toolbar_lay) layoutParams.addRule(RelativeLayout.BELOW, R.id.toolbar_lay)
mEmpty?.layoutParams = layoutParams mEmpty?.layoutParams = layoutParams
} }
} }
fun showEmpty(emptyMessage:String="暂无数据",color: Int=0){ fun showEmpty(emptyMessage: String = "暂无数据", color: Int = 0) {
try { try {
if(color!=0){ if (color != 0) {
mEmpty?.setBackgroundColor(color) mEmpty?.setBackgroundColor(color)
} }
mEmpty?.findViewById<TextView>(R.id.tv_empty)?.setText(emptyMessage) mEmpty?.findViewById<TextView>(R.id.tv_empty)?.setText(emptyMessage)
if (mEmpty?.parent==null) { if (mEmpty?.parent == null) {
mRootView?.addView(mEmpty) mRootView?.addView(mEmpty)
}else{ } else {
mRootView?.removeView(mEmpty) mRootView?.removeView(mEmpty)
mRootView?.addView(mEmpty) mRootView?.addView(mEmpty)
} }
@@ -161,37 +164,28 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
} }
} }
fun hindEmpty(emptyMessage:String="暂无数据"){ fun hindEmpty(emptyMessage: String = "暂无数据") {
try { try {
mRootView?.removeView(mEmpty) mRootView?.removeView(mEmpty)
} catch (e: Exception) { } catch (e: Exception) {
} }
} }
/** /**
* 是否是透明状态栏 * 是否是透明状态栏
*/ */
open fun transparentStatusBar(): Boolean { open fun transparentStatusBar(): Boolean {
return false return false
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
mIsVisible=isVisible()
if (lifecycle.currentState == Lifecycle.State.STARTED && mIsFirstLoading) { if (lifecycle.currentState == Lifecycle.State.STARTED && mIsFirstLoading) {
lazyLoadData() lazyLoadData()
mIsFirstLoading = false mIsFirstLoading = false
} }
} }
override fun onHiddenChanged(hidden: Boolean) {
super.onHiddenChanged(hidden)
mIsVisible=!hidden
}
override fun onStop() {
super.onStop()
mIsVisible=false
}
fun addClickViews(vararg views: View) { fun addClickViews(vararg views: View) {
for (view in views) { for (view in views) {
view.setOnClickListener(this) view.setOnClickListener(this)
@@ -234,7 +228,7 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
if (it.code() == 401) { if (it.code() == 401) {
startLoginActivity(requireContext()) startLoginActivity(requireContext())
requireActivity().finish() requireActivity().finish()
}else if (it.code() == 404) { } else if (it.code() == 404) {
CustomToast.makeText( CustomToast.makeText(
requireContext(), requireContext(),
"服务器走丢了,请稍后重试", "服务器走丢了,请稍后重试",
@@ -253,14 +247,17 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
requireContext(), requireContext(),
getString(R.string.network_error), Toast.LENGTH_SHORT getString(R.string.network_error), Toast.LENGTH_SHORT
).show() ).show()
is IOException, is SQLException -> is IOException, is SQLException ->
CustomToast.makeText( CustomToast.makeText(
requireContext(), requireContext(),
getString(R.string.response_error), Toast.LENGTH_SHORT getString(R.string.response_error), Toast.LENGTH_SHORT
).show() ).show()
is WindowManager.BadTokenException ->{
is WindowManager.BadTokenException -> {
} }
else -> else ->
CustomToast.makeText( CustomToast.makeText(
requireContext(), requireContext(),
@@ -283,17 +280,14 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
else -> { else -> {
it?.message?.run { it?.message?.run {
if (mIsVisible) {
CustomToast.makeText( CustomToast.makeText(
requireContext(), requireContext(),
this ?: getString(R.string.response_error), this ?: getString(R.string.response_error),
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()
}
} }
it?.msg?.run { it?.msg?.run {
if (mIsVisible) {
CustomToast.makeText( CustomToast.makeText(
requireContext(), requireContext(),
this ?: getString(R.string.response_error), this ?: getString(R.string.response_error),
@@ -305,7 +299,6 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
} }
} }
} }
}
/** 提供一个请求错误的方法,用于像关闭加载框之类的 */ /** 提供一个请求错误的方法,用于像关闭加载框之类的 */
open fun requestError(msg: String? = null) { open fun requestError(msg: String? = null) {
@@ -337,14 +330,12 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
protected abstract fun bindEvent() protected abstract fun bindEvent()
fun showToast(message: String?) { fun showToast(message: String?) {
if (message != null && message.isNotEmpty()) { if (message != null && message.isNotEmpty()) {
if (this.mIsVisible) {
try { try {
CustomToast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show() CustomToast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
} catch (e: Exception) { } catch (e: Exception) {
} }
} }
} }
}
fun toActivity(clazz: Class<*>?) { fun toActivity(clazz: Class<*>?) {
val intent = Intent(activity, clazz) val intent = Intent(activity, clazz)
@@ -362,7 +353,7 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
/** /**
* 历史遗留方法,懒得改以前的了,新页面无视即可 * 历史遗留方法,懒得改以前的了,新页面无视即可
*/ */
open fun getStatusbarStyle(): Int{ open fun getStatusbarStyle(): Int {
return 0 return 0
} // 0 主题色+白字 1白底黑字 } // 0 主题色+白字 1白底黑字
@@ -0,0 +1,14 @@
package com.xjjk.healthyclients.bean
data class CardInfoBean(
val fromAccount: String,
val groupId: String,
val msgId: String,
val toAccount: String?
)
data class CardMessageReadLog(
val type: Int,
val msg: String?
)
@@ -131,5 +131,11 @@ interface CommonApi {
@GET("health-consultation/api/consult/conHelper/selectHelperInfoDesc") @GET("health-consultation/api/consult/conHelper/selectHelperInfoDesc")
suspend fun selectHelperInfoDesc(@QueryMap params: MutableMap<String, Any?>): ApiResponse<IMDoctorInfoBean> suspend fun selectHelperInfoDesc(@QueryMap params: MutableMap<String, Any?>): ApiResponse<IMDoctorInfoBean>
/**
* 医生卡片校验
*/
@POST("health-consultation/con-message/saveReadLog")
suspend fun postCardInfo(@Body info: RequestBody): ApiResponse<String>
} }
@@ -2,6 +2,7 @@ package com.xjjk.healthyclients.data.repository
import com.sw.healthyclients.utils.FileUtils import com.sw.healthyclients.utils.FileUtils
import com.xjjk.healthyclients.BuildConfig import com.xjjk.healthyclients.BuildConfig
import com.xjjk.healthyclients.bean.AppUpdateBean import com.xjjk.healthyclients.bean.AppUpdateBean
import com.xjjk.healthyclients.bean.CardInfoBean
import com.xjjk.healthyclients.bean.CommonSettingMenuBean import com.xjjk.healthyclients.bean.CommonSettingMenuBean
import com.xjjk.healthyclients.bean.SelectUserInfoBean import com.xjjk.healthyclients.bean.SelectUserInfoBean
import com.xjjk.healthyclients.bean.SelectUserMessageListBean import com.xjjk.healthyclients.bean.SelectUserMessageListBean
@@ -10,10 +11,10 @@ import com.xjjk.healthyclients.bean.user.IMDoctorInfoBean
import com.xjjk.healthyclients.bean.user.SelectEmergencyContactListBean import com.xjjk.healthyclients.bean.user.SelectEmergencyContactListBean
import com.xjjk.healthyclients.data.api.CommonApi import com.xjjk.healthyclients.data.api.CommonApi
import com.xjjk.healthyclients.data.bean.ApiResponse import com.xjjk.healthyclients.data.bean.ApiResponse
import com.xjjk.healthyclients.retrofit.RetrofitManager
import com.xjjk.healthyclients.retrofit.RetrofitManager.toRequestBody
import com.xjjk.healthyclients.data.repository.EmergencyRepository.apiCall import com.xjjk.healthyclients.data.repository.EmergencyRepository.apiCall
import com.xjjk.healthyclients.event.UserNoticeBean import com.xjjk.healthyclients.event.UserNoticeBean
import com.xjjk.healthyclients.retrofit.RetrofitManager
import com.xjjk.healthyclients.retrofit.RetrofitManager.toRequestBody
import com.xjjk.healthyclients.superfuntion.toJson import com.xjjk.healthyclients.superfuntion.toJson
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody import okhttp3.MultipartBody
@@ -192,6 +193,14 @@ object CommonRepository {
service.selectHelperInfoDesc(map) service.selectHelperInfoDesc(map)
} }
} }
/**
* 医生卡片校验
*/
suspend fun postCardInfo(info: CardInfoBean): ApiResponse<String> {
return apiCall {
service.postCardInfo(info.toJson().toRequestBody())
}
}
} }
@@ -6,6 +6,8 @@ import com.sw.healthyclients.data.local.DataStoreManager
import com.sw.healthyclients.utils.CustomActivityManager import com.sw.healthyclients.utils.CustomActivityManager
import com.sw.healthyclients.view.LoadingDialog import com.sw.healthyclients.view.LoadingDialog
import com.xjjk.healthyclients.base.viewmodel.BaseViewModel import com.xjjk.healthyclients.base.viewmodel.BaseViewModel
import com.xjjk.healthyclients.bean.CardInfoBean
import com.xjjk.healthyclients.bean.CardMessageReadLog
import com.xjjk.healthyclients.bean.user.IMDoctorInfoBean import com.xjjk.healthyclients.bean.user.IMDoctorInfoBean
import com.xjjk.healthyclients.data.repository.CommonRepository import com.xjjk.healthyclients.data.repository.CommonRepository
import com.xjjk.healthyclients.event.UserNoticeBean import com.xjjk.healthyclients.event.UserNoticeBean
@@ -26,14 +28,17 @@ class MainViewModel : BaseViewModel() {
var tokenOverdue = MutableSharedFlow<Boolean>() var tokenOverdue = MutableSharedFlow<Boolean>()
var timePrescription = MutableSharedFlow<String>() var timePrescription = MutableSharedFlow<String>()
var selectTfHelper = MutableSharedFlow<Boolean>() var selectTfHelper = MutableSharedFlow<Boolean>()
var cardInfoString = MutableSharedFlow<CardMessageReadLog>()
var submitNoticeChooseResult = MutableSharedFlow<Boolean>() var submitNoticeChooseResult = MutableSharedFlow<Boolean>()
var imDialog: LoadingDialog? = null var imDialog: LoadingDialog? = null
override fun init() { override fun init() {
// getNoticeData() // getNoticeData()
checkTokenIsEffective() checkTokenIsEffective()
} }
fun initIMDialog(){ fun initIMDialog() {
imDialog = LoadingDialog( imDialog = LoadingDialog(
CustomActivityManager.getInstance().TopActivity(), CustomActivityManager.getInstance().TopActivity(),
ProgressDialog.STYLE_SPINNER, "数据加载中" ProgressDialog.STYLE_SPINNER, "数据加载中"
@@ -113,36 +118,44 @@ class MainViewModel : BaseViewModel() {
) )
} }
fun getAgreement(){ fun getAgreement() {
launch({ launch({
handleRequest(CommonRepository.getCommonSettingMenuList("qh_jump_url"), successBlock = { handleRequest(CommonRepository.getCommonSettingMenuList("qh_jump_url"), successBlock = {
it.result?.let { list -> it.result?.let { list ->
if (list != null) { if (list != null) {
list?.let { list?.let {
for (index in 0 until it.size){ for (index in 0 until it.size) {
when(it[index].value){ when (it[index].value) {
"1" -> { "1" -> {
//用户协议 //用户协议
if (it[index].text.isNotEmpty()) { if (it[index].text.isNotEmpty()) {
DataStoreManager.saveUserAgreementUrl( DataStoreManager.saveUserAgreementUrl(
UrlConfig.getH5BaseUrl( UrlConfig.getH5BaseUrl(
UrlConfig.baseUrlType)+ it[index].text) UrlConfig.baseUrlType
) + it[index].text
)
} }
} }
"2" -> { "2" -> {
//隐私政策 //隐私政策
if (it[index].text.isNotEmpty()) { if (it[index].text.isNotEmpty()) {
DataStoreManager.savePrivacyAgreementUrl( DataStoreManager.savePrivacyAgreementUrl(
UrlConfig.getH5BaseUrl( UrlConfig.getH5BaseUrl(
UrlConfig.baseUrlType)+ it[index].text) UrlConfig.baseUrlType
) + it[index].text
)
} }
} }
"3" -> { "3" -> {
//相关法律说明 //相关法律说明
if (it[index].text.isNotEmpty()) { if (it[index].text.isNotEmpty()) {
DataStoreManager.saveLawUrl( DataStoreManager.saveLawUrl(
UrlConfig.getH5BaseUrl( UrlConfig.getH5BaseUrl(
UrlConfig.baseUrlType)+ it[index].text) UrlConfig.baseUrlType
) + it[index].text
)
} }
} }
} }
@@ -151,7 +164,7 @@ class MainViewModel : BaseViewModel() {
} }
} }
}) })
},isAutoShowEmpty=true) }, isAutoShowEmpty = true)
} }
/** /**
@@ -178,7 +191,7 @@ class MainViewModel : BaseViewModel() {
* 获取全科医生信息 * 获取全科医生信息
*/ */
fun selectHelperInfoDesc(id: String) { fun selectHelperInfoDesc(id: String) {
launch(showDialog=true, launch(showDialog = true,
{ {
handleRequest( handleRequest(
CommonRepository.selectHelperInfoDesc(id), CommonRepository.selectHelperInfoDesc(id),
@@ -192,4 +205,23 @@ class MainViewModel : BaseViewModel() {
) )
} }
/**
* 医生卡片校验
*/
fun postCardInfo(info: CardInfoBean) {
launch(
{
handleRequest(
CommonRepository.postCardInfo(info),
successBlock = {
cardInfoString.emit(CardMessageReadLog(0,""))
}, errorBlock = {
cardInfoString.emit(CardMessageReadLog(1,it.message))
true
})
}
)
}
} }
+2 -2
View File
@@ -2,8 +2,8 @@ ext {
minSdkVersion = 26 minSdkVersion = 26
targetSdkVersion = 32 targetSdkVersion = 32
compileSdkVersion = 33 compileSdkVersion = 33
versionCode = 106 versionCode = 107
versionName = "1.0.6" versionName = "1.0.7"
//Dependencies //Dependencies
junitVersion = "4.12" junitVersion = "4.12"
lifecycleVersion = "2.6.0-alpha01" lifecycleVersion = "2.6.0-alpha01"