Compare commits

...

2 Commits

  1. 79
      weapp/src/packages/patrol/index.jsx

79
weapp/src/packages/patrol/index.jsx

@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import Taro, { useRouter } from '@tarojs/taro'; import Taro, { useRouter } from '@tarojs/taro';
import { View, RadioGroup, Radio, Image, Input, Picker, Video } from '@tarojs/components'; 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 InputPicker from '../components/inputPicker';
import InputPickers from '../components/inputPickers'; import InputPickers from '../components/inputPickers';
import VideoUpload from '../../components/uploads' import VideoUpload from '../../components/uploads'
@ -58,6 +58,7 @@ const Index = () => {
const [handlePicPn, setHandlePicPn] = useState([]) const [handlePicPn, setHandlePicPn] = useState([])
const [handleId, setHandleId] = useState([]) const [handleId, setHandleId] = useState([])
const [video, setVideo] = useState('') const [video, setVideo] = useState('')
const [videoqn, setVideoqn] = useState([])
const prjType = const prjType =
isAnomaly ? isAnomaly ?
@ -145,6 +146,7 @@ const Index = () => {
setConserveUnderwayPic(data.conserveUnderwayPic ? data.conserveUnderwayPic.map(item => ({ url: imgUrl + item })) : []) setConserveUnderwayPic(data.conserveUnderwayPic ? data.conserveUnderwayPic.map(item => ({ url: imgUrl + item })) : [])
setConserveAfterPic(data.conserveAfterPic ? data.conserveAfterPic.map(item => ({ url: imgUrl + item })) : []) setConserveAfterPic(data.conserveAfterPic ? data.conserveAfterPic.map(item => ({ url: imgUrl + item })) : [])
setHandleId(data.id) setHandleId(data.id)
setVideo(imgUrl + data.videoUrl[0])
if (data.handleContent) { if (data.handleContent) {
setHandleCenter(data.handleContent) setHandleCenter(data.handleContent)
} }
@ -285,6 +287,7 @@ const Index = () => {
codeRoad, codeRoad,
projectName, projectName,
handleState: isAnomaly ? '待处理' : undefined, handleState: isAnomaly ? '待处理' : undefined,
videoUrl: videoqn
} }
if (reportType === 'patrol' || isAnomaly || isRoad) { if (reportType === 'patrol' || isAnomaly || isRoad) {
data['scenePic'] = sceneImg data['scenePic'] = sceneImg
@ -572,29 +575,42 @@ const Index = () => {
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
maxDuration: 15, maxDuration: 15,
camera: 'back', camera: 'back',
success (res) { success(res) {
console.log(res, '上传的视频');
const tempFilePaths = res.tempFiles[0].tempFilePath const tempFilePaths = res.tempFiles[0].tempFilePath
setVideo(res.tempFiles[0].tempFilePath)
let token = getState('token') || Taro.getStorageSync('token') let token = getState('token') || Taro.getStorageSync('token')
Taro.uploadFile({ if (res.tempFiles[0].duration < 15) {
url: `${baseUrl}${postImage()}?token=${token}`, Taro.showLoading({
filePath: tempFilePaths, title: '视频上传中'
name: 'file', })
success: (ress) => { Taro.uploadFile({
Taro.hideLoading(); url: `${baseUrl}${postImage()}?token=${token}`,
if (ress.statusCode == 200) { filePath: tempFilePaths,
// setVideo(res.tempFiles[0].tempFilePath) name: 'file',
} else { success: (ress) => {
Taro.showToast({ title: '上传失败,请重试', icon: 'error' }) 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 ( return (
<View className='patrol'> <View className='patrol'>
{/* { {/* {
@ -895,20 +911,24 @@ const Index = () => {
videoShow ? '' : videoShow ? '' :
<view> <view>
{ {
video != '' ? <Video video != '' ? <view style={{ position: 'relative' }}>
style={{ width: '90%', marginLeft: '-45%', left: '50%', marginBottom: 20 }} <view onClick={() => { setVideo('') }} style={{ position: 'absolute', zIndex: '999', right: '70rpx', top: '30rpx' }}>
src={video} <AtIcon value='close-circle' size='30' color='#fff'></AtIcon>
poster='../../static/img/date.png' </view>
initialTime={0} <Video
controls={true} style={{ width: '90%', marginLeft: '-45%', left: '50%', marginBottom: 20 }}
autoplay={false} src={video}
loop={false} poster='../../static/img/date.png'
muted={false} initialTime={0}
/> : '' controls={true}
autoplay={false}
loop={false}
muted={false}
/></view> : ''
} }
{ {
!isView ? <AtButton type='secondary' size='small' onClick={addVideo}>添加视频</AtButton> : '' !isView && video == '' ? <AtButton type='secondary' size='small' onClick={addVideo}>添加视频</AtButton> : ''
} }
</view> </view>
@ -953,6 +973,7 @@ const Index = () => {
</View> </View>
</view> : '' </view> : ''
} }
<AtMessage />
</View> </View>
) )
} }

Loading…
Cancel
Save