Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-ui
Commits
f18eb389
提交
f18eb389
authored
9月 11, 2025
作者:
lidongxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(inspection/index.vue): 测试:勤策移动端_售点稽查_安卓单独判断需要如何拍照
上级
d5750400
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
147 行增加
和
55 行删除
+147
-55
file.js
src/utils/file.js
+2
-2
index.vue
...y/sales_point_inspection/examine/inspectionTask/index.vue
+145
-53
没有找到文件。
src/utils/file.js
浏览文件 @
f18eb389
...
@@ -13,8 +13,8 @@ function isImage(url) {
...
@@ -13,8 +13,8 @@ function isImage(url) {
// 判断 URL 是一个视频
// 判断 URL 是一个视频
function
isVideo
(
url
)
{
function
isVideo
(
url
)
{
const
fileType
=
getFileTypeExt
(
url
)
const
fileType
=
getFileTypeExt
(
url
)
console
.
log
([
'mp4'
,
'avi'
,
'mov'
,
'wmv'
,
'flv'
].
includes
(
fileType
.
toLowerCase
()),
2
)
console
.
log
([
'mp4'
,
'avi'
,
'mov'
,
'wmv'
,
'flv'
,
'3gp'
,
'mkv'
,
'webm'
].
includes
(
fileType
.
toLowerCase
()),
2
)
return
[
'mp4'
,
'avi'
,
'mov'
,
'wmv'
,
'flv'
].
includes
(
fileType
.
toLowerCase
())
return
[
'mp4'
,
'avi'
,
'mov'
,
'wmv'
,
'flv'
,
'3gp'
,
'mkv'
,
'webm'
].
includes
(
fileType
.
toLowerCase
())
}
}
// 来个统一出口
// 来个统一出口
export
function
getMediaType
(
url
)
{
export
function
getMediaType
(
url
)
{
...
...
src/views/mobile/pages/audit_activity/sales_point_inspection/examine/inspectionTask/index.vue
浏览文件 @
f18eb389
...
@@ -50,7 +50,9 @@
...
@@ -50,7 +50,9 @@
<van-field
label=
"门头照(1张)"
<van-field
label=
"门头照(1张)"
label-align=
"top"
>
label-align=
"top"
>
<template
#
input
>
<template
#
input
>
<van-uploader
:max-count=
"1"
<!-- 苹果设备上传组件 -->
<van-uploader
v-if=
"deviceType === 'ios'"
:max-count=
"1"
accept=
"image/*,video/*"
accept=
"image/*,video/*"
:model-value=
"form.commitStorePicture"
:model-value=
"form.commitStorePicture"
:after-read=
"commitStorePhotosRead"
:after-read=
"commitStorePhotosRead"
...
@@ -109,9 +111,79 @@
...
@@ -109,9 +111,79 @@
</div>
</div>
</
template
>
</
template
>
</van-uploader>
</van-uploader>
<!-- 安卓设备上传组件 -->
<div
v-else-if=
"deviceType === 'android'"
>
<!-- 上传按钮 -->
<div
class=
"upload-btn"
@
click=
"show = true"
>
<van-icon
name=
"photograph"
/>
</div>
<!-- 安卓设备根据选择显示的上传组件 -->
<div
style=
"display: none;"
class=
"android-uploader-wrapper"
>
<van-uploader
:max-count=
"1"
:accept=
"selectedMediaType === 'image' ? 'image/*' : 'video/*'"
ref=
"uploaderRef"
capture=
"camera"
:model-value=
"form.commitStorePicture"
:after-read=
"commitStorePhotosRead"
preview-size=
"2.13333rem"
@
delete=
"deleteCommitStorePhotos"
:max-size=
"5 * 1024 * 1024"
@
oversize=
"onOversize"
>
<
template
#
preview-cover=
"{ url, index }"
>
<div
class=
"preview-container"
@
click
.
stop
>
<!-- 图片预览 -->
<van-image
v-if=
"getMediaType(url) === 'image'"
:src=
"url"
alt=
""
class=
"preview-media"
fit=
"cover"
@
click=
"previewImage(url)"
/>
<!-- 视频预览 -->
<div
class=
"video-wrap"
v-else-if=
"getMediaType(url) === 'video'"
>
<video
:src=
"url"
alt=
""
ref=
"videoRef"
muted
autoplay
playsinline
preload=
"auto"
class=
"preview-media"
@
loadeddata=
"handleVideoLoaded"
/>
<div
class=
"play-hint"
@
click
.
stop=
"showVideoFullscreen(url)"
>
</div>
</div>
<!-- 删除按钮 -->
<van-icon
name=
"clear"
class=
"delete-icon"
@
click
.
stop=
"deleteCommitStorePhotos"
/>
<!-- 类型标识 -->
<span
v-if=
"getMediaType(url) === 'video'"
class=
"video-tag"
>
视频
</span>
</div>
</
template
>
</van-uploader>
</div>
</div>
</template>
</template>
</van-field>
</van-field>
</div>
</div>
<!-- 拍照方式选择 -->
<van-action-sheet
v-model:show=
"show"
:actions=
"actions"
@
select=
"onSelect"
/>
<!-- 渠道类型选择 -->
<!-- 渠道类型选择 -->
<van-field
label-width=
"150px"
<van-field
label-width=
"150px"
label-position=
"top"
label-position=
"top"
...
@@ -240,8 +312,6 @@ import { getFileTypeExt, getMediaType } from '@/utils'
...
@@ -240,8 +312,6 @@ import { getFileTypeExt, getMediaType } from '@/utils'
// 引入必要的组件
// 引入必要的组件
import
{
showImagePreview
}
from
'vant'
;
import
{
showImagePreview
}
from
'vant'
;
const
router
=
useRouter
()
const
router
=
useRouter
()
const
route
=
useRoute
()
const
route
=
useRoute
()
...
@@ -410,6 +480,60 @@ const handleClickLocation = () => {
...
@@ -410,6 +480,60 @@ const handleClickLocation = () => {
}
}
/*************** 门头照上传 ***************/
/*************** 门头照上传 ***************/
// 检测设备类型
const
deviceType
=
computed
(()
=>
{
const
userAgent
=
navigator
.
userAgent
.
toLowerCase
();
if
(
userAgent
.
includes
(
'iphone'
)
||
userAgent
.
includes
(
'ipad'
))
{
return
'ios'
;
}
else
if
(
userAgent
.
includes
(
'android'
))
{
return
'android'
;
}
return
'android'
;
})
const
onSelect
=
(
item
)
=>
{
selectedMediaType
.
value
=
item
.
type
nextTick
(()
=>
{
if
(
uploaderRef
.
value
)
{
// 获取uploader组件实例
const
uploaderInstance
=
uploaderRef
.
value
// 方法1: 如果组件暴露了open或click方法
if
(
uploaderInstance
.
open
)
{
uploaderInstance
.
open
()
}
else
if
(
uploaderInstance
.
click
)
{
uploaderInstance
.
click
()
}
else
{
// 方法2: 直接查找内部的input元素并触发点击
// 查找uploader组件内的input[type="file"]元素
const
inputElement
=
uploaderInstance
.
$el
.
querySelector
(
'input[type="file"]'
)
if
(
inputElement
)
{
// 触发点击事件
inputElement
.
click
()
}
else
{
console
.
error
(
'未找到文件上传input元素'
)
}
}
}
else
{
console
.
error
(
'uploader组件未加载完成'
)
}
show
.
value
=
false
})
}
const
show
=
ref
(
false
)
const
actions
=
ref
([
{
name
:
'拍照片'
,
type
:
'image'
},
{
name
:
'拍视频'
,
type
:
'video'
}
])
const
uploaderRef
=
ref
(
null
)
const
selectedMediaType
=
ref
(
''
)
// 上传照片
// 上传照片
const
commitStorePhotosRead
=
async
(
file
)
=>
{
const
commitStorePhotosRead
=
async
(
file
)
=>
{
form
.
commitStorePicture
=
[{
form
.
commitStorePicture
=
[{
...
@@ -466,41 +590,7 @@ const handleVideoLoaded = () => {
...
@@ -466,41 +590,7 @@ const handleVideoLoaded = () => {
videoRef
.
value
.
pause
()
videoRef
.
value
.
pause
()
}
}
// 全屏播放
const
videoPosters
=
ref
({});
const
videoLoadingStatus
=
ref
({});
// 跟踪每个视频的加载状态
const
isWebView
=
ref
(
false
);
// 组件挂载时检测环境
// onMounted(() => {
// detectEnvironment();
// });
// // 检测是否在webView中
// const detectEnvironment = () => {
// // 检测是否在iOS设备上
// const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
// // 检测是否在webView中 - 可以根据实际项目中的webView特征调整
// // 这里使用了一些常见的webView特征检测方法
// const isInWebView = () => {
// // iOS webView检测
// if (isiOS) {
// // 检查是否存在UIWebView特有的属性
// const hasUIWebViewProperty = typeof navigator.standalone !== 'undefined' && !navigator.standalone;
// // 检查userAgent中是否包含特定App的标识
// const hasCustomUserAgent = /AppName|CustomWebView/i.test(navigator.userAgent);
// return hasUIWebViewProperty || hasCustomUserAgent;
// }
// return false;
// };
// isWebView.value = isInWebView();
// };
// 修改showVideoFullscreen函数,添加环境检测逻辑
const
showVideoFullscreen
=
async
(
url
)
=>
{
const
showVideoFullscreen
=
async
(
url
)
=>
{
const
video
=
videoRef
.
value
;
const
video
=
videoRef
.
value
;
if
(
!
video
)
return
;
if
(
!
video
)
return
;
...
@@ -522,7 +612,7 @@ const showVideoFullscreen = async (url) => {
...
@@ -522,7 +612,7 @@ const showVideoFullscreen = async (url) => {
// 跨浏览器请求全屏(保留之前的实现)
// 跨浏览器请求全屏(保留之前的实现)
const
requestFullscreen
=
(
element
)
=>
{
const
requestFullscreen
=
(
element
)
=>
{
if
(
!
element
)
return
Promise
.
reject
(
new
Error
(
'
Element not found
'
));
if
(
!
element
)
return
Promise
.
reject
(
new
Error
(
'
video 标签不存在
'
));
const
methods
=
[
const
methods
=
[
// 标准API
// 标准API
...
@@ -535,7 +625,7 @@ const requestFullscreen = (element) => {
...
@@ -535,7 +625,7 @@ const requestFullscreen = (element) => {
element
.
webkitEnterFullscreen
();
element
.
webkitEnterFullscreen
();
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
return
Promise
.
reject
(
new
Error
(
'
webkitEnterFullscreen not supported
'
));
return
Promise
.
reject
(
new
Error
(
'
不支持全屏播放
'
));
}
}
];
];
...
@@ -555,7 +645,7 @@ const requestFullscreen = (element) => {
...
@@ -555,7 +645,7 @@ const requestFullscreen = (element) => {
continue
;
continue
;
}
}
}
}
reject
(
new
Error
(
'
All fullscreen methods failed
'
));
reject
(
new
Error
(
'
所有全屏播放方法失败
'
));
});
});
};
};
...
@@ -758,6 +848,19 @@ const deleteLongTimePictureArr = async (file, { name, index }) => {
...
@@ -758,6 +848,19 @@ const deleteLongTimePictureArr = async (file, { name, index }) => {
.header-photo-section
{
.header-photo-section
{
margin-top
:
10px
;
margin-top
:
10px
;
.upload-btn
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
background-color
:
#f8f8f8
;
width
:
80px
;
height
:
80px
;
border
:
1px
dashed
#ccc
;
border-radius
:
4px
;
color
:
#dcdee0
;
font-size
:
24px
;
}
::v-deep
(
.van-uploader__upload
)
{
::v-deep
(
.van-uploader__upload
)
{
width
:
80px
!
important
;
width
:
80px
!
important
;
height
:
80px
!
important
;
height
:
80px
!
important
;
...
@@ -771,18 +874,7 @@ const deleteLongTimePictureArr = async (file, { name, index }) => {
...
@@ -771,18 +874,7 @@ const deleteLongTimePictureArr = async (file, { name, index }) => {
.van-uploader
{
.van-uploader
{
.upload-btn
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
background-color
:
#f8f8f8
;
width
:
80px
;
height
:
80px
;
border
:
1px
dashed
#ccc
;
border-radius
:
4px
;
color
:
#dcdee0
;
font-size
:
24px
;
}
::v-deep
(
.van-uploader__file
)
{
::v-deep
(
.van-uploader__file
)
{
.van-badge__wrapper
{
.van-badge__wrapper
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论