From e672292835f3b65aaa06237154418f9122a0d0c8 Mon Sep 17 00:00:00 2001 From: ww664853070 Date: Wed, 19 Jul 2023 10:44:20 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E8=A7=86=E9=A2=91=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=EF=BC=8C=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapp/src/packages/patrol/index.jsx | 77 ++++++++++++++++++----------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/weapp/src/packages/patrol/index.jsx b/weapp/src/packages/patrol/index.jsx index 440e3c26..fcec62b9 100644 --- a/weapp/src/packages/patrol/index.jsx +++ b/weapp/src/packages/patrol/index.jsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import Taro, { useRouter } from '@tarojs/taro'; import { View, RadioGroup, Radio, Image, Input, Picker, Video } from '@tarojs/components'; -import { AtButton, AtTextarea, AtImagePicker } from 'taro-ui'; +import { AtButton, AtTextarea, AtImagePicker, AtMessage, AtIcon } from 'taro-ui'; import InputPicker from '../components/inputPicker'; import InputPickers from '../components/inputPickers'; import VideoUpload from '../../components/uploads' @@ -58,6 +58,7 @@ const Index = () => { const [handlePicPn, setHandlePicPn] = useState([]) const [handleId, setHandleId] = useState([]) const [video, setVideo] = useState('') + const [videoqn, setVideoqn] = useState([]) const prjType = isAnomaly ? @@ -145,6 +146,7 @@ const Index = () => { setConserveUnderwayPic(data.conserveUnderwayPic ? data.conserveUnderwayPic.map(item => ({ url: imgUrl + item })) : []) setConserveAfterPic(data.conserveAfterPic ? data.conserveAfterPic.map(item => ({ url: imgUrl + item })) : []) setHandleId(data.id) + setVideo(imgUrl + data.videoUrl[0]) if (data.handleContent) { setHandleCenter(data.handleContent) } @@ -284,6 +286,7 @@ const Index = () => { codeRoad, projectName, handleState: isAnomaly ? '待处理' : undefined, + videoUrl: videoqn } if (reportType === 'patrol' || isAnomaly || isRoad) { data['scenePic'] = sceneImg @@ -572,28 +575,41 @@ const Index = () => { maxDuration: 15, camera: 'back', success(res) { - console.log(res,'上传的视频'); const tempFilePaths = res.tempFiles[0].tempFilePath - - setVideo(res.tempFiles[0].tempFilePath) let token = getState('token') || Taro.getStorageSync('token') - Taro.uploadFile({ - url: `${baseUrl}${postImage()}?token=${token}`, - filePath: tempFilePaths, - name: 'file', - success: (ress) => { - Taro.hideLoading(); - if (ress.statusCode == 200) { - // setVideo(res.tempFiles[0].tempFilePath) - } else { - Taro.showToast({ title: '上传失败,请重试', icon: 'error' }) + if (res.tempFiles[0].duration < 15) { + Taro.showLoading({ + title: '视频上传中' + }) + Taro.uploadFile({ + url: `${baseUrl}${postImage()}?token=${token}`, + filePath: tempFilePaths, + name: 'file', + success: (ress) => { + Taro.hideLoading(); + if (ress.statusCode == 200) { + setVideo(res.tempFiles[0].tempFilePath) + let videoqns = videoqn + videoqns.push(JSON.parse(ress.data).key) + setVideoqn(videoqns) + } else { + Taro.showToast({ title: '上传失败,请重试', icon: 'error' }) + } + }, + fail: (res) => { + Taro.hideLoading(); } - } - }); + }); + } else { + Taro.atMessage({ + 'message': '请传15秒内的视频!', + 'type': 'error', + }) + } + } }) } - console.log(isView, '============'); return ( {/* { @@ -894,20 +910,24 @@ const Index = () => { videoShow ? '' : { - video != '' ? @@ -952,6 +972,7 @@ const Index = () => { : '' } + ) }