Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
7ca66d04
Commit
7ca66d04
authored
Sep 08, 2021
by
yinjiacheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update C端客户端信息服务获取登录状态支持是否打开登录页面
parent
16f66007
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
8 deletions
+36
-8
HttpResultObserver.kt
...c/main/java/com/yidian/bcommon/http/HttpResultObserver.kt
+27
-0
HttpResultSubscriber.kt
...main/java/com/yidian/bcommon/http/HttpResultSubscriber.kt
+9
-8
No files found.
CommonLib/BCommon/src/main/java/com/yidian/bcommon/http/HttpResultObserver.kt
View file @
7ca66d04
...
...
@@ -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
?:
"网络请求失败"
)
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/http/HttpResultSubscriber.kt
View file @
7ca66d04
...
...
@@ -68,9 +68,10 @@ 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
)
{
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
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment