Showing
3 changed files
with
16 additions
and
5 deletions
@@ -5,9 +5,12 @@ | @@ -5,9 +5,12 @@ | ||
5 | */ | 5 | */ |
6 | var $ = require('jquery'); | 6 | var $ = require('jquery'); |
7 | var $userAvatar = $('.user-avatar'); | 7 | var $userAvatar = $('.user-avatar'); |
8 | -var myImage = new Image(); | 8 | +var myImage = new Image(), |
9 | + avatar; | ||
9 | 10 | ||
10 | -myImage.src = $userAvatar.attr('src'); | ||
11 | -myImage.onerror = function() { | ||
12 | - $userAvatar.attr('src', 'http://static.dev.yohobuy.com/img/me/index/user-avatar.png'); | 11 | +// 部分老用户没有头像,显示默认头像 |
12 | +avatar = $userAvatar.data('avatar'); | ||
13 | +myImage.src = avatar; | ||
14 | +myImage.onload = function() { | ||
15 | + $userAvatar.css('background-image', 'url(' + avatar + ')'); | ||
13 | }; | 16 | }; |
@@ -17,6 +17,14 @@ | @@ -17,6 +17,14 @@ | ||
17 | } | 17 | } |
18 | height: 80rem / $pxConvertRem; | 18 | height: 80rem / $pxConvertRem; |
19 | border-bottom: 1px solid #e0e0e0; | 19 | border-bottom: 1px solid #e0e0e0; |
20 | + | ||
21 | + .user-avatar { | ||
22 | + width: 100%; | ||
23 | + height: 100%; | ||
24 | + background-image: image-url("me/index/user-avatar.png"); | ||
25 | + background-size: 100%; | ||
26 | + } | ||
27 | + | ||
20 | span{ | 28 | span{ |
21 | &:first-of-type{ | 29 | &:first-of-type{ |
22 | color: #444; | 30 | color: #444; |
1 | {{> layout/header}} | 1 | {{> layout/header}} |
2 | <div class="personal-details"> | 2 | <div class="personal-details"> |
3 | <ul> | 3 | <ul> |
4 | - <li><span>头像</span><span><i class="head-portrait"><img class="user-avatar" src="{{ head_ico }}"></i></span></li> | 4 | + <li><span>头像</span><span><i class="head-portrait"><span class="user-avatar" data-avatar="{{ head_ico }}"></span></i></span></li> |
5 | <li><span>昵称</span><span>{{ username }}</span></li> | 5 | <li><span>昵称</span><span>{{ username }}</span></li> |
6 | <li><span>性别</span><span>{{ gender }}</span></li> | 6 | <li><span>性别</span><span>{{ gender }}</span></li> |
7 | <li><span>生日</span><span>{{ birthday }}</span></li> | 7 | <li><span>生日</span><span>{{ birthday }}</span></li> |
-
Please register or login to post a comment