|
楼主 |
发表于 2016-5-17 18:08:24
|
显示全部楼层
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<!--控制手机全屏 : 强制让文档的宽度与设备的宽度保持1:1,并且文档最大的宽度比例是1.0,且不允许用户点击屏幕放大浏览-->
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<title></title>
<script src='/cordova.js' type='text/javascript'></script>
<!--oa知道首页tab切换-->
<script type="text/javascript" charset="utf-8">
var pictureSource; //图片来源
var destinationType; //设置返回值的格式
// 等待PhoneGap连接设备
document.addEventListener("deviceready",onDeviceReady,false);
// PhoneGap准备就绪,可以使用!
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
function onLoadImageFail(message) {
alert(message);
}
function oncameraImageFail(message) {
alert(message);
}
function loadImageLocal() {
//获取本地图片并显示在屏幕
navigator.camera.getPicture(onLoadImageLocalSuccess, onLoadImageFail, {
//mediaType : 0,//只选择图片
quality: 50,
//targetWidth:800, //图片输出宽度
//targetHeight:800, //图片输出高度
//destinationType: destinationType.FILE_URI,
//sourceType: pictureSource.PHOTOLIBRARY,
//saveToPhotoAlbum:false
sourceType : 0,// 0、2为从相册文件中选择,1为拍照
argetWidth:800, //图片输出宽度
targetHeight:800 //图片输出高度
});
}
//本地图片选择成功后回调此函数
function onLoadImageLocalSuccess(imageURI) {
uploadPic(imageURI,"photo");
}
function loadImageUpload() {
//拍照上传并显示在屏幕
navigator.camera.getPicture(onLoadImageUploadSuccess, oncameraImageFail, {
quality: 50,
destinationType: destinationType.FILE_URI,
targetWidth:800, //图片输出宽度
targetHeight:800, //图片输出高度
saveToPhotoAlbum:true
});
}
//图片拍照成功后回调此函数
function onLoadImageUploadSuccess(imageURI) {
uploadPic(imageURI,"camera");
}
function uploadPic(imageURI,type){
alert("upload"+type);
}
</script>
</head>
<body>
<form name=frmMain>
<span class="anzhuo_ico" id="camera_oa" >拍照</span>
<span class="anzhuo_ico" id="add_img" >相册</span>
</form>
</body>
</html>
|
|