var hdy_sdk_config;
let _hdy_sdk_config = {
opts: {
isauto: true,
css: 'http://napi.tls.manjier.com/advsdk/css/v1',
title: '', //',
tplt: `
{title}
{html}
`,
tplt_pre: `
{data}
`
},
data: [{
name: '营销APP',
image: 'http://dlpt.xmesh.cn/Ft0vuxJc7qssZXHbLVfon-y2koxh',
link: 'http://mkt.dy.manjier.com/pages/app/hdysjb'
}, {
name: '代理加盟',
image: 'http://dlpt.xmesh.cn/FjFjmyU1no3DDWeYmEo3nPORsIqP',
link: 'http://h.dy.manjier.com/pages/no_verify/marketing/attract'
}]
};
function init_hdy_adv_sdk(fun) {
if (hdy_sdk_config) {
hdy_sdk_config(_hdy_sdk_config)
}
if (fun) {
fun(_hdy_sdk_config)
}
// 处理uniapp下广告显示位置异常
var uniApp = document.querySelector('uni-app');
if (uniApp != null) {
uniApp.style.height = 'auto';
}
// 处理推荐位样式
var recCount = 0;
var recInter = setInterval(function() {
recCount++;
if (recCount > 20) {
clearInterval(recInter);
}
var recPoint = document.querySelector('#recpoint');
if (recPoint != null) {
var next = recPoint.nextElementSibling;
if (next != null) {
clearInterval(recInter);
next.className = next.className.replace(/magic-popup-adv-pro-v2/g, '');
}
}
}, 300)
// 兼容处理商家图片显示异常
var _well_list = document.querySelectorAll('.magic-well-vdo');
if (_well_list != null && _well_list.length > 0) {
if (_well_list[0].previousElementSibling == null) {
var _well_img = _well_list[0].querySelector('img');
if (_well_img != null) {
_well_img.style.height = '4em';
_well_img.style.borderRadius = '4em';
}
}
if (_well_list[_well_list.length - 1].nextElementSibling == null) {
var _well_img = _well_list[_well_list.length - 1].querySelector('img');
if (_well_img != null) {
_well_img.style.height = '4em';
_well_img.style.borderRadius = '4em';
}
}
}
var _sel_list = document.querySelectorAll('.magic-well-sel');
if (_sel_list != null && _sel_list.length > 0) {
_sel_list.forEach(function(t) {
var __img = t.querySelector('img');
if (__img != null) {
__img.style.height = '4em';
__img.style.borderRadius = '4em';
}
})
}
// 处理商家动态预览
var _dyn_list = document.querySelectorAll('[data-magic-raw]')
if (_dyn_list != null && _dyn_list.length > 0) {
_dyn_list.forEach(function(t) {
t.onclick = function() {
var _type = t.dataset['magicType']
var _raw = t.dataset['magicRaw']
var _data = _hdy_sdk_config.opts.tplt_pre.replace(/{data}/,
_type == '1' ? `` : ``)
document.querySelector('._hdy_sdk_preview').innerHTML = _data
document.querySelector('._hdy_sdk_preview').style.display = 'table'
}
})
if (document.querySelector('._hdy_sdk_preview') == null) {
var div = document.createElement("div");
div.className = '_hdy_sdk_preview'
div.innerHTML = _hdy_sdk_config.opts.tplt_pre;
document.body.appendChild(div);
document.querySelector('._hdy_sdk_preview').onclick = function() {
this.style.display = 'none'
}
}
}
if (!_hdy_sdk_config.opts.isauto) {
return
}
var _hdy_sdk_advs_data = []
for (var i in _hdy_sdk_config.data) {
_hdy_sdk_advs_data.push(``)
}
var data = _hdy_sdk_config.opts.tplt.replace(/{title}/g, _hdy_sdk_config.opts.title).replace(/{html}/g, _hdy_sdk_advs_data.join(''))
if (document.querySelector('._hdy_sdk') != null) {
document.querySelectorAll('._hdy_sdk').forEach(function(t) {
t.innerHTML = data
})
} else {
var div = document.createElement("div");
div.className = "_hdy_sdk";
div.innerHTML = data;
document.body.appendChild(div);
}
};
function init_hdy_play() {
// document.addEventListener("touchstart", function() {
// document.querySelectorAll('video').forEach(function(t) {
// t.play()
// })
// }, false);
document.addEventListener("WeixinJSBridgeReady", function() {
document.querySelectorAll('video').forEach(function(t) {
t.play()
})
}, false);
};
// init_hdy_play();
// (function() {
// document.write(``);
// })();
// window.addEventListener("load", function() {
// init_hdy_adv_sdk()
// }, false);
// module.exports = {
// init_hdy_adv_sdk: init_hdy_adv_sdk,
// init_hdy_play: init_hdy_play,
// }