ChooseImage() {
let that = this
uni.chooseImage({
count: Number(that.Imglength), //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album','camera'], //从相册选择
success: (res) => {
let path = res.tempFilePaths
if (path) {
for (var i = 0; i < path.length; i++) {
uni.uploadFile({
url: Api.url.imguploadUrl, //仅为示例,非真实的接口地址
header: {
'token': uni.getStorageSync("token")
},
filePath: path[i],
name: 'file',
success: (uploadFileRes) => {
if (uploadFileRes.statusCode == 200) {
let imgData = JSON.parse(uploadFileRes.data);
let file={ name:imgData.fileName,url:imgData.id,fileType:imgData.fileType }
that.file.push(file)
this.$emit("input",JSON.stringify(that.file));
uni.showToast({
title: '上传成功',
icon: 'none'
})
}
}
})
}
}
},
});
},

1***@qq.com
- 发布:2021-12-10 16:28
- 更新:2023-08-28 11:34
- 阅读:390
