Files
SinoGYS/webapp/supplier/uploadPhoto.jsp
2018-07-12 14:08:55 +08:00

143 lines
4.5 KiB
Plaintext

<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page isELIgnored="false" %>
<%@ page import="com.sino.weixin.oauth.util.*"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>照片上传</title>
<link rel="stylesheet" href="/SinoGYS/weixincss/weui.min.css">
<link rel="stylesheet" href="/SinoGYS/weixincss/jquery-weui.css">
<link rel="stylesheet" href="/SinoGYS/css/newCss/reset.css" />
<link rel="stylesheet" href="/SinoGYS/css/newCss/uploadPhoto.css" />
<script src="/SinoGYS/js/jquery-1.7.2.js" type="text/javascript"></script>
<script src="/SinoGYS/js/jquery-weui.js"></script>
<script src="/SinoGYS/js/ajaxHelper.js" type="text/javascript"></script>
<script src="/SinoGYS/js/json2.js" type="text/javascript"></script>
<script type="text/javascript">
var ohtml=document.documentElement;
function getWidth(){
var screenWidth=ohtml.clientWidth;
if(screenWidth<320){
ohtml.style.fontSize="13.3333px";
}else if(screenWidth>1080){
ohtml.style.fontSize="45px";
}else{
ohtml.style.fontSize=screenWidth/(1080/45)+"px";
}
}
getWidth();
window.onresize=function(){
getWidth();
};
</script>
</head>
<%
String rescueCode=request.getParameter("rescueCode");
String code=request.getParameter("code");
System.out.print(code+"此时状态");
%>
<body>
<form >
<input type="hidden" id="orderId" name="orderId" value="${param.orderId}">
<input type="hidden" id="state" name="state" value="${param.state}">
<input type="hidden" id="image_0" name="image_0" value="">
<input type="hidden" id="image_1" name="image_1" value="">
<input type="hidden" id="image_2" name="image_2" value="">
<input type="hidden" id="image_3" name="image_3" value="">
</form>
<div class="uploadWrapper">
<div class="uploadTitle">
照片最多上传4张
</div>
<div class="photoWrapper clearfix">
<div class="photo">
</div>
<div class="imgWrapper" id="chooseImage">
<a href="#"><img src="/SinoGYS/images/newImage/addIcon.png" /></a>
</div>
</div>
<div class="inputWrapper">
<input class="loginFormSubmit loginBtnActive" type="button" value="确 定">
</div>
</div>
</body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"> </script>
<script>
$(document).ready(function() {
checkWeixinApi();
});
function checkWeixinApi(){
var targetUrl = window.location.href;
var action = "/SinoGYS/ApiSignatureAction.do?CMD=signature&url="+targetUrl+"&d="+((new Date()).getTime());
ajaxRequest(action,function(_response){
var data = _response.responseTEXT;
if (data!=null){
var obj = new Function("return" + data)();
wx.config({
debug: false,
appId: obj.appId,
timestamp: obj.timestamp,
nonceStr: obj.nonce,
signature: obj.signature,
jsApiList:[
'chooseImage',
'uploadImage',
]
});
} else {
alert("失败");
}
},false);
}
function showImage(data,i){
var imageUrl=null;
imageUrl = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=<%=Constants.ACCESS_TOKEN %>&media_id="+data;
console.log(imageUrl);
$(".photo").append('<div class="imgWrapper"><img src="'+imageUrl+'"/><input type="hidden" name="img_div" value="'+data+'"></div>');
}
$(".loginBtnActive").click(function(){
$.showLoading("上传中...");
var images=document.getElementsByName("img_div");
//alert(images.length);
for(var i=0;i<images.length;i++){
$("#image_"+i).val(images[i].value);
}
$.ajax({
async: true,
url:"/SinoGYS/DownLoadImageAction.do?CMD=upload",
dataType: "json",
type: "POST",
data: $("form").serialize(),
success: function (jsonObject) {
if(jsonObject.code==true){
$.hideLoading();
alert("成功上传照片");
window.location.href="http://www.sino-assist.com:8099/jsp/clientCustomer/jsp/takePhoto.jsp?rescueCode="+<%=rescueCode%>+"&code="+"<%=code%>";
// window.location.href="http://www.sinoassistance.com:8380/jsp/clientCustomer/jsp/takePhoto.jsp?rescueCode="+<%=rescueCode%>+"&code="+"<%=code%>";
}
}
});
});
</script>
<script src="/SinoGYS/js/weixin-api-6.1_1.js?d=2018030559859"> </script>
</html>