Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
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
杨凯
YDL-Component-Medical
Commits
ba02ea5f
Commit
ba02ea5f
authored
Aug 02, 2022
by
YKai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增js方法拆分,冗余代码删除
parent
ff5d495d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
384 deletions
+17
-384
WebServiceImpl.java
app/src/main/java/com/ydl/component/service/WebServiceImpl.java
+0
-34
JsMethod.kt
app/src/main/java/com/ydl/component/service/web/JsMethod.kt
+0
-128
WVClickAbstractListener.java
app/src/main/java/com/ydl/component/service/web/WVClickAbstractListener.java
+0
-0
WebJavascriptHandler.kt
app/src/main/java/com/ydl/component/service/web/WebJavascriptHandler.kt
+0
-0
WebViewClientClickListener.java
app/src/main/java/com/ydl/component/service/web/WebViewClientClickListener.java
+0
-218
NewH5_JavascriptHandler.kt
m-js/src/main/java/com/ydl/js/NewH5_JavascriptHandler.kt
+17
-4
No files found.
app/src/main/java/com/ydl/component/service/WebServiceImpl.java
deleted
100644 → 0
View file @
ff5d495d
package
com
.
ydl
.
component
.
service
;
import
android.app.Activity
;
import
android.content.Context
;
import
com.alibaba.android.arouter.facade.annotation.Route
;
import
com.tencent.smtt.sdk.WebView
;
import
com.ydl.component.service.web.WVClickAbstractListener
;
import
com.ydl.component.service.web.WebJavascriptHandler
;
import
com.ydl.webview.IJavascriptHandler
;
import
com.ydl.webview.IWebService
;
import
com.ydl.webview.TellData
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
/**
* Created by haorui on 2019-10-10.
* Des:
*/
@Route
(
path
=
"/web/webservice"
)
public
class
WebServiceImpl
implements
IWebService
{
@Override
public
void
init
(
Context
context
)
{
}
@NotNull
@Override
public
IJavascriptHandler
getJavascripHandler
(
@NotNull
Activity
activity
,
@Nullable
WebView
webView
,
@NotNull
TellData
tellData
)
{
return
new
WebJavascriptHandler
(
webView
,
new
WVClickAbstractListener
(
activity
));
}
}
app/src/main/java/com/ydl/component/service/web/JsMethod.kt
deleted
100644 → 0
View file @
ff5d495d
package
com.ydl.component.service.web
import
android.Manifest
import
com.blankj.utilcode.util.PermissionUtils
import
com.google.gson.JsonObject
import
com.google.gson.JsonParser
import
com.tencent.smtt.sdk.WebView
import
com.ydl.audioim.YDLavManager
import
com.ydl.confide.api.IConfideService
import
com.ydl.confide.event.ConfideDialogEvent
import
com.ydl.webview.H5Params
import
com.ydl.webview.NewH5Activity
import
com.ydl.ydlcommon.base.BaseActivityMgr
import
com.ydl.ydlcommon.modular.findRouteService
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.common.tools.asFragmentActivity
import
com.yidianling.user.UserHelper
import
de.greenrobot.event.EventBus
class
JsMethod
(
private
val
webView
:
WebView
?)
{
fun
handle
(
param
:
String
):
Boolean
{
try
{
val
obj
=
JsonParser
().
parse
(
param
).
asJsonObject
val
cmd
=
obj
.
getAsJsonObject
(
"cmd"
)
val
actionName
=
cmd
?.
getAsJsonPrimitive
(
"action_name"
)
?.
asString
if
(
actionName
.
isNullOrBlank
())
return
false
return
innerHandle
(
actionName
,
cmd
)
}
catch
(
throwable
:
Throwable
)
{
throwable
.
printStackTrace
()
return
false
}
}
private
fun
innerHandle
(
actionName
:
String
,
obj
:
JsonObject
):
Boolean
{
val
param
=
obj
.
getAsJsonObject
(
"params"
)
when
(
actionName
)
{
"handle_confide_btn"
->
{
val
show
=
param
.
getAsJsonPrimitive
(
"show"
).
asInt
EventBus
.
getDefault
().
post
(
ConfideDialogEvent
(
show
))
return
true
}
"show_loading"
->
{
// val topActivity = BaseActivityMgr.INST.getTopActivity()
// Loading.show(topActivity)
return
true
}
"close_loading"
->
{
// Loading.close()
return
true
}
"open_app_eval_list"
->
{
val
url
=
param
.
getAsJsonPrimitive
(
"url"
).
asString
val
topActivity
=
BaseActivityMgr
.
INST
.
getTopActivity
()
NewH5Activity
.
start
(
topActivity
,
H5Params
(
url
,
""
))
return
true
}
"toast"
->
{
val
msg
=
param
.
getAsJsonPrimitive
(
"msg"
).
asString
if
(!
msg
.
isNullOrBlank
())
{
ToastUtil
.
toastShort
(
msg
)
}
return
true
}
"has_audio_permission"
->
{
val
callback
=
param
.
getAsJsonPrimitive
(
"callback"
).
asString
if
(
callback
.
isNullOrBlank
())
return
true
if
(
PermissionUtils
.
isGranted
(
Manifest
.
permission
.
RECORD_AUDIO
))
{
webView
?.
post
{
webView
.
loadUrl
(
"javascript:$callback(1)"
)
}
return
true
}
(
webView
?.
context
?.
asFragmentActivity
())
?.
let
{
findRouteService
(
IConfideService
::
class
.
java
).
requestConfidePermission
(
it
)
{
granted
->
webView
.
post
{
webView
.
loadUrl
(
"javascript:$callback(${if (granted) 1 else 0})"
)
}
}
}
return
true
}
"confide_dial"
->
{
//倾诉链接 java接口,支持axb和声网
val
id
=
param
.
getAsJsonPrimitive
(
"id"
).
asInt
val
data
=
param
.
getAsJsonObject
(
"data"
).
toString
()
val
topActivity
=
BaseActivityMgr
.
INST
.
topActivity
if
(!
YDLavManager
.
isOnlineRtm
)
{
//异常退出或者账号被顶掉,重新登录并拨打
YDLavManager
.
instances
.
login
(
UserHelper
.
getUserInfo
()
?.
uid
)
{
isSuccess
:
Boolean
,
_
->
if
(
isSuccess
)
{
findRouteService
(
IConfideService
::
class
.
java
).
confideDial
(
id
,
data
,
topActivity
)
}
else
{
ToastUtil
.
toastShort
(
"请重新拨打"
)
}
}
}
else
{
findRouteService
(
IConfideService
::
class
.
java
).
confideDial
(
id
,
data
,
topActivity
)
}
return
true
}
"check_app_support"
->
{
val
callback
=
param
.
getAsJsonPrimitive
(
"callback"
).
asString
val
type
=
param
.
getAsJsonPrimitive
(
"type"
).
asInt
if
(
callback
.
isNullOrBlank
())
return
true
webView
?.
post
{
when
(
type
)
{
1
,
2
->
{
//检查音频权限能力
webView
.
loadUrl
(
"javascript:$callback(1)"
)
}
else
->
{
webView
.
loadUrl
(
"javascript:$callback(0)"
)
}
}
}
return
true
}
else
->
{
return
false
}
}
}
}
\ No newline at end of file
app/src/main/java/com/ydl/component/service/web/WVClickAbstractListener.java
deleted
100644 → 0
View file @
ff5d495d
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ydl/component/service/web/WebJavascriptHandler.kt
deleted
100644 → 0
View file @
ff5d495d
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ydl/component/service/web/WebViewClientClickListener.java
deleted
100644 → 0
View file @
ff5d495d
package
com
.
ydl
.
component
.
service
.
web
;
import
com.ydl.webview.H5JsBean
;
/**
* webview 点击事件监听
* Created by harvie on 2017/7/4 0004.
*/
public
interface
WebViewClientClickListener
{
void
openH5
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
courseList
();
void
activeDetail
(
String
id
);
void
contactYi
();
void
contactCourseCustomerService
();
void
openTopicDetail
(
String
topic_id
);
void
openMember
(
String
id
);
void
sendTrend
();
void
sendResultTrend
(
final
String
cover1
,
final
String
title1
,
final
String
purl1
,
String
share_url1
);
void
sendInfo
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
searchList
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
openExpertsHome
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
openTest
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
chat
(
int
id
,
int
toUid
,
int
canTalk
,
String
accessToken
,
int
isFromQingShu
);
void
chatSendMessage
(
int
id
,
int
toUid
,
int
canTalk
,
String
accessToken
,
int
isFromQingShu
);
void
chatTeam
(
int
tid
,
int
doctorId
);
void
jumpLogin
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
openFmDetail
(
int
id
);
void
openArticle
();
void
openFmList
();
void
sendSubscriptionTimeMessage
(
String
to_uid
);
void
pay
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
payReceipt
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
payCourse
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
payTest
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
viewTestResult
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
ydlNative
(
H5JsBean
.
H5JsCmd
jsData
);
//用于神策统计
void
openOrderDetail
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
expertProduct
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
order
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
toOrderCt
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
showDocList
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
goodExpert
();
void
copyWechat
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
goWechat
();
void
listenOrderDetail
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
detailSub
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
openAgreement
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
modifyEval
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
visitEval
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
coursePlay
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
closeFloatView
();
void
courseWriteComment
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
courseComment
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
listenTel
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
voiceBroadcast
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
tel
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
onOrderByApp
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
orderSetTime
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
searchServiceDoc
(
int
cateId
);
void
openTestDetail
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
shareAction
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
openTestList
();
void
feedBack
();
void
phoneCall
();
void
chatSchedule
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
invite
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
balance
(
H5JsBean
.
H5JsCmd
.
Params
params
);
//是否显示下拉刷新控件
void
switchDownRefresh
(
H5JsBean
.
H5JsCmd
.
Params
params
);
//跳转充值界面
void
recharge
();
void
bindPhone
();
//界面刷新
void
refresh
();
//声网拨号逻辑
void
listenAgora
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
setTitle
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
saveImage
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
sendToExpert
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
confideConnect
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
confidePay
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
void
back
();
//调用公共支付的
void
commonPay
(
H5JsBean
.
H5JsCmd
.
Params
jsData
);
//隐藏statusbar,全屏展示
void
hideStatusBar
();
void
showStatusBar
();
//打开与关闭右上角菜单
void
openRightTopMenu
();
//打开与关闭底部分享弹框
void
openShareMenu
(
H5JsBean
.
H5JsCmd
.
Params
params
);
//关闭页面
void
closeWebKit
();
void
goHome
(
H5JsBean
.
H5JsCmd
.
Params
params
);
//保存图片
// void storePic();
void
sendUnReadNum
(
String
callbackFuncName
,
String
uid
);
//是否展示标题栏
void
shouldShowTitleBar
(
boolean
isShowTitleBar
);
//设置当前页面类型
void
setSelfPageType
(
int
selfType
);
//关闭私聊窗口立即咨询webview
void
chatCloseBottomWebView
();
default
void
playMeditation
(
int
mediaId
,
long
meditationId
,
int
meditationType
,
String
mediaCoverUrl
){}
default
void
switchSound
(
int
mediaId
,
long
meditationId
,
int
meditationType
,
int
businessType
,
String
buried
,
String
mediaUrl
,
String
mediaCoverUrl
,
String
title
,
String
desc
,
int
status
){
}
//页面内跳转url
void
reloadUrl
(
String
url
);
default
void
setWebViewBG
(
String
rgb
,
String
alpha
){}
void
getNextExpertStatus
(
String
doctorID
,
String
title
,
String
uid
,
String
linkUrl
);
//h5页面是否需要打开推送
void
switchPushStatus
(
H5JsBean
.
H5JsCmd
.
Params
params
);
//显示评论弹窗
void
showCommentArticleDialog
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
resourceToPreview
(
H5JsBean
.
H5JsCmd
.
Params
params
);
void
showDocBooking
(
H5JsBean
.
H5JsCmd
.
Params
params
);
// 打开时间选择器
void
openTimePicker
(
String
jsCallBackName
,
String
day
,
String
doctorId
,
String
orderId
);
}
m-js/src/main/java/com/ydl/js/NewH5_JavascriptHandler.kt
View file @
ba02ea5f
...
...
@@ -10,10 +10,10 @@ import com.ydl.js_module.manager.WebViewRouterManager
import
com.ydl.webview.H5JsBean
import
com.ydl.webview.IJavascriptHandler
import
com.ydl.ydl_router.manager.YDLRouterManager
import
com.ydl.ydlcommon.utils.Utils
import
com.ydl.ydlcommon.base.BaseActivityMgr
import
com.ydl.ydlcommon.base.config.HttpConfig
import
com.ydl.ydlcommon.modular.findRouteService
import
com.ydl.ydlcommon.utils.Utils
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.utils.log.AliYunLogConfig
import
com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
...
...
@@ -35,8 +35,7 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
@JavascriptInterface
fun
sendDataToOC
(
params
:
String
)
{
LogUtil
.
i
(
"js"
,
params
)
LogUtil
.
d
(
"sendDataToOC"
)
LogUtil
.
e
(
"js"
,
params
)
AliYunRichLogsHelper
.
getInstance
().
sendRichLog
(
AliYunLogConfig
.
WEB
,
"params:$params"
)
//js交互路由 后期会去除掉这个路由 统一使用下面的路由
//该路由只有测试记录h5页面在使用 - 测试题支付/测试题详情/测试题结果
...
...
@@ -122,7 +121,7 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
"view_test_result"
->
//查看测试结果
if
(
wvEnventPro
!=
null
)
{
wvEnventPro
?
.
viewTestResult
(
jsData
.
cmd
?.
params
)
wvEnventPro
!!
.
viewTestResult
(
jsData
.
cmd
?.
params
)
}
"chat"
->
//私聊
...
...
@@ -492,6 +491,20 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
wvEnventPro
?.
chatCloseBottomWebView
()
}
}
"open_article_comment_dialog"
->
{
wvEnventPro
?.
showCommentArticleDialog
(
jsData
.
cmd
?.
params
)
}
"resources_to_preview"
->
{
wvEnventPro
?.
resourceToPreview
(
jsData
.
cmd
?.
params
)
}
"doctor_booking"
->
{
wvEnventPro
?.
showDocBooking
(
jsData
.
cmd
?.
params
)
}
}
}
}
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