Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 设置配置项默认值
var posId = [opt.posId] || [1];
var kw = opt.kw || '';
var element = opt.element;
var $plus = $('mip-ck-ad-plus');
var ckAdPutNum = $plus.length;
var ckAdNum = $body.attr('ck-ad-num') || 0;
// 接口参数值
var query = {
kw: kw,
pid: posId.join(',')
};
// 如果adData不是一个Object,强制转为{}
if (!(adData && $.isPlainObject(adData))) {
adData = {};
}
query = $.extend(adData, query);
query.pid = getPids($plus).join(',');
$body.attr('ck-ad-num', ++ckAdNum);
var ckAdOpt = {
adUrl: adUrl,
query: query,
element: element
};
// 广告组件数量 不等于 已经渲染的广告组件数量 直接退出 不请求接口
$.each(data, function (k, v) {
// 获取投放直销广告的节点
element = $('mip-ck-ad-plus[pid="' + k + '"]');
uid = element.attr('ck-ad-uid');
// 根据医生id判断物料类型
v = (query.uid && $.isPlainObject(v)) ? v[uid] : v;
// 有特定广告位id的直投广告 先隐藏网盟 再显示直投
if ($.trim(v)) {
element.children(':first-child').remove();
element.html(v);
$body.addClass('view-ck-ad-' + (+k));
isHasCkAd = true;
}
// 无特定广告位id直投广告显示网盟
else {
element.children(':first-child').show();
$body.addClass('view-ck-ad-' + (+k) + '-union');
}
$.each(data, function (k, v) {
// 获取投放直销广告的节点
element = $('mip-fh-ad-plus[fh-ad-pid="' + k + '"]');
uid = element.attr('fh-ad-uid');
// 根据医生id判断物料类型
v = (query.uid && $.isPlainObject(v)) ? v[uid] : v;
// 有特定广告位id的直投广告 先隐藏网盟 再显示直投
if ($.trim(v)) {
element.children(':first-child').remove();
element.html(v);
$body.addClass('view-fh-ad-' + (+k));
isHasFhAd = true;
}
// 无特定广告位id直投广告显示网盟
else {
element.children(':first-child').show();
$body.addClass('view-fh-ad-' + (+k) + '-union');
}
$.each(data, function (k, v) {
// 获取投放直销广告的节点
element = $('mip-fh-zhida-plus[fh-ad-pid="' + k + '"]');
uid = element.attr('fh-ad-uid');
// 根据医生id判断物料类型
v = (query.uid && $.isPlainObject(v)) ? v[uid] : v;
// 有特定广告位id的直投广告 先隐藏网盟 再显示直投
if ($.trim(v)) {
element.children(':first-child').remove();
element.html(v);
$body.addClass('view-fh-ad-' + (+k));
isHasFhAd = true;
}
// 无特定广告位id直投广告显示网盟
else {
element.children(':first-child').show();
$body.addClass('view-fh-ad-' + (+k) + '-union');
}