Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix(avatar): 头像资源修正
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Sep 25, 2018
1 parent be49e73 commit e1e10e4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
avatar: {
get() {
const avatar = this.user.avatar || {};
return avatar.url;
return avatar.url || null;
},
set(val) {
this.user.avatar.url = val;
Expand Down
3 changes: 2 additions & 1 deletion src/page/UserHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,12 @@ export default {
this.$route.fullPath;
const signUrl =
this.$store.state.BROWSER.OS === "IOS" ? window.initUrl : shareUrl;
const avatar = this.user.avatar || {};
wechatShare(signUrl, {
title: this.user.name,
desc: this.user.bio,
link: shareUrl,
imgUrl: this.user.avatar.url || ""
imgUrl: avatar.url || ""
});
}
Expand Down
8 changes: 6 additions & 2 deletions src/page/group/detail/GroupPostDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
:style="{ zIndex: 5-index }"
:class="`m-avatar-box-${user.sex}`"
class="m-avatar-box tiny">
<img :src="user.avatar.url">
<img :src="getAvatar(user.avatar)">
</li>
</ul>
<span>{{ likeCount | formatNum }}人点赞</span>
Expand All @@ -87,7 +87,7 @@
:key="rew.id"
:class="`m-avatar-box-${rew.user.sex}`"
class="m-flex-grow0 m-flex-shrink0 m-art-rew m-avatar-box tiny">
<img :src="rew.user.avatar.url">
<img :src="getAvatar(rew.user.avatar)">
</li>
<li v-if="rewardList.length > 0" class="m-box m-aln-center">
<svg class="m-style-svg m-svg-def" style="fill:#bfbfbf">
Expand Down Expand Up @@ -573,6 +573,10 @@ export default {
this.commentCount -= 1;
this.$Message.success("删除评论成功");
});
},
getAvatar(avatar) {
avatar = avatar || {};
return avatar.url || null;
}
}
};
Expand Down
8 changes: 6 additions & 2 deletions src/page/news/NewsDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
:key="id"
:style="{ zIndex: 5-index }"
class="m-avatar-box tiny">
<img :src="user.avatar.url">
<img :src="getAvatar(user.avatar)">
</li>
</ul>
<span>{{ likeCount | formatNum }}人点赞</span>
Expand All @@ -61,7 +61,7 @@
:key="rew.id"
:class="`m-avatar-box-${rew.user.sex}`"
class="m-flex-grow0 m-flex-shrink0 m-art-rew m-avatar-box tiny">
<img :src="rew.user.avatar.url">
<img :src="getAvatar(rew.user.avatar)">
</li>
<li v-if="rewardList.length > 0" class="m-box m-aln-center">
<svg class="m-style-svg m-svg-def" style="fill:#bfbfbf">
Expand Down Expand Up @@ -497,6 +497,10 @@ export default {
this.fetchNews(() => {
this.$refs.loadmore.afterRefresh(true);
});
},
getAvatar(avatar) {
avatar = avatar || {};
return avatar.url || null;
}
}
};
Expand Down
8 changes: 6 additions & 2 deletions src/page/question/AnswerDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
:style="{ zIndex: 5-index }"
:class="`m-avatar-box-${user.sex}`"
class="m-avatar-box tiny">
<img :src="user.avatar.url">
<img :src="getAvatar(user.avatar)">
</li>
</ul>
<span>{{ likeCount | formatNum }}人点赞</span>
Expand All @@ -68,7 +68,7 @@
:key="rew.id"
:class="`m-avatar-box-${rew.user.sex}`"
class="m-flex-grow0 m-flex-shrink0 m-art-rew m-avatar-box tiny">
<img :src="rew.user.avatar.url">
<img :src="getAvatar(rew.user.avatar)">
</li>
<li v-if="rewardList.length > 0" class="m-box m-aln-center">
<svg class="m-style-svg m-svg-def" style="fill:#bfbfbf">
Expand Down Expand Up @@ -195,6 +195,10 @@ export default {
},
isMine() {
return this.user.id === this.CURRENTUSER.id;
},
getAvatar(avatar) {
avatar = avatar || {};
return avatar.url || null;
}
},
created() {
Expand Down

0 comments on commit e1e10e4

Please sign in to comment.