Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
X
xxsq
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
xxsq
Commits
6ce27ae8
Commit
6ce27ae8
authored
Jun 02, 2022
by
王雪伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[提交人]:王雪伟
[提交简述] :小象省钱 [实现方案] :调整H5支付
parent
c9f665d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
106 deletions
+66
-106
SkillShopActivity.kt
...in/java/com/zxbw/modulemain/activity/SkillShopActivity.kt
+47
-96
ToPaySkillGoodsActivity.kt
...a/com/zxbw/modulemain/activity/ToPaySkillGoodsActivity.kt
+0
-6
activity_layout_skill_shop.xml
...leMain/src/main/res/layout/activity_layout_skill_shop.xml
+19
-4
No files found.
moduleMain/src/main/java/com/zxbw/modulemain/activity/SkillShopActivity.kt
View file @
6ce27ae8
...
...
@@ -27,6 +27,7 @@ import com.zxhl.cms.net.model.box.GoodList
import
com.zxhl.cms.net.model.box.OrderEntity
import
com.zxhl.cms.net.model.uc.AliPayEntity
import
com.zxhl.cms.net.model.uc.PayResultEntity
import
com.zxhl.cms.pay.H5PayUtil
import
com.zxhl.cms.pay.PayActivity
import
com.zxhl.cms.pay.alipay.AlipayServer
import
com.zxhl.cms.utils.EventUtils
...
...
@@ -39,12 +40,16 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.functions.Consumer
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.*
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_img_back
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_img_close_pay_web
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_rights_pay_web_view
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_rl_h5_pay_view
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_rl_hava_address
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_rl_no_address
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_tv_pay_money
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_tv_to_pay
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_tv_user_address
import
kotlinx.android.synthetic.main.activity_layout_skill_shop.id_tv_user_name_phone
import
kotlinx.android.synthetic.main.activity_layout_to_pay_skill_goods.*
class
SkillShopActivity
:
BaseActivity
(),
CardDetailContract
.
View
{
private
var
mPayPresenter
:
CardDetailPresenter
?
=
null
...
...
@@ -94,6 +99,9 @@ class SkillShopActivity : BaseActivity(), CardDetailContract.View {
id_tv_to_pay
?.
setOnClickListener
{
toPay
()
}
id_img_close_pay_web
?.
setOnClickListener
{
id_rl_h5_pay_view
.
visibility
=
View
.
GONE
}
id_rl_no_address
?.
setOnClickListener
{
val
intent
=
Intent
(
mActivity
,
ReceiveAddressActivity
::
class
.
java
)
intent
.
putExtra
(
"order"
,
"order"
)
...
...
@@ -255,6 +263,19 @@ class SkillShopActivity : BaseActivity(), CardDetailContract.View {
mLoading
?.
setResult
(
false
,
"取消支付"
,
1000
)
}
}
1
->
{
if
(
mLoading
!=
null
)
{
mLoading
?.
setResult
(
false
,
"支付异常"
,
0
)
}
id_rl_h5_pay_view
.
visibility
=
View
.
VISIBLE
EventUtils
.
onEvent
(
"h5_pay_end"
)
}
2
->
{
if
(
mLoading
!=
null
)
{
mLoading
?.
setResult
(
false
,
"支付异常"
,
0
)
}
id_rl_h5_pay_view
.
visibility
=
View
.
VISIBLE
}
}
false
}
...
...
@@ -283,7 +304,32 @@ class SkillShopActivity : BaseActivity(), CardDetailContract.View {
EventUtils
.
onEvent
(
"h5_pay_error"
)
showResultLoading
(
false
)
}
else
{
loadH5Pay
(
result
.
outTradeNo
!!
)
mHandler
.
sendEmptyMessageDelayed
(
1
,
8000
)
H5PayUtil
().
loadH5PayWeb
(
this
,
id_rights_pay_web_view
,
result
.
outTradeNo
?:
""
,
object
:
H5PayUtil
.
H5PayCallBack
{
override
fun
jumpZfbAppSuc
()
{
id_rl_h5_pay_view
.
visibility
=
View
.
GONE
EventUtils
.
onEvent
(
"h5_open_zfb_suc"
)
mHandler
.
removeMessages
(
1
)
}
override
fun
jumpZfbAppException
(
e
:
Exception
)
{
EventUtils
.
onEvent
(
"h5_open_zfb_error"
,
e
.
toString
())
mHandler
.
removeMessages
(
1
)
mHandler
.
sendEmptyMessage
(
2
)
}
override
fun
loadH5Error1
(
errorStr
:
String
)
{
EventUtils
.
onEvent
(
"h5_pay_error1"
,
errorStr
)
}
override
fun
loadH5Error2
(
errorStr
:
String
)
{
EventUtils
.
onEvent
(
"h5_pay_error2"
,
errorStr
)
}
})
}
}
else
if
(
pay_type
==
RightsDetailActivity
.
ALI_PAY
)
{
AlipayServer
.
payV2
(
this
,
result
.
wakeup
!!
)
...
...
@@ -342,101 +388,6 @@ class SkillShopActivity : BaseActivity(), CardDetailContract.View {
RxBus
.
get
().
unregister
(
Constant
.
PAY_RESULT
,
payResultObservable
!!
)
}
private
fun
loadH5Pay
(
form
:
String
)
{
// id_rights_pay_web_view.visibility = View.VISIBLE
Log
.
d
(
"wxw"
,
"startTime"
+
System
.
currentTimeMillis
())
val
webSettings
=
id_rights_pay_web_view
.
settings
//如果访问的页面中要与Javascript交互,则webview必须设置支持Javascript
webSettings
.
javaScriptEnabled
=
true
//设置自适应屏幕,两者合用
webSettings
.
useWideViewPort
=
true
//将图片调整到适合webview的大小
webSettings
.
loadWithOverviewMode
=
true
// 缩放至屏幕的大小
//其他细节操作
webSettings
.
cacheMode
=
WebSettings
.
LOAD_NO_CACHE
//关闭webview中缓存
webSettings
.
allowFileAccess
=
true
//设置可以访问文件
webSettings
.
javaScriptCanOpenWindowsAutomatically
=
true
//支持通过JS打开新窗口
webSettings
.
loadsImagesAutomatically
=
true
//支持自动加载图片
webSettings
.
defaultTextEncodingName
=
"utf-8"
//设置编码格式
webSettings
.
domStorageEnabled
=
true
webSettings
.
allowFileAccessFromFileURLs
=
true
;
webSettings
.
allowUniversalAccessFromFileURLs
=
true
;
id_rights_pay_web_view
?.
webViewClient
=
object
:
WebViewClient
()
{
override
fun
shouldOverrideUrlLoading
(
view
:
WebView
?,
url
:
String
?):
Boolean
{
Log
.
e
(
"WXW"
,
"dURL"
+
url
.
toString
())
if
(
url
==
null
)
return
false
try
{
if
(
url
.
startsWith
(
"alipays://"
)
//支付宝
)
{
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
url
))
startActivity
(
intent
)
EventUtils
.
onEvent
(
"h5_open_zfb_suc"
)
return
true
}
}
catch
(
e
:
Exception
)
{
//防止crash (如果手机上没有安装处理某个scheme开头的url的APP, 会导致crash)
EventUtils
.
onEvent
(
"h5_open_zfb_error"
,
e
.
toString
())
showResultLoading
(
false
)
return
true
//没有安装该app时,返回true,表示拦截自定义链接,但不跳转,避免弹出上面的错误页面
}
//处理http和https开头的url
view
?.
loadUrl
(
url
)
return
false
}
override
fun
onPageFinished
(
view
:
WebView
?,
url
:
String
?)
{
Log
.
e
(
"WXW"
,
"cURL"
+
url
.
toString
())
Log
.
d
(
"wxw"
,
"EndTime"
+
System
.
currentTimeMillis
())
super
.
onPageFinished
(
view
,
url
)
if
(
url
?.
contains
(
NetConfig
.
H5
.
WEB_URL_H5_PAY
)
==
true
)
{
id_rights_pay_web_view
?.
loadUrl
(
"javascript:loadPayHtml('$form')"
);
}
}
override
fun
onReceivedError
(
view
:
WebView
?,
request
:
WebResourceRequest
?,
error
:
WebResourceError
?
)
{
super
.
onReceivedError
(
view
,
request
,
error
)
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
M
)
{
// Log.d("wxw", "1error${error?.errorCode}")
// Log.d("wxw", "2error${error?.description}")
EventUtils
.
onEvent
(
"h5_pay_error1"
,
"code: ${error?.errorCode} desc: ${error?.description}"
)
}
else
{
EventUtils
.
onEvent
(
"h5_pay_error1"
,
error
.
toString
())
}
showResultLoading
(
false
)
}
override
fun
onReceivedHttpError
(
view
:
WebView
?,
request
:
WebResourceRequest
?,
errorResponse
:
WebResourceResponse
?
)
{
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
if
(
request
?.
url
?.
path
?.
endsWith
(
"/favicon.ico"
)
==
true
)
{
}
else
{
EventUtils
.
onEvent
(
"h5_pay_error2"
,
errorResponse
?.
statusCode
.
toString
()
+
" url:${request?.url}"
)
showResultLoading
(
false
)
}
}
else
{
EventUtils
.
onEvent
(
"h5_pay_error2"
,
errorResponse
.
toString
())
showResultLoading
(
false
)
}
super
.
onReceivedHttpError
(
view
,
request
,
errorResponse
)
}
}
id_rights_pay_web_view
.
loadUrl
(
NetConfig
.
H5
.
WEB_URL_H5_PAY
)
}
override
fun
onKeyDown
(
keyCode
:
Int
,
event
:
KeyEvent
?):
Boolean
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
if
(
TextUtils
.
equals
(
type
,
"1"
))
{
...
...
moduleMain/src/main/java/com/zxbw/modulemain/activity/ToPaySkillGoodsActivity.kt
View file @
6ce27ae8
package
com.zxbw.modulemain.activity
import
android.content.Intent
import
android.graphics.Paint
import
android.net.Uri
import
android.os.Handler
import
android.text.TextUtils
import
android.util.Log
import
android.view.KeyEvent
import
android.view.View
import
android.webkit.*
import
com.zxbw.modulemain.R
import
com.zxbw.modulemain.contract.CardDetailContract
import
com.zxbw.modulemain.presenter.CardDetailPresenter
import
com.zxbw.modulemain.view.DialogUtils
import
com.zxhl.cms.AppContext
import
com.zxhl.cms.common.Constant
import
com.zxhl.cms.common.NetConfig
import
com.zxhl.cms.common.base.BaseActivity
import
com.zxhl.cms.net.SettingPreference
import
com.zxhl.cms.net.model.qy.SkillGoodsEntity
...
...
@@ -32,13 +28,11 @@ import com.zxhl.cms.widget.LoadingDialog
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.functions.Consumer
import
kotlinx.android.synthetic.main.activity_layout_card_detail.*
import
kotlinx.android.synthetic.main.activity_layout_to_pay_skill_goods.*
import
kotlinx.android.synthetic.main.activity_layout_to_pay_skill_goods.id_img_back
import
kotlinx.android.synthetic.main.activity_layout_to_pay_skill_goods.id_img_close_pay_web
import
kotlinx.android.synthetic.main.activity_layout_to_pay_skill_goods.id_rights_pay_web_view
import
kotlinx.android.synthetic.main.activity_layout_to_pay_skill_goods.id_rl_h5_pay_view
import
kotlinx.android.synthetic.main.activity_layout_to_pay_skill_goods.view.*
class
ToPaySkillGoodsActivity
:
BaseActivity
(),
CardDetailContract
.
View
{
private
var
mPayPresenter
:
CardDetailPresenter
?
=
null
...
...
moduleMain/src/main/res/layout/activity_layout_skill_shop.xml
View file @
6ce27ae8
...
...
@@ -327,10 +327,25 @@
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
<
WebView
android:id=
"@+id/id_r
ights_pay_web
_view"
<
RelativeLayout
android:id=
"@+id/id_r
l_h5_pay
_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
/>
android:layout_height=
"match_parent"
android:layout_below=
"@+id/id_order_title"
android:visibility=
"gone"
>
<WebView
android:id=
"@+id/id_rights_pay_web_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<ImageView
android:id=
"@+id/id_img_close_pay_web"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignRight=
"@+id/id_member_pay_web_view"
android:padding=
"10dp"
android:src=
"@drawable/icon_guanbi"
/>
</RelativeLayout>
</RelativeLayout>
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