修改一些bug

This commit is contained in:
Strange 2024-05-17 02:40:32 +08:00
parent 56a86e74b3
commit f56bac576f
4 changed files with 110 additions and 106 deletions

View File

@ -149,7 +149,8 @@ export default {
});
this.dialogVisible = false;
}, 1000);
location.reload();
// location.reload();
this.searchUser()
});
},
@ -162,6 +163,8 @@ export default {
message: "删除成功",
type: "success",
});
this.searchUser()
// location.reload();
}, 1000);
});

View File

@ -3,11 +3,12 @@
<div class="mine">
<el-upload
class="avatar-uploader"
action="https://9miao.fun:6838/prod-api/common/alibabaUpload"
:action="baseURL + '/common/alibabaUpload'"
:show-file-list="false"
:headers="headerObj"
name="file"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload">
>
<img v-if="user.avatar" :src="user.avatar" class="avatar" />
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
@ -17,7 +18,7 @@
<p>昵称</p>
<input
type="text"
:placeholder="username?username:'请输入昵称'"
:placeholder="'请输入昵称'"
v-model="user.nicekname"
/>
</div>
@ -40,8 +41,8 @@
</div>
<div class="btn">
<p @click="save">保存</p>
<p @click="logout">注销</p>
<el-button type="primary" @click="save">保存</el-button>
<el-button type="danger" @click="logout">注销</el-button>
</div>
</div>
</div>
@ -50,26 +51,28 @@
<script>
import { apiServe } from "@/api/api.js";
import { baseURL } from "@/api/http";
import router from "@/router";
export default {
name: "WenhuaWebuiMine",
data() {
return {
baseURL: baseURL,
cdata: {},
headerObj: {
"Content-Type": "application/json",
"saToken" : localStorage.getItem('token')
// "Content-Type": "application/json",
saToken: localStorage.getItem("token"),
},
imageUrl:'',
UrlImgs:'',
imageUrl: "",
UrlImgs: "",
user: {
phonenumber: "",
nicekname: "",
avatar: "",
sex: "",
},
username:"",
username: "",
};
},
@ -79,62 +82,56 @@ export default {
},
methods: {
handleSelect(e){
handleSelect(e) {},
},
beforeAvatarUpload(file) {
const isJPG = file.type === 'image/jpeg';
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG 格式!');
}
if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 2MB!');
}
return isJPG && isLt2M;
},
handleAvatarSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw);
console.log(res);
// this.imageUrl = URL.createObjectURL(file.raw);
// console.log(this.imageUrl,"onSuccessImgs");
this.user.avatar = this.imageUrl
this.user.avatar = res.url;
},
searchUser() {
// $token=${this.cdata.token}
// console.log(this.cdata,"this.cdata")
apiServe.admin(this.cdata).then((res) => {
console.log(res,"MimeRes");
console.log(res, "MimeRes");
this.user = res.data.data;
this.imageUrl = res.data.data?.avatar;
this.username = res.data?.data?.username
localStorage.setItem("userid", res.data.data?.id);
localStorage.setItem("img", this.imageUrl);
});
},
save() {
console.log(this.user,"this.user")
console.log(this.user, "this.user");
apiServe.editAdmin(this.user).then((res) => {
console.log(res);
if (res.data.code == 200) {
// localStorage.setItem("img", this.user.avatar);
this.$router.push("/index");
this.$message({
message: "个人信息保存成功!",
type: "success",
});
}
if (res.code == 500) {
this.$message({
message: "个人信息保存失败!",
type: "error",
});
}
});
},
logout(){
apiServe.LogOut().then(res => {
console.log(res,"注销用户")
localStorage.removeItem("img")
localStorage.removeItem("userid")
localStorage.removeItem("token")
logout() {
apiServe.LogOut().then((res) => {
console.log(res, "注销用户");
localStorage.removeItem("img");
localStorage.removeItem("userid");
localStorage.removeItem("token");
this.$message({
message: '注销成功',
type: 'success'
})
this.$router.push("/")
message: "注销成功",
type: "success",
});
this.$router.push("/");
location.reload();
})
});
},
},
};
@ -163,23 +160,7 @@ export default {
border-radius: 10px;
.btn {
display: flex;
flex-direction: column;
// background-color: rgba(242, 242, 242, 1);
justify-content: center;
align-items: center;
p {
width: 150px;
height: 35px;
font-size: 14px;
text-align: center;
line-height: 35px;
background-color: rgba(22, 155, 213, 1);
color: #ffffff;
border-radius: 5px;
// padding: 20px;
}
// align-items: ;
}
.item {

View File

@ -15,7 +15,11 @@
</div>
<div class="search">
<input type="text" placeholder="说点什么吧!!!~~~~" v-model="commentContent" />
<input
type="text"
placeholder="说点什么吧!!!~~~~"
v-model="commentContent"
/>
<div class="btns">
<p @click="answer">发送评论</p>
</div>
@ -39,63 +43,60 @@
</template>
<script>
import { apiServe } from '@/api/api';
import { apiServe } from "@/api/api";
export default {
name: "WenhuaWebuiZhiShiDesc",
data() {
return {
id:null,
uid:null,
list:[],
answerList:[],
id: null,
uid: null,
commentContent:"",
list: [],
answerList: [],
};
},
created() {
// query
this.id = this.$route.query.id;
this.uid = localStorage.getItem('userid')
this.uid = localStorage.getItem("userid");
},
mounted() {
this.searchUser()
this.pinglist()
this.searchUser();
this.pinglist();
},
methods: {
searchUser() {
apiServe.Clwh(this.id).then((res) => {
console.log(res);
this.list = res.data.data
this.list = res.data.data;
});
},
pinglist() {
apiServe.pinglun(this.id).then((res) => {
console.log(res);
this.answerList = res.data.data
this.answerList = res.data.data;
});
},
answer() {
let cdata = {
commentContent:this.commentContent,
id:this.uid,
cid: this.id
}
commentContent: this.commentContent,
id: this.uid,
cid: this.id,
};
apiServe.addpinglun(cdata).then((res) => {
console.log(res);
this.searchUser()
this.pinglist();
this.$message({
message: "评论成功!",
type: "success",
});
setTimeout(() => {
location.reload();
}, 1000);
});
},
},
};
@ -242,7 +243,7 @@ export default {
.item_answer {
margin-bottom: 10px;
border-bottom: 1px solid #EBEBEB;
border-bottom: 1px solid #ebebeb;
padding: 10px 0;
}

View File

@ -15,9 +15,13 @@
<el-dropdown-menu slot="dropdown" > </el-dropdown-menu>
<div class="ronde" @click="handleOut">
<img src="../assets/mine.png" alt="" v-if="!token" />
<img :src="img" alt="">
<!-- <img :src="user.avatar" alt=""> -->
<el-avatar v-else :src="user.avatar"></el-avatar>
</div>
<el-dropdown-menu slot="dropdown" v-if="token">
<el-dropdown-item >
<p>{{ user.nicekname }}</p>
</el-dropdown-item>
<el-dropdown-item >
<a href="javascript:;" @click="gomine" >个人中心</a>
</el-dropdown-item>
@ -29,12 +33,17 @@
</template>
<script>
import { apiServe } from "@/api/api.js";
export default {
data() {
return {
userName: localStorage.getItem("userName"),
token: '',
img: ''
user:{
}
};
},
@ -42,9 +51,19 @@ export default {
this.token = localStorage.getItem('token')
this.img = localStorage.getItem('img')
// console.log(this.img, "this.img")
this.searchUser()
},
methods: {
searchUser() {
// $token=${this.cdata.token}
// console.log(this.cdata,"this.cdata")
apiServe.admin(this.cdata).then((res) => {
console.log(res, "MimeRes");
this.user = res.data.data;
});
},
handleOut() {
let token = localStorage.getItem('token')
console.log(token, "Tokens")