From a11bc1bed7953b88213330582c2085f60b5a73b1 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期三, 12 六月 2024 15:01:56 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/dmvisit

---
 h5/pages/staff/snapshot.vue |  171 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 109 insertions(+), 62 deletions(-)

diff --git a/h5/pages/staff/snapshot.vue b/h5/pages/staff/snapshot.vue
index a6096ef..c0a30be 100644
--- a/h5/pages/staff/snapshot.vue
+++ b/h5/pages/staff/snapshot.vue
@@ -55,23 +55,37 @@
             class="adduser_list_item_ipt1_upload"
             v-for="(item, i) in submitFileList"
             :key="i"
-            ><image :src="item.fileurlFull" mode="widthFix"></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
           ></view>
         </view>
       </view>
       <view class="empty"></view>
-       <view class="upload_line" style="padding: 15px 0 0;">
-        <view class="name" style="margin-bottom: 10rpx;">
-          <text style="color: #e42d2d;">*</text>
+      <view class="upload_line" style="padding: 15px 0 0">
+        <view class="name" style="margin-bottom: 10rpx">
+          <text style="color: #e42d2d">*</text>
           <text>鎯呭喌璇存槑</text>
         </view>
-        <view class="value"
-          ><textarea
+        <view class="value">
+          <textarea
             placeholder="璇疯缁嗘弿杩扮幇鍦烘儏鍐碉紝涓嶅皯浜�10涓瓧"
             minlength="10"
             v-model="param.content"
             placeholder-style="color: #999999;"
-        /></view>
+          />
+        </view>
       </view>
       <view class="empty"></view>
       <view class="line">
@@ -184,17 +198,19 @@
     }
   },
   onLoad(option) {
-    if (option && option.id) {
-      this.$set(this.param, 'checkUserId', option.id)
-      this.$set(this.param, 'applyCheckUserId', option.id)
-      this.$set(this.param, 'checkorName', option.name)
-    }
     this.initConfig()
     const userInfo = uni.getStorageSync('userInfo') || {}
     this.$set(this.param, 'memberName', userInfo.realname)
     this.$set(this.param, 'memberPhone', userInfo.mobile)
     this.$set(this.param, 'memberId', userInfo.id)
     this.$set(this.param, 'submitTime', dayjs().format('YYYY-MM-DD HH:mm:ss'))
+  },
+  mounted() {
+    this.$eventBus.$on('snapshotSel', (option) => {
+      this.$set(this.param, 'checkUserId', option.id)
+      this.$set(this.param, 'applyCheckUserId', option.id)
+      this.$set(this.param, 'checkorName', option.name)
+    })
   },
   methods: {
     onSubmit() {
@@ -255,71 +271,92 @@
         url: '/pages/staff/memberSel'
       })
     },
+    fileDel(i) {
+      this.submitFileList.splice(i, 1)
+    },
     uploadImage() {
       this.showUpload = false
+      let token = uni.getStorageSync('token') || ''
       uni.chooseImage({
-        count: 6,
+        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'
+            },
+            header: {
+              Dm_user_token: token
+            },
+            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()
+              // }
+            }
+          })
+          // }
         }
       })
     },
     uploadVideo() {
       this.showUpload = false
       let that = this
+      let token = uni.getStorageSync('token') || ''
       uni.chooseVideo({
         success: (chooseImageRes) => {
           uni.showLoading({ title: '涓婁紶涓�', mask: true })
-          for (let i = 0; i < chooseImageRes.tempFilePaths.length; i++) {
-            uni.uploadFile({
-              url: `${uploadUrl}`,
-              filePath: chooseImageRes.tempFilePaths[i],
-              name: 'file',
-              formData: {
-                folderCode: 'HIDDEN_DANGER_FILE'
-              },
-              success: (uploadFileRes) => {
-                let res = JSON.parse(uploadFileRes.data)
-                console.log('uploadFileRes', res)
-                let obj = { type: '1' }
-                obj.fileurl = res.data.halfPath
-                obj.fileurlFull = res.data.addr
-                that.submitFileList.push(obj)
-                console.log(that.submitFileList)
-              },
-              complete() {
-                if (i === chooseImageRes.tempFilePaths.length - 1) {
-                  uni.hideLoading()
-                }
+          uni.uploadFile({
+            url: `${uploadUrl}`,
+            filePath: chooseImageRes.tempFilePath,
+            header: {
+              Dm_user_token: token
+            },
+            name: 'file',
+            formData: {
+              folder: 'HIDDEN_DANGER_FILE'
+            },
+            success: (uploadFileRes) => {
+              let res = JSON.parse(uploadFileRes.data)
+              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)
+                })
               }
-            })
-          }
+            },
+            complete() {
+              uni.hideLoading()
+            }
+          })
         }
       })
     },
@@ -331,6 +368,7 @@
 
 <style lang="scss">
 .main_wrap {
+  padding-bottom: 200rpx;
   .line {
     display: flex;
     justify-content: space-between;
@@ -366,7 +404,7 @@
   }
   .upload_line {
     padding: 30rpx 0;
-    .wrap{
+    .wrap {
       display: flex;
       flex-wrap: wrap;
     }
@@ -382,10 +420,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;
       }
     }
   }
@@ -412,7 +459,7 @@
     height: 88rpx;
     line-height: 88rpx;
     text-align: center;
-    background: #4e99a9;
+    background: $uni-color-primary;
     border-radius: 44rpx;
     font-size: 32rpx;
     color: #ffffff;

--
Gitblit v1.9.3