<{import file="common.html" title="订单支付"}>  
<style type="text/css">  
body{ background:#fff; }
.lbox{ width:100%; background:#fff; float:left; } 
.pinfo{ width:100%; padding:0.2rem 0; float:left; }
.pinfo dl{ width:100%; padding:0.2rem 0; vertical-align:middle; float:left; }
.pinfo dl dt{ width:1.4rem; padding:0 0 0 0.2rem; font-size:0.28rem; color:#666; float:left; }
.pinfo dl dd{ width:5.5rem; padding:0 0.2rem 0 0; font-size:0.28rem; color:#333; float:left; }
.pinfo dl dd span{ font-size:0.28rem; float:left; }
.pinfo dl dd span.price{}
.pinfo dl dd span.price i{ padding:0.12rem 0.1rem 0 0; font-size:0.25rem; color:#f00; float:left; }
.pinfo dl dd span.price em{ color:#f00; font-size:0.4rem; float:left;  }

.pay_name{ width:100%; padding:0 0.2rem; box-sizing: border-box; float:left; }
.pay_name .btm{ width:100%; border-bottom:1px solid #efefef; float:left; }
.pay_name .btm span{ padding:0.2rem 0 0.2rem 0; font-size:0.32rem; color:#333; font-weight:bold; float:left; }

.pay_ck{ width:100%; padding:0 0.2rem 0.3rem; box-sizing: border-box; float:left; } 
.pay_ck a.paybox{ width:100%; border-bottom:1px solid #efefef; position:relative; background:#fff; padding:0.3rem 0; float:left; }
.pay_ck a.paybox.selected{ } 
.pay_ck a.paybox.selected i{ width:0.35rem; height:0.35rem; margin:0.1rem 0 0 0; background:url(<{$__PUBLIC__}>svg/dui.svg); background-size:0.35rem 0.35rem; float:right; } 
.pay_ck a svg{ width:0.6rem; float:left; } 
.pay_ck a span{ padding:0.1rem 0 0 0.2rem; font-size:0.28rem; float:left; }
 
a.submit{ background:#ddd; color:#888; }
a.submit.on{ background:#f00; color:#fff; }
</style>
<body>
<div class="cnav">
	<a class="back">&nbsp;</a>订单支付<a href="javascript:;" class="thome">主页</a>
</div>
<{uqcms m="account" v="row" c="admin_pay:trade_no=smarty.get.trade_no"}> 
<{if $row.error == '1'}>
	<div class="lbox">
		<div class="payBox" style="padding:0;">
			<dl>
				<dt>支付状态</dt>
				<dd><span class="ttl"><{$row.msg}></span></dd>
			</dl>
		</div>
	</div>	
<{else}>
	<div class="lbox">
		<input type="hidden" name="trade_no" id="trade_no" value="<{$row.trade_no}>"/> 
		<input type="hidden" id="pay_type" value="<{$row.pay_type}>"/>
		<div class="payBox">
			<div class="pinfo"> 
				<dl>
					<dt>交易单号</dt>
					<dd><{$row.trade_no}></dd>
				</dl>
				<dl>
					<dt>支付名称</dt>
					<dd><{$row.title}></dd>
				</dl>
				<dl>
					<dt>支付金额</dt>
					<dd><span class="price"><i>¥</i><em><{$row.price}></em></span></dd>
				</dl>
			</div> 
			<div class="pay_name"><div class="btm"><span>支付方式</span></div></div>
			<div class="pay_ck">
				<{uqcms m="api" v="pay" c="alist:type=pay"}>
				<{if $pay}>
					<{foreach item=i from=$pay}>
						<{if $UQCMS.browser == 'wchat'}>
							<{if $i.alias != 'alipay'}><!--屏蔽掉微信不支持的-->
								<a href="javascript:;" class="paybox" data-code="<{$i.alias}>"> 
									<{$i.svg}>
									<span><{$i.name}></span>
									<i></i>
								</a>
							<{/if}>
						<{else}>
							<a href="javascript:;" class="paybox" data-code="<{$i.alias}>"> 
								<{$i.svg}>
								<span><{$i.name}></span>
								<i></i>
							</a> 
						<{/if}> 
					<{/foreach}> 
				<{else}>
					<span>请先配置支付接口</span>
				<{/if}>
			</div> 
		</div> 
	</div> 
	<div class="sbutton"><a href="javascript:;" class="submit" id="payurl">确认支付</a></div>
<{/if}> 
<{import file="footer.html"}>
<script type="text/javascript" charset="UTF-8" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
<script type="text/javascript"> 
// 手机访问无需检测，执行成功，会自动跳转到对应的页面 
$(function(){
	$(".pay_ck a").click(function(){
		$(this).addClass('selected').siblings().removeClass('selected');
		$this = $(this);
		trade_no = $("#trade_no").val();
		payment = $this.attr('data-code');
		$.post(URI+'ajax/pay', {trade_no:trade_no, payment:payment}, function(result){ 
			data = jQuery.parseJSON(result); 
			if(data.type == 'link'){
				$('#payurl').addClass('on').attr('href', data.link);
			}else if(data.type == 'js_wchat'){			//	js微信支付
				$(".hidden_wchat").remove();
				html = '<div class="hidden_wchat">'+
					'<input type="hidden" id="timeStamp" value=""/>'+
					'<input type="hidden" id="nonceStr" value=""/>'+
					'<input type="hidden" id="package" value=""/>'+
					'<input type="hidden" id="signType" value=""/>'+
					'<input type="hidden" id="paySign" value=""/>'+
				'</div>';
				$("body").append(html);
				
				// 填充配置信息
				$("#timeStamp").val(data.jsrow.timeStamp);
				$("#nonceStr").val(data.jsrow.nonceStr);
				$("#package").val(data.jsrow.package);
				$("#signType").val(data.jsrow.signType);
				$("#paySign").val(data.jsrow.paySign);
				
				// 然后给予提交onclick事件 
				$("#payurl").addClass('on').attr('href', 'javascript:;').attr('data-code', 'wchat_js'); 
			}else{
				$.alert(data.msg);
			}
		});
	}); 
	<{if $UQCMS.browser == 'wchat'}>
	$("#payurl").click(function(){
		$this = $(this);
		if($this.attr('data-code') == 'wchat_js'){ 
			<{uqcms m="wchat" v="js_row" c="js_config"}>
			<{if $js_row.appid}>
			function wxInit(){
				wx.config({
					//debug:true,
					appId:"<{$js_row.appid}>",
					timestamp:"<{$js_row.timestamp}>",
					nonceStr:"<{$js_row.noncestr}>",
					signature:"<{$js_row.signature}>",
					jsApiList:["chooseWXPay"]
				});
			}
			
			wxInit(); 
			var timeStamp 	= $('#timeStamp').val(); 
			var nonceStr 	= $('#nonceStr').val(); 
			var package 	= $('#package').val(); 
			var signType 	= $('#signType').val(); 
			var paySign 	= $('#paySign').val(); 
			
			var payType 	= $('#pay_type').val();
			wx.ready(function(){
				wx.chooseWXPay({
					timestamp:timeStamp, 
					nonceStr:nonceStr, 
					package:package, 
					signType:signType, 
					paySign:paySign, 
					success: function(res){
						if(res.errMsg == "chooseWXPay:ok") { 
							$.alert("支付成功");
							if(payType == '1'){
								location.href=WAP+"order/index"; 
							}else if(payType == '2'){
								location.href=WAP+"account/wallet"; 
							}
						}else{ 
							$.alert("支付失败"+res.errMsg); 
						}
					},
					cancel:function(){ 
						//alert('取消操作');
						//history.back(-1);
					}
				});
			}); 
			<{/if}> 
		}else{
			// 链接跳转
		} 
	});
	<{/if}>
	
});
/*
function balance_pay(){ 
	var trade_no = $("#trade_no").val();
	$.post(URI+'notice/balance_pay',{trade_no:trade_no},function(result){
		data = jQuery.parseJSON(result); 
		if(data.error == '0'){ 
			$.alert('支付成功');
		}else{
			$.alert(data.msg);
		}
	});  
}*/

</script>