From b4d6944076f1df6eedaae35c4c2a7072fe988e8a Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期二, 30 四月 2024 15:34:02 +0800 Subject: [PATCH] update: package-lock.json --- PAMapp/components/editConsultantAvatar.vue | 51 +++++++++++++++++++++++++++++---------------------- 1 files changed, 29 insertions(+), 22 deletions(-) diff --git a/PAMapp/components/editConsultantAvatar.vue b/PAMapp/components/editConsultantAvatar.vue index a02b772..d36439d 100644 --- a/PAMapp/components/editConsultantAvatar.vue +++ b/PAMapp/components/editConsultantAvatar.vue @@ -6,33 +6,40 @@ ref="upload" action="#" :auto-upload="false" - :on-change="handleAvatarSuccess" + :on-change="handleAvatarUploaded" :show-file-list="false" accept="image/png, image/jpeg, image/jpg"> <el-avatar - :size="150" :src="imgSrc" class="pam-avatar cursor--pointer fix-chrome-click--issue" ></el-avatar> - <div class="pam-avatar-uploader__action-label mt-10 cursor--pointer" >閮剖����</div> + <div class="text--center mt-10"> + <el-button + >閮剖����</el-button> + </div> </el-upload> <div v-if="showResetAvatarBtn" class="pam-avatar-uploader__action-label text--center mt-10 cursor--pointer" - @click="resetAvatar"> - �������� + style="line-height: 1.5" + > + <i class="icon-information"></i> + 隢����銝������������� + <span class="text--primary cursor--pointer text--underline" @click="resetAvatar">���迨����</span> + </div> </div> </template> <script lang="ts"> + import { Vue, Component, Prop, PropSync } from 'nuxt-property-decorator'; + import { MessageBox } from 'element-ui'; import { MessageBoxData } from 'element-ui/types/message-box'; - import { Vue, Component, Prop, PropSync } from 'nuxt-property-decorator'; + import myConsultantService from '~/shared/services/my-consultant.service'; - import _ from 'lodash'; @Component export default class editConsultantAvatar extends Vue { @@ -52,29 +59,29 @@ if(this.agentNo) this.initConsultantAvatar() } - initConsultantAvatar(): void { + private initConsultantAvatar(): void { myConsultantService.getConsultantAvatar(this.agentNo) .then(base64=> this.splitBase64WithCommon(base64) ) } - handleAvatarSuccess(file:any, fileList:any) { - const isFollowUploadRule =_.includes(file.raw.type,'image/'); - isFollowUploadRule ? this.getImgSrc(file) : this.showErrorMsg() - } - - getImgSrc(file:any):void{ - const blob = file.raw; - this.blobToBase64(blob).then(base64=>{ - this.splitBase64WithCommon(base64 as string); - }); - } - ////////////////////////////////////////////////////////////////////// resetAvatar(): void { this.imgSrc = this._imgSrc; + } + + handleAvatarUploaded(file:any): void { + const isFollowUploadRule = file.raw.type.includes('image/'); + isFollowUploadRule ? this.getImgSrc(file) : this.showFileUploadErrorMsg() + } + + private getImgSrc(file:any):void{ + const blob = file.raw; + this.blobToBase64(blob).then(base64=>{ + this.splitBase64WithCommon(base64 as string); + }); } private blobToBase64(blob:File):Promise<string | ArrayBuffer | null> { @@ -88,7 +95,7 @@ } private splitBase64WithCommon(base64: string): void { - const splitBase64=_.split(base64, ','); // �鈭�� data:image , base64 閫������; + const splitBase64 = base64.split(','); // �鈭�� data:image , base64 閫������; this.syncPhotoBase64 = splitBase64[1]; // NOTE: �����誑 agentNO ���� avatar ��仃���� // ����迨��靘蝭���*蝷�'������'���瘜�� [Tomas, 2022/1/3] @@ -98,7 +105,7 @@ this.imgSrc = base64; } - private showErrorMsg():Promise<MessageBoxData>{ + private showFileUploadErrorMsg():Promise<MessageBoxData>{ return MessageBox({ message:`<div class="message-header">銝�撘�炊</div> <div class="message-content">隢�甇�蝣箏���</div>`, -- Gitblit v1.8.0