Showing
1 changed file
with
15 additions
and
40 deletions
@@ -16,13 +16,16 @@ lazyLoad($('img.lazy')); | @@ -16,13 +16,16 @@ lazyLoad($('img.lazy')); | ||
16 | 16 | ||
17 | $('body').addClass('star-class-body'); | 17 | $('body').addClass('star-class-body'); |
18 | 18 | ||
19 | -function loadIntimacyAvatar(myImage, src) { | ||
20 | - var newSrc = ''; | 19 | +function setAvatar($userAvatar) { |
20 | + var myImage = new Image(), | ||
21 | + avatar; | ||
21 | 22 | ||
23 | + // 部分老用户没有头像,显示默认头像 | ||
24 | + avatar = $userAvatar.data('avatar'); | ||
25 | + myImage.src = avatar; | ||
22 | myImage.onload = function() { | 26 | myImage.onload = function() { |
23 | - newSrc = 'background-image:url(' + src + ')'; | 27 | + $userAvatar.css('background-image', 'url(' + avatar + ')'); |
24 | }; | 28 | }; |
25 | - return newSrc; | ||
26 | } | 29 | } |
27 | 30 | ||
28 | // 日历弹出框显示及粉丝排行榜数据组装 | 31 | // 日历弹出框显示及粉丝排行榜数据组装 |
@@ -33,7 +36,6 @@ function intimacyData(data) { | @@ -33,7 +36,6 @@ function intimacyData(data) { | ||
33 | signDay = data.signDay.split(','), | 36 | signDay = data.signDay.split(','), |
34 | html = '', | 37 | html = '', |
35 | style = '', | 38 | style = '', |
36 | - bgStyle = '', | ||
37 | nowDate = new Date(), | 39 | nowDate = new Date(), |
38 | myImage = new Image(), | 40 | myImage = new Image(), |
39 | nowYear = nowDate.getFullYear(), | 41 | nowYear = nowDate.getFullYear(), |
@@ -59,17 +61,9 @@ function intimacyData(data) { | @@ -59,17 +61,9 @@ function intimacyData(data) { | ||
59 | style = ''; | 61 | style = ''; |
60 | } | 62 | } |
61 | 63 | ||
62 | - if (data.fanCharts[i].img !== '' && data.fanCharts[i].img !== null) { | ||
63 | - myImage.src = data.fanCharts[i].img; | ||
64 | - bgStyle = loadIntimacyAvatar(myImage, data.fanCharts[i].img); | ||
65 | - } else { | ||
66 | - bgStyle = ''; | ||
67 | - } | ||
68 | - | ||
69 | html += '<li>' + | 64 | html += '<li>' + |
70 | '<i class="rank-ico">' + data.fanCharts[i].num + '</i>' + | 65 | '<i class="rank-ico">' + data.fanCharts[i].num + '</i>' + |
71 | - '<span data-avatar="' + data.fanCharts[i].img + '" style="' + bgStyle + | ||
72 | - '" class="rank-avatar"></span>' + | 66 | + '<span data-avatar="' + data.fanCharts[i].img + '" class="rank-avatar"></span>' + |
73 | '<span class="fans-name">' + data.fanCharts[i].name + '</span>' + | 67 | '<span class="fans-name">' + data.fanCharts[i].name + '</span>' + |
74 | '<div class="fans-intimacy">亲密度<span class="' + style + '">' + | 68 | '<div class="fans-intimacy">亲密度<span class="' + style + '">' + |
75 | data.fanCharts[i].intimacyNum + '</span></div>' + | 69 | data.fanCharts[i].intimacyNum + '</span></div>' + |
@@ -78,6 +72,12 @@ function intimacyData(data) { | @@ -78,6 +72,12 @@ function intimacyData(data) { | ||
78 | 72 | ||
79 | $ul.html(html); | 73 | $ul.html(html); |
80 | 74 | ||
75 | + $('.fan-charts-cont .rank-avatar').each(function(key, item) { | ||
76 | + if ($(item).attr('data-avatar') !== '') { | ||
77 | + setAvatar($(item)); | ||
78 | + } | ||
79 | + }); | ||
80 | + | ||
81 | $myIntimacy.find('span').html(data.todayIntimacy); | 81 | $myIntimacy.find('span').html(data.todayIntimacy); |
82 | $increased.find('span').html(data.todayIntimacy); | 82 | $increased.find('span').html(data.todayIntimacy); |
83 | 83 | ||
@@ -251,35 +251,10 @@ $('.add-intimacy').on('touchstart', function(event) { | @@ -251,35 +251,10 @@ $('.add-intimacy').on('touchstart', function(event) { | ||
251 | 251 | ||
252 | // 关闭日历弹出窗事件 | 252 | // 关闭日历弹出窗事件 |
253 | $('.pop-intimacy .pop-close, .classroom-mask').on('click', function() { | 253 | $('.pop-intimacy .pop-close, .classroom-mask').on('click', function() { |
254 | - // $('.pop-intimacy').css({ | ||
255 | - // zIndex: '-1' | ||
256 | - // }).hide(); | ||
257 | - // $('.classroom-mask').css({ | ||
258 | - // zIndex: '-1' | ||
259 | - // }).hide(); | ||
260 | - | ||
261 | - // $('body').css({ | ||
262 | - // overflow: 'visible' | ||
263 | - // }); | ||
264 | - | ||
265 | - // location.reload(); | ||
266 | - | ||
267 | history.go(0); | 254 | history.go(0); |
268 | }); | 255 | }); |
269 | 256 | ||
270 | -function setAvatar() { | ||
271 | - var $userAvatar = $('.user-head'), | ||
272 | - myImage = new Image(), | ||
273 | - avatar; | ||
274 | - | ||
275 | - // 部分老用户没有头像,显示默认头像 | ||
276 | - avatar = $userAvatar.data('avatar'); | ||
277 | - myImage.src = avatar; | ||
278 | - myImage.onload = function() { | ||
279 | - $userAvatar.css('background-image', 'url(' + avatar + ')'); | ||
280 | - }; | ||
281 | -} | ||
282 | 257 | ||
283 | if ($('.user-head').attr('data-avatar') !== '') { | 258 | if ($('.user-head').attr('data-avatar') !== '') { |
284 | - setAvatar(); | 259 | + setAvatar($('.user-head')); |
285 | } | 260 | } |
-
Please register or login to post a comment