/*
* 鑷姩骞垮憡-鍩轰簬jquery 20160720
* 骞垮憡灞曠ず娆″簭鍦ㄥ悗鍙版帶鍒
* 椤堕儴鎷夊箷骞垮憡鏈夊涓椂锛屼緷娆℃媺骞曞睍绀
* 椤堕儴鍥哄畾骞垮憡銆佸鑱斿箍鍛婃湁澶氫釜鏃朵粠涓婂埌涓嬪悓鏃跺睍绀
* 杩斿洖鍊煎涓嬶細
Array
(
[res] => Array
(
[0] => Array
(
[title] => 鎴戞槸瀵硅仈鏂瑰紡
[img] => /uploads/image/1808/24/1808241115298f46m.jpg
[imgwidth] => 100
[imgheight] => 155
[top] => 190
[url] => http://baidu.com/
[adtype] => 5
[fontcolor] =>
[bgcolor] =>
)
[1] => array(......)
),
[duiliantype] => 0
)
*/
var wxyAD_first_child = null, //body绗竴涓瓙鍏冪礌锛岀敤鏉ュ湪鍏跺墠闈緷娆℃坊鍔犻《閮ㄥ浐瀹氬箍鍛婏紝涓斾繚璇佸湪鎷夊箷骞垮憡涓嬫柟
wxyAD_lamu_status = 0, //褰撳墠鏄惁鏈夋媺骞曞箍鍛婃鍦ㄥ睍绀
wxyAD_duilian_type = 0; //瀵硅仈鏂瑰紡灞曠ず鏂瑰紡锛?娴姩1鍥哄畾
$(function(){
//鑾峰彇骞垮憡骞惰繘琛屽睍绀
$.post('/index.php/myapi/ad', {is_index:jsGet('wxyad.js', 'is_index')}, function(json){
wxyAD_duilian_type = typeof(json.duiliantype)=='undefined' ? 0 : parseInt(json.duiliantype);
if(typeof(json.res)!=='undefined')wxyAD_show(json.res);
}, 'json');
});
/*
* 妯℃嫙php $_GET鑾峰彇js鍚庣殑鍙傛暟
* jsName涓簀s鏂囦欢鍚嶇О锛屽 jquery.js
* para涓哄弬鏁板悕
*/
function jsGet(jsName, para){
if(!jsName)return '';
jsName='/'+jsName+'?';
var script = $('script'), arr='';
for(var i=0; i-1){arr = script.eq(i).prop('src').split(jsName)[1]; break;}}
if(!arr || typeof(para)=='undefined' || !para)return '';
arr = arr.split('&');
para += '=';
for(i=0; i@media(max-width:767px){.ad-lamu, .ad-lamu a{max-height:180px;background-size:cover !important;}'
+ (ad.url ? '
' : '')
+ '
[鍏抽棴]'
+ '
');
}
//鎷夊箷骞垮憡
function wxyAD_lamu(ad, flag){
if(wxyAD_lamu_status==1){
if(typeof(flag)=='undefined')$('');
setTimeout(function(){wxyAD_lamu(ad, 1)}, 500);
return;
}
wxyAD_lamu_status=1;
$('').load(function(){
var obj=$(this).get(0);
var div=wxyAD_div(ad);
div.prependTo('body');
div=div.filter('div');
div.slideDown(500, function(){setTimeout(function(){div.slideUp(500, function(){$(this).remove();wxyAD_lamu_status=0;})}, 1e4)});
div.find('em').click(function(){div.slideUp(500, function(){$(this).remove();wxyAD_lamu_status=0;})});
});
}
//椤堕儴鍥哄畾骞垮憡
function wxyAD_fixed(ad){
var div = wxyAD_div(ad);
div.insertBefore(wxyAD_first_child).slideDown(300);
div.find('em').click(function(){div.slideUp(500, function(){$(this).remove();})});
}
//瀵硅仈骞垮憡
function wxyAD_duilian(ad){
if(ad.adtype==3){//涓や晶瀵硅仈骞垮憡宸﹀彸鍒嗗埆娣诲姞
ad.adtype=4; wxyAD_duilian(ad);
ad.adtype=5; wxyAD_duilian(ad);
return;
}
var adtype = ad.adtype==4 ? 'left' : 'right',
div = $('.js-wxy-ad-'+adtype),
top = ad.top>0 ? ad.top : (div.size() ? div.last().position().top+div.last().height()+10 : 70); //绗竴鏉″鑱斿箍鍛婇粯璁よ窛椤堕儴璺濈涓?0鍍忕礌
div = $(''
+ (ad.url ? '
' : '
')
+ '
X'
+ '
');
div.appendTo($('body'));
div.find('em').click(function(){div.remove()});
}