filecache
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
<template>
|
||||
<u-avatar @longpress="longpress" @click="click" @onError="errorHandle" :src="getAvatarUrl" :text="avatarText"
|
||||
<u-avatar @longpress="longpress" @click="click" @onError="errorHandle" :src="cachesrc" :text="avatarText"
|
||||
bg-color="#cdcdcd" :defaultUrl="getDdefaultUrl" :shape="shape" :size="size" mode="aspectFill" font-size="14">
|
||||
</u-avatar>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import defaultGroupIcon from "@/static/images/contact_my_group.png";
|
||||
import defaultUserIcon from "@/static/images/user/avatar.png";
|
||||
import defaultNotifyIcon from "@/static/images/default_notify_icon.png";
|
||||
import util from "@/util";
|
||||
import md5 from "md5";
|
||||
export default {
|
||||
name: "MyAvatar",
|
||||
props: {
|
||||
@@ -34,26 +36,37 @@
|
||||
data() {
|
||||
return {
|
||||
avatarText: undefined,
|
||||
cachesrc:"",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
getAvatarUrl() {
|
||||
if (this.src) {
|
||||
return util.cdn(this.src);
|
||||
}
|
||||
if (this.isGroup) {
|
||||
return defaultGroupIcon;
|
||||
}
|
||||
if (this.isNotify) {
|
||||
return defaultNotifyIcon;
|
||||
}
|
||||
this.avatarText = this.desc ? this.desc.slice(0, 1) : "未知";
|
||||
return "";
|
||||
},
|
||||
getDdefaultUrl() {
|
||||
return this.isGroup ? defaultGroupIcon : undefined;
|
||||
return this.isGroup ? defaultGroupIcon : defaultUserIcon;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
//_this.cachesrc = plus.io.convertAbsoluteFileSystem();
|
||||
const _this = this;
|
||||
if (this.src) {
|
||||
util.cacheFile(util.cdn(this.src),'avatar').then(res=>{
|
||||
_this.avatarText=""
|
||||
_this.cachesrc = res;
|
||||
//_this.cachesrc = plus.io.convertAbsoluteFileSystem(res);
|
||||
//console.log(_this.cachesrc);
|
||||
});
|
||||
return ;
|
||||
}
|
||||
if (this.isGroup) {
|
||||
_this.cachesrc = defaultGroupIcon;
|
||||
return ;
|
||||
}
|
||||
if (this.isNotify) {
|
||||
_this.cachesrc = defaultNotifyIcon;
|
||||
return ;
|
||||
}
|
||||
this.avatarText = this.desc ? this.desc.slice(0, 1) : "未知";
|
||||
return "";
|
||||
},
|
||||
methods: {
|
||||
errorHandle() {
|
||||
this.avatarText = this.desc ? this.desc.slice(0, 1) : "未知";
|
||||
@@ -70,8 +83,9 @@
|
||||
this.$emit("longpress");
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
src() {
|
||||
src(nv,ov) {
|
||||
this.redirectShow();
|
||||
},
|
||||
desc() {
|
||||
|
||||
Reference in New Issue
Block a user