| | |
| | | studentList: () => get('/api/admin/user/student/list'), |
| | | getClassesCurrentUserList: (param) => get('/api/admin/user/classes/students', param), |
| | | updatePassword: (data) => post('/api/common/user/update/password', data), |
| | | uploadImg: (data) => post('/api/admin/upload/img', data), |
| | | } |
| | |
| | | |
| | | <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> |
| | |
| | | |
| | | <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, |
| | |
| | | ...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> |