<script>
jQuery(function($) {
(function() {
var $bnBar = $(''),
$topBn = $('#J_topBn'),
$topBnBackdrop = $('#J_topBackdrop'),
$counter = $('.J_counter'),
$closeBnTrigger = $('.J_closeBn'),
timeoutTopBn,
bnCounter = 10;

function countDown() {
bnCounter -= 1;
if (bnCounter < 1) {
closeBn();
}
else {
$counter.text(bnCounter + '秒后');
}
}

function closeBn() {
window.clearInterval(timeoutTopBn);
$counter.remove();
$topBn.animate({
'top': -$topBn.height()
}, 500, function() {
$topBn.hide();
$topBnBackdrop.hide();
});

var expireDate;
expireDate = new Date(Math.round(new Date().getTime()) + 1000 * 60 * 60 * 6);

XIAOMI.app.cookie('indexTopBn', '1', {
expires: expireDate
});
}

//$bnBar.insertBefore($('.site-topbar'));

if (XIAOMI.app.cookie('indexTopBn') !== '1') {
$topBn.show();
$topBnBackdrop.height($(document).height()).show();

timeoutTopBn = window.setInterval(function() {
countDown();
}, 1000);

$closeBnTrigger.on('click', function(e) {
e.preventDefault();
closeBn();
});
}
}());

(function() {
if (!$('.site-bn').length) {
if(window.location.href.split('?').length < 2){
return false;
}
if (window.location.href.split('?')[1].indexOf('f=xiaomi') !== -1) {

var timeoutModalFrom,
modalFromCounter = 5,
$modalFrom = $('<div class="modal modal-from-xiaomi"><div class="modal-body"><a class="btn-enter J_closeModalFrom" href="javascript: void(0);"><span class="J_xmCounter">10秒后</span> 进入小米网</a><span class="close J_closeModalFrom" data-dismiss="modal"><i class="iconfont"></i></span></div></div>');

function modalCountDown() {
modalFromCounter -= 1;

if (modalFromCounter < 1) {
closeModalFrom();
}
else {
$('.J_xmCounter').text(modalFromCounter + '秒后');
}
}

function closeModalFrom() {
window.clearInterval(timeoutModalFrom);
$modalFrom.modal('hide');
var expireDate = new Date(Math.round(new Date().getTime()) + 1000 * 60 * 60 * 2);
XIAOMI.app.cookie('indexFromXiaomi', '1', {
expires: expireDate
});
}

if (XIAOMI.app.cookie('indexFromXiaomi') !== '1') {
$('body').append($modalFrom);
$modalFrom.modal({
'show': true
});

timeoutModalFrom = window.setInterval(function() {
modalCountDown();
}, 1000);

$('.J_closeModalFrom').on('click', function(e) {
e.preventDefault();
closeModalFrom();
});
}
}
}
}());

});
</script>

05-08 08:12