feat(home): 新增健康银行H5链接参数服务端加密功能

- 新增 EncryptInfoBean 数据类,承载服务端返回的加密参数
- 新增 getSysEnCryptInfo 接口及完整数据层/视图层调用链
- 修改 getHomeBankH5Url() 仅返回参数字符串,由调用方拼接完整 URL
- 将 HOME_BANK_H5 改为 public,支持 Fragment 层直接引用
- 测试环境下健康银行入口通过加密参数跳转 WebActivity
- 登录后预加载加密信息,提升首次点击响应速度

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
zhanglei
2026-03-09 16:42:19 +08:00
co-authored by Claude Sonnet 4.6
parent e2d53f851d
commit dc55c65b87
6 changed files with 66 additions and 9 deletions
@@ -49,3 +49,6 @@ data class HomeBannerBean(
val updateTime: String
)
data class EncryptInfoBean(
val encryptData: String?
)
@@ -4,6 +4,7 @@ import com.xjjk.healthyclients.bean.home.HomeBannerBean
import com.xjjk.healthyclients.bean.home.HomeNoticeBean
import com.xjjk.healthyclients.bean.home.HomeWatchAllDataBean
import com.xjjk.healthyclients.bean.home.WatchInfoBean
import com.xjjk.healthyclients.bean.home.EncryptInfoBean
import com.xjjk.healthyclients.bean.user.CheckInBean
import com.xjjk.healthyclients.bean.user.PointDetailBean
import com.xjjk.healthyclients.bean.user.PointRank
@@ -85,5 +86,11 @@ interface HomeApi {
@GET("/health-watch/api/watchData/findWatchInfo")
suspend fun getHomeWatchInfo(@QueryMap params: MutableMap<String, Any?>): ApiResponse<WatchInfoBean>
/**
* weburl参数加密
*/
@GET("/health-system/api/sys/encryptInfo")
suspend fun getSysEnCryptInfo(@QueryMap params: MutableMap<String, Any?>): ApiResponse<EncryptInfoBean>
}
@@ -1,6 +1,7 @@
package com.xjjk.healthyclients.data.repository
import com.xjjk.healthyclients.base.repository.BaseRepository
import com.xjjk.healthyclients.bean.home.EncryptInfoBean
import com.xjjk.healthyclients.bean.home.HomeBannerBean
import com.xjjk.healthyclients.bean.home.HomeNoticeBean
import com.xjjk.healthyclients.bean.home.HomeWatchAllDataBean
@@ -100,4 +101,12 @@ object HomeRepository : BaseRepository() {
service.getHomeWatchInfo(map)
}
}
suspend fun getSysEnCryptInfo(str: String?): ApiResponse<EncryptInfoBean> {
return apiCall {
val map = mutableMapOf<String, Any?>()
map["str"] = str
service.getSysEnCryptInfo(map)
}
}
}
@@ -1,6 +1,7 @@
package com.xjjk.healthyclients.fragment
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
@@ -17,12 +18,14 @@ import com.xjjk.healthyclients.base.BaseVMBFragment
import com.xjjk.healthyclients.bean.guidance.GuidanceListBean
import com.xjjk.healthyclients.databinding.FragmentHomeBinding
import com.xjjk.healthyclients.event.HomeTabChangeEvent
import com.xjjk.healthyclients.retrofit.UrlConfig
import com.xjjk.healthyclients.superfuntion.initColors
import com.xjjk.healthyclients.superfuntion.showBanner
import com.xjjk.healthyclients.superfuntion.startAppointmentWaitAffirmActivity
import com.xjjk.healthyclients.superfuntion.startGroupChat
import com.xjjk.healthyclients.superfuntion.startLoginActivity
import com.xjjk.healthyclients.superfuntion.startMyGuidanceActivity
import com.xjjk.healthyclients.superfuntion.startWebActivity
import com.xjjk.healthyclients.ui.activity.EmptyActivity
import com.xjjk.healthyclients.ui.activity.LoginActivity
import com.xjjk.healthyclients.ui.activity.guidance.adapter.GuidanceFragmentDoctorAdapter
@@ -169,16 +172,26 @@ class HomeFragment :
}
R.id.home_head_tab4 -> {
if (UrlConfig.baseUrlType == UrlConfig.BaseUrlType.TEST) {
if (DataStoreManager.isLogin()) {
val value = mViewModel.enCryptInfoUrl.value
if (TextUtils.isEmpty(value)) {
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
showToast("网络错误")
return
}
requireContext().startWebActivity(UrlConfig.HOME_BANK_H5+"?param="+ value, myTitle = "健康银行")
} else {
startLoginActivity(requireContext())
}
return
}
val bundle = Bundle()
bundle.putString("title", "健康银行")
toActivity(EmptyActivity::class.java, bundle)
//
// if (DataStoreManager.isLogin()) {
// requireContext().startWebActivity(UrlConfig.getHomeBankH5Url(), myTitle = "健康银行")
// } else {
// startLoginActivity(requireContext())
// }
}
R.id.home_head_tab3 -> {
@@ -327,6 +340,16 @@ class HomeFragment :
}
}
}
// lifecycleScope.launch{
// repeatOnLifecycle(Lifecycle.State.CREATED){
// mViewModel.enCryptInfoUrl.collectLatest { url ->
// requireContext().startWebActivity(
// UrlConfig.HOME_BANK_H5+"?param="+url,
// myTitle = "健康银行"
// )
// }
// }
// }
}
@@ -338,6 +361,7 @@ class HomeFragment :
if (DataStoreManager.isLogin()) {
homeNoticeStartRepeat()
mViewModel.getHomeWatchInfo(DataStoreManager.getUserId())
mViewModel.getSysEnCryptInfo(UrlConfig.getHomeBankH5Url())
}
}
@@ -28,7 +28,7 @@ object UrlConfig {
// 安眼修改密码
const val ANYAN_CHANGE_PASSWORD_H5 = "https://sso.iosp.ydpt.tech/SSOManageClient/userController/changePassword"
private const val HOME_BANK_H5 = "https://gstest.superwx.cn/healthbank/index.html"
const val HOME_BANK_H5 = "https://gstest.superwx.cn/healthbank/index.html"
val baseUrlType: BaseUrlType = BaseUrlType.PRODUCT
@@ -100,12 +100,12 @@ object UrlConfig {
}
/**
* 手机银行外链h5
* 手机银行外链h5 参数
*/
fun getHomeBankH5Url(): String{
var httpUrl = getDefaultBaseUrl().toHttpUrl()
return HOME_BANK_H5+"?scheme=" + httpUrl.scheme +
return "scheme=" + httpUrl.scheme +
"&host=" + httpUrl.host +
"&tokenF=" + DataStoreManager.getToken()
@@ -23,6 +23,8 @@ class HomeViewModel : BaseViewModel() {
var homeBannerList = MutableSharedFlow<MutableList<HomeBannerBean>?>()
var sessionPicUrl = MutableSharedFlow<String?>()
var enCryptInfoUrl = MutableStateFlow<String?>(null)
//手表
var watchInfo = MutableSharedFlow<WatchInfoBean?>()
var watchAllData = MutableSharedFlow<MutableList<HomeWatchAllDataBean>?>()
@@ -164,5 +166,17 @@ class HomeViewModel : BaseViewModel() {
)
}
fun getSysEnCryptInfo(str: String?) {
launch(showDialog = false,
{
handleRequest(
HomeRepository.getSysEnCryptInfo(str),
successBlock = {
enCryptInfoUrl.emit(it.result?.encryptData)
})
}
)
}
}