From 966ff06798ef5b4968be3f2d9bcd6019d0cc918a Mon Sep 17 00:00:00 2001 From: ww664853070 Date: Fri, 14 Jul 2023 09:29:51 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BC=88fixed=EF=BC=8911730=20=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=BE=85=E5=8A=9E=E4=BA=8B=E9=A1=B9-?= =?UTF-8?q?=E5=BE=85=E5=8A=9E=E4=BA=8B=E9=A1=B9=E5=B1=95=E7=A4=BA=E4=BA=86?= =?UTF-8?q?=E6=9C=AA=E6=8C=87=E6=B4=BE=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapp/src/packages/patrol/index.jsx | 71 ++++++++++++++++++++----- weapp/src/packages/patrolView/index.jsx | 3 ++ 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/weapp/src/packages/patrol/index.jsx b/weapp/src/packages/patrol/index.jsx index 30b8767a..33d25597 100644 --- a/weapp/src/packages/patrol/index.jsx +++ b/weapp/src/packages/patrol/index.jsx @@ -57,6 +57,7 @@ const Index = () => { const [handlePic, setHandlePic] = useState([]) const [handlePicPn, setHandlePicPn] = useState([]) const [handleId, setHandleId] = useState([]) + const [video, setVideo] = useState('') const prjType = isAnomaly ? @@ -241,7 +242,7 @@ const Index = () => { ]) }, [reportType]) - function report () { + function report() { if (!canReport) { return } if ( (isPatrol && (!projectType || !road)) @@ -317,7 +318,7 @@ const Index = () => { }) } - function deleteReport () { + function deleteReport() { Taro.showModal({ title: '提示', content: '确定删除吗?', @@ -344,7 +345,7 @@ const Index = () => { }) } - function handleInput ({ detail: { value } }, type) { + function handleInput({ detail: { value } }, type) { switch (type) { case 'roadSectionStart': setRoadSectionStart(value) @@ -379,15 +380,15 @@ const Index = () => { } } - function handleTypeChange (e) { + function handleTypeChange(e) { setReportType(e.detail.value) } - function handleImgChange (files, operationType, index, type) { + function handleImgChange(files, operationType, index, type) { if (operationType === 'remove') { setImg(false) } - function setImg (isAdd, url) { + function setImg(isAdd, url) { switch (type) { case 'scenePic': let nextImg = sceneImg @@ -462,6 +463,7 @@ const Index = () => { default: break; } + console.log(files, '=============='); for (i; i < files.length; i++) { const tempFilePaths = files[i].url let token = getState('token') || Taro.getStorageSync('token') @@ -484,19 +486,19 @@ const Index = () => { } } - function handleImgClick (index, file) { + function handleImgClick(index, file) { Taro.previewImage({ urls: [file.url] // 需要预览的图片http链接列表 }) } - function handleImgClicks (index, file) { + function handleImgClicks(index, file) { Taro.previewImage({ urls: [file] // 需要预览的图片http链接列表 }) } useEffect(() => { if (!isView) { - let newRoadList = roadList.filter(e => e?.routeName?.match(road)) + let newRoadList = roadList.filter(e => e.routeName.match(road)) let codeRoadSel = [] if (newRoadList.length && road != '') { newRoadList.forEach((e, index) => { @@ -511,7 +513,7 @@ const Index = () => { } } }, [road]) - function handleOk () { + function handleOk() { if (!canReport) { return } let str = handleCenter.trim() if (!str) { @@ -562,6 +564,36 @@ const Index = () => { } }) } + function addVideo() { + wx.chooseMedia({ + count: 1, + mediaType: ['video'], + sourceType: ['album', 'camera'], + maxDuration: 15, + camera: 'back', + success(res) { + console.log(res, 'res'); + const tempFilePaths = res.tempFiles[0].tempFilePath + let token = getState('token') || Taro.getStorageSync('token') + Taro.uploadFile({ + url: `${baseUrl}${postImage()}?token=${token}`, + filePath: tempFilePaths, + name: 'file', + success: (ress) => { + console.log(ress, '上传成功'); + Taro.hideLoading(); + if (ress.statusCode == 200) { + setVideo(res.tempFiles[0].tempFilePath) + } else { + Taro.showToast({ title: '上传失败,请重试', icon: 'error' }) + } + } + }); + } + }) + } + console.log(video, 'video'); + console.log(scenePic, 'tupia'); return ( {/* { @@ -600,7 +632,6 @@ const Index = () => { onInput={setProjectType} selector={prjTypeSelector} isView={isView} - onlySelect={true} /> : '' } @@ -610,9 +641,7 @@ const Index = () => { title='反馈类型:' placeholder='请选择反馈类型' value={projectType} - onInput={(v) => { - setProjectType(v) - }} + onInput={setProjectType} selector={prjTypeSelector} isView={isView} onlySelect={true} @@ -861,6 +890,20 @@ const Index = () => { } } + { + video.length ?