92 lines
2.4 KiB
JavaScript
92 lines
2.4 KiB
JavaScript
(function($, window, document) {
|
|
var Request = Public.getRequest();
|
|
var imgName = Request['ImgName'];
|
|
var gongDanNo = Request['BillNo'];
|
|
var status = Request['Status'];
|
|
|
|
$.init({
|
|
swipeBack: false,
|
|
statusBarBackground: '#f7f7f7',
|
|
gestureConfig: {
|
|
doubletap: true
|
|
}
|
|
});
|
|
$.plusReady(function() {
|
|
postUrl = plus.storage.getItem('PostUrl');
|
|
//postUrl = "http://192.168.8.5:8081/Api.aspx";
|
|
if (status == "No") {
|
|
document.getElementById("Bar-Tab").classList.add("none");
|
|
var imgUrl = postUrl.substring(0, postUrl.length - 9);
|
|
var src = imgUrl + "/UpLoaded/" + gongDanNo + "/" + imgName;
|
|
var img = document.getElementById("BillImg");
|
|
img.src = src;
|
|
}
|
|
|
|
document.querySelector('#SendData_Btn').addEventListener('tap', function(e) {
|
|
plus.nativeUI.showWaiting("正在上传图片...");
|
|
uploadImgage("-1");
|
|
});
|
|
|
|
document.querySelector('#PaiZhao_Btn').addEventListener('tap', function(e) {
|
|
plus.nativeUI.showWaiting("正在打开摄像头...");
|
|
captureImage();
|
|
});
|
|
});
|
|
|
|
var captureImage = function() {
|
|
var cmr = plus.camera.getCamera();
|
|
var res = cmr.supportedImageResolutions[0];
|
|
var fmt = cmr.supportedImageFormats[0];
|
|
console.log("Resolution: " + res + ", Format: " + fmt);
|
|
cmr.captureImage(function(path) {
|
|
plus.nativeUI.closeWaiting();
|
|
console.log("Capture image success: " + path);
|
|
plus.io.resolveLocalFileSystemURL(path, function(entry) {
|
|
//转化本地绝对路径
|
|
var img = document.getElementById("BillImg");
|
|
img.src = entry.fullPath;
|
|
});
|
|
},
|
|
function(error) {
|
|
console.log("Capture image failed: " + error.message);
|
|
}, {
|
|
resolution: res,
|
|
format: fmt
|
|
}
|
|
);
|
|
};
|
|
|
|
var uploadImgage = function(billNo) {
|
|
var url = postUrl;
|
|
var img = document.getElementById("BillImg");
|
|
var imgPath = img.src;
|
|
var task = plus.uploader.createUpload(url, {
|
|
method: "POST",
|
|
blocksize: 204800,
|
|
priority: 100
|
|
},
|
|
function(t, status) {
|
|
// 上传完成
|
|
plus.nativeUI.closeWaiting();
|
|
if (status == 200) {
|
|
plus.nativeUI.toast("上传成功");
|
|
document.getElementById("BillImg").src = "";
|
|
$.back();
|
|
} else {
|
|
plus.nativeUI.toast("上传成功");
|
|
document.getElementById("BillImg").src = "";
|
|
$.back();
|
|
}
|
|
}
|
|
);
|
|
task.addFile(imgPath, {
|
|
key: "-1"
|
|
});
|
|
task.addData("ServiceName", "UploadImg");
|
|
task.addData("billNo", "-1");
|
|
task.addData("gongDanNo", gongDanNo);
|
|
task.start();
|
|
};
|
|
|
|
}(mui, window, document));
|