Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mall-webview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frontend
mall-webview
Commits
c1ae52ec
Commit
c1ae52ec
authored
Mar 29, 2021
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: callback name
parent
e7253e60
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
use-native-bridge.ts
src/util/use-native-bridge.ts
+3
-3
index.vue
src/views/bonus/index.vue
+6
-5
No files found.
src/util/use-native-bridge.ts
View file @
c1ae52ec
...
...
@@ -28,7 +28,7 @@ window.$geek_excuteJS = function(args) {
}
};
const
sendNativeMessage
=
(
data
:
{
type
:
string
;
data
?:
any
})
=>
{
const
sendNativeMessage
=
(
data
:
{
type
:
string
;
data
?:
any
;
__callback__
?:
string
})
=>
{
if
(
isAndroid
())
{
window
.
ReactNativeWebView
&&
window
.
ReactNativeWebView
.
onMessage
&&
...
...
@@ -90,7 +90,7 @@ const INVOKE_NATIVE_METHOD_TIMEOUT = 10000;
function
invokeNativeMethod
<
T
=
any
,
P
=
any
>
(
arg
:
{
type
:
string
;
data
?:
P
}):
Promise
<
T
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
callbackName
=
`
${
arg
.
type
}
_callback
`
;
const
callbackName
=
`
${
arg
.
type
}
_callback
_
${
Math
.
random
()}
`
.
replace
(
/
\.
/
,
""
)
;
const
timer
=
setTimeout
(()
=>
{
reject
(
new
Error
(
`invoke
${
arg
.
type
}
timeout`
));
...
...
@@ -111,7 +111,7 @@ function invokeNativeMethod<T = any, P = any>(arg: { type: string; data?: P }):
}
}
sendNativeMessage
(
arg
);
sendNativeMessage
(
{
...
arg
,
__callback__
:
callbackName
}
);
});
}
...
...
src/views/bonus/index.vue
View file @
c1ae52ec
...
...
@@ -169,7 +169,7 @@ import { Dialog, Button, Col, Row, Cell, List, Toast } from "vant";
import
{
BonusAccountResponse
,
WithdrawListParams
,
WithdrawListResponse
}
from
"@/model/bonus"
;
import
{
bonusModel
}
from
"@/server/api"
;
import
{
BonusAccountStatus
,
ErrCode
}
from
"@/model/bonus/constant"
;
import
{
useNativeBridge
}
from
"@/util/use-native-bridge"
;
import
{
useNativeBridge
,
makecall
}
from
"@/util/use-native-bridge"
;
import
{
formatBonusTipTxt
}
from
"@/util/formatBonusTipTxt"
;
interface
BonusState
{
...
...
@@ -244,10 +244,11 @@ const Bonus = defineComponent({
state
.
showWithdrawRules
=
true
;
};
const
phoneCall
=
()
=>
{
sendNativeMessage
({
type
:
"phoneCall"
,
data
:
"400—8777389"
});
makecall
(
'400—8777389'
)
// sendNativeMessage({
// type: "phoneCall",
// data: "400—8777389"
// });
};
const
bindWeChat
=
()
=>
{
sendNativeMessage
({
...
...
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