Skip to content

Commit

Permalink
Merge pull request #84 from laoono/master
Browse files Browse the repository at this point in the history
use mip-fixed
  • Loading branch information
PEI WANG authored Nov 18, 2016
2 parents adc17e0 + 8e164d4 commit 51b1241
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
14 changes: 10 additions & 4 deletions mip-fh-ad/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ mip-fh-ad 用来支持m.fh21.com.cn问答详情页的直投广告显示

在MIP HTML中,直接使用标签, 用于正常显示直投的广告。示例如下:

```
<mip-fh-ad fh-ad-pid="49"></mip-fh-ad>
- P.S.: mip-fh-ad目录没有自带属性,直接按照正常的html标签使用即可
```html
<mip-ad type="ad-qwang" cpro_psid="u2355234"></mip-ad>
<!--<div id="adParam" data-keyword="鼻炎,过敏,结膜炎"></div>-->
<mip-fixed type="bottom">
<div style="op-0">x</div>
<mip-fh-ad fh-ad-pid="1" lazy="false"></mip-fh-ad>
</mip-fixed>
<div>
<mip-fh-ad fh-ad-pid="49"></mip-fh-ad>
</div>
```

## 属性
Expand Down
42 changes: 18 additions & 24 deletions mip-fh-ad/mip-fh-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ['<div class="fh-ad-1">', '<span class="btn-fh-ad-1" on="tap:fh-ad-1.close"></span>', '</div>'];

html = html.concat(['<mip-ad type="ad-qwang" ', 'cpro_psid="u2355234"', '></mip-ad>']);

html = html.join('');
return html;
};

// 初始化直投广告
Expand Down Expand Up @@ -95,27 +82,35 @@ 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:
$('#ad-s-1255').show();
$('#ask-inof-blew-ad').show();
break;
}

$body.addClass('view-fh-ad-' + (+k) + '-union');
}
});
});
}
else {
$('#ad-s-1255').show();
$('#ask-inof-blew-ad').show();
if (posId == 1) {
element.html(loadBdAd());
}
$body.addClass('view-fh-ad-union');
}
};

Expand Down Expand Up @@ -173,4 +168,3 @@ define(function (require) {

return customElem;
});

0 comments on commit 51b1241

Please sign in to comment.