2024-08-05 16:16:08 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="accountEdit_page">
|
|
|
|
|
<div class="accountEdit_page_head">
|
|
|
|
|
<div class="upload_item">
|
|
|
|
|
<div class="upload_file_item">
|
|
|
|
|
<a-upload
|
|
|
|
|
:capture="null"
|
|
|
|
|
list-type="picture-card"
|
|
|
|
|
:before-upload="beforeUpload"
|
|
|
|
|
v-model:file-list="fileList"
|
|
|
|
|
:customRequest="function(){}"
|
|
|
|
|
:maxCount="1"
|
|
|
|
|
accept=".jpg,.png,.jpeg,.bmp"
|
|
|
|
|
@change="fileUploadChange"
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
class="upload_tip_block"
|
|
|
|
|
>
|
2024-08-23 10:19:02 +08:00
|
|
|
<!-- <i class="fi fi-br-upload"></i> -->
|
|
|
|
|
<img :src="uploadUrl" alt="">
|
2024-08-05 16:16:08 +08:00
|
|
|
</div>
|
|
|
|
|
</a-upload>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="accountEdit_page_body">
|
|
|
|
|
<div class="accountEdit_page_body_item">
|
2024-09-03 16:39:06 +08:00
|
|
|
<div class="accountEdit_page_body_item_name">{{$t('account.userName')}}:</div>
|
2024-08-05 16:16:08 +08:00
|
|
|
<div class="accountEdit_page_body_item_inut">
|
2024-08-23 10:19:02 +08:00
|
|
|
<input type="text" disabled :value="cookieUserInfo.userName">
|
2024-08-05 16:16:08 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="accountEdit_page_body_item">
|
2024-09-03 16:39:06 +08:00
|
|
|
<div class="accountEdit_page_body_item_name">{{$t('account.email')}}:</div>
|
2024-08-05 16:16:08 +08:00
|
|
|
<div class="accountEdit_page_body_item_inut">
|
2024-08-23 10:19:02 +08:00
|
|
|
<input type="text" disabled :value="cookieUserInfo.email">
|
2024-08-05 16:16:08 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="accountEdit_page_body_item">
|
2024-08-23 10:19:02 +08:00
|
|
|
<div class="started_btn" @click="setSubmit">
|
2024-09-03 16:39:06 +08:00
|
|
|
{{$t('account.Submit')}}
|
2024-08-05 16:16:08 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Cropper ref="Cropper" @handleCropperSuccess="handleCropperSuccess" @closeCropper="deletUploadFile()" :cropperFileData="cropperFileData" :isRound="true"></Cropper>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts">
|
2024-08-23 10:19:02 +08:00
|
|
|
import { defineComponent,computed,ref,reactive,nextTick,toRefs,createVNode, onMounted} from 'vue'
|
2024-08-05 16:16:08 +08:00
|
|
|
import { Https } from "@/tool/https";
|
|
|
|
|
import { Modal,message } from 'ant-design-vue';
|
|
|
|
|
import { useStore } from "vuex";
|
|
|
|
|
import Cropper from '@/component/HomePage/Cropper.vue'
|
|
|
|
|
import { setCookie, getCookie, WriteCookie } from "@/tool/cookie";
|
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
components:{
|
|
|
|
|
Cropper,
|
|
|
|
|
},
|
|
|
|
|
setup() {
|
|
|
|
|
const store = useStore();
|
2024-08-23 10:19:02 +08:00
|
|
|
let userInfo:any= computed(()=>{
|
|
|
|
|
return store.state.UserHabit.userInfo
|
|
|
|
|
})
|
|
|
|
|
let cookieUserInfo = JSON.parse(getCookie('userInfo') as any)
|
|
|
|
|
let accountHomeData:any = reactive({
|
2024-08-05 16:16:08 +08:00
|
|
|
cropperFileData:{name:'',uid:''}, //裁剪的原始文件数据
|
2024-08-23 10:19:02 +08:00
|
|
|
uploadUrl:userInfo.value?.avatar,
|
|
|
|
|
uploadFile:undefined,
|
2024-08-05 16:16:08 +08:00
|
|
|
token:'',
|
|
|
|
|
fileList:[]
|
|
|
|
|
})
|
|
|
|
|
let Cropper = ref()
|
|
|
|
|
// provide('exhibitionList',exhibitionList)
|
|
|
|
|
let handleCropperSuccess = (event:any)=>{
|
2024-08-19 10:36:46 +08:00
|
|
|
let {file, fileData,base64} =event
|
2024-08-23 10:19:02 +08:00
|
|
|
accountHomeData.fileList[0].status = 'done'
|
|
|
|
|
accountHomeData.uploadUrl = base64
|
|
|
|
|
accountHomeData.uploadFile = file
|
2024-08-05 16:16:08 +08:00
|
|
|
Cropper.value.closeCropper()
|
|
|
|
|
}
|
|
|
|
|
let beforeUpload=(file:any,fileList:any)=>{
|
|
|
|
|
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg' || file.type === 'image/bmp';
|
|
|
|
|
if (!isJpgOrPng) {
|
|
|
|
|
message.info(useI18n().t('PrintboardUpload.jsContent1'));
|
|
|
|
|
}
|
|
|
|
|
const isLt2M = file.size / 1024 / 1024 < 5;
|
|
|
|
|
if (!isLt2M) {
|
|
|
|
|
message.info(useI18n().t('PrintboardUpload.jsContent2'));
|
|
|
|
|
}
|
|
|
|
|
if(isJpgOrPng && isLt2M){
|
|
|
|
|
// }else{
|
|
|
|
|
// return (isJpgOrPng && isLt2M) || Upload.LIST_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
let fileUploadChange = (data:any)=>{
|
|
|
|
|
let file = data.file
|
|
|
|
|
// file.id = res.data.id?res.data.id:""
|
|
|
|
|
var reader = new FileReader();
|
|
|
|
|
reader.onload = (e:any) => {
|
|
|
|
|
let data_new;
|
|
|
|
|
if (typeof e.target.result === 'object') {
|
|
|
|
|
// 把Array Buffer转化为blob 如果是base64不需要
|
|
|
|
|
data_new = window.URL.createObjectURL(new Blob([e.target.result]));
|
|
|
|
|
} else {
|
|
|
|
|
data_new = e.target.result;
|
|
|
|
|
}
|
|
|
|
|
Cropper.value.getOptionImg(data_new)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
// 转化为base64
|
|
|
|
|
// reader.readAsDataURL(file)
|
|
|
|
|
// 转化为blob
|
|
|
|
|
reader.readAsArrayBuffer(file.originFileObj);
|
|
|
|
|
Cropper.value.changeShowModal(true)
|
|
|
|
|
}
|
|
|
|
|
let deletUploadFile = () => {
|
|
|
|
|
accountHomeData.fileList = []
|
|
|
|
|
// let index = -1
|
|
|
|
|
// this.fileList.forEach((ele:any,index1:any) => {
|
|
|
|
|
// if(this.cropperFileData.uid === ele.uid){
|
|
|
|
|
// index = index1
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if(index > -1){
|
|
|
|
|
// this.fileList.splice(index, 1)
|
|
|
|
|
// }
|
|
|
|
|
}
|
2024-08-23 10:19:02 +08:00
|
|
|
let setSubmit = ()=>{
|
|
|
|
|
if(!accountHomeData.uploadFile)return
|
|
|
|
|
let param = new FormData();
|
|
|
|
|
param.append('file',accountHomeData.uploadFile);
|
|
|
|
|
let config:any = {headers:{'Content-Type':'multipart/form-data','Accept':'*/*' }}
|
|
|
|
|
Https.axiosPost(Https.httpUrls.uploadAvatar,param,config)
|
|
|
|
|
.then((rv)=>{
|
|
|
|
|
let data = {
|
|
|
|
|
avatar : rv
|
|
|
|
|
}
|
|
|
|
|
store.commit("setUserInfo", data)
|
|
|
|
|
message.success('提交成功')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
2024-08-05 16:16:08 +08:00
|
|
|
return{
|
|
|
|
|
...toRefs(accountHomeData),
|
2024-08-23 10:19:02 +08:00
|
|
|
userInfo,
|
|
|
|
|
cookieUserInfo,
|
2024-08-05 16:16:08 +08:00
|
|
|
Cropper,
|
|
|
|
|
handleCropperSuccess,
|
|
|
|
|
beforeUpload,
|
|
|
|
|
fileUploadChange,
|
|
|
|
|
deletUploadFile,
|
2024-08-23 10:19:02 +08:00
|
|
|
setSubmit,
|
2024-08-05 16:16:08 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data(){
|
|
|
|
|
return{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.accountEdit_page{
|
|
|
|
|
padding: 8rem 5rem;
|
|
|
|
|
.accountEdit_page_head{
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
width: 20rem;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
position: relative;
|
|
|
|
|
img{
|
2024-08-19 10:36:46 +08:00
|
|
|
width: 15rem;
|
2024-09-30 15:43:37 +08:00
|
|
|
object-fit: contain;
|
2024-08-19 10:36:46 +08:00
|
|
|
height: 15rem;
|
2024-08-05 16:16:08 +08:00
|
|
|
border-radius: 50%;
|
2024-08-23 10:19:02 +08:00
|
|
|
background: #fff;
|
2024-08-05 16:16:08 +08:00
|
|
|
}
|
|
|
|
|
.accountEdit_page_head_upload{
|
|
|
|
|
width: auto;
|
|
|
|
|
}
|
|
|
|
|
.upload_item{
|
2024-08-23 10:19:02 +08:00
|
|
|
:deep(.ant-upload-list-picture-card-container){
|
|
|
|
|
display: none !important;
|
|
|
|
|
}
|
2024-08-05 16:16:08 +08:00
|
|
|
}
|
2024-08-23 10:19:02 +08:00
|
|
|
|
2024-08-05 16:16:08 +08:00
|
|
|
margin-bottom: 5rem;
|
|
|
|
|
}
|
|
|
|
|
.accountEdit_page_body{
|
|
|
|
|
.accountEdit_page_body_item{
|
|
|
|
|
display: flex;
|
|
|
|
|
margin-bottom: 5rem;
|
|
|
|
|
width: 100%;
|
|
|
|
|
.started_btn{
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
input,textarea{
|
|
|
|
|
padding-left: 2rem;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
border: 1px solid #dcdfe6;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
.accountEdit_page_body_item_name{
|
|
|
|
|
color: #606266;
|
|
|
|
|
width: 14rem;
|
|
|
|
|
text-align: right;
|
|
|
|
|
}
|
|
|
|
|
.accountEdit_page_body_item_inut{
|
|
|
|
|
margin-left: 2rem;
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.accountEdit_page_body_item:last-child{
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|