Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
杨建斌
/
dy-wx2
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
8ba9954d
authored
2018-09-01 17:02:37 +0800
by
ex
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
h5
1 parent
eb0f4c86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
17 deletions
js/JSBridge.js
js/JSBridge.js
View file @
8ba9954
var
u
=
navigator
.
userAgent
;
var
isAndroid
=
u
.
indexOf
(
'Android'
)
>
-
1
||
u
.
indexOf
(
'Adr'
)
>
-
1
;
//android终端
var
isiOS
=
!!
u
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
);
//ios终端
var
appClient
=
new
AppClient
({},
false
);;
function
AppClient
(
appObj
,
isAndroid
)
{
layer
.
open
({
content
:
appObj
,
content
:
JSON
.
stringify
(
appObj
)
,
time
:
2
})
this
.
appObj
=
appObj
;
...
...
@@ -42,16 +43,17 @@ AppClient.prototype.getERCode = function (jsonStr, getCallback, postCallback) {
from
:
'H5'
,
params
:
dataParams
};
// if(this.isAndroid) {
// this.appObj.callHandler('getERCode', jsonStr, function (res) {
// layer.open({
// content: res,
// time: 2
// })
// });
// } else {
this
.
appObj
.
registerHandler
(
"postERCOde"
,
postCallback
)
this
.
appObj
.
callHandler
(
"getERCode"
,
param
,
getCallback
);
if
(
this
.
isAndroid
)
{
window
.
WebViewJavascriptBridge
.
appObj
.
callHandler
(
'getERCode'
,
jsonStr
,
function
(
res
)
{
layer
.
open
({
content
:
res
,
time
:
2
})
});
}
else
{
this
.
appObj
.
callHandler
(
"getERCode"
,
param
,
getCallback
);
this
.
appObj
.
registerHandler
(
"postERCOde"
,
postCallback
)
}
// }
};
AppClient
.
prototype
.
getGPS
=
function
(
jsonStr
,
getCallback
,
postCallback
)
{
...
...
@@ -103,15 +105,15 @@ if(isAndroid || isiOS) {
responseCallback
({
'Javascript Responds'
:
'Wee!'
})
})
}
if
(
isiOS
)
{
if
(
isiOS
)
{
appClient
=
new
AppClient
(
bridge
,
false
);
}
// 此处可以调用一些init的方法
});
}
else
{
appClient
=
new
AppClient
({},
false
);
layer
.
open
({
content
:
'环境判断失败
'
,
time
:
2
})
//
layer.open({
// content: '非原生
',
//
time: 2
//
})
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment