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 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)
}
@ -285,6 +287,7 @@ const Index = () => {
codeRoad,
projectName,
handleState: isAnomaly ? '待处理' : undefined,
videoUrl: videoqn
}
if (reportType === 'patrol' || isAnomaly || isRoad) {
data['scenePic'] = sceneImg
@ -572,29 +575,42 @@ const Index = () => {
sourceType: ['album', 'camera'],
maxDuration: 15,
camera: 'back',
success (res) {
console.log(res, '上传的视频');
success(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 (
<View className='patrol'>
{/* {
@ -895,20 +911,24 @@ const Index = () => {
videoShow ? '' :
<view>
{
video != '' ? <Video
style={{ width: '90%', marginLeft: '-45%', left: '50%', marginBottom: 20 }}
src={video}
poster='../../static/img/date.png'
initialTime={0}
controls={true}
autoplay={false}
loop={false}
muted={false}
/> : ''
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 }}
src={video}
poster='../../static/img/date.png'
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>
@ -953,6 +973,7 @@ const Index = () => {
</View>
</view> : ''
}
<AtMessage />
</View>
)
}

Loading…
Cancel
Save