xiongzhu %!s(int64=2) %!d(string=hai) anos
pai
achega
56626f26de

+ 1 - 1
src/main/java/com/izouma/jmrh/security/WebSecurityConfig.java

@@ -62,7 +62,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 //swagger-ui放行路径
                 .antMatchers("/v2/api-docs", "/swagger-ui.html", "/swagger-resources/**", "/webjars/**").permitAll()
                 .antMatchers("/user/register").permitAll()
-                .antMatchers("/upload/**").permitAll()
+//                .antMatchers("/upload/**").permitAll()
                 .antMatchers("/static/**").permitAll()
                 .antMatchers("/auth/**").permitAll()
                 .antMatchers("/admin/**").permitAll()

+ 8 - 0
src/main/jmrh/src/components/SingleUpload.vue

@@ -5,6 +5,7 @@
         :show-file-list="false"
         :on-success="onSuccess"
         :before-upload="beforeUpload"
+        :headers="headers"
     >
         <div></div>
         <div class="wrapper">
@@ -53,6 +54,13 @@ export default {
             };
         } */
     //},
+    computed: {
+        headers() {
+            return {
+                Authorization: 'Bearer ' + localStorage.getItem('token')
+            };
+        }
+    },
     methods: {
         onSuccess(res, file) {
             this.loading = false;

+ 17 - 34
src/main/jmrh/src/views/mine/editInfo.vue

@@ -7,19 +7,7 @@
         </el-row>
         <div class="avatar-wrapper">
             <!--  <img :src="avatar" /> -->
-            <el-upload
-                :action="uploadUrl"
-                :show-file-list="false"
-                :on-success="handleAvatarSuccess"
-                :before-upload="beforeAvatarUpload"
-                :on-error="handleAvatarError"
-                accept="image/*"
-                v-loading="avatarUploading"
-            >
-                <img v-if="avatar" :src="avatar" />
-                <i v-else class="avatar"></i>
-                <div class="edit_avatar">点击头像修改</div>
-            </el-upload>
+            <single-upload :value="(userInfo || {}).avatar" @input="changeAvatar"> </single-upload>
         </div>
         <el-form ref="form" :model="form" label-width="150px" :rules="rules" style="max-width: 600px;" size="small">
             <el-form-item label="企业名称" prop="orgName">
@@ -102,6 +90,7 @@ import resolveUrl from 'resolve-url';
 import province from '@/mixins/provinces.json';
 import cities from '@/mixins/cities.json';
 import areas from '@/mixins/areas.json';
+import { mapState } from 'vuex';
 
 export default {
     name: 'editInfo',
@@ -197,10 +186,8 @@ export default {
                 });
             }
         },
-        handleAvatarSuccess(res, file) {
-            this.avatar = URL.createObjectURL(file.raw);
-            this.avatarUploading = false;
-            this.$http.post('/user/updateProfile', { avatar: res }).then(res => {
+        changeAvatar(avatar) {
+            this.$http.post('/user/updateProfile', { avatar }).then(res => {
                 this.$message.success('修改成功');
                 this.$http.get('/user/my').then(res => {
                     this.$store.commit('updateUserInfo', res);
@@ -270,7 +257,9 @@ export default {
                 this.$message.error(e.error);
             });
     },
-    computed: {}
+    computed: {
+        ...mapState(['userInfo'])
+    }
 };
 </script>
 <style lang="less" scoped>
@@ -297,23 +286,17 @@ export default {
     // flex-direction: column;
     // align-items: center;
     // justify-content: center;
-    .el-upload {
-        img {
-            width: 148px;
-            height: 148px;
-            border-radius: 74px;
-        }
+    /deep/ .upload-image {
+        width: 148px;
+        height: 148px;
+        border-radius: 74px;
+        object-fit: cover;
     }
-    .edit_avatar {
-        width: 96px;
-        height: 36px;
-        margin: 20px auto 0 auto;
-        line-height: 36px;
-        text-align: center;
-        cursor: pointer;
-        color: #939599;
-        font-size: 13px;
-        border: 1px solid #dcdfe6;
+    /deep/ .single-uploader-icon {
+        width: 148px;
+        height: 148px;
+        line-height: 148px;
+        border-radius: 74px;
     }
 }
 .editInfo {