Authored by 王水玲

新潮

... ... @@ -16,13 +16,16 @@ lazyLoad($('img.lazy'));
$('body').addClass('star-class-body');
function loadIntimacyAvatar(myImage, src) {
var newSrc = '';
function setAvatar($userAvatar) {
var myImage = new Image(),
avatar;
// 部分老用户没有头像,显示默认头像
avatar = $userAvatar.data('avatar');
myImage.src = avatar;
myImage.onload = function() {
newSrc = 'background-image:url(' + src + ')';
$userAvatar.css('background-image', 'url(' + avatar + ')');
};
return newSrc;
}
// 日历弹出框显示及粉丝排行榜数据组装
... ... @@ -33,7 +36,6 @@ function intimacyData(data) {
signDay = data.signDay.split(','),
html = '',
style = '',
bgStyle = '',
nowDate = new Date(),
myImage = new Image(),
nowYear = nowDate.getFullYear(),
... ... @@ -59,17 +61,9 @@ function intimacyData(data) {
style = '';
}
if (data.fanCharts[i].img !== '' && data.fanCharts[i].img !== null) {
myImage.src = data.fanCharts[i].img;
bgStyle = loadIntimacyAvatar(myImage, data.fanCharts[i].img);
} else {
bgStyle = '';
}
html += '<li>' +
'<i class="rank-ico">' + data.fanCharts[i].num + '</i>' +
'<span data-avatar="' + data.fanCharts[i].img + '" style="' + bgStyle +
'" class="rank-avatar"></span>' +
'<span data-avatar="' + data.fanCharts[i].img + '" class="rank-avatar"></span>' +
'<span class="fans-name">' + data.fanCharts[i].name + '</span>' +
'<div class="fans-intimacy">亲密度<span class="' + style + '">' +
data.fanCharts[i].intimacyNum + '</span></div>' +
... ... @@ -78,6 +72,12 @@ function intimacyData(data) {
$ul.html(html);
$('.fan-charts-cont .rank-avatar').each(function(key, item) {
if ($(item).attr('data-avatar') !== '') {
setAvatar($(item));
}
});
$myIntimacy.find('span').html(data.todayIntimacy);
$increased.find('span').html(data.todayIntimacy);
... ... @@ -251,35 +251,10 @@ $('.add-intimacy').on('touchstart', function(event) {
// 关闭日历弹出窗事件
$('.pop-intimacy .pop-close, .classroom-mask').on('click', function() {
// $('.pop-intimacy').css({
// zIndex: '-1'
// }).hide();
// $('.classroom-mask').css({
// zIndex: '-1'
// }).hide();
// $('body').css({
// overflow: 'visible'
// });
// location.reload();
history.go(0);
});
function setAvatar() {
var $userAvatar = $('.user-head'),
myImage = new Image(),
avatar;
// 部分老用户没有头像,显示默认头像
avatar = $userAvatar.data('avatar');
myImage.src = avatar;
myImage.onload = function() {
$userAvatar.css('background-image', 'url(' + avatar + ')');
};
}
if ($('.user-head').attr('data-avatar') !== '') {
setAvatar();
setAvatar($('.user-head'));
}
\ No newline at end of file
... ...