+
选择一种方式即可!
+
url:
@@ -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);
+
})
},