<!VDNDOC "PageBase":"nvo_wxpay_qr","IniEvent":"PageIni">
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>微信扫码支付</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="css/mui.min.css">
		<style>
			p1 {
				text-indent: 22px;
				padding: 5px 8px;
			}
			
			h4 {
				margin-left: 5px;
			}
			
			#qrcode,
			#barcode {
				display: inline-block;
				margin: 20px auto;
				//box-shadow: 0 0 16px rgba(0, 0, 0, 0.5);
			}
			
			#qrcode>*,
			#barcode>* {
				display: block;
			}
		</style>
	</head>

	<body>
		<div class="mui-content-padded">
			<img id="img-buffer" src="images/weixin.png" class="mui-hidden" />
			<h3>请使用微信扫码支付</h3>
			<div class="mui-content-padded mui-text-center">
				<div id="qrcode-hide" class="qrcode mui-hidden"></div>
				<img id='imgQR' class="qrcode" />
				<h5>后台生成图片</h5>
			</div>
			<br/>
			<div class="mui-content-padded mui-text-center">
				<div id="qrcode" class="qrcode"></div>
				<h5>前台使用jquery-qrcode动态生成</h5>
			</div>
			<br/>
			<div id="d_content" class="mui-text-center result"></div>
		</div>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" src="js/jquery-2.2.3.min.js"></script>
		<script src="js/jquery.tmpl.js"></script>
		<script type="text/javascript" src="js/jquery-qrcode-0.14.0.min.js"></script>
		<script src="js/vdn.js"></script>
		<script>
			$(function() {
				//==================二维码=======================
				//选项
				var options = {
					render: "canvas", //canvas\image\div
					minVersion: 6,
					fill: "#000000",
					text: "<!--INCLUDE:qr_text;JS-->",
					size: 189,
					radius: 0.5,
					//中央图标 2:Label 4:Image
					mode: 4, //0 无  1 显示label  4 显示图片
					mSize: 0.15,
					mPosX: 0.5,
					mPosY: 0.5,

					label: "Vesn",
					fontname: "Ubuntu",
					fontcolor: "#FF9818",
					image: $('#img-buffer')[0]
				};
				//生成二维码
				if(result == false) {
					jQuery('#qrcode').qrcode(options);
				}
			});

			var result = "/*<!--INCLUDE:pay_result;JS-->*/";
			$(document).ready(function() {
				if(result == false) {
					mui("#d_result").button('loading');
					setTimeout(function() {
						GetResult()
					}, 3000);
				}
			});
			//获取支付结果
			var iCount = 0;

			function GetResult() {
				iCount++;
				vdn.get({
						method: 'nvo_wxpay_qr.getresult',
						params: '<!--INCLUDE:billid;JS-->' + "/" + iCount.toString(),
					}, function(data) {
						if(data.Result != "N" && data.Result != "NULL" && data.Result != "C") {
							result = true;
							$(location).prop('href', "pay_result2.html?id=" + "<!--INCLUDE:billid;JS-->");
						} else {
							var n = 3000;
							if(data.Result == "C") $("#d_content").text("已扫码");
							if(data.Result != "NULL") n = 2000;
							setTimeout(function() {
								GetResult()
							}, n);
						}
					},
					function(err) {
						alert(err.Message + "(" + err.Code.toString() + ")");
					});
			}
		</script>
	</body>

</html>