[1.0.7]1.医生卡片点击接口对接
This commit is contained in:
@@ -23,6 +23,7 @@ import com.tencent.qcloud.tuicore.TUICore
|
||||
import com.tencent.qcloud.tuikit.tuichat.TUIChatService
|
||||
import com.tencent.qcloud.tuikit.tuichat.classicui.event.IMChatEvent
|
||||
import com.xjjk.healthyclients.base.BaseVMBActivity
|
||||
import com.xjjk.healthyclients.bean.CardInfoBean
|
||||
import com.xjjk.healthyclients.bottomtab.HomeBottomTabLayout
|
||||
import com.xjjk.healthyclients.databinding.ActivityMainBinding
|
||||
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() {
|
||||
@@ -364,7 +385,14 @@ class MainActivity : BaseVMBActivity<MainViewModel, ActivityMainBinding>(R.layou
|
||||
if (event.getType()==0) {
|
||||
mIMChatEvent=event
|
||||
mViewModel.initIMDialog()
|
||||
mViewModel.selectDoctorCardExpireTime(event.time)
|
||||
mViewModel.postCardInfo(
|
||||
CardInfoBean(
|
||||
event.fromAccount,
|
||||
event.groupId,
|
||||
event.msgId,
|
||||
DataStoreManager.getUserId()
|
||||
)
|
||||
)
|
||||
}else if (event.getType()==1){
|
||||
if (event.message.isNotEmpty()) {
|
||||
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.view.CustomToast
|
||||
import com.sw.healthyclients.view.LoadingDialog
|
||||
import com.xjjk.healthyclients.R
|
||||
import com.xjjk.healthyclients.BR
|
||||
import com.xjjk.healthyclients.R
|
||||
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_SHOW
|
||||
@@ -50,14 +50,14 @@ import java.sql.SQLException
|
||||
*/
|
||||
abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private val contentViewResId: Int) :
|
||||
Fragment(), View.OnClickListener {
|
||||
var mRootView: RelativeLayout?=null
|
||||
var mRootView: RelativeLayout? = null
|
||||
|
||||
/** 是否第一次加载 */
|
||||
private var mIsFirstLoading = true
|
||||
var dialog: LoadingDialog? = null
|
||||
protected lateinit var mViewModel: VM
|
||||
lateinit var mBinding: B
|
||||
var mEmpty: View?=null
|
||||
var mIsVisible: Boolean=false
|
||||
var mEmpty: View? = null
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
@@ -129,30 +129,33 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
|
||||
}
|
||||
}
|
||||
|
||||
open fun onDrawFinish(){
|
||||
mRootView=mBinding.root.findViewById<RelativeLayout>(R.id.rl_empty_root_view)
|
||||
mRootView?.let{
|
||||
mEmpty=LayoutInflater.from(context)
|
||||
open fun onDrawFinish() {
|
||||
mRootView = mBinding.root.findViewById<RelativeLayout>(R.id.rl_empty_root_view)
|
||||
mRootView?.let {
|
||||
mEmpty = LayoutInflater.from(context)
|
||||
.inflate(R.layout.layout_empty, it, false).apply {
|
||||
findViewById<TextView>(R.id.tv_empty).text = "暂无数据"
|
||||
}
|
||||
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)
|
||||
mEmpty?.layoutParams = layoutParams
|
||||
}
|
||||
}
|
||||
|
||||
fun showEmpty(emptyMessage:String="暂无数据",color: Int=0){
|
||||
fun showEmpty(emptyMessage: String = "暂无数据", color: Int = 0) {
|
||||
try {
|
||||
if(color!=0){
|
||||
if (color != 0) {
|
||||
mEmpty?.setBackgroundColor(color)
|
||||
}
|
||||
mEmpty?.findViewById<TextView>(R.id.tv_empty)?.setText(emptyMessage)
|
||||
|
||||
if (mEmpty?.parent==null) {
|
||||
if (mEmpty?.parent == null) {
|
||||
mRootView?.addView(mEmpty)
|
||||
}else{
|
||||
} else {
|
||||
mRootView?.removeView(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 {
|
||||
mRootView?.removeView(mEmpty)
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是透明状态栏
|
||||
*/
|
||||
open fun transparentStatusBar(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mIsVisible=isVisible()
|
||||
if (lifecycle.currentState == Lifecycle.State.STARTED && mIsFirstLoading) {
|
||||
lazyLoadData()
|
||||
mIsFirstLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHiddenChanged(hidden: Boolean) {
|
||||
super.onHiddenChanged(hidden)
|
||||
mIsVisible=!hidden
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mIsVisible=false
|
||||
}
|
||||
|
||||
fun addClickViews(vararg views: View) {
|
||||
for (view in views) {
|
||||
view.setOnClickListener(this)
|
||||
@@ -234,7 +228,7 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
|
||||
if (it.code() == 401) {
|
||||
startLoginActivity(requireContext())
|
||||
requireActivity().finish()
|
||||
}else if (it.code() == 404) {
|
||||
} else if (it.code() == 404) {
|
||||
CustomToast.makeText(
|
||||
requireContext(),
|
||||
"服务器走丢了,请稍后重试",
|
||||
@@ -253,14 +247,17 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
|
||||
requireContext(),
|
||||
getString(R.string.network_error), Toast.LENGTH_SHORT
|
||||
).show()
|
||||
|
||||
is IOException, is SQLException ->
|
||||
CustomToast.makeText(
|
||||
requireContext(),
|
||||
getString(R.string.response_error), Toast.LENGTH_SHORT
|
||||
).show()
|
||||
is WindowManager.BadTokenException ->{
|
||||
|
||||
is WindowManager.BadTokenException -> {
|
||||
|
||||
}
|
||||
|
||||
else ->
|
||||
CustomToast.makeText(
|
||||
requireContext(),
|
||||
@@ -283,23 +280,19 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
|
||||
|
||||
else -> {
|
||||
it?.message?.run {
|
||||
if (mIsVisible) {
|
||||
CustomToast.makeText(
|
||||
requireContext(),
|
||||
this ?: getString(R.string.response_error),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
CustomToast.makeText(
|
||||
requireContext(),
|
||||
this ?: getString(R.string.response_error),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
|
||||
}
|
||||
it?.msg?.run {
|
||||
if (mIsVisible) {
|
||||
CustomToast.makeText(
|
||||
requireContext(),
|
||||
this ?: getString(R.string.response_error),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
CustomToast.makeText(
|
||||
requireContext(),
|
||||
this ?: getString(R.string.response_error),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -337,11 +330,9 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
|
||||
protected abstract fun bindEvent()
|
||||
fun showToast(message: String?) {
|
||||
if (message != null && message.isNotEmpty()) {
|
||||
if (this.mIsVisible) {
|
||||
try {
|
||||
CustomToast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
try {
|
||||
CustomToast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -362,7 +353,7 @@ abstract class BaseVMBFragment<VM : BaseViewModel, B : ViewDataBinding>(private
|
||||
/**
|
||||
* 历史遗留方法,懒得改以前的了,新页面无视即可
|
||||
*/
|
||||
open fun getStatusbarStyle(): Int{
|
||||
open fun getStatusbarStyle(): Int {
|
||||
return 0
|
||||
} // 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")
|
||||
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.xjjk.healthyclients.BuildConfig
|
||||
import com.xjjk.healthyclients.bean.AppUpdateBean
|
||||
import com.xjjk.healthyclients.bean.CardInfoBean
|
||||
import com.xjjk.healthyclients.bean.CommonSettingMenuBean
|
||||
import com.xjjk.healthyclients.bean.SelectUserInfoBean
|
||||
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.data.api.CommonApi
|
||||
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.event.UserNoticeBean
|
||||
import com.xjjk.healthyclients.retrofit.RetrofitManager
|
||||
import com.xjjk.healthyclients.retrofit.RetrofitManager.toRequestBody
|
||||
import com.xjjk.healthyclients.superfuntion.toJson
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.MultipartBody
|
||||
@@ -192,6 +193,14 @@ object CommonRepository {
|
||||
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.view.LoadingDialog
|
||||
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.data.repository.CommonRepository
|
||||
import com.xjjk.healthyclients.event.UserNoticeBean
|
||||
@@ -26,14 +28,17 @@ class MainViewModel : BaseViewModel() {
|
||||
var tokenOverdue = MutableSharedFlow<Boolean>()
|
||||
var timePrescription = MutableSharedFlow<String>()
|
||||
var selectTfHelper = MutableSharedFlow<Boolean>()
|
||||
var cardInfoString = MutableSharedFlow<CardMessageReadLog>()
|
||||
var submitNoticeChooseResult = MutableSharedFlow<Boolean>()
|
||||
var imDialog: LoadingDialog? = null
|
||||
|
||||
|
||||
override fun init() {
|
||||
// getNoticeData()
|
||||
checkTokenIsEffective()
|
||||
}
|
||||
|
||||
fun initIMDialog(){
|
||||
fun initIMDialog() {
|
||||
imDialog = LoadingDialog(
|
||||
CustomActivityManager.getInstance().TopActivity(),
|
||||
ProgressDialog.STYLE_SPINNER, "数据加载中"
|
||||
@@ -113,36 +118,44 @@ class MainViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
fun getAgreement(){
|
||||
fun getAgreement() {
|
||||
launch({
|
||||
handleRequest(CommonRepository.getCommonSettingMenuList("qh_jump_url"), successBlock = {
|
||||
it.result?.let { list ->
|
||||
if (list != null) {
|
||||
list?.let {
|
||||
for (index in 0 until it.size){
|
||||
when(it[index].value){
|
||||
for (index in 0 until it.size) {
|
||||
when (it[index].value) {
|
||||
"1" -> {
|
||||
//用户协议
|
||||
if (it[index].text.isNotEmpty()) {
|
||||
DataStoreManager.saveUserAgreementUrl(
|
||||
UrlConfig.getH5BaseUrl(
|
||||
UrlConfig.baseUrlType)+ it[index].text)
|
||||
UrlConfig.baseUrlType
|
||||
) + it[index].text
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
"2" -> {
|
||||
//隐私政策
|
||||
if (it[index].text.isNotEmpty()) {
|
||||
DataStoreManager.savePrivacyAgreementUrl(
|
||||
UrlConfig.getH5BaseUrl(
|
||||
UrlConfig.baseUrlType)+ it[index].text)
|
||||
UrlConfig.baseUrlType
|
||||
) + it[index].text
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
"3" -> {
|
||||
//相关法律说明
|
||||
if (it[index].text.isNotEmpty()) {
|
||||
DataStoreManager.saveLawUrl(
|
||||
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) {
|
||||
launch(showDialog=true,
|
||||
launch(showDialog = true,
|
||||
{
|
||||
handleRequest(
|
||||
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
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user