把插件里面的 appCamera() 这个方法替换成
appCamera() {
var cmr = plus.camera.getCamera();
var res = cmr.supportedImageResolutions[0];
var fmt = cmr.supportedImageFormats[0];
let that = this;
//console.log("Resolution: " + res + ", Format: " + fmt);
cmr.captureImage((path) => {
//alert("Capture image success: " + path);
plus.io.resolveLocalFileSystemURL(path, function(entry) {
console.log(entry.toLocalURL())
that.compressImage(entry.toLocalURL(),entry.name);
}, function(e) {
plus.nativeUI.toast("读取拍照文件错误:" + e.message);
});
},
(error) => {
//alert("Capture image failed: " + error.message);
console.log("Capture image failed: " + error.message)
}, {
resolution: res,
format: fmt
}
);
},
compressImage(url,filename){
var name="_doc/upload/"+filename;
let that = this;
uni.compressImage({
src:url,//src: (String 类型 )压缩转换原始图片的路径
dst:name,//压缩转换目标图片的路径
overwrite:true,//overwrite: (Boolean 类型 )覆盖生成新文件
success: res => {
this.chooseSuccessMethod([res.tempFilePath], 0)
},
fail: (err) => {
//console.log(err.errMsg);
console.log("Capture image failed: " + err)
},
complete: () => {
//uni.hideLoading();
}
})
},
增加了一个compressImage(url,filename) 方法用来处理路径无效问题