fix: 功能修改完善。

This commit is contained in:
tianyongbao
2026-07-06 00:37:01 +08:00
parent 9027869e97
commit 6846ea3e0f
7 changed files with 132 additions and 22 deletions

View File

@@ -432,12 +432,26 @@ function chooseImage() {
proxy.$refs['uToast'].show({ message: '正在上传中,请稍候', type: 'warning' })
return
}
// H5 端传 camera 会触发 getUserMedia可能卡死微信小程序/APP 需要相机选项
let sourceType
// #ifdef H5
sourceType = ['album']
// #endif
// #ifndef H5
sourceType = ['album', 'camera']
// #endif
uni.chooseImage({
count: 9 - attachmentList.value.length,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
sourceType,
success: (res) => {
uploadImages(res.tempFilePaths, 0)
},
fail: (err) => {
// 用户取消选择不走 success也不会报错但某些浏览器会触发 fail
if (err && err.errMsg && err.errMsg.indexOf('cancel') === -1) {
proxy.$refs['uToast'].show({ message: '选择图片失败', type: 'warning' })
}
}
})
}
@@ -449,7 +463,9 @@ function uploadImages(paths, index) {
return
}
uploading.value = true
uni.showLoading({ title: `上传中 ${index + 1}/${paths.length}`, mask: true })
// H5 端 mask: true 会让页面无法点击,一旦上传出问题会导致用户被“锁住”
// 这里改为 mask: false允许用户取消会提示正在上传
uni.showLoading({ title: `上传中 ${index + 1}/${paths.length}`, mask: false })
uploadFile({
filePath: paths[index],
name: 'file'