//选择图片
chooseImg() {
uni.chooseImage({
sourceType: ['album', 'camera'], //camera使用相机
// count: 5 - this.zximageList.length,
count: 1,
success: res => {
console.log(res)
this.imageList = this.imageList.concat(res.tempFilePaths);
this.toUploadFile(this.imageList);
},
fail(e) {
console.log(e);
}
});
},
//上传文件
toUploadFile: function(path) {
console.log(path)
var that = this
// for (var i = 0; i < that.imageList.length; i++) {
// console.log(that.imageList[i])
// }
var lengtha = that.imageList.length - 1
uni.uploadFile({
url: that.$Url + "/mobile/web-api/addFile",
// url: "/ksy/mobile/web-api/addFile",
filePath: that.imageList[lengtha],
name: 'file',
success: (uploadFileRes) => {
var fpath = JSON.parse(uploadFileRes.data)
that.zximageList = that.zximageList.concat('' + fpath.msg);
// uni.showToast({
// icon: 'none',
// title: "文件上传成功",
// })
},
fail() {
uni.showToast({
icon: 'none',
title: "文件上传失败"
})
}
});
},