|
测试在安卓6.0的版本下没有问题 ,但是安卓7.0使用相机,允许软件使用相机功能会闪退,再次打开软件点击拍照后进入失败的回调 提示error length=1;index=1
不过在本地相册选择图片上传是可以的
require("$UI/system/lib/cordova/cordova");
require("cordova!cordova-plugin-camera");
代码如下:
Model.prototype.liPhotoClick = function(event){
var me = this;
this.currentImgType = $(event.currentTarget).attr("imgtype");
if ($(this.getElementByXid("span_check_" + this.currentImgType)).css("display") == "none") {
$(this.getElementByXid("pp_photo")).show();
} else {
justep.Shell.showPage("bmphoto", {
imgType: this.currentImgType,
imgLabel: $(event.currentTarget).attr("imglabel"),
applyId: this.applyId,
backHandle: function(imgType){
console.log(imgType);
$(me.getElementByXid("span_check_" + imgType)).hide();
}
});
}
};
Model.prototype.liPopCloseClick = function(event){
$(this.getElementByXid("pp_photo")).hide();
};
Model.prototype.liSelPhotoClick = function(event){
var me = this;
if(!navigator.camera) {
return;
}
navigator.camera.getPicture(onLoadImageSuccess, onLoadImageFail, {
mediaType:0,
destinationType:navigator.camera.DestinationType.DATA_URL,
allowEdit:false,
quality:80,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
});
function onLoadImageSuccess(imageData){
$(me.getElementByXid("pp_photo")).hide();
var sendData = new Object();
sendData.applyId = me.applyId;
sendData.method = "UPLOAD_IMG_BASE64";
var imgs = new Array();
var img = new Object();
img.imgType = me.currentImgType;
img.imgContent = imageData;
imgs.push(img);
sendData.imgs = imgs;
sendData.userId = global_userid;
tfcall("DSP.C022", sendData, function (data){
if (data.replyCode == "1") {
$(me.getElementByXid("span_check_" + me.currentImgType)).show();
} else {
new MsgDialog({
parentNode : me.getElementByXid("panel_main")
}).show({
title:'提醒',
type:"OK",
message:data.errorMsg
});
}
});
}
function onLoadImageFail(error){
new MsgDialog({
parentNode : me.getElementByXid("panel_main")
}).show({
title:'错误',
type:"OK",
message:error
});
}
};
Model.prototype.liDoPhotoClick = function(event){
var me = this;
if(!navigator.camera) {
return;
}
navigator.camera.getPicture(onLoadImageSuccess, onLoadImageFail, {
destinationType:navigator.camera.DestinationType.DATA_URL,
allowEdit:false,
quality:80
});
function onLoadImageSuccess(imageData){
$(me.getElementByXid("pp_photo")).hide();
var sendData = new Object();
sendData.applyId = me.applyId;
sendData.method = "UPLOAD_IMG_BASE64";
var imgs = new Array();
var img = new Object();
img.imgType = me.currentImgType;
img.imgContent = imageData;
imgs.push(img);
sendData.imgs = imgs;
sendData.userId = global_userid;
tfcall("DSP.C022", sendData, function (data){
if (data.replyCode == "1") {
$(me.getElementByXid("span_check_" + me.currentImgType)).show();
} else {
new MsgDialog({
parentNode : me.getElementByXid("panel_main")
}).show({
title:'提醒',
type:"OK",
message:data.errorMsg
});
}
});
}
function onLoadImageFail(error){
new MsgDialog({
parentNode : me.getElementByXid("panel_main")
}).show({
title:'错误',
type:"OK",
message:error
});
}
};
|
|