From c3501daa1d6cf6f0cb8428afcaa329755ca16621 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期五, 07 六月 2024 16:40:30 +0800
Subject: [PATCH] ‘’

---
 h5/pages/staff/snapshot.vue |  101 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 64 insertions(+), 37 deletions(-)

diff --git a/h5/pages/staff/snapshot.vue b/h5/pages/staff/snapshot.vue
index a72a86b..0c80c25 100644
--- a/h5/pages/staff/snapshot.vue
+++ b/h5/pages/staff/snapshot.vue
@@ -55,15 +55,20 @@
             class="adduser_list_item_ipt1_upload"
             v-for="(item, i) in submitFileList"
             :key="i"
-            ><image
+          >
+            <u-icon
+              class="close"
+              size="20"
+              name="close-circle-fill"
+              color="red"
+              @click="fileDel(i)"
+            ></u-icon>
+            <image
               v-if="item.type == 0"
               :src="item.fileurlFull"
               mode="widthFix"
             ></image
-            ><video
-              v-if="item.type == 1"
-              :src="item.fileurlFull"
-            ></video
+            ><video v-if="item.type == 1" :src="item.fileurlFull"></video
           ></view>
         </view>
       </view>
@@ -266,38 +271,53 @@
         url: '/pages/staff/memberSel'
       })
     },
+    fileDel(i) {
+      this.submitFileList.splice(i, 1)
+    },
     uploadImage() {
       this.showUpload = false
       uni.chooseImage({
-        count: 1,
+        count: 4,
         success: (chooseImageRes) => {
           console.log('chooseImageRes.tempFilePaths', chooseImageRes.tempFilePaths)
           uni.showLoading({ title: '涓婁紶涓�', mask: true })
-          for (let i = 0; i < chooseImageRes.tempFilePaths.length; i++) {
-            uni.uploadFile({
-              url: `${uploadUrl}`,
-              filePath: chooseImageRes.tempFilePaths[i],
+          const tempFilePaths = chooseImageRes.tempFilePaths
+          let imgs = tempFilePaths.map((value, index) => {
+            return {
               name: 'file',
-              formData: {
-                folderCode: 'HIDDEN_DANGER_FILE'
-              },
-              success: (uploadFileRes) => {
-                let res = JSON.parse(uploadFileRes.data)
-                console.log('res', res)
-                let obj = {
-                  type: '0'
-                }
-                obj.fileurl = res.data.halfPath
-                obj.fileurlFull = res.data.addr
-                this.submitFileList.push(obj)
-              },
-              complete() {
-                if (i === chooseImageRes.tempFilePaths.length - 1) {
-                  uni.hideLoading()
-                }
+              uri: value
+            }
+          })
+          uni.uploadFile({
+            url: `${uploadUrl}`,
+            files: imgs,
+            name: 'file',
+            formData: {
+              folder: 'HIDDEN_DANGER_FILE'
+            },
+            success: (uploadFileRes) => {
+              let res = JSON.parse(uploadFileRes.data)
+              console.log('res', res.data)
+              if (res.data && res.data.length > 0) {
+                res.data.forEach(i => {
+                  i.type = 0
+                  i.fileurl = i.imgaddr
+                  i.fileurlFull = i.url
+                  this.submitFileList.push(i)
+                })
               }
-            })
-          }
+            },
+            fail(err) {
+              console.log('err', err)
+            },
+            complete() {
+              uni.hideLoading()
+              // if (i === chooseImageRes.tempFilePaths.length - 1) {
+              //   uni.hideLoading()
+              // }
+            }
+          })
+          // }
         }
       })
     },
@@ -312,17 +332,18 @@
             filePath: chooseImageRes.tempFilePath,
             name: 'file',
             formData: {
-              folderCode: 'HIDDEN_DANGER_FILE'
+              folder: 'HIDDEN_DANGER_FILE'
             },
             success: (uploadFileRes) => {
               let res = JSON.parse(uploadFileRes.data)
-              console.log('res', res)
-              let obj = {
-                type: '1'
+              if (res.data && res.data.length > 0) {
+                res.data.forEach(i => {
+                  i.type = 1
+                  i.fileurl = i.imgaddr
+                  i.fileurlFull = i.url
+                  this.submitFileList.push(i)
+                })
               }
-              obj.fileurl = res.data.halfPath
-              obj.fileurlFull = res.data.addr
-              this.submitFileList.push(obj)
             },
             complete() {
               uni.hideLoading()
@@ -390,13 +411,19 @@
       display: flex;
       align-items: center;
       justify-content: center;
-      overflow: hidden;
+      position: relative;
+      .close {
+        position: absolute;
+        right: -20rpx;
+        top: -20rpx;
+      }
       image {
         width: 100%;
         height: 100%;
       }
       video {
         width: 100%;
+        max-height: 160rpx;
       }
     }
   }

--
Gitblit v1.9.3