Browse Source

修复上传头像bug

xiaohaizhao 1 year ago
parent
commit
442cf5b7ff
2 changed files with 39 additions and 30 deletions
  1. 33 26
      cloud/businessCard/edit.vue
  2. 6 4
      team/team/getInvite.vue

+ 33 - 26
cloud/businessCard/edit.vue

@@ -4,7 +4,8 @@
             <template v-if="isShow" slot="head">
                 <view class="headportrait" hover-class="navigator-hover">
                     <view class="content">
-                        <My_upload maxCount="1" ref="upload" @onLoading="imageOnLoading" @uploadCallback="uploadCallback"></My_upload>
+                        <My_upload maxCount="1" ref="upload" @onLoading="imageOnLoading" @uploadCallback="uploadCallback">
+                        </My_upload>
                         <button class="avatar-box" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
                         </button>
                         <view style="display: flex;align-items: center;">
@@ -15,8 +16,8 @@
                                     </template>
                                 </u--image>
                             </view>
-                            
-                            <view :style="'width:'+tovw(255)" />
+
+                            <view :style="'width:' + tovw(255)" />
                             <view class="iconfont icon-a-wodetiaozhuan" />
                         </view>
                     </view>
@@ -38,7 +39,7 @@
 </template>
 
 <script>
-import {formattedFiles} from '../../utils/settleFiles.js'
+import { formattedFiles } from '../../utils/settleFiles.js'
 export default {
     data() {
         return {
@@ -46,14 +47,13 @@ export default {
             form: [],
             attachmentids: [],
             uncomplete: true,
-            onUpload:false,
-            copyUncomplete: false,
+            onUpload: false,
             loading: false,
             headportrait: "https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202404231713854678447B26b4363.svg",
             userid: 0,
             isShow: true,
-            isSubmit:false,
-            origin:''
+            isSubmit: false,
+            origin: ''
         }
     },
     onLoad(options) {
@@ -68,15 +68,15 @@ export default {
         if (!this.isSubmit) this.$refs.form.deleteFiles()
     },
     methods: {
-        onChooseAvatar (e) {
-            let ext = e.detail.avatarUrl.substr(e.detail.avatarUrl.lastIndexOf('.')+1)
+        onChooseAvatar(e) {
+            let ext = e.detail.avatarUrl.substr(e.detail.avatarUrl.lastIndexOf('.') + 1)
             let name = `${Date.now()}.${ext}`
             let temp = {
-                name:name,
-                type:'image',
-                url:e.detail.avatarUrl
+                name: name,
+                type: 'image',
+                url: e.detail.avatarUrl
             }
-            this.afterRead({file:[temp]})
+            this.afterRead({ file: [temp] })
         },
 
         afterRead({ file }) {
@@ -180,7 +180,7 @@ export default {
             })
         },
 
-        
+
         init() {
             let form = [{
                 key: "name",
@@ -218,19 +218,19 @@ export default {
                     label: "自我介紹",
                     isMust: false,//是否必填
                     value: '',
-                },{
+                }, {
                     key: "tag",
                     type: "tag",
                     label: "印象标签",
                     isMust: false,//是否必填
                     marginTop: 10,
-                    placeholder:'请填写,最多十个字',
-                    verify:[{
+                    placeholder: '请填写,最多十个字',
+                    verify: [{
                         reg: '^.{1,10}$',
                         errText: "限制1-10字!"
                     }],
                     value: [],
-                },{
+                }, {
                     key: "attachmentids",
                     type: "upload",
                     label: "图片",
@@ -248,7 +248,7 @@ export default {
             this.$Http.basic({
                 "id": 20240514161502,
                 "content": {
-                    userid:this.userid
+                    userid: this.userid
                 },
             }).then(res => {
                 console.log("获取个人信息", res)
@@ -355,10 +355,9 @@ export default {
         },
         imageOnLoading(e) {
             if (e) {
-                this.copyUncomplete = this.uncomplete;
                 this.uncomplete = true;
             } else {
-                this.uncomplete = this.copyUncomplete;
+                this.$refs.form.verify();
             }
         },
         uploadCallback(attachmentids, ownertable = 'temporary', ownerid = '99999999') {
@@ -391,7 +390,7 @@ export default {
                     });
                     if (ownertable == 'temporary') {
                         this.attachmentids = attachmentids;
-                        console.log(res.data[0],'结果');
+                        console.log(res.data[0], '结果');
                         this.headportrait = res.data[0].url;
                         this.linksid = res.data[0].linksid;
                     }
@@ -408,6 +407,7 @@ export default {
     width: 100vw;
     padding-left: 10px;
     background: #fff;
+
     .content {
         display: flex;
         align-items: center;
@@ -417,6 +417,7 @@ export default {
         padding: 10px;
         padding-left: 0;
         position: relative;
+
         .avatar-box {
             width: 100%;
             height: 76px;
@@ -425,6 +426,7 @@ export default {
             top: 0;
             opacity: 0;
         }
+
         .label {
             font-family: Source Han Sans SC, Source Han Sans SC;
             font-size: 14px;
@@ -442,26 +444,31 @@ export default {
     font-weight: 400;
     font-size: 16px;
     color: #333333;
+
     .type-line {
         padding: 12px 0;
         display: flex;
         justify-content: space-evenly;
         align-items: center;
         border-bottom: 1px #DDDDDD solid;
+
         .line-1 {
             display: flex;
             align-items: center;
             align-content: center;
+
             text {
                 margin-right: 10px;
             }
+
             image {
                 width: 24px !important;
                 height: 24px !important;
             }
         }
+
         text {}
-        
+
     }
 }
 
@@ -475,6 +482,7 @@ export default {
     box-sizing: border-box;
     padding: 5px 10px;
     display: flex;
+
     .add {
         display: flex;
         align-items: center;
@@ -491,5 +499,4 @@ export default {
     .forbidden {
         opacity: .6;
     }
-}
-</style>
+}</style>

+ 6 - 4
team/team/getInvite.vue

@@ -44,7 +44,6 @@ export default {
             form: [],
             attachmentids: [],
             uncomplete: true,
-            copyUncomplete: true,
             loading: false,
             headportrait: "https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202404231713854678447B26b4363.svg",
             userid: 0,
@@ -138,13 +137,16 @@ export default {
                 // if (this.cutoff(res.msg)) return;
                 if (res.msg == '成功') {
                     this.headportraits = res.data.attinfos;
-                    this.headportrait = this.headportraits.find(v => v.usetype == "headportrait").url || this.headportrait;
+                    if (this.headportraits.length) {
+                        this.headportrait = this.headportraits.find(v => v.usetype == "headportrait").url || this.headportrait;
+                    }
                     form = form.map(v => {
                         v.value = res.data[v.key] || v.value
                         return v
                     })
                 }
                 this.form = form;
+                console.log("this.form ", this.form)
             })
 
         },
@@ -206,10 +208,9 @@ export default {
         },
         imageOnLoading(e) {
             if (e) {
-                this.copyUncomplete = this.uncomplete;
                 this.uncomplete = true;
             } else {
-                this.uncomplete = this.copyUncomplete;
+                this.$refs.form.verify();
             }
         },
         uploadCallback(attachmentids, ownertable = 'temporary', ownerid = '99999999') {
@@ -257,6 +258,7 @@ export default {
     width: 100vw;
     padding-left: 10px;
     background: #fff;
+    box-sizing: border-box;
 
     .content {
         display: flex;