diff --git a/mip-fh-ad/README.md b/mip-fh-ad/README.md index 66b10d8ef..2b281b46e 100644 --- a/mip-fh-ad/README.md +++ b/mip-fh-ad/README.md @@ -12,10 +12,16 @@ mip-fh-ad 用来支持m.fh21.com.cn问答详情页的直投广告显示 在MIP HTML中,直接使用标签, 用于正常显示直投的广告。示例如下: -``` - - - - P.S.: mip-fh-ad目录没有自带属性,直接按照正常的html标签使用即可 +```html + + + +
x
+ +
+
+ +
``` ## 属性 diff --git a/mip-fh-ad/mip-fh-ad.js b/mip-fh-ad/mip-fh-ad.js index e215a0f86..c46ce08c9 100644 --- a/mip-fh-ad/mip-fh-ad.js +++ b/mip-fh-ad/mip-fh-ad.js @@ -8,39 +8,26 @@ */ define(function (require) { + var $ = require('zepto'); var customElem = require('customElement').create(); + var $body = $('body'); // 直投广告请求url var ajaxurl = 'https://partners.fh21.com.cn/partners/showcodejsonp?callback=?'; // 页面广告参数 var param = $('#adParam'); var paramObj = param.data('keyword'); - // 加载js文件 - var loadJSFile = function (url, callback) { - - // Adding the script tag to the head as suggested before - var head = document.getElementsByTagName('head')[0]; - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = url; - - // Then bind the event to the callback function. - // There are several events for cross browser compatibility. - script.onreadystatechange = callback; - script.onload = callback; - - // Fire the loading - head.appendChild(script); - }; + // load btm baidu ad var loadBdAd = function () { - window.cpro_psid = 'u2355234'; - window.cpro_psdata = { - staticDomain: 'su.bdimg.com' - }; - loadJSFile('https://su.bdimg.com/static/dspui/js/umf.js'); + var html = ['
', '', '
']; + + html = html.concat(['']); + + html = html.join(''); + return html; }; // 初始化直投广告 @@ -95,13 +82,15 @@ define(function (require) { element.html(v); break; } + + $body.addClass('view-fh-ad-' + (+k)); } // 无特定广告位id投广告 else { switch (+k) { // 广告位id为1时,加载底部漂浮的百度广告 case 1: - loadBdAd(); + element.html(loadBdAd()); break; // 广告位id为47时,加载我要提问下方文字广告和问题详情下方网盟广告 case 47: @@ -109,6 +98,8 @@ define(function (require) { $('#ask-inof-blew-ad').show(); break; } + + $body.addClass('view-fh-ad-' + (+k) + '-union'); } }); }); @@ -116,6 +107,10 @@ define(function (require) { else { $('#ad-s-1255').show(); $('#ask-inof-blew-ad').show(); + if (posId == 1) { + element.html(loadBdAd()); + } + $body.addClass('view-fh-ad-union'); } }; @@ -173,4 +168,3 @@ define(function (require) { return customElem; }); -