最近在使用openinstall提供的第三方SDK来实现浏览器中一键拉起应用和免填邀请码的功能,这里尝试使用vue进行web集成,仅供参考。
确保通过下载按钮点击触发下载,其他下载方式如自动下载或者伪点击触发均不能保证参数获取精度。
<script>
export default {
mounted:function(){
const s = document.createElement('script');
s.type = 'text/javascript';
s.src = '//web.cdn.openinstall.io/openinstall.js' ;
s.addEventListener('load',()=>{
var data = OpenInstall.parseUrlParams();
new OpenInstall({
appKey : “xxxxxx”,
preferWakeup:true,
mask:function(){
return
"<div id='openinstall_shadow'style='position:fixed;left:0;top:0;background:rgba(0,255,0, 0.5);filter:alpha(opacity=50);width:100%;height:100%;z-index:10000;'>
</div>"
},
onready : function() {
var m = this,
button = document.getElementById("downloadButton");
m.schemeWakeup();
button.style.visibility = "visible";
button.onclick = function() {
m.wakeupOrInstall();
return false;
}
}
},data);
},false)
document.head.appendChild(s);
</script>