fastman3-dfyjapp-callapp
Version:
h5 call app
82 lines • 2.96 kB
JavaScript
/*
* @Author: wangzhenfeng
* @Date: 2021-06-24 09:56:57
* @Company: orientsec.com.cn
* @Description: h5 唤起 app
*/
// import Taro from "@tarojs/taro";
import { isFromWeiBo, isFromWeiXin, detect } from "./utils";
import CallApp from 'callapp-lib';
import "./callApp.scss";
var callLib = new CallApp({
scheme: {
protocol: "dfyj20170811"
},
appstore: "https://itunes.apple.com/cn/app/id961539789",
yingyongbao: "//a.app.qq.com/o/simple.jsp?pkgname=com.dfzq.winner",
fallback: "https://cfyjh5-v3.dfzq.com.cn/html5-marketing/marketing-install/index.html",
timeout: 15000
});
/**
* h5唤起app,引流-打开赢家APP
* 1.是否是微博
* 2.是否是微信
* 3.打开app内对应页面,若是没有app,跳转至下载页
*/
var callApp = function callApp() {
// console.log('callApp--nint--package-new');
if (isFromWeiBo()) {
// console.log("form--weibo-");
// 废弃:在微博打开会有问题
// Taro.showToast({
// title:'请点击右上角浏览器打开',
// duration:2000,
// icon:'none',
// })
weiXinPanel();
var weixinAllHtml_1 = document.getElementById('weixinPanel');
weixinAllHtml_1 === null || weixinAllHtml_1 === void 0 ? void 0 : weixinAllHtml_1.addEventListener('click', function () {
document.body.removeChild(weixinAllHtml_1);
});
} else if (isFromWeiXin()) {
// 添加微信中打开遮罩
// console.log("form--weixin");
weiXinPanel();
var weixinAllHtml_2 = document.getElementById('weixinPanel');
weixinAllHtml_2 === null || weixinAllHtml_2 === void 0 ? void 0 : weixinAllHtml_2.addEventListener('click', function () {
document.body.removeChild(weixinAllHtml_2);
});
} else {
// console.log("form--else");
// 跳转至指定页面
callLib.open({
path: "dl/wb?url=".concat(encodeURIComponent(location.href)),
callback: function callback() {
if (detect.os.ios) {
location.href = 'https://itunes.apple.com/cn/app/dong-fang-ying-jia-cai-fu/id961539789';
} else {
location.href = 'https://cfyjh5-v3.dfzq.com.cn/html5-marketing/marketing-install/index.html';
}
}
});
}
};
/**
* 微信提示模版
*/
var weiXinPanel = function weiXinPanel() {
var bottomText = detect.os.ios ? '在默认浏览器中打开' : '在浏览器中打开';
var weixinPanelHtml = document.createElement('div');
weixinPanelHtml.id = 'weixinPanel';
document.body.appendChild(weixinPanelHtml);
var imgWraperTtml = document.createElement('div');
imgWraperTtml.id = 'arraw';
var imgHtml = document.createElement('div');
imgHtml.className = 'img';
imgWraperTtml.appendChild(imgHtml);
var pHtml = document.createElement('p');
pHtml.innerText = "\u8BF7\u70B9\u51FB\u53F3\u4E0A\u89D2\u6309\u94AE\uFF0C\u9009\u62E9".concat(bottomText);
weixinPanelHtml.appendChild(imgWraperTtml);
weixinPanelHtml.appendChild(pHtml);
};
export { callApp };