<!DOCTYPE html>
<html class="ui-mobile landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title>
</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="css/ui-media.css">
<link rel="stylesheet" href="css/ui-base.css">
<link rel="stylesheet" href="css/ui-apple.css">
<script src="js/zy_anim.js">
</script>
<script src="js/zy_control.js">
</script>
<script src="js/zy_tmpl.js">
</script>
</head>
<body class="ui-mobile-viewport" >
<div id="page" class="ui-page ui-body-d ui-page-active ui-header-fixed" tabindex="0">
<div data-role="header" class="ui-header ui-bar-iphone " >
<h1 class="ui-title" tabindex="0" role="heading" aria-level="1">Images</h1>
<div class="ui-btn ui-btn-right ui-btn-corner-all ui-shadow ui-btn-a " οnclick="actionsheet();"> <span class="ui-btn-inner ui-btn-corner-all"> <span class="ui-btn-text">选择</span> </span></div>
</div>
<div id="msgid" class="ui-bar ui-bar-e ">
</div>
<div class="ui-content ui-body-d">
<img id="imgid" src="img/2.png" style="height:500px;width:450px;position:absolute;left:0.5em;"/>
</div>
<div data-role="footer" class="ui-footer ui-bar-a ui-footer-fixed">
<div class="ui-bar ui-bar-a ">
<div class="ui-btn ui-btn-corner-all ui-shadow ui-btn-a ui-btn-inline " οnclick="viewpic();"> <span class="ui-btn-inner ui-btn-corner-all"> <span class="ui-btn-text">图片查看器</span> </span> <button class="ui-btn-hidden">按钮</button> </div>
<div class="ui-btn ui-btn-corner-all ui-shadow ui-btn-a ui-btn-inline " οnclick="downloadurl();"> <span class="ui-btn-inner ui-btn-corner-all"> <span class="ui-btn-text">下载网络图片</span> </span> <button class="ui-btn-hidden">按钮</button> </div>
<div class="ui-btn ui-btn-corner-all ui-shadow ui-btn-a ui-btn-inline " οnclick="uploadpic();"> <span class="ui-btn-inner ui-btn-corner-all"> <span class="ui-btn-text">上传</span> </span> <button class="ui-btn-hidden">按钮</button> </div>
</div>
</div>
</div>
<script>
var imgurl = "wgt://img/2.png";//默认图片url
//显示log
function setLog(msg){
document.getElementById("msgid").innerHTML = msg;
}
//弹出actionSheet
function actionsheet(){
uexWindow.actionSheet("选择图片", "取消", ["照相机拍摄","本地文件","网络文件"]);
}
//通过图片查看器查看图片
function viewpic(){
var ar = new Array();
ar[0]=imgurl;
uexImageBrowser.open(ar);
}
//下载网络图片
var dopCode=1;
var inSavePath=null;
function downloadurl(){
if(imgurl.indexOf("http://")==0){
var q = imgurl.match(/.*\.(.*)/);
inSavePath = (new Date()).getTime()+"."+q[1];
uexDownloaderMgr.createDownloader(dopCode);
}else{
uexWindow.toast(0,5,"非网络图片",1000);
}
}
//上传图片
var uploadHttp = "http://*.*.net/server/upload.php";
/*upload.php 和普通的上传一样, 你写个upload.php,文件里面就一个<?php file_put_contents('log',print_r($_FILES,1));就知道了,不要来加群,就为了问这个,谢谢*/
var uopCode =2;
function uploadpic(){
if(imgurl.indexOf("http://")<0)
uexUploaderMgr.createUploader(uopCode,uploadHttp);
else
uexWindow.toast(0,5,"非本地图片",1000);
}
window.uexOnload = function(){
uexWindow.cbActionSheet = function(opId,dataType,data){
switch(parseInt(data)){
case 0:
uexCamera.open();
break;
case 1:
uexFileMgr.explorer("");
break;
case 2:
uexWindow.prompt("提示", "输入网络图片URL", "",["确定","取消"]);
break;
}
}
uexWindow.cbPrompt=function(opId,dataType,data){
if(dataType==1){
var d = eval("("+data+")");
if(d.num=="0"){
if(d.value.indexOf('http://')>-1){
imgurl=d.value;
document.getElementById("imgid").src=imgurl;
}
else
alert("网络URL错误");
}
}
}
uexCamera.cbOpen = function(opId,dataType,data){
if(dataType==0)
{
imgurl = data;
document.getElementById("imgid").src=imgurl;
}
}
uexFileMgr.cbExplorer = function(opId,dataType,data){
uexLog.sendLog(dataType);
if(dataType==0){
uexLog.sendLog(data);
imgurl = data;
document.getElementById("imgid").src=imgurl;
uexLog.sendLog(document.getElementById("imgid").src);
}
}
//****************下载回调***************
uexDownloaderMgr.cbCreateDownloader=function(opId,dataType,data){
uexDownloaderMgr.download(dopCode,imgurl,inSavePath,0);
setLog("开始下载图片");
}
uexDownloaderMgr.onStatus = function(opId,fileSize,percent,status){
if(status == 0)
setLog("下载进度:"+percent+"%");
if(status == 1){
setLog("下载完成");
imgurl = inSavePath;
uexDownloaderMgr.closeDownloader(dopCode);
}
if(status == 2){
setLog("下载出错");
uexDownloaderMgr.closeDownloader(dopCode);
uexFileMgr.deleteFileByPath(inSavePath);
}
}
//******************************************
//****************上传回调***************
uexUploaderMgr.cbCreateUploader = function(opId,dataType,data){
uexUploaderMgr.uploadFile(uopCode,imgurl,"filename",1);
setLog("开始上传图片");
}
uexUploaderMgr.onStatus = function(opId,fileSize,percent,serverPath,status){
if(status==0)
setLog("上传进度:"+percent+"%");
if(status == 1){
setLog("上传完成");
uexUploaderMgr.closeUploader(uopCode);
}
if(status == 2){
setLog("上传出错");
}
}
//******************************************
}
</script>
</body>
</html>
我的QQ群:
PHPer&Webgame&移动开发,群号:95303036