Compare commits

...

2 Commits

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

39
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
@ -573,11 +576,12 @@ const Index = () => {
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')
if (res.tempFiles[0].duration < 15) {
Taro.showLoading({
title: '视频上传中'
})
Taro.uploadFile({ Taro.uploadFile({
url: `${baseUrl}${postImage()}?token=${token}`, url: `${baseUrl}${postImage()}?token=${token}`,
filePath: tempFilePaths, filePath: tempFilePaths,
@ -585,16 +589,28 @@ const Index = () => {
success: (ress) => { success: (ress) => {
Taro.hideLoading(); Taro.hideLoading();
if (ress.statusCode == 200) { if (ress.statusCode == 200) {
// setVideo(res.tempFiles[0].tempFilePath) setVideo(res.tempFiles[0].tempFilePath)
let videoqns = videoqn
videoqns.push(JSON.parse(ress.data).key)
setVideoqn(videoqns)
} else { } else {
Taro.showToast({ title: '上传失败,请重试', icon: 'error' }) 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,7 +911,11 @@ const Index = () => {
videoShow ? '' : videoShow ? '' :
<view> <view>
{ {
video != '' ? <Video video != '' ? <view style={{ position: 'relative' }}>
<view onClick={() => { setVideo('') }} style={{ position: 'absolute', zIndex: '999', right: '70rpx', top: '30rpx' }}>
<AtIcon value='close-circle' size='30' color='#fff'></AtIcon>
</view>
<Video
style={{ width: '90%', marginLeft: '-45%', left: '50%', marginBottom: 20 }} style={{ width: '90%', marginLeft: '-45%', left: '50%', marginBottom: 20 }}
src={video} src={video}
poster='../../static/img/date.png' poster='../../static/img/date.png'
@ -904,11 +924,11 @@ const Index = () => {
autoplay={false} autoplay={false}
loop={false} loop={false}
muted={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