$def with (data)
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>购买宝塔Linux专业版</title>
		<script src="/static/js/jquery-1.10.2.min.js" language="javascript"></script>
		<script src="/static/layer/layer.js"></script>
		<script src="/static/js/jquery.qrcode.min.js"></script>
	</head>
	<style>	body{background-color:#f7f7f7;line-height:1.4;color:#333;font-family:"微软雅黑",Arial,Helvetica,sans-serif;font-size:12px}input,textarea,select{font-size:100%;font-family:inherit}body,h1,h2,h3,h4,h5,h6,p,ul,ol,form{margin:0}h4,h5,h6{font-size:1em}ul,ol{padding-left:0;list-style-type:none}fieldset,img{border:0}a{color:#333;border:0;text-decoration:none}a:hover{text-decoration:none}a:link{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-touch-callout:none}:-moz-placeholder{color:#999}::-moz-placeholder{color:#999}input:-ms-input-placeholder{color:#999}input::-webkit-input-placeholder{color:#999}
		.hide{
			display:none
		}
		.bt-input-text {
			box-sizing: border-box;
			border: 1px solid #ccc;
			padding-left: 5px;
			border-radius: 3px;
			-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
			-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
			transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s
		}
		
		.bt-input-text:focus,
		.bt-input-text:active {
			border: #66afe9 1px solid;
			-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
			box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6)
		}
		.bt-submit {
			background-color: #20a53a;
			border-radius: 3px;
			width: 140px;
			height: 34px;
			line-height: 34px;
			text-align: center;
			color: #fff;
			cursor: pointer
		}
		.cursor {
			cursor: pointer
		}
		.text-right{
			text-align: right;
		}
		.libLogin{
			width: 400px;
		    height: 300px;
		    position: absolute;
		    left: 50%;
		    top: 50%;
		    margin-top: -165px;
		    margin-left: -240px;
		    border: #cecece;
		    background: #fff;
		    border-radius: 5px;
		    padding:0 40px 30px 40px;
		    box-shadow: 0 0 50px #ccc;
		}
		.btlink{
			color: #20A53A;
		}
		.title{
		    color: #444;
		    font-family: "微软雅黑";
		    font-size: 26px;
		    margin: 30px 0 30px;
		    text-align: center;
		    font-weight: normal;
		}
		.libLogin .bt-input-text {
		    width: 100%;
		    height: 40px;
		    line-height: 40px;
			padding-left:10px;
		}
		.libLogin .line{
			margin-bottom: 20px;
			position:relative;
		}
		.libLogin .login-button{
			width: 100%;
		    height: 44px;
		    background: #20a53a;
		    background: linear-gradient(#20a53a,#189d32);
		    box-shadow: inset 0 1px 2px #30ad42;
		    color: #fff;
		    text-shadow: #00851a 0 -1px 0;
		    border: 1px solid #20a53a;
		    text-align: center;
		    font-size: 16px;
		    color: #fff;
		    border-radius: 3px;
		    cursor: pointer;
		}
		.libLogin .login-button:hover{background:#10952a;background:linear-gradient(#10952a,#088d22);border:1px solid #10952a}
		.paypro_1{
			width: 916px;
			position: absolute;
			left: 50%;
			top: 15%;
			margin-left: -458px;
			border: #cecece;
			background: #fff;
			box-shadow: 0 0 50px #ccc;
		}
		.paypro{
			width: 770px;
			position: absolute;
			left: 50%;
			top: 15%;
			margin-left: -385px;
			border: #cecece;
			background: #fff;
			box-shadow: 0 0 50px #ccc;
		}
		.paypro .tit{
		    height: 42px;
		    line-height: 42px;
		    border-bottom: 1px solid #eee;
		    font-size: 14px;
		    color: #333;
		    background-color: #f3f3f3;
		    padding: 0 20px;
		}
		.pd20{
			padding: 20px 30px;
		}
		.bt-account{
			margin-bottom: 20px;
		}
		.account-title{
			font-size: 14px;
		}
		.account-name{
			font-weight:bold;
		}
		.change-id{
			color: #20A53A;
			font-size: 12px;
			margin-left: 10px;
			cursor: pointer;
		}
		.glyphicon-refresh{
			background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAMBAMAAABGh1qtAAAAA3NCSVQICAjb4U/gAAAAMFBMVEX///8gpTogpTogpTogpTogpTogpTogpTogpTogpTogpTogpTogpTogpTogpTogpTpS39cHAAAAEHRSTlMAESIzRFVmd4iZqrvM3e7/dpUBFQAAAAlwSFlzAAALEgAACxIB0t1+/AAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNi8wNy8xOPcaU5AAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzbovLKMAAAAXElEQVQImQ3JLRJAQACA0W/Xzy2YrRqjiHsFyTX2BLJbiGakzYIZmkqSiLS9wfLqg+w6lSF8iup1pBp6RweRdxwQlDkOEJa/kDfjALHFL5Bo/IrcYG+n2YASTQ0fPdIYtgAVvVMAAAAASUVORK5CYII=");
			width: 11px;
			height: 12px;
			margin-right: 5px;
			display: inline-block;
			vertical-align: -2px;
		}
		.pay-type{
			height: 40px;
			margin-bottom: 15px;
		}
		.pay-type span{
			height: 40px;
			line-height: 36px;
			width: 130px;
			box-sizing: border-box;
			border: #ddd 1px solid;
			text-align: center;
			display: block;
			float: left;
			margin-right: 15px;
			font-size: 14px;
			color: #444444;
			cursor: pointer;
			transition: border-color .1s ease-in,color .1s ease-in;
			padding:1px;
		}
		.pay-type span:hover,.cycle-item:hover{
			border-color: #20A53A;
		}
		.pay-type .on,.cycle-item.on{
			background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAAAA3NCSVQICAjb4U/gAAAAdVBMVEX///8loj4moz/z//bu//Hr/+/j/+nc/+PZ/+HP/9jB/866/8iy/8Gv/7+t/72i/7Wa/69y74tT0GxRzmpQzWlNymZLyGRJxmJIxWFEwV0/vFg9ulY7uFQ3tFA2s081sk40sU0zsEwyr0sxrkowrUktqkYsqUU5eNs/AAAAJ3RSTlMAd4j///////////////////////////////////////////////+C06LGAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAFnRFWHRDcmVhdGlvbiBUaW1lADA2LzA3LzE49xpTkAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAACFSURBVCiRdc5JAoIwEETRgigqiorzhAND3/+Iik2AJN21+Ju3KcSkDNAIKkEliLR7duLT3uRWLL2qtmezrXthapabkuiWZCUNwnQw689jnr5pLEzHySpdFOQK02k6u5MvTJcrheKeh0quIFJlRL4MFEhPoVgSpCNJmET5kywtKfIjTRB9Ac7nKdRpF+QDAAAAAElFTkSuQmCC") no-repeat right top;
			border: #20A53A 2px solid;
			padding:0;
		}
		.cycle{
			float: left;
			margin-bottom: 15px;
			overflow: auto;
			width: 100%;
		}
		.cycle-item{
			padding:1px;
			float: left;
			width: 130px;
			height: 140px;
			border: #ddd 1px solid;
			margin-right: 15px;
			margin-bottom:15px;
			box-sizing: border-box;
			cursor: pointer;
			transition: border-color .1s ease-in,color .1s ease-in;
		}
		.cycle-item:nth-of-type(5n){
			margin-right: 0;
		}
		.cycle-item:hover{
			box-shadow: 0 0 38px rgba(0, 0, 0, .03) inset;
		}
		.total{
			text-align: center;
			height: 83px;
			padding-top: 16px;
		}
		.sale-price{
			font-size: 30px;
			color: #313131;
			margin-right: 5px;
		}
		.yuan{
			font-size: 14px;
			color: #969696;
		}
		.o-price{
			color: #aaa;
		}
		.cy-len{
			border-top: 1px dashed #ddd;
			margin: 0 10px;
			text-align: center;
			height: 38px;
			line-height: 38px;
			font-size: 16px;
			position: relative;
		}
		.cy-len span{
		    color: #ff7300;
		}
		.lib-price-box {
		    padding-bottom: 5px;
		}
		.lib-price-name, .price-txt {
		    margin-right: 6px;
		    font-size: 14px;
		}
		.price-txt{
			color: #FF7301;
		}
		.pay-sale-price {
		    font-size: 20px;
		    margin-right: 5px;
		}
		.lib-price-box{
			float: left;
			height: 30px;
			width: 100%;
			text-align: center;
		}
		.paymethod{
			clear: both;
			text-align: center;
			margin-bottom: 15px;
		}
		.paymethod .pay-wx canvas{
		    width: 150px;
		    height: 150px;
		    border: #ddd 1px solid;
		    margin: 6px auto;
			padding:5px;
			border-bottom-color:#00c800;
		}
		.loading{
			background-image: url("data:image/gif;base64,R0lGODlhJQAlAJECAL3L2AYrTv///wAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFCgACACwAAAAAJQAlAAACi5SPqcvtDyGYIFpF690i8xUw3qJBwUlSadmcLqYmGQu6KDIeM13beGzYWWy3DlB4IYaMk+Dso2RWkFCfLPcRvFbZxFLUDTt21BW56TyjRep1e20+i+eYMR145W2eefj+6VFmgTQi+ECVY8iGxcg35phGo/iDFwlTyXWphwlm1imGRdcnuqhHeop6UAAAIfkEBQoAAgAsEAACAAQACwAAAgWMj6nLXAAh+QQFCgACACwVAAUACgALAAACFZQvgRi92dyJcVJlLobUdi8x4bIhBQAh+QQFCgACACwXABEADAADAAACBYyPqcsFACH5BAUKAAIALBUAFQAKAAsAAAITlGKZwWoMHYxqtmplxlNT7ixGAQAh+QQFCgACACwQABgABAALAAACBYyPqctcACH5BAUKAAIALAUAFQAKAAsAAAIVlC+BGL3Z3IlxUmUuhtR2LzHhsiEFACH5BAUKAAIALAEAEQAMAAMAAAIFjI+pywUAIfkEBQoAAgAsBQAFAAoACwAAAhOUYJnAagwdjGq2amXGU1PuLEYBACH5BAUKAAIALBAAAgAEAAsAAAIFhI+py1wAIfkEBQoAAgAsFQAFAAoACwAAAhWUL4AIvdnciXFSZS6G1HYvMeGyIQUAIfkEBQoAAgAsFwARAAwAAwAAAgWEj6nLBQAh+QQFCgACACwVABUACgALAAACE5RgmcBqDB2MarZqZcZTU+4sRgEAIfkEBQoAAgAsEAAYAAQACwAAAgWEj6nLXAAh+QQFCgACACwFABUACgALAAACFZQvgAi92dyJcVJlLobUdi8x4bIhBQAh+QQFCgACACwBABEADAADAAACBYSPqcsFADs=");
			background-repeat:no-repeat;
			background-position:62px 41px;
			border: #ddd 1px solid;
			width: 150px;
			height: 150px;
			padding:5px;
			background-color: #787878;
			color: #fff;
			display: inline-block;
			margin: 6px auto;
			line-height: 200px;
			font-size: 14px;
		}
		.cloading{
			background-image: url("data:image/gif;base64,R0lGODlhJQAlAJECAL3L2AYrTv///wAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFCgACACwAAAAAJQAlAAACi5SPqcvtDyGYIFpF690i8xUw3qJBwUlSadmcLqYmGQu6KDIeM13beGzYWWy3DlB4IYaMk+Dso2RWkFCfLPcRvFbZxFLUDTt21BW56TyjRep1e20+i+eYMR145W2eefj+6VFmgTQi+ECVY8iGxcg35phGo/iDFwlTyXWphwlm1imGRdcnuqhHeop6UAAAIfkEBQoAAgAsEAACAAQACwAAAgWMj6nLXAAh+QQFCgACACwVAAUACgALAAACFZQvgRi92dyJcVJlLobUdi8x4bIhBQAh+QQFCgACACwXABEADAADAAACBYyPqcsFACH5BAUKAAIALBUAFQAKAAsAAAITlGKZwWoMHYxqtmplxlNT7ixGAQAh+QQFCgACACwQABgABAALAAACBYyPqctcACH5BAUKAAIALAUAFQAKAAsAAAIVlC+BGL3Z3IlxUmUuhtR2LzHhsiEFACH5BAUKAAIALAEAEQAMAAMAAAIFjI+pywUAIfkEBQoAAgAsBQAFAAoACwAAAhOUYJnAagwdjGq2amXGU1PuLEYBACH5BAUKAAIALBAAAgAEAAsAAAIFhI+py1wAIfkEBQoAAgAsFQAFAAoACwAAAhWUL4AIvdnciXFSZS6G1HYvMeGyIQUAIfkEBQoAAgAsFwARAAwAAwAAAgWEj6nLBQAh+QQFCgACACwVABUACgALAAACE5RgmcBqDB2MarZqZcZTU+4sRgEAIfkEBQoAAgAsEAAYAAQACwAAAgWEj6nLXAAh+QQFCgACACwFABUACgALAAACFZQvgAi92dyJcVJlLobUdi8x4bIhBQAh+QQFCgACACwBABEADAADAAACBYSPqcsFADs=");
			background-repeat: no-repeat;
			background-position: center 45px;
			height: 150px;
			width: 100%;
			line-height: 210px;
			text-align: center;
			font-size: 14px;
		}
		.pay-wx{
			height:177px
		}
		.pay-wx-info{
			font-size: 16px;
		}
		.wx-pay-ico {
			background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAMAAAAR8Wy4AAAAA3NCSVQICAjb4U/gAAAAtFBMVEUAzABM2Ezx/PHB8sEazhqf6p+B5IE61TrU9tRm3mYq0Sqz77P///8Lygvj+ePI88iP549U2lR54nlF10Wm7KY31Dcj0CPS9dL1/fW58Lnr++sx0zHY99jD8sMSzBJc3FxA1kCU6JQfzx+t7a1s32zm+uaj66O377cPyw+q7ar////c99zH88fL9Mu177VG10Yk0CSR55Eczxw81TzX9tdp32k41Ti78Lsy0zLF88UhzyHB88EyB+unAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAFnRFWHRDcmVhdGlvbiBUaW1lADA1LzI5LzE4XO1tXgAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAACTSURBVAiZRU8JDsIwDHNXGMcCjHNjMBhnQTAVcQjE/x9G0qHOUtLYal0HJEiiXaQzN4JrU/TAmL2WTgjG8GiyEHxqvj2yEHra0pdYEW7AgwtqTnkBXMF+w35n3aanlWtnEZATpfvq3QRd7jaNV3+jAWI5Gt6Yc0zrb3EqJZjy/Ktd9DdwF7oYZdUuoU0OxpjS7UY/XkQJtfApswsAAAAASUVORK5CYII=") no-repeat;
			display: inline-block;
			width: 16px;
			height: 14px;
			margin-right: 5px;
		}
		.cost-price{
			color: #666;
		}
		.coupon-info{
			margin-top: 25px;
			color: #666;
		}
		.submit-btn{
			clear: both;
			text-align: center;
			padding:10px 0 25px 0;
		}
		.submit-btn button{
			border: #20a53a 1px solid;
			background-color: #20a53a;
			border-radius: 3px;
			width: 240px;
			height: 40px;
			line-height: 40px;
			text-align: center;
			color: #fff;
			cursor: pointer;
		}
		.tips{
			position:absolute;
			top: 7px;
			right: 10px;
			background: #ff4949;
			color: #fff;
			padding: 4px 6px;
			border-radius: 5px;
		}
		.tname{
			font-size:14px;
			margin-left:68px;
		}
		.tval{
			font-weight:bold
		}
		.full-right{
			float:right;
		}
		.help{
			color:#999;
			position:absolute;
			bottom:-82px;
		}
		.help p{
			margin-bottom:6px;
			text-indent: 2em;
			white-space: nowrap;
		}
		.help p:first-child{
			text-indent: 0;
			color:red;
		}
		
	</style>
	<body>
		<div id="order_info" class="order_info">
			<div class="libLogin" style="display: black;">
				<div class="bt-form text-center">
					<div class="line"><h3 class="title">绑定宝塔官网账号</h3></div>
					<div class="line"><input id="btusername" class="bt-input-text" name="username" type="text" placeholder="手机"></div>
					<div class="line"><input id="btpassword" class="bt-input-text" type="password" name="password" placeholder="密码"></div>
					<div class="line"><input class="login-button" value="登录" type="button"></div>
					<p class="text-right"><a class="btlink" href="https://www.bt.cn/register.html" target="_blank">未有账号，去注册</a></p>
				</div>
			</div>
			<div class="paypro" style="display:none">
				<div class="tit">购买宝塔Linux专业版</div>
				<div class="pd20">
					<div class="bt-account">
						<span class="account-title">绑定账号：</span>
						<span class="account-name"></span>
						<span class="change-id"><i class="glyphicon-refresh"></i>更换</span>
					</div>
					<div class="pay-type hide">
						<span class="on">微信支付</span>
						<span>代金券</span>
					</div>
					<div class="pay-type-con">
						<div class="wepay">
						</div>
						<div class="coupon" style="display: none;">
							<div class="cycle" id="couponList"></div>
							<div class="submit-btn"><button>提交</button></div>
						</div>
					</div>
				</div>
				<div class="help">
					<p>注：1、已购买过插件的用户，可以通过补差价升级专业版<a href="http://wpa.qq.com/msgrd?v=3&uin=136537222&site=qq&menu=yes" target="_blank" class="btlink"><img src="http://wpa.qq.com/pa?p=1:136537222:4" style="margin-right:5px;margin-left:3px;vertical-align: -1px;">136537222</a></p>
					<p>2、升级宝塔专业版，所有插件免费使用。</p>
					<p>3、专业版已过期后将不可使用。</p>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			//判断账号绑定
			$$.get("/ssl?action=GetUserInfo",function(rdata){
				if(rdata.status){
					$$(".paypro").show();
					$$(".libLogin").hide();
					$$(".account-name").text(rdata.data.username);
					$$(".wepay").html("<div class='cloading'>加载中，请稍后</div>");
					$$.get("/auth?action=get_order_status",function(ddata){
						switch (ddata.status){
							case true:
								if(ddata.msg.endtime>0){
									$$(".paypro .tit").text("续费宝塔Linux专业版 ["+ddata.msg.address+"]");
									$$(".bt-account").append("<span class='tname'>到期时间： </span><span class='tval'>"+formatDate(ddata.msg.endtime)+"</span>");
									$$(".tit").append("<a class='btlink full-right' href='/'>返回首页</a>");
									//获取数据
									get_coupon();
								}
								else{
									$$(".paypro .tit").text("宝塔Linux专业版");
									$$(".bt-account").append("<span class='tname'>到期时间： </span><span class='tval'>永久授权</span>");
									$$(".tit").append("<a class='btlink full-right' href='/'>返回首页</a>");
									$$(".wepay").html("");
									return;
								}
								break;
							case -1:
								//获取数据
								get_coupon();
								break;
							case -2:
								//获取数据
								get_coupon();
								$$(".paypro .tit").text("续费宝塔Linux专业版");
								$$(".bt-account").append("<span class='tname'>到期时间： </span><span class='tval' style='color:red'>已过期，请续费</span>");
								$$(".tit").append("<a class='btlink full-right' href='/'>返回首页</a>");
								break;
						}
					})
				}
				else{
					$$(".paypro").hide();
					$$(".libLogin").show();
				}
			});
			//登录绑定
			function btlogin(){
				$$("#btusername").blur(function(){
					if(!(/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$$/.test($$(this).val()))){ 
						$$(this).css("border","1px solid #e53451");
						$$(this).parent().find(".tips").remove();
						$$(this).after("<span class='tips'>请输入手机号码</span>");
					}
					else{
						$$(this).removeAttr("style");
						$$(this).next("span").remove();
					}
				}).keyup(function(event){
					if(event.keyCode ==13){
						$$("#btpassword").focus();
					}
				});
				$$("#btpassword").blur(function(){
					if($$(this).val() ==''){ 
						$$(this).css("border","1px solid #e53451");
						$$(this).parent().find(".tips").remove();
						$$(this).after("<span class='tips'>请输入密码</span>");
					}
					else{
						$$(this).removeAttr("style");
						$$(this).next("span").remove();
					}
				}).keyup(function(event){
					if(event.keyCode ==13){
						$$(".login-button").click();
					}
				});
				$$(".login-button").click(function(){
					var p1 = $$("#btusername").val();
					var p2 = $$("#btpassword").val();
					if(!(/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$$/.test(p1)) || p2 =="") return;
					var loadT = layer.msg('正在获取密钥...',{icon:16,time:0,shade: [0.3, '#000']});
					$$.post("/ssl?action=GetToken",{username:p1,password:p2}, function(b){
						layer.close(loadT);
						layer.msg(b.msg, {icon: b.status?1:2});
						if(b.status) {
							window.location.reload();
						}
					})
				})
			}
			//时间转换
			function add0(m){return m<10?'0'+m:m }
			function formatDate(timestamp){
				timestamp = timestamp*1000;
				var time = new Date(timestamp);
				var year = time.getFullYear();
				var month = time.getMonth()+1;
				var date = time.getDate();
				var hours = time.getHours();
				var minutes = time.getMinutes();
				var seconds = time.getSeconds();
				if(timestamp ==0){
					return "永久授权";
				}
				else{
					return year+'-'+add0(month)+'-'+add0(date)+' '+add0(hours)+':'+add0(minutes)+':'+add0(seconds);
				}
			}
			//单位转换
			function conver_unit(name){
				var unit= '';
				switch (name){
					case "year":
						unit = "年";
						break;
					case "month":
						unit = "个月";
						break;
					case "day":
						unit = "天";
						break;
					case "1":
						unit = "1个月";
						break;
					case "3":
						unit = "3个月";
						break;
					case "6":
						unit = "6个月";
						break;
					case "12":
						unit = "1年";
						break;
					case "24":
						unit = "2年";
						break;
					case "36":
						unit = "3年";
						break;
					case "999":
						unit = "永久";
						break;
				}
				return unit;
			}
			//取专业版代金券
			function get_coupon(){
				$$(".wepay").html("<div class='cloading'>加载中，请稍后</div>");
				$$.get("/auth?action=get_voucher",function(rdata){
					if(rdata !=null){
						$$(".pay-type").show();
						var con = '';
						var len = rdata.length;
						for(var i=0; i<len; i++){
							if(rdata[i].status !=1){
								var cyc = rdata[i].cycle+conver_unit(rdata[i].unit);
								if(rdata[i].cycle == 999){
									cyc = "永久"
								}
								con += '<div class="cycle-item" data-code="'+rdata[i].code+'">\
											<div class="total">\
												<p class="coupon-info">专业版代金券</p>\
											</div>\
											<div class="cy-len">'+cyc+'</div>\
										</div>';
							}
						}
						if(len>8){
							$$("#couponList").css("height","296px");
						}
						$$("#couponList").html(con);
						$$(".cycle > div").click(function(){
							$$(this).addClass("on").siblings().removeClass("on")
						});
					}
					else{
						$$(".pay-type").hide();
					}
					//取产品折扣
					get_product_discount();
				})
			}
			//取产品折扣信息
			function get_product_discount(){
				var hcon = '<div class="cycle" id="product-discount"></div>\
							<div class="lib-price-box">\
								<span class="lib-price-name"><b>总计</b></span>\
								<span class="price-txt"><b class="pay-sale-price"></b>元</span>\
								<s class="cost-price"></s>\
							</div>\
							<div class="paymethod">\
								<div class="pay-wx"></div>\
								<div class="pay-wx-info"><span class="wx-pay-ico"></span>微信扫码支付</div>\
							</div>'
				$$(".wepay").html("<div class='cloading'>加载中，请稍后</div>");
				$$.get("/auth?action=get_product_discount_by",function(rdata){
					if(rdata !=null){
						$$(".wepay").html(hcon);
						var con = '';
						var qarr = Object.keys(rdata);
						var qlen = qarr.length;
						//折扣列表
						for(var i=0;i<qlen;i++){
							var j = qarr[i];
							var a = rdata[j].price;
							var b = rdata[j].sprice;
							var c = rdata[j].discount;
							con += '<div class="cycle-item" onclick="getRsCode('+rdata.pid+','+a+','+b+','+j+')">\
											<div class="total">\
												<p><span class="sale-price">'+a+'</span><span class="yuan">元</span></p>\
												<p class='+(a==b?"hide":"")+'><s class="o-price">'+b+'元</s></p>\
											</div>\
											<div class="cy-len">'+conver_unit(j)+(c==1?"":'<span>('+c*10+'折)</span>')+'</div>\
										</div>';
						}
						$$("#product-discount").html(con);
						$$(".cycle > div").click(function(){
							$$(this).addClass("on").siblings().removeClass("on");
						});
						$$(".cycle-item").eq(0).click();
					}
				})
			}
			//微信二维码
			var wxpayTimeId = 0;
			function getRsCode(pid,price,sprice,cycle){
				$$(".pay-sale-price").text(price);
				if(price == sprice){
					$$(".cost-price").addClass("hide").text(sprice+'元');
				}
				else{
					$$(".cost-price").text(sprice+'元').removeClass("hide");
				}
				
				$$(".pay-wx").html('<span class="loading">加载中，请稍后</span>');
				$$.post('/auth?action=create_order',{pid:pid,cycle:cycle},function(rdata){
					if(rdata.status === false){
						layer.msg(rdata.msg,{icon:2});
						return;
					}
					$$(".pay-wx").html('');
					$$(".pay-wx").qrcode(rdata.msg);
					clearInterval(wxpayTimeId);
					wxpayTimeId = setInterval(function(){
						$$.post('/auth?action=get_re_order_status',{id:pid},function(rdata){
							if(rdata.status) {
								layer.msg('支付成功!',{icon:1});
								clearInterval(wxpayTimeId);
								location.href="/";
							}
						})
					},3000);
					
				});
			}
			//代金券续费
			function useCoupon(code){
				var loadT = layer.msg("提交中，请稍后。",{ icon: 16, time: 0, shade: [0.3, "#000"]});
				$$.post("/auth?action=create_order_voucher",{code:code},function(rdata){
					layer.close(loadT);
					layer.msg(rdata.msg);
					if(rdata.status){
						setTimeout(function(){
							location.href="/";
						},2000)
					}
					else{
						get_coupon()
					}
				})
			}
		</script>
		<script type="text/javascript">
			//调用登录绑定事件
			btlogin();
			$$(".change-id").click(function(){
				//$$(".paypro").hide();
				//$$(".libLogin").show();
				//$$(".back").show();
				var login = $$(".libLogin").html();
				$$(".libLogin").empty();
				layer.open({
				  type: 1, 
				  area: ['480px', '373px'],
				  title: '更改绑定账号',
				  shade: 0.4,
				  closeBtn:2,
				  anim: -1,
				  cancel:function(){
					$$(".libLogin").html(login)
				  },
				  content: '<div class="libLogin">'+login+'</div>'
				});
				//调用登录绑定事件
				btlogin();
			});
			$$(".pay-type span").click(function(){
				var i = $$(this).index();
				$$(this).addClass("on").siblings().removeClass("on");
				$$(".pay-type-con > div").eq(i).show().siblings().hide();
				if(i==1){
					clearInterval(wxpayTimeId);
				}
				else{
					$$(".wepay .cycle-item").eq(0).click();
				}
			})
			$$(".submit-btn").click(function(){
				var data_code = $$("#couponList .on").attr("data-code");
				useCoupon(data_code);
			})
		</script>
	</body>
</html>
