我正在使用Phonegap
,我需要拍摄最少 2 张和最多 8 张照片。我需要在同一个屏幕上显示所有拍摄的照片。我可以拍摄 1 张照片并显示,但无法显示所有 8 张照片。
另外,我需要将这些图像附加到邮件中。如果我给了“/mnt/sdcard/Android/data/pacakgename/cache/1380176187637.jpg”,我正在使用电子邮件作曲家,那么它会附在邮件中,但所有 8 张图片都没有附上。在下面的屏幕截图中,您可以看到只查看了一张图片:
我只能显示一张图片,但我需要显示所有 8 张图片并将其附加到邮件中。
以下是我的代码
<html>
<head>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="emailcomposer.js"> </script>
<script type="text/javascript">
function deviceready() {
console.log("Device ready");
destinationType=navigator.camera.DestinationType;
}
var destinationType; // sets the format of returned value
function composeText(){
//console.log();
var file1 = document.getElementById('vehiclepic1').value
var message1 = document.getElementById('message_body').value;
console.log(message1);
window.plugins.emailComposer.showEmailComposer(
"Get Estimation",
message1,
["sth@mail.com",],
[],
[],
true,
["image.jpeg", "file.zip"]
);
}
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL });
}
function onPhotoDataSuccess(imageData) {
// Uncomment to view the base64-encoded image data
// console.log(imageData);
// Get image handle
//
var i = 0;
if(imageData.length != 0){
i++;
//alert(i++);
var smallImage = document.getElementById('vehiclepic1');
// Unhide image elements
//
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
smallImage.src = "data:image/jpeg;base64," + imageData;
}
}
function onFail(message) {
alert('Failed because: ' + message);
}
function callAnotherPage(){
window.location = "test.html";
}
document.addEventListener("deviceready", deviceready, true);
</script>
<style type="text/css">
li{
list-style: none;
float:left;
padding: 0 5 5 0 ;
}
</style>
</head>
<body>
Pictures
<ul>
<li>
<img style="width:100px;height:80px;" id="vehiclepic1" onclick="capturePhoto();" src="" />
</li>
<li>
<img style="width:100px;height:80px;" id="vehiclepic2" src="" onclick="capturePhoto();"/>
</li>
<li>
<img style="width:100px;height:80px;" id="vehiclepic3" src="" onclick="capturePhoto();" />
</li>
<li>
<img style="width:100px;height:80px;" id="vehiclepic4" src="" onclick="capturePhoto();"/>
</li>
<li>
<img style="width:100px;height:80px;" id="vehiclepic5" src="" onclick="capturePhoto();"/>
</li>
<li>
<img style="width:100px;height:80px;" id="vehiclepic6" src="" onclick="capturePhoto();"/>
</li>
<li>
<img style="width:100px;height:80px;" id="vehiclepic7" src="" onclick="capturePhoto();"/>
</li>
<li>
<img style="width:100px;height:80px;" id="vehiclepic8" src="" onclick="capturePhoto();"/>
</li>
</ul>
<div style="clear:both;"></div>
<button onclick="callAnotherPage();">Next</button>
</body>
任何想法。