Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hoàng Văn Đạt
mypoint_flutter_app
Commits
89983084
Commit
89983084
authored
Oct 16, 2025
by
DatHV
Browse files
update logic. refactor code
parent
928c3660
Changes
22
Hide whitespace changes
Inline
Side-by-side
lib/screen/webview/payment_web_view_screen.dart
View file @
89983084
...
...
@@ -2,7 +2,6 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/widgets/custom_app_bar.dart'
;
import
'package:webview_flutter/webview_flutter.dart'
;
import
'package:url_launcher/url_launcher.dart'
;
...
...
@@ -113,6 +112,21 @@ class _PaymentWebViewScreenState extends BaseState<PaymentWebViewScreen> with Ba
_controller
=
WebViewController
()
..
setJavaScriptMode
(
JavaScriptMode
.
unrestricted
)
..
addJavaScriptChannel
(
'MyPoint'
,
onMessageReceived:
(
JavaScriptMessage
message
)
{
final
data
=
message
.
message
;
debugPrint
(
'📩 JS Message:
$data
'
);
// Expect JSON string with {"event":"payment_result","status":"success|failure"}
if
(
data
.
contains
(
'payment_result'
))
{
if
(
data
.
contains
(
'success'
))
{
_onPaymentResult
(
PaymentProcess
.
success
);
}
else
if
(
data
.
contains
(
'failure'
))
{
_onPaymentResult
(
PaymentProcess
.
failure
);
}
}
},
)
..
setNavigationDelegate
(
NavigationDelegate
(
onPageStarted:
(
_
)
{
...
...
@@ -205,6 +219,29 @@ class _PaymentWebViewScreenState extends BaseState<PaymentWebViewScreen> with Ba
launchUrl
(
uri
,
mode:
LaunchMode
.
externalApplication
);
return
NavigationDecision
.
prevent
;
}
// Xử lý chung mypointapp:// và các scheme ngoài http/https
if
(
uri
!=
null
)
{
// mypointapp://open?click_action_type=PAYMENT_SUCCESS|PAYMENT_FAIL
if
(
uri
.
scheme
==
'mypointapp'
)
{
final
action
=
uri
.
queryParameters
[
'click_action_type'
]
??
''
;
if
(
action
==
'PAYMENT_SUCCESS'
)
{
_onPaymentResult
(
PaymentProcess
.
success
);
return
NavigationDecision
.
prevent
;
}
if
(
action
==
'PAYMENT_FAIL'
)
{
_onPaymentResult
(
PaymentProcess
.
failure
);
return
NavigationDecision
.
prevent
;
}
// Các action khác: cố mở ngoài ứng dụng
launchUrl
(
uri
,
mode:
LaunchMode
.
externalApplication
);
return
NavigationDecision
.
prevent
;
}
// Bất kỳ scheme không phải http/https: cố gắng mở ngoài
if
(
uri
.
scheme
.
isNotEmpty
&&
uri
.
scheme
!=
'http'
&&
uri
.
scheme
!=
'https'
)
{
launchUrl
(
uri
,
mode:
LaunchMode
.
externalApplication
);
return
NavigationDecision
.
prevent
;
}
}
return
NavigationDecision
.
navigate
;
}
...
...
lib/services/login_service.dart
View file @
89983084
...
...
@@ -44,6 +44,7 @@ class LoginService extends RestfulApiViewModel {
final
authResponse
=
await
client
.
login
(
phone
,
password
);
if
(!
authResponse
.
isSuccess
||
authResponse
.
data
==
null
)
{
print
(
'Login failed:
${authResponse.errorMessage}
'
);
return
_handleAuthError
(
authResponse
);
}
...
...
@@ -80,7 +81,7 @@ class LoginService extends RestfulApiViewModel {
final
errorMsg
=
response
.
errorMessage
??
Constants
.
commonError
;
switch
(
errorCode
)
{
case
ErrorCodes
.
deviceUndefined
:
case
ErrorCodes
.
deviceUndefined
||
ErrorCodes
.
deviceLock
:
return
LoginResponse
(
result:
LoginResult
.
deviceUndefined
,
message:
errorMsg
,
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
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