Browse Source

feat:发布

chenqilong 1 year ago
parent
commit
eff23b2283
1 changed files with 13 additions and 8 deletions
  1. 13 8
      src/components/zj-upload/index.vue

+ 13 - 8
src/components/zj-upload/index.vue

@@ -6,7 +6,7 @@
         <template v-else>
           <image mode="aspectFit" :src="item.loUrl" style="width: 100%; height: 100%"> </image>
           <view class="mack" @tap.stop="() => {}"></view>
-          <image @tap.stop="() => {}" class="uploadImg" mode="aspectFit" src="/static/upload/loading.png"> </image>
+          <image @tap.stop="() => {}" class="uploadImg" mode="aspectFit" src="./loading.png"> </image>
         </template>
         <template v-if="!disabled">
           <image class="delImg" mode="aspectFit" src="/static/upload/del.png" @tap.stop="del(index)"> </image>
@@ -14,11 +14,16 @@
       </view>
     </view>
     <template v-if="!disabled">
-      <view v-if="count === 0 ? true : count - files.length" class="file-upload-view" @click="upload">
+      <view v-if="(count === 0 ? true : count - files.length) && !showLoading" class="file-upload-view" @click="upload">
         <view class="file-upload-ckick">
           <image class="uploadImg" mode="aspectFit" src="/static/upload/upload.png"> </image>
         </view>
       </view>
+      <view v-else class="file-upload-view">
+        <view class="file-upload-ckick">
+          <image class="uploadImg" mode="aspectFit" src="./loading.png"> </image>
+        </view>
+      </view>
     </template>
   </view>
 </template>
@@ -48,6 +53,7 @@ export default {
   },
   data() {
     return {
+      showLoading: false,
       imageUrl: this.$imageUrl,
       files: this.setFileVal(this.fileList)
     }
@@ -130,13 +136,13 @@ export default {
         // count: this.count === 0 ? 0 : this.count - this.files.length,
         count: 1,
         success: async res => {
-          console.log(res)
+          this.showLoading = true
           let pathType = this.checkFileType(res.tempFiles[0].name)
           if (pathType !== 'image') {
             return this.$toast('当前格式仅支持jpg, jpeg, png,请检查')
           }
           //  #ifdef H5
-           const value = uni.getStorageSync('recycle_mobile_user')
+          const value = uni.getStorageSync('recycle_mobile_user')
           // 获取选择的文件路径
           let phone = value.mobile
           phone = phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
@@ -154,7 +160,6 @@ export default {
               'X-Token': store.getters.token
             }
           }
-
           // 发送上传请求
           axios(config)
             .then(response => {
@@ -162,11 +167,11 @@ export default {
               this.files.push({
                 url: response.data.data
               })
-              console.log(response.data)
+              this.showLoading = false
             })
             .catch(error => {
               // 处理上传失败的错误
-              console.error(error)
+              this.showLoading = false
             })
 
           // uploadImgs(res.tempFiles[0]).then(res => {
@@ -181,7 +186,7 @@ export default {
           // #endif
         },
         fail: err => {
-          console.log(err)
+          this.showLoading = false
         }
       })
     },