/* 创建在h5端全局悬浮引导用户下载app的功能, 如不需要本功能直接移除配置文件baseapp.config.js下的h5/openApp即可 */ import CONFIG from '../baseapp.config.js'; const CONFIG_OPEN = CONFIG?.h5?.openApp?.openUrl ? CONFIG.h5.openApp : {}; // 仅H5端添加"打开APP" export default function() { // #ifdef H5 if (!CONFIG_OPEN.openUrl) return; let openLogo = CONFIG_OPEN.logo ? `` : ''; let openApp = document.createElement("div"); openApp.id = 'openApp'; openApp.style = 'position: fixed;background:#FFFFFF;box-shadow: #eeeeee 1px 1px 9px; ;top: 0;left: 0;right: 0;z-index: 999;width: 100%;height: 45px;display: flex;flex-direction: row;justify-content: space-between;align-items: center;box-sizing: border-box;padding: 0 0.5rem;' openApp.innerHTML = `
${openLogo}
${CONFIG_OPEN.appname || ''}
下载app
`; document.body.insertBefore(openApp, document.body.firstChild); document.body.style = 'height:calc(100% - 45px); margin-top:45px;'; openApp.addEventListener('click', e => { var target = e.target || e.srcElement; if (target.className.indexOf('openBtn') >= 0) { window.location.href = CONFIG_OPEN.openUrl; } }) //#endif }