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
f5b13dca
Commit
f5b13dca
authored
May 25, 2022
by
万齐军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: webview支付修改
parent
b3e227f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
6 deletions
+82
-6
ConfideBottomSheetDialogFragment.kt
m-confide/src/main/java/com/ydl/confide/home/ConfideBottomSheetDialogFragment.kt
+81
-5
Route.kt
m-confide/src/main/modular_api/com/ydl/confide/api/Route.kt
+1
-1
No files found.
m-confide/src/main/java/com/ydl/confide/home/ConfideBottomSheetDialogFragment.kt
View file @
f5b13dca
...
...
@@ -2,7 +2,9 @@ package com.ydl.confide.home
import
android.annotation.SuppressLint
import
android.app.Dialog
import
android.content.Intent
import
android.net.Uri
import
android.os.Build
import
android.os.Bundle
import
android.view.Gravity
import
android.view.LayoutInflater
...
...
@@ -16,10 +18,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import
com.google.android.material.bottomsheet.BottomSheetDialog
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
import
com.tencent.smtt.export.external.interfaces.JsResult
import
com.tencent.smtt.sdk.ValueCallback
import
com.tencent.smtt.sdk.WebChromeClient
import
com.tencent.smtt.sdk.WebSettings
import
com.tencent.smtt.sdk.WebView
import
com.tencent.smtt.sdk.*
import
com.ydl.confide.R
import
com.ydl.confide.home.http.ConfideHomeApi
import
com.ydl.utils.WebUrlParamsUtils
...
...
@@ -35,6 +34,7 @@ import com.yidianling.im.api.service.IImService
import
com.yidianling.user.api.service.IUserService
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
java.util.*
class
ConfideBottomSheetDialogFragment
:
BottomSheetDialogFragment
()
{
companion
object
{
...
...
@@ -43,6 +43,8 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
private
const
val
KEY_SHOULD_SHOW
=
"should_show"
}
private
var
firstVisitWXH5PayUrl
=
true
lateinit
var
wv_content
:
ProgressWebView
lateinit
var
text_title
:
TextView
lateinit
var
line
:
View
...
...
@@ -250,7 +252,13 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
}
else
{
wv_content
.
requestDisallowInterceptTouchEvent
(
true
);
}
false
;
false
}
wv_content
.
webViewClient
=
object
:
WebViewClient
()
{
override
fun
shouldOverrideUrlLoading
(
webview
:
WebView
,
url
:
String
?):
Boolean
{
if
(
url
.
isNullOrBlank
())
return
false
return
shouldOverridePayUrl
(
webview
,
url
)
}
}
wv_content
.
webChromeClient
=
object
:
WebChromeClient
()
{
override
fun
onJsAlert
(
...
...
@@ -306,6 +314,74 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
}
}
}
private
fun
shouldOverridePayUrl
(
view
:
WebView
,
url
:
String
):
Boolean
{
if
(
url
.
startsWith
(
"weixin://"
))
{
return
try
{
startActivity
(
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
url
)))
true
}
catch
(
e
:
java
.
lang
.
Exception
)
{
// 防止手机没有安装处理某个 scheme 开头的 url 的 APP 导致 crash
ToastUtil
.
toastShort
(
"该手机没有安装微信"
)
true
}
}
else
if
(
url
.
startsWith
(
"alipays://"
)
||
url
.
startsWith
(
"alipay"
))
{
return
try
{
startActivity
(
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
url
)))
true
}
catch
(
e
:
java
.
lang
.
Exception
)
{
// 防止手机没有安装处理某个 scheme 开头的 url 的 APP 导致 crash
// 启动支付宝 App 失败,会自行跳转支付宝网页支付
true
}
}
// 处理普通 http 请求跳转
// if (!(url.startsWith("http") || url.startsWith("https"))) {
// return true;
// }
// 处理微信 H5 支付跳转时验证请求头 referer 失效
// 验证不通过会出现“商家参数格式有误,请联系商家解决”
if
(
url
.
contains
(
"wx.tenpay.com"
))
{
// 申请微信 H5 支付时填写的域名
// 比如经常用来测试网络连通性的 http://www.baidu.com
val
parse
=
Uri
.
parse
(
url
)
//从url 中获取 域名信息
val
redirectUrlStr
=
parse
.
getQueryParameter
(
"redirect_url"
)
val
redirectUrl
=
Uri
.
parse
(
redirectUrlStr
)
// 申请微信 H5 支付时填写的域名
val
referer
=
redirectUrl
.
scheme
+
"://"
+
redirectUrl
.
host
// 兼容 Android 4.4.3 和 4.4.4 两个系统版本设置 referer 无效的问题
return
if
(
"4.4.3"
==
Build
.
VERSION
.
RELEASE
||
"4.4.4"
==
Build
.
VERSION
.
RELEASE
)
{
if
(
firstVisitWXH5PayUrl
)
{
view
.
loadDataWithBaseURL
(
referer
,
"<script>window.location.href=\"$url\";</script>"
,
"text/html"
,
"utf-8"
,
null
)
// 修改标记位状态,避免循环调用
// 再次进入微信H5支付流程时记得重置状态 firstVisitWXH5PayUrl = true
firstVisitWXH5PayUrl
=
false
}
// 返回 false 由系统 WebView 自己处理该 url
false
}
else
{
// HashMap 指定容量初始化,避免不必要的内存消耗
val
map
=
HashMap
<
String
,
String
>(
1
)
map
[
"Referer"
]
=
referer
view
.
loadUrl
(
url
,
map
)
true
}
}
else
if
(
url
.
contains
(
"alipay"
))
{
return
false
}
return
false
}
fun
getUnReadByUid
(
uid
:
String
):
Int
{
return
ARouter
.
getInstance
().
navigation
(
IImService
::
class
.
java
).
getUnReadByUid
(
uid
)
}
...
...
m-confide/src/main/modular_api/com/ydl/confide/api/Route.kt
View file @
f5b13dca
...
...
@@ -2,7 +2,7 @@ package com.ydl.confide.api
object
ConfideRoute
{
const
val
R_VIDEO_SHOW
=
"confide/expert_video"
const
val
R_VIDEO_SHOW
=
"
/
confide/expert_video"
fun
h5ConfideIntro
(
id
:
String
)
=
"jy/listenMask?listenerId=${id}"
...
...
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