fix: 功能修改完善。
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user