修改一些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; this.dialogVisible = false;
}, 1000); }, 1000);
location.reload(); // location.reload();
this.searchUser()
}); });
}, },
@ -162,6 +163,8 @@ export default {
message: "删除成功", message: "删除成功",
type: "success", type: "success",
}); });
this.searchUser()
// location.reload(); // location.reload();
}, 1000); }, 1000);
}); });

View File

@ -2,22 +2,23 @@
<div class="box"> <div class="box">
<div class="mine"> <div class="mine">
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
action="https://9miao.fun:6838/prod-api/common/alibabaUpload" :action="baseURL + '/common/alibabaUpload'"
:show-file-list="false" :show-file-list="false"
:headers="headerObj" :headers="headerObj"
:on-success="handleAvatarSuccess" name="file"
:before-upload="beforeAvatarUpload"> :on-success="handleAvatarSuccess"
<img v-if="user.avatar" :src="user.avatar" class="avatar" /> >
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <img v-if="user.avatar" :src="user.avatar" class="avatar" />
</el-upload> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<div class="msg"> <div class="msg">
<div class="item"> <div class="item">
<p>昵称</p> <p>昵称</p>
<input <input
type="text" type="text"
:placeholder="username?username:'请输入昵称'" :placeholder="'请输入昵称'"
v-model="user.nicekname" v-model="user.nicekname"
/> />
</div> </div>
@ -40,8 +41,8 @@
</div> </div>
<div class="btn"> <div class="btn">
<p @click="save">保存</p> <el-button type="primary" @click="save">保存</el-button>
<p @click="logout">注销</p> <el-button type="danger" @click="logout">注销</el-button>
</div> </div>
</div> </div>
</div> </div>
@ -50,26 +51,28 @@
<script> <script>
import { apiServe } from "@/api/api.js"; import { apiServe } from "@/api/api.js";
import { baseURL } from "@/api/http";
import router from "@/router"; import router from "@/router";
export default { export default {
name: "WenhuaWebuiMine", name: "WenhuaWebuiMine",
data() { data() {
return { return {
baseURL: baseURL,
cdata: {}, cdata: {},
headerObj: { headerObj: {
"Content-Type": "application/json", // "Content-Type": "application/json",
"saToken" : localStorage.getItem('token') saToken: localStorage.getItem("token"),
}, },
imageUrl:'', imageUrl: "",
UrlImgs:'', UrlImgs: "",
user: { user: {
phonenumber: "", phonenumber: "",
nicekname: "", nicekname: "",
avatar: "", avatar: "",
sex: "", sex: "",
}, },
username:"", username: "",
}; };
}, },
@ -79,62 +82,56 @@ export default {
}, },
methods: { 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) { handleAvatarSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw); console.log(res);
// console.log(this.imageUrl,"onSuccessImgs"); // this.imageUrl = URL.createObjectURL(file.raw);
this.user.avatar = this.imageUrl // console.log(this.imageUrl,"onSuccessImgs");
this.user.avatar = res.url;
}, },
searchUser() { searchUser() {
// $token=${this.cdata.token} // $token=${this.cdata.token}
// console.log(this.cdata,"this.cdata") // console.log(this.cdata,"this.cdata")
apiServe.admin(this.cdata).then((res) => { apiServe.admin(this.cdata).then((res) => {
console.log(res,"MimeRes"); console.log(res, "MimeRes");
this.user = res.data.data; 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() { save() {
console.log(this.user,"this.user") console.log(this.user, "this.user");
apiServe.editAdmin(this.user).then((res) => { apiServe.editAdmin(this.user).then((res) => {
console.log(res); console.log(res);
this.$router.push("/index"); if (res.data.code == 200) {
this.$message({ // localStorage.setItem("img", this.user.avatar);
message: "个人信息保存成功!", this.$router.push("/index");
type: "success", this.$message({
}); message: "个人信息保存成功!",
type: "success",
});
}
if (res.code == 500) {
this.$message({
message: "个人信息保存失败!",
type: "error",
});
}
}); });
}, },
logout(){ logout() {
apiServe.LogOut().then(res => { apiServe.LogOut().then((res) => {
console.log(res,"注销用户") console.log(res, "注销用户");
localStorage.removeItem("img") localStorage.removeItem("img");
localStorage.removeItem("userid") localStorage.removeItem("userid");
localStorage.removeItem("token") localStorage.removeItem("token");
this.$message({ this.$message({
message: '注销成功', message: "注销成功",
type: 'success' type: "success",
}) });
this.$router.push("/") this.$router.push("/");
location.reload(); location.reload();
}) });
}, },
}, },
}; };
@ -163,23 +160,7 @@ export default {
border-radius: 10px; border-radius: 10px;
.btn { .btn {
display: flex; // align-items: ;
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;
}
} }
.item { .item {

View File

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

View File

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