From a38e8dc8f74ebd4b5ce49efe5d3d9bce90834968 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 30 十月 2024 10:32:29 +0800
Subject: [PATCH] Merge branch 'test'
---
src/views/profile/components/UserCard.vue | 60 ++++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/src/views/profile/components/UserCard.vue b/src/views/profile/components/UserCard.vue
index 251824c..567ff28 100644
--- a/src/views/profile/components/UserCard.vue
+++ b/src/views/profile/components/UserCard.vue
@@ -6,32 +6,41 @@
<div class="user-profile">
<div class="box-center">
- <img :src="userInfo.imagePath === null ? require('@/assets/avatar.gif') : userInfo.imagePath " height="100px" width="100px" style="border-radius: 50px">
+ <input
+ type="file"
+ @change="changeHeadPortrait"
+ accept=".jpg, .png"
+ style="display: none"
+ ref="fileHeadPortrait"
+ id="fileHeadPortrait"
+ />
+
+ <img :src="userInfo.imagePath?'api/files/' + userInfo.imagePath : '/static/icons/touxiang.png'"
+ height="100px"
+ width="100px"
+ style="border-radius: 50px"
+ @click="uploadImage"
+ class="img"
+ id="headPortrait">
</div>
<div class="box-center">
<div class="user-name text-center">{{ userInfo.userName }}</div>
<div class="user-role text-center text-muted">{{ enumFormat(roleEnum,userInfo.role) }}</div>
</div>
</div>
-
- <div class="user-bio">
- <div class="user-education user-bio-section">
- <div class="user-bio-section-header"><svg-icon icon-class="education" /><span>涓汉绠�浠�</span></div>
- <div class="user-bio-section-body">
- <div class="text-muted">
- 鏃�
- </div>
- </div>
- </div>
-
- </div>
</el-card>
</template>
<script>
import { mapGetters, mapState } from 'vuex'
+import userApi from '@/api/user'
export default {
+ data() {
+ return {
+ uploadUrl: 'http://localhost:8000/api/upload/upload'
+ }
+ },
props: {
userInfo: {
type: Object,
@@ -52,8 +61,31 @@
...mapState('enumItem', {
roleEnum: state => state.user.roleEnum
})
+ },
+ methods: {
+ changeHeadPortrait(e) {
+ let formData = new FormData();
+ if (e.target.files[0]) {
+ formData.set("file", e.target.files[0]);
+ userApi.uploadImg(formData).then(
+ this.$message.success('涓婁紶鎴愬姛'),
+ );
+ }
+ },
+ uploadImage(){
+ let logoFile = document.getElementById("fileHeadPortrait");
+ if (logoFile) {
+ logoFile.click();
+ }
+ },
+ getPage() {
+ userApi.getCurrentUser.then(re => {
+ let _this = this
+ _this.userInfo = re.data
+ })
+ }
}
-}
+};
</script>
<style lang="scss" scoped>
--
Gitblit v1.8.0