|
请教各位大神,我是用3.5版本打的ios包,点击相册添加图片在andriod上正常,在ios上无法执行navigator.camera.getPicture方法,代码如下所示:
// 点击相册添加附件
Model.prototype.imageClick = function(event){
if(!navigator.camera){
alert("return");
return;
}
var me = this;
var nativeURL = "";
var data = this.comp("mediaData");
alert("相册");
navigator.camera.getPicture(onSuccess, onFail, {
destinationType : navigator.camera.DestinationType.FILE_URI,// 这里要用FILE_URI,才会返回文件的URI地址
//sourceType : 0,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
quality : 20,
//mediaType : navigator.camera.MediaType.PICTURE
mediaType: 0
});
function onSuccess(imageURI) {
// 采用插件方式 实现content路径与file路径的相互转换
// alert(imageURI);
window.FilePath.resolveNativePath(imageURI, onSuccessPath, onErrorPath);
}
function onFail(message) {
// me.comp("messageDialog").show();
}
// 文件操作失败
function onErrorPath(error) {
justep.Util.hint("系统出现异常:" + error.code, {
'delay' : 3000
});
}
function onSuccessPath(nativeURL) {
data.newData({
"index" : 0,
"defaultValues" : [ {
"ACCIDENT_ID" : "",
"FILE_PATH" : nativeURL,
"FILE_NAME" : nativeURL.substr(nativeURL.lastIndexOf('/') + 1),
"FILE_TYPE" : "jpg",
"IS_DELETE" : "0"
} ]
});
me.comp("imgPopOver").hide();
function success(fileEntry) {
function win(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
// alert(evt.target.result);
$(me.getElementByXid("image1")).attr("src", evt.target.result);
};
reader.readAsDataURL(file);
}
var fail = function(evt) {
me.comp("PicPopOver").hide();
};
fileEntry.file(win, fail);
}
window.resolveLocalFileSystemURI(nativeURL, success, function(error) {
alert("error");
});
}
}; |
|