//5+拍照
function photographWork(arr) {
var imgPathArr = arr;
var cmr = plus.camera.getCamera();
cmr.captureImage(function(path) {
plus.io.resolveLocalFileSystemURL(path, function(entry) {
var localurl = entry.toLocalURL();
imgPathArr.push(localurl);
plus.nativeUI.confirm('当前已拍摄:'+imgPathArr.length+'张\n是否继续拍摄',function(res){
if(res.index == 0){
photographWork(imgPathArr);
}else{
//开始上传作业
uploadWorks(imgPathArr);
}
},{
title: '提示',
buttons: [
'继续拍摄',
'开始上传'
]
});
}, function(e) {
toast('读取拍照文件错误:' + e.message);
});
}, function(e) {
alert(JSON.stringify(e));
plus.nativeUI.confirm('当前已拍摄:'+imgPathArr.length+'张\n是否放弃作业上传',function(res){
if(res.index == 0){
photographWork(imgPathArr);
}else if(res.index == 2){
//开始上传作业
uploadWorks(imgPathArr);
}
},{
title: '提示',
buttons: [
'继续拍摄',
'放弃上传',
'开始上传'
]
});
}, {
filename: '_doc/head.jpg',
});
}
//5+相机选择
function albumWork() {
plus.gallery.pick(function(path) {
var path = path.files;
plus.nativeUI.confirm('已选择:'+path.length+'张照片\n是否开始上传',function(res){
if(res.index == 0){
uploadWorks(path);
}else{
albumWork();
}
},{
title: '提示',
buttons: [
'开始上传',
'重新选择'
]
})
}, function(e) {
toast('取消选择图片');
}, {
filter: 'image',
multiple: true
});
}
//上传作业图集
function uploadWorks(pathArr){
// TODO 上传作业
showWating('作业上传中...');
$ajax({
url: '/uploadSubject.jspx',
data: {
userId: userItem.userId,
SubjectType: workType,
photoCount: pathArr.length
},
success: function(data){
if(+data['code'] == 1000){
uploadImgFun(pathArr, 0, data['result']);
}else{
closeWating();
showToast(data['message']);
}
},
error: function(e){
closeWating();
showToast('上传作业失败,请重试');
}
})
}
function uploadImgFun(paths, i, items){
imgUrlToBlob(paths[i], function(img, imgWidth, imgHeight){
var config = {
useCdnDomain: true,
disableStatisticsReport: false,
retryCount: 6,
};
var putExtra = {
fname: "",
params: {},
mimeType: null
};
var observable = qiniu.upload(img, items[i]['key'], items[i]['token'],putExtra ,config);
var subscription = observable.subscribe({
next: function(res){
},
error: function(err){
closeWating();
showToast("上传作业失败");
},
complete: function(res){
res['userId'] = userItem.userId;
res['photoId'] = items[i]['photoId'];
res['photoSort'] = items[i]['photoSort'];
res['groupId'] = items[i]['groupId'];
res['qiniuKey'] = items[i]['qiniuKey'];
res['subjectType'] = workType;
res['width'] = imgWidth;
res['height'] = imgHeight;
$ajax({
url: '/uploadOKSubject.jspx',
data: res,
success: function(data){
closeWating();
if(+data['code']==1000){
}else{
}
},
error: function(e){
}
})
i = i+1;
if(i < paths.length){
uploadImgFun(paths, i, items);
}else{
closeWating();
showToast('作业上传完成');
}
}
}) // 上传开始
})
}
plus.nativeUI.confirm("请选择您需要上传的作业科目", function(res){
if(res.index == 0){
workType = '02';
}else{
workType = '01';
}
var bts = [{
title: "拍照"
}, {
title: "从相册选取"
}];
//5+actionSheet
if(res.index == 0 || res.index == 1){
plus.nativeUI.actionSheet({
title: "上传作业",
cancel: "取消",
buttons: bts
},
function(e) {
var idx = e.index;
switch(idx) {
case 0:
break;
case 1:
photographWork([]);
break;
case 2:
albumWork();
break;
default:
break;
}
}
);
}
},{
title: '选择科目',
buttons: [
'数学',
'语文'
]
})
6 个回复
sureyinZero (作者)
sureyinZero (作者)
自己顶起
sureyinZero (作者)
这是。。没有人来回应一下的吗?
sureyinZero (作者)
再顶最后一次了
l***@163.com
顶一次,这是android 7.1.1版本的问题,有没有人解决
sureyinZero (作者)
这个问题没有人来解决的吗?