Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
X
XiTianSenMall
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
leiqingsong
XiTianSenMall
Commits
b1e5ecef
Commit
b1e5ecef
authored
4 years ago
by
leiqingsong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_lqs' into 'master'
安卓调用 See merge request
!30
parents
7166fd91
425b6dfb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
bridgeToAppFun.js
H5/src/utils/bridgeToAppFun.js
+20
-6
No files found.
H5/src/utils/bridgeToAppFun.js
View file @
b1e5ecef
// H5 去调用App的方法
// H5 去调用App的方法
import
jsBridge
from
"./bridge"
;
import
jsBridge
from
"./bridge"
;
import
{
getUserInfo
}
from
"@/api/user"
;
import
{
getUserInfo
}
from
"@/api/user"
;
function
saveUser
(
data
)
{
localStorage
.
setItem
(
"token"
,
data
);
if
(
data
)
{
getUserInfo
().
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
localStorage
.
setItem
(
"user"
,
JSON
.
stringify
(
res
.
data
));
}
})
}
else
{
console
.
log
(
"调用失败"
);
}
}
// 获取Token
// 获取Token
export
function
getAuthToken
()
{
export
function
getAuthToken
()
{
getUserInfo
().
then
()
const
userAgent
=
navigator
.
userAgent
;
// return new Promise((resolve, reject) => {
if
(
userAgent
.
indexOf
(
'Android'
)
>
-
1
||
userAgent
.
indexOf
(
'Adr'
)
>
-
1
)
{
// android
// console.log("调用1");
const
token
=
window
.
android
.
getAuthToken
();
saveUser
(
token
);
}
else
if
(
userAgent
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
))
{
// ios
jsBridge
.
callhandler
(
"getAuthToken"
,
null
,
data
=>
{
jsBridge
.
callhandler
(
"getAuthToken"
,
null
,
data
=>
{
console
.
log
(
"调用2"
);
console
.
log
(
"调用2"
);
localStorage
.
setItem
(
"token"
,
data
);
localStorage
.
setItem
(
"token"
,
data
);
...
@@ -16,13 +32,11 @@ export function getAuthToken() {
...
@@ -16,13 +32,11 @@ export function getAuthToken() {
localStorage
.
setItem
(
"user"
,
JSON
.
stringify
(
res
.
data
));
localStorage
.
setItem
(
"user"
,
JSON
.
stringify
(
res
.
data
));
}
}
})
})
// resolve(data);
}
else
{
}
else
{
// reject("调用失败,未返回data");
console
.
log
(
"调用失败"
);
console
.
log
(
"调用失败"
);
}
}
});
});
// });
}
}
}
// 退出
// 退出
...
...
This diff is collapsed.
Click to expand it.
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