<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>史带支付</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
 <script language="javascript">
    var out_trade_no = "<%= request.getAttribute("out_trade_no") %>";
    var finished = 0;
    var XMLHttpReq;  
        //创建XMLHttpRequest对象         
        function createXMLHttpRequest() {  
            if(window.XMLHttpRequest) { //Mozilla 浏览器  
                XMLHttpReq = new XMLHttpRequest();  
            }  
            else if (window.ActiveXObject) { // IE浏览器  
                try {  
                    XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");  
                } catch (e) { 
                	alert(e); 
                    try {  
                        XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");  
                    } catch (e) {alert(e);}  
                }  
            }  
        }  
        //发送请求函数  
        function sendRequest() {  
            createXMLHttpRequest();  
            var url = "payResult?out_trade_no="+out_trade_no;  
            XMLHttpReq.open("GET", url, true);  
            XMLHttpReq.onreadystatechange = processResponse;//指定响应函数  
            XMLHttpReq.send(null);  // 发送请求  
        }  
        // 处理返回信息函数  
        function processResponse() {  
            if (XMLHttpReq.readyState == 4) { // 判断对象状态  
                if (XMLHttpReq.status == 200) { // 信息已经成功返回，开始处理信息  
	                if(finished == 0){
	                    DisplayHot();  
	                    setTimeout("sendRequest()", 2000);
	                }  
                } else { //页面不正常  
                    window.alert("您所请求的页面有异常。");  
                }  
            }  
        }  
        function DisplayHot() {  
            //var name = XMLHttpReq.responseXML.getElementsByTagName("name")[0].firstChild.nodeValue;  
            //var count = XMLHttpReq.responseXML.getElementsByTagName("count")[0].firstChild.nodeValue;  
            //document.getElementById("product").innerHTML = name;      
            //document.getElementById("count").innerHTML = count;   
            var result = XMLHttpReq.responseText;
            //alert('in DisplayHot ,result = '+result);
            //alert( result == "OK");
            if(result == "OK"){
            	finished = 1;
            	//fm.saomiao.style.display = "none";
            	//fm.jieguo.style.display = "";
            	document.getElementById("saomiao").style.display="none";//隐藏  
				document.getElementById("jieguo").style.display="";//显示  
            }
            
        }  
      
      
    </script>    
  <body >
  	<form name="fm">
	  	<div id="saomiao">
		  <table align="center">
		  	<tr align="center"><td colspan="2"><b>请打开微信扫码支付</b></td></tr>
		  	<tr><td colspan="2"><img  style="height:200px;width:200px" src=<%=request.getParameter("payurl") %> /></td></tr>
		  </table>
		</div>
	  	<div id="jieguo" style="display:none">
		  <table align="center">
		  	<tr align="center"><td colspan="2"><b>支付成功！</b></td></tr>
		  </table>
		</div>
	</form>
  </body>
</html>
