用户上传完善

This commit is contained in:
2023-07-08 01:00:34 +08:00
parent eaffa1ace3
commit fc64a179e8
5 changed files with 106 additions and 30 deletions

View File

@@ -20,7 +20,7 @@
<div style="display: flex;flex-direction: column;margin-left: 15px;">
<div style="display: flex;flex-direction: row;align-items: center;justify-content: flex-start;">
<span style="font-size: 20px;font-weight: bold;">{{username}}</span>
<span style="font-size: 15px;font-weight: bold;color: #3b82f6;margin-left: 10px">Lv.1</span>
<span style="font-size: 15px;font-weight: bold;color: #3b82f6;margin-left: 10px">Lv.{{userLevel}}</span>
</div>
<span style="display: flex;justify-content:flex-start;margin-top: 10px;color: #6b7280;font-size: 15px">你是 HelloGitHub 社区的第<span style="font-size: 16px;color:#2b2e33;font-weight: bold "> {{userId}} </span>位用户 {{creatTime}} 加入</span>
<span style="display: flex;justify-content: flex-start;margin-top: 10px;color: #6b7280;font-size: 15px">
@@ -104,7 +104,8 @@
append-to-body
:close-on-click-modal="false"
>
<div style="display: flex;flex-direction: row;align-items: center;justify-content: space-between">
<span style="font-size: 14px;color: #9ca3af">选择一种方式即可</span>
<div style="margin-top: 10px;display: flex;flex-direction: row;align-items: center;justify-content: space-between">
<el-input placeholder="请输入头像链接" style="width: 17vw" v-model="AvatarUrl">
<template slot="prepend">url:</template>
</el-input>
@@ -158,12 +159,25 @@ export default {
article:[],
openChangeAvatar:false,
AvatarUrl:'',
imageUrl:'',
imageUrl:'http://localhost:8082/helloGithub_war_exploded/retUserAv',
userLevel:null,
}
},
mounted() {
this.getUserInfo()
this.getUserDetail();
setTimeout(()=>{
this.updateUserLevel();
this.getUserInfo();
},1000)
// this.changeAvatarByLocal();
},
created() {
this.updateUserLevel();
this.getUserInfo();
},
watch: {
$route () {
@@ -171,7 +185,7 @@ export default {
this.getUserInfo() //重新调用http请求实现页面的重新渲染
this.getUserDetail();
}
}
},
},
computed: {
headers() {
@@ -200,7 +214,8 @@ export default {
that.creatTime=res.data.creatTime;
that.projectNum=res.data.projectNum;
that.userId=res.data.userId;
that.imageUrl=res.data.userAvatar;
// that.imageUrl=res.data.userAvatar;
that.userLevel=res.data.userLevel;
});
},
getUserDetail(){
@@ -219,14 +234,33 @@ export default {
that.commentList=JSON.parse(res.data.comment);
that.like=JSON.parse(res.data.like)
that.article=JSON.parse(res.data.article);
console.log(that.commentList);
// console.log(that.commentList);
});
},
updateUserLevel(){
if(this.$cookie.get("username")!=null){
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/levelup',
// URL 中的查询参数
params: {
}
});
}else{
return;
}
},
changeAvatar(){
this.openChangeAvatar=true;
if(this.$route.query.name!==this.$cookie.get('username')){
return;
}else{
this.openChangeAvatar=true;
}
},
changeAvatarByUrl(){
var that=this;
if(this.AvatarUrl!==''){
axios({
method: 'post',
@@ -244,7 +278,6 @@ export default {
type: 'success',
offset: 50
});
that.$root.URL=that.imageUrl;
}else{
Vue.prototype.$notify.error({
title: '错误',
@@ -265,6 +298,7 @@ export default {
},
upload(params){
var that=this;
const formData = new FormData();
formData.append("file", params.file);
axios({
@@ -273,36 +307,40 @@ export default {
url: '/upload/UploadHandle',
headers:{"Content-Type": "multipart/form-data"},
// URL 中的查询参数
data:formData
data:formData,
params: {
username: this.$cookie.get('username')
}
}).then((res)=>{
console.log(res);
if(res.data.code===200){
Vue.prototype.$notify({
title: '成功',
message: ('i', {style: 'color: teal'}, res.data.msg),
type: 'success',
offset: 50
});
}else{
if(res.data.code===500){
Vue.prototype.$notify.error({
title: '错误',
message: res.data.msg,
offset: 50
});
}else{
Vue.prototype.$notify({
title: '成功',
message: ('i', {style: 'color: teal'}, "上传成功"),
type: 'success',
offset: 50
});
that.openChangeAvatar=false;
}
})
},
changeAvatarByLocal(){
var that=this;
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/retUserAv',
url: '/api/retUserAv',
// URL 中的查询参数
responseType: 'blob',
}).then((res)=>{
console.log(res);
})
},