您使用的浏览器版本过低,为保证正常浏览,请前往下载新版本
$(document).ready(function() {
// 新鲜事日期
$.ajax({
type: 'get',
url: '/login/AsynApi/getNewsList',
success: function(res) {
var num = 0;
$.each(res.data, function(index, item) {
var url = item.is_out == "1" ? item.url : 'http://v.ruc.edu.cn/account/news/detail/id/' + item.id;
if (index == 0) {
var date = item.publishdate.split(' ')[0].split('-');
var day = date[2];
var month = date[1];
var year = date[0];
$('.nothingNew-title > h3 a').text(item.title).attr({
'href': url,
'data-id': item.id,
'isOut': item.is_out
}).on('click', function() {
articleCount(this);
});
$('.nothingNew-content a').text(item.summary || '...').attr({
'href': url,
'data-id': item.id,
'isOut': item.is_out
}).on('click', function() {
articleCount(this);
});
} else {
$('.nothingNew-main-right li').eq(num).find('a').text(item.title).attr({
'href': url,
'data-id': item.id,
'isOut': item.is_out
}).on('click', function() {
articleCount(this);
});
if (item.is_out == "1") {
$('.nothingNew-main-right li').eq(num).append('
');
}
num ++;
}
})
},
error: function(err) {
console.log(err);
}
})
// banner
$.ajax({
type: 'get',
url: '/login/AsynApi/getBanner',
success: function(res) {
$('.nothingNew-right a')
.eq(0)
.attr('href', res.data[0].url)
.on('click', function() { count('banner', this) })
.find('img')
.attr('src', res.data[0].pic);
$('.nothingNew-right a')
.eq(1)
.attr('href', res.data[1].url)
.on('click', function() { count('banner', this) })
.find('img')
.attr('src', res.data[1].pic);
}
})
$.ajax({
type: 'get',
url: '/login/AsynApi/getLoginPt',
success: function(res) {
var urlType = checkFileType(res.data[0].url);
if (urlType == 'mp4') {
$('#video').attr('src', res.data[0].url);
$('#bannerImg').hide();
} else {
$('#bannerImg').attr('src', res.data[0].url);
$('#video').hide();
}
// console.log(res);
}
})
// 数字处理
function thousands(num){
var splits = [],res = [];
var splits = num.toString().split(".");
splits[0].split("").reverse().map(function(item, i) {
if (i % 3 == 0 && i != 0) {
res.push(",");
}
res.push(item);
});
return res.reverse().join("")+(splits.length > 1 ? "." + splits[1] : "");
}
var video = $('#video').get(0);
$('.login-banner').on('click', function() {
video.play();
count('video');
})
var loginSwiper = new Swiper('.login-swiper', {
slidesPerView : 2,
spaceBetween : 20,
pagination: {
el: '.swiper-pagination',
},
})
$('.login-box a').on('click', function() { count('other', this) } );
$('.login-box-mp a').on('click', function() { count('other', this) });
function count(v, ele) {
var type = '/';
var index = 0;
var _this = $(ele);
switch ( v ) {
case 'video':
type = "index_play"
break;
case 'banner':
index = _this.index();
index == 0 ? type = "index_banner1" : type = "index_banner2";
break;
case 'other':
index = _this.parent().index();
switch (index) {
case 0:
type = "index_xyk";
break;
case 1:
type = "index_cloud";
break;
case 2:
type = "index_email";
break;
case 3:
type = "index_xyw";
break;
case 4:
type = "index_vpn";
break;
}
}
$.ajax({
type: 'post',
data: {
type: type
},
url: '/login/AsynApi/addCount'
})
}
function articleCount(ele) {
var _this = $(ele);
var isOut = _this.attr('isOut') - 0;
if ( isOut ) {
var id = _this.attr('data-id') - 0;
$.ajax({
type: 'post',
data: {
id: id
},
url: '/login/AsynApi/addCount',
})
}
}
var webInfo = {
visitors : '/',
onlineEquipment : '/',
email : '',
service : ''
}
// 网站信息统计
// setInterval(function() {
$.ajax({
type: 'get',
url: "/login/AsynApi/getApiList",
success: function(res) {
$.each(res.data, function(key, item) {
if (item !== webInfo[key]) {
$('.' + key).text(thousands(item));
webInfo[key] = item;
}
})
},
error: function(err) {
$('.infoItem h3').text('');
}
})
// }, 1000);
/**
* 获取文件类型
* @param {String} 文件地址
* @returns 文件后缀
*/
function checkFileType(filename) {
var suffix = filename.substring(filename.lastIndexOf('.') + 1).toLowerCase();
var type = "";
switch (suffix) {
case 'mp4':
type = 'mp4';
break;
case 'ppt':
case 'pptx':
case 'doc':
case 'docx':
case 'pdf':
type = 'office';
break;
case 'jpg':
case 'jpeg':
case 'png':
case 'bmp':
case 'gif':
type = 'pic';
break;
}
return type;
}
});