直接使用uni.chooseImage

- 发布:2021-10-25 14:03
- 更新:2021-10-25 17:14
- 阅读:515
产品分类: uniapp/H5
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 未知
HBuilderX类型: 正式
HBuilderX版本号: 3.2.9
浏览器平台: 手机系统浏览器
浏览器版本: 未知
项目创建方式: HBuilderX
操作步骤:
预期结果:
可以像安卓系统一样正常使用
可以像安卓系统一样正常使用
实际结果:
无法使用
无法使用
bug描述:
无法使用图片选择,也没有任何反应
1***@qq.com (作者)
所有的ios都有问题
// 选择图片
async chooseImg() {
await this.getQNImgUrl()
let { image_url, token, upload_url } = this.QNInfo
let { fromUser } = this
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: async (res)=> {
const { tempFiles } = res
uni.showLoading({
title: '发送中...'
})
for(let file of tempFiles) {
const suffix = file.name.substr(file.name.lastIndexOf(".") + 1)
uni.uploadFile({
url: upload_url,
filePath: file.path,
name: 'file',
formData: {
'key':
shop/${(new Date).getTime()}.${suffix}
,'token': token
},
success: (uploadFileRes) => {
let path = image_url + JSON.parse(uploadFileRes.data).key
console.log(path)
// 发送图片
this.fitOnMsg('image', path, fromUser)
},
complete: ()=> {
uni.hideLoading()
}
})
}
setTimeout(()=> {
uni.showLoading({
complete: () => {
uni.hideLoading()
}
})
}, 1500)
},
fail: (res)=> {
console.log('调用相机失败')
}
})
},
2021-10-26 09:16