Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
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
865af639
Commit
865af639
authored
4 years ago
by
leiqingsong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_lqs' into 'master'
修改 See merge request
!38
parents
e21bca2f
9c909e17
master
dev_lqs
dev_wm
dev_xll
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
bridgeToAppFun.js
H5/src/utils/bridgeToAppFun.js
+19
-19
No files found.
H5/src/utils/bridgeToAppFun.js
View file @
865af639
...
...
@@ -2,29 +2,29 @@
import
jsBridge
from
"./bridge"
;
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
(
"调用失败"
);
}
}
//
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
export
function
getAuthToken
()
{
const
userAgent
=
navigator
.
userAgent
;
console
.
log
(
"ua"
,
userAgent
);
if
(
userAgent
.
indexOf
(
'Android'
)
>
-
1
||
userAgent
.
indexOf
(
'Adr'
)
>
-
1
)
{
// android
console
.
log
(
"android"
);
const
token
=
window
.
android
.
getAuthToken
();
saveUser
(
token
);
}
else
if
(
userAgent
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
))
{
// ios
console
.
log
(
"ios"
);
//
if (userAgent.indexOf('Android') > -1 || userAgent.indexOf('Adr') > -1) { // android
//
console.log("android");
//
const token = window.android.getAuthToken();
//
saveUser(token);
//
} else if (userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) { // ios
//
console.log("ios");
return
jsBridge
.
callhandler
(
"getAuthToken"
,
null
,
data
=>
{
console
.
log
(
"调用2"
);
localStorage
.
setItem
(
"token"
,
data
);
...
...
@@ -40,7 +40,7 @@ export function getAuthToken() {
}
});
}
//
}
}
// 退出
...
...
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