feat(home): 健康资讯模块增加登录校验及未登录态UI处理

所有健康资讯H5跳转入口(文章详情、健康知识、健康咨询、搜索)增加
登录状态校验,未登录时提示"请先登录"并引导至登录页;健康知识模块
未登录时隐藏Tab栏显示"暂未登录"空态。版本号升至 1.0.14。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
zhanglei
2026-06-30 18:22:04 +08:00
co-authored by Claude Opus 4.7
parent 7a830c3272
commit 4b5da9269d
2 changed files with 89 additions and 33 deletions
@@ -59,7 +59,7 @@ class HomeFragment :
private var mApi = getBankRetrofit().create(HomeApi::class.java)
var watchBindDialog: WatchBindDialog ?=null
var watchBindDialog: WatchBindDialog? = null
var stringList: MutableList<String> = mutableListOf()
var mDoctorList = arrayListOf<GuidanceListBean>()
@@ -71,8 +71,10 @@ class HomeFragment :
/** 健康资讯请求 */
private var mHealthInfoRequest: HealthInfoRequest? = null
/** 健康资讯 Token */
private var mHealthToken: String? = null
/** 健康知识子栏目列表 */
private var mKnowledgeCategories: MutableList<CategoryBean> = mutableListOf()
@@ -168,9 +170,9 @@ class HomeFragment :
}
mBinding.watchView.mBinding.imgWatchMore.setOnClickListener {
if (DataStoreManager.isLogin()) {
if (watchInfo?.hasWatch==true){
if (watchInfo?.hasWatch == true) {
EventBus.getDefault().post(HomeTabChangeEvent().apply { index = 3 })
}else {
} else {
showWatchBindDialog()
}
} else {
@@ -325,7 +327,7 @@ class HomeFragment :
if (TextUtils.isEmpty(value)) {
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
showToast("网络错误")
}else {
} else {
requireContext().startWebActivity(
UrlConfig.getHealthCheckH5Url() + "?param=" + value,
isFull = true,
@@ -469,6 +471,11 @@ class HomeFragment :
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
getBankPointDetail()
loadHealthInfoData()
} else {
mBinding.healthKnowledgeView.mBinding.tabLayout.visibility = View.GONE
mBinding.healthKnowledgeView.mBinding.tvEmpty.visibility = View.VISIBLE
mBinding.healthKnowledgeView.mBinding.tvEmpty.text = "暂未登录"
}
}
@@ -542,6 +549,10 @@ class HomeFragment :
/** 加载健康资讯数据(Token → 栏目 → 文章) */
private fun loadHealthInfoData() {
mBinding.healthKnowledgeView.mBinding.tabLayout.visibility = View.VISIBLE
mBinding.healthKnowledgeView.mBinding.tvEmpty.visibility = View.GONE
mBinding.healthKnowledgeView.mBinding.tvEmpty.text = "暂无健康知识"
mHealthInfoRequest?.fetchToken(
onSuccess = { token ->
mHealthToken = token
@@ -602,48 +613,93 @@ class HomeFragment :
/** 跳转文章详情 H5 */
private fun navigateToArticleDetail(articleId: Int) {
val param = mViewModel.enCryptInfoUrl.value
if (param.isNullOrEmpty()) {
showToast("网络错误")
return
if (DataStoreManager.isLogin()) {
val param = mViewModel.enCryptInfoUrl.value
if (param.isNullOrEmpty()) {
showToast("网络错误")
return
}
val url = "${UrlConfig.getHealthNewsDetailH5Url()}?param=$param&articleId=$articleId"
requireContext().startWebActivity(
url,
isFull = true,
myTitle = "文章详情",
hideStatus = true
)
} else {
showToast("请先登录")
toActivity(LoginActivity::class.java)
}
val url = "${UrlConfig.getHealthNewsDetailH5Url()}?param=$param&articleId=$articleId"
requireContext().startWebActivity(url, isFull = true, myTitle = "文章详情", hideStatus = true)
}
/** 跳转健康知识更多 H5 */
private fun navigateToHealthKnowledgeMore() {
val param = mViewModel.enCryptInfoUrl.value
if (param.isNullOrEmpty()) {
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
showToast("网络错误")
return
if (DataStoreManager.isLogin()) {
val param = mViewModel.enCryptInfoUrl.value
if (param.isNullOrEmpty()) {
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
showToast("网络错误")
return
}
val url = "${UrlConfig.getHealthKnowledgeH5Url()}?param=$param"
requireContext().startWebActivity(
url,
isFull = true,
myTitle = "健康知识",
hideStatus = true
)
} else {
showToast("请先登录")
toActivity(LoginActivity::class.java)
}
val url = "${UrlConfig.getHealthKnowledgeH5Url()}?param=$param"
requireContext().startWebActivity(url, isFull = true, myTitle = "健康知识", hideStatus = true)
}
/** 跳转健康知识 搜索 */
private fun navigateToHealthKnowledgeSearch(key: String) {
val param = mViewModel.enCryptInfoUrl.value
if (param.isNullOrEmpty()) {
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
showToast("网络错误")
return
if (DataStoreManager.isLogin()) {
val param = mViewModel.enCryptInfoUrl.value
if (param.isNullOrEmpty()) {
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
showToast("网络错误")
return
}
val url = "${UrlConfig.getHealthNewsSearchH5Url()}?param=$param&secrchVal=$key"
requireContext().startWebActivity(
url,
isFull = true,
myTitle = "搜索",
hideStatus = true
)
} else {
showToast("请先登录")
toActivity(LoginActivity::class.java)
}
val url = "${UrlConfig.getHealthNewsSearchH5Url()}?param=$param&secrchVal=$key"
requireContext().startWebActivity(url, isFull = true, myTitle = "搜索", hideStatus = true)
}
/** 跳转健康咨询更多 H5 */
private fun navigateToHealthConsultationMore() {
val param = mViewModel.enCryptInfoUrl.value
if (param.isNullOrEmpty()) {
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
showToast("网络错误")
return
if (DataStoreManager.isLogin()) {
val param = mViewModel.enCryptInfoUrl.value
if (param.isNullOrEmpty()) {
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
showToast("网络错误")
return
}
val url = "${UrlConfig.getHealthConsultationH5Url()}?param=$param"
requireContext().startWebActivity(
url,
isFull = true,
myTitle = "健康咨询",
hideStatus = true
)
} else {
showToast("请先登录")
toActivity(LoginActivity::class.java)
}
val url = "${UrlConfig.getHealthConsultationH5Url()}?param=$param"
requireContext().startWebActivity(url, isFull = true, myTitle = "健康咨询", hideStatus = true)
}
}
+2 -2
View File
@@ -2,8 +2,8 @@ ext {
minSdkVersion = 26
targetSdkVersion = 32
compileSdkVersion = 33
versionCode = 1013
versionName = "1.0.13"
versionCode = 1014
versionName = "1.0.14"
//Dependencies
junitVersion = "4.12"
lifecycleVersion = "2.6.0-alpha01"