<?php if(!defined('IN_SDCMS')) exit;?>{include file="top.php"}
<title>订单详情_{sdcms[web_name]}</title>
<meta name="keywords" content="{sdcms[seo_key]}">
<meta name="description" content="{sdcms[seo_desc]}">
</head>

<body>

    {include file="head.php"}
    
    <div class="bg_inner">
        <div class="width banner_inner">
            <div class="left">
                <ul>
                    <li class="hover"><a>订单详情</a></li>
                </ul>
            </div>
        	<div class="right"><span class="am-icon-phone am-icon-fw"></span>{sdcms[ct_tel]}{block("inner_text")}</div>
        </div>
    </div>
    
    <div class="width inner_container">
    	
        <div class="bread bread-1">
        	<ul>
                <li><a href="{$webroot}">首页</a></li>
                <li class="active">订单详情</li>
            </ul>
        </div>
                
        <div class="ordershow">
        	<div class="tip">
            	<div>订单金额：<em>{$pro_price}</em> 元</div>
            	<h3><span class="ui-icon-check-circle mr-15 font-30 text-green"></span>{if $ispay==0}订单提交成功{else}订单付款成功{/if}</h3>
                <p>订单号：<em>{$orderid}</em></p>
            </div>
            <h5>订单明细</h5>
        	<ul class="info">
                <li><span>订购产品：</span>{$pro_name}</li>
                <li><span>订购数量：</span>{$pro_num}</li>
                <li><span>姓名：</span>{$truename}</li>
                <li><span>手机号：</span>{$mobile}</li>
                <li><span>地址：</span>{$address}</li>
                <li><span>备注：</span>{$remark}</li>
            </ul>
            {if C('pay_open')==1&&$ispay==0}
            <form method="post" id="form_order">
            <h5>支付方式</h5>
            <ul class="pay" id="orderpay">
            	{if C('pay_alipay_open')==1}
            	<li><div><img src="{WEB_ROOT}api/pay/alipay/images/pay.png" data-config="alipay"><em></em></div></li>
                {/if}
                {if C('pay_wxpay_open')==1}
                <li><div><img src="{WEB_ROOT}api/pay/wxpay/images/pay.png" data-config="wxpay"><em></em></div></li>
                {/if}
            </ul>
            <input type="hidden" name="payway" id="payway" value="" data-rule="支付方式:required;">
            <div class="bottom"><button type="submit" class="btn btn-blue">在线支付</button></div>
            </form>
            {/if}
        </div>
        
    </div>
    
    {include file="foot.php"}
    <script src="{WEB_ROOT}public/js/jquery.qrcode.js"></script>  
    <script>
		$(function()
		{
			$("#form_order").form(
			{
				type:2,
				hide:2,
				align:'center',
				result:function(form)
				{
					var payway=($(form).serialize()).substring(7);
					if(payway=='wxpay')
					{
						$.ajax(
						{
							type:'get',
							dataType:'json',
							url:'{WEB_ROOT}api/pay/wxpay/p/api.php?orderid={$orderid}',
							error:function(e){alert(e.responseText);},
							success:function(d)
							{
								if(d.state=='success')
								{
									$.dialog(
									{
										'title':"微信支付",
										'text':'<div class="text-center"><div id="qrcode" style="width:300px;height:300px;"></div><p>请打开【微信】，使用【扫一扫】完成付款。</p></div>',
										'ok':function(e)
										{
											e.close();
										}
									});
									$("#qrcode").qrcode(d.msg[0]);
								}
								else
								{
									sdcms.error(d.msg[0]);
								}
							}
						});
					}
					else
					{
						location.href='{WEB_DOMAIN}api/pay/'+payway+'/p/api.php?orderid={$orderid}';
					}
				}
			});

		})
		var timer=window.setInterval(freshorder,1000);
		function freshorder()
		{
			$.ajax(
			{
				type:"post",
				cache:"false",
				url:"{THIS_LOCAL}",
				success:function(d){
					if(d==1)
					{
						location.href='{THIS_LOCAL}';
						clearInterval(timer);
					}
				}
			})
		}
	</script>
</body>
</html>