Commit 7ca66d04 authored by yinjiacheng's avatar yinjiacheng

update C端客户端信息服务获取登录状态支持是否打开登录页面

parent 16f66007
......@@ -4,10 +4,21 @@ import com.google.gson.Gson
import com.google.gson.JsonParseException
import com.yidian.bcommon.app.YdBaseApplication
import com.yidian.bcommon.constant.ResultCode
import com.yidian.bcommon.constant.XEventConfig
import com.yidian.bcommon.constant.XRouterPathConstants
import com.yidian.bcommon.sdk.BCommonManager
import com.yidian.bcommon.sdk.ClientType
import com.yidian.bcommon.sdk.JudgeClientUtils
import com.yidian.bcommon.services.ZapServiceActionConstants
import com.yidian.bcommon.services.ZapServiceNameConstants
import com.yidian.utils.ToastUtil
import com.yidian.xarc.xevent.XBaseEvent
import com.yidian.xarc.xevent.XEventManager
import com.yidian.xpage.XPageManager
import com.yidian.yac.core.zap.ZapTicket
import io.reactivex.rxjava3.core.Observer
import io.reactivex.rxjava3.disposables.Disposable
import org.json.JSONObject
import timber.log.Timber
/**
......@@ -55,6 +66,22 @@ abstract class HttpResultObserver<T> : Observer<HttpResult<T>> {
Timber.tag(BCommonManager.TAG_HTTP).d("response result: ${gson.toJson(result.result)}")
onRequestSuccess(result)
}
ResultCode.INVALID -> {
// 登录失效 B端跳转登录页 C端登录成功后跳转管理中心
if (JudgeClientUtils.judgeClient(YdBaseApplication.context.packageName) == ClientType.MERCHANT_B) {
XPageManager.push(XRouterPathConstants.LOGIN_LIFE_CIRCLE, null)
} else {
ZapTicket(ZapServiceNameConstants.ClientInfoService).withAction(ZapServiceActionConstants.ActionGetLoginStatus)
.withServiceParams(JSONObject().put("needLogin", true)).onResult {
val loginStatus = (it.result as JSONObject).optBoolean("loginStatus")
if (loginStatus) {
XPageManager.popTo(XRouterPathConstants.MERCHANT_CENTER, null)
// 通知登录成功
XEventManager.post(XBaseEvent(XEventConfig.CLIENT_C_LOGIN_SUCCESS, null))
}
}.ship()
}
}
else -> {
onFailure(result)
ToastUtil.showToast(YdBaseApplication.context, result.reason ?: "网络请求失败")
......
......@@ -68,14 +68,15 @@ abstract class HttpResultSubscriber<T>(private var showProgress: Boolean = false
if (JudgeClientUtils.judgeClient(YdBaseApplication.context.packageName) == ClientType.MERCHANT_B) {
XPageManager.push(XRouterPathConstants.LOGIN_LIFE_CIRCLE, null)
} else {
ZapTicket(ZapServiceNameConstants.ClientInfoService).withAction(ZapServiceActionConstants.ActionGetLoginStatus).onResult {
val result = (it.result as JSONObject).optBoolean("loginStatus")
if (result) {
XPageManager.popTo(XRouterPathConstants.MERCHANT_CENTER, null)
// 通知登录成功
XEventManager.post(XBaseEvent(XEventConfig.CLIENT_C_LOGIN_SUCCESS, null))
}
}.ship()
ZapTicket(ZapServiceNameConstants.ClientInfoService).withAction(ZapServiceActionConstants.ActionGetLoginStatus)
.withServiceParams(JSONObject().put("needLogin", true)).onResult {
val loginStatus = (it.result as JSONObject).optBoolean("loginStatus")
if (loginStatus) {
XPageManager.popTo(XRouterPathConstants.MERCHANT_CENTER, null)
// 通知登录成功
XEventManager.post(XBaseEvent(XEventConfig.CLIENT_C_LOGIN_SUCCESS, null))
}
}.ship()
}
}
else -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment