Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
xianyu-ufo-app-web
·
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
Email Patches
Plain Diff
Browse Files
Authored by
shuaiguo
5 years ago
Commit
d1b31929ba12c55f4fc9a9717442c0febb2bbdbc
1 parent
3984e9e7
feat: 增加share demo
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
174 additions
and
0 deletions
apps/utils/xianyu-share-demo.js
apps/utils/xianyu-share-demo.js
0 → 100644
View file @
d1b3192
import
goldlog
from
'@ali/universal-goldlog'
;
import
{
isWeex
}
from
'@ali/universal-env'
;
import
{
isFM
,
isWechat
,
isDD
,
isUC
,
isWB
,
isYK
}
from
'../env'
;
import
{
obj2qs
}
from
'../index'
;
import
confirm
from
'../confirm/index'
;
import
Windvane
from
'@weex-module/windvane'
;
import
Navigator
from
'@weex-module/navigator'
;
import
showGuideMaskInWechat
from
'./showGuideMaskInWechat'
;
// h5 详情页定制逻辑,增加 itemPvid
const
searchParams
=
new
URLSearchParams
(
location
.
search
);
let
lxTrackParam
;
if
(
searchParams
.
get
(
'lxTrackParam'
))
{
try
{
lxTrackParam
=
JSON
.
parse
(
searchParams
.
get
(
'lxTrackParam'
));
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
export
default
function
(
url
,
success
,
error
,
cancel
,
noConfirm
)
{
if
(
typeof
url
===
'object'
)
{
let
opts
=
url
;
url
=
opts
.
url
;
success
=
opts
.
success
;
error
=
opts
.
error
;
cancel
=
opts
.
cancel
;
noConfirm
=
opts
.
noConfirm
;
lxTrackParam
=
opts
.
lxTrackParam
;
}
if
(
isWeex
)
{
if
(
isFM
)
{
Windvane
.
call2
(
'Base.openWindow'
,
{
url
,
popBeforeOpen
:
true
},
()
=>
{},
()
=>
{}
);
return
false
;
}
Windvane
.
call2
(
'Base.isInstall'
,
{
ios
:
'fleamarket://'
,
android
:
'com.taobao.idlefish'
},
()
=>
{
if
(
noConfirm
)
{
callappByWindvaneWhenInstalled
(
url
,
success
,
error
);
}
else
{
goldlog
.
record
(
'/xyzz.5.17'
,
'CLK'
,
''
,
'GET'
);
confirm
({
titles
:
[
'即将离开手机淘宝'
,
'打开“闲鱼App”'
],
cancelCallback
:
()
=>
{
goldlog
.
record
(
'/xyzz.5.18'
,
'CLK'
,
''
,
'GET'
);
cancel
&&
cancel
();
},
okCallback
:
()
=>
{
goldlog
.
record
(
'/xyzz.5.19'
,
'CLK'
,
''
,
'GET'
);
callappByWindvaneWhenInstalled
(
url
,
success
,
error
);
}
});
}
},
()
=>
{
error
&&
error
();
}
);
}
else
{
if
(
window
.
AlipayJSBridge
)
{
AlipayJSBridge
.
call
(
'openInBrowser'
,
{
url
:
getCallappUrl
(
url
)
});
let
startTime
=
Date
.
now
();
let
timer
=
setTimeout
(()
=>
{
if
(
Date
.
now
()
-
startTime
<
3000
)
{
error
&&
error
();
}
},
2000
);
document
.
addEventListener
(
'visibilitychange'
,
function
()
{
if
(
timer
)
{
clearTimeout
(
timer
);
}
success
&&
success
();
});
return
;
}
else
if
(
isWechat
)
{
showGuideMaskInWechat
();
}
else
if
(
isDD
||
isUC
||
isYK
)
{
window
.
location
.
href
=
getCallappUrl
(
url
);
error
&&
error
();
}
else
if
(
isWB
)
{
url
=
`
fleamarket
:
//home?forward_url=${encodeURIComponent(url)}`;
new
lib
.
idle
.
callapp
({
iosNativeUrl
:
url
,
androidNativeUrl
:
url
,
lauchFailCallback
:
function
()
{
error
&&
error
();
}
});
}
else
if
(
typeof
lib
!==
'undefined'
&&
lib
.
idle
&&
lib
.
idle
.
callapp
)
{
new
lib
.
idle
.
callapp
({
iosNativeUrl
:
url
,
androidNativeUrl
:
url
,
lauchFailCallback
:
function
()
{
error
&&
error
();
}
});
}
}
}
function
getCallappUrl
(
url
=
''
)
{
if
(
/^http/
.
test
(
url
))
{
return
`
fleamarket
:
//weex?url=${encodeURIComponent(url)}`
}
else
{
return
url
;
}
}
function
callappByWindvaneWhenInstalled
(
url
,
success
,
error
)
{
goldlog
.
record
(
'/widle.tbMiniApp.h5detailinstall'
,
'CLK'
,
''
,
'GET'
);
const
gokey
=
obj2qs
(
lxTrackParam
);
if
(
weex
.
config
.
env
.
appName
==
'TM'
)
{
Navigator
.
open
(
{
url
:
url
||
'fleamarket://home'
},
()
=>
{
goldlog
.
record
(
'/widle.tbMiniApp.h5detailcallappsuccess'
,
'CLK'
,
gokey
,
'GET'
)
success
&&
success
();
},
()
=>
{
goldlog
.
record
(
'/widle.tbMiniApp.h5detailcallapperror'
,
'CLK'
,
''
,
'GET'
)
error
&&
error
();
}
);
}
else
{
Windvane
.
call2
(
'WVClient.open'
,
{
url
:
getCallappUrl
(
url
)
||
'fleamarket://home'
},
()
=>
{
goldlog
.
record
(
'/widle.tbMiniApp.h5detailcallappsuccess'
,
'CLK'
,
gokey
,
'GET'
)
success
&&
success
();
},
()
=>
{
goldlog
.
record
(
'/widle.tbMiniApp.h5detailcallapperror'
,
'CLK'
,
''
,
'GET'
)
error
&&
error
();
}
);
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment