Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
陈峰
8 years ago
Commit
709bc12c1cd6ed10815a9b9c49aac705dc4986fc
2 parents
cfa6acb6
b2429a7d
Merge branch 'feature/yas' into 'release/5.4.1'
完善 H5 唤起 APP 规则 See merge request
!312
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
public/js/common/open-app.js
public/js/common/open-app.js
View file @
709bc12
...
...
@@ -2,14 +2,19 @@
* 移动端尝试打开 app
*/
const
qs
=
require
(
'yoho-qs'
);
const
cookie
=
require
(
'yoho-cookie'
);
const
u
=
navigator
.
userAgent
;
const
isFromYOHO
=
/m
\.
yohobuy
\.
com/i
.
test
(
document
.
referrer
);
const
isApp
=
/yohobuy/i
.
test
(
u
)
||
!!
window
.
yohoInterface
||
/app_version=/i
.
test
(
location
.
search
)
||
/openrefer=/i
.
test
(
location
.
search
);
const
isApp
=
/yohobuy/i
.
test
(
u
)
||
!!
window
.
yohoInterface
||
/app_version=/i
.
test
(
location
.
search
)
||
/openrefer=/i
.
test
(
location
.
search
);
const
isiOS
=
/
(
iPhone|iPad|iPod|iOS
)
/i
.
test
(
u
);
// ios终端
const
isAndroid
=
/Android/i
.
test
(
u
);
// android终端
const
iOSVersion
=
parseInt
((
u
.
match
(
/OS
(\d
+
)
_
(\d
+
)
_
?(\d
+
)?
/i
)
||
[])[
1
],
10
);
// iOS 版本
// const iOSVersion = parseInt((u.match(/OS (\d+)_(\d+)_?(\d+)?/i) || [])[1], 10); // iOS 版本
const
nodownload
=
document
.
getElementById
(
'no-download'
);
// 页面不需要下载
const
urlBlacklist
=
[
'm.yohobuy.com/brands'
,
'm.yohobuy.com/passport'
];
...
...
@@ -21,12 +26,12 @@ const canOpenApp = () => {
if
(
isApp
||
isFromYOHO
||
nodownload
||
qs
.
nodownload
||
qs
.
no_openapp
||
blackCheck
)
{
return
false
;
}
return
isAndroid
||
i
OSVersion
<
9
||
qs
.
openapp
;
return
isAndroid
||
i
siOS
||
qs
.
openapp
;
};
const
getAppPath
=
()
=>
{
let
appPath
=
document
.
getElementById
(
'main-wrap'
).
dataset
.
apppath
||
'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.home","params":{"gender":"1","channel":"2"}}'
;
let
ct
=
qs
.
mkt_code
||
qs
.
union_type
;
let
ct
=
qs
.
mkt_code
||
qs
.
union_type
||
cookie
.
get
(
'mkt_code'
)
||
'100000000000349'
;
if
(
ct
)
{
appPath
=
appPath
.
replace
(
'goapp?'
,
'goapp?ct='
+
ct
+
'&'
);
...
...
Please
register
or
login
to post a comment