<!--{assign var="menu_id" value="pay"}-->
<!--{include file="<!--{$oetplpath}-->widget/block_header.tpl"}-->
<body class="bg_body">
<div class="oe_top bo_bf7 cursor">
  <!--{if $nofollow == '1'}-->
  <a href="<!--{$oefile}-->"><span class="back"><i class="iconfont icon-fanhui"></i></span></a>
  <!--{else}-->
  <span class="back" f="back"><i class="iconfont icon-fanhui"></i></span>
  <!--{/if}-->
  <h1>微信支付...</h1>
</div>
<div class="h48"></div>
<div class="t_center pt40">
  <i class="iconfont icon-weixinzhifu fz50 color_weixinpay inline_block lh60"></i>
</div>
<div class="t_center fz14 pt30">
  <h4 class="fz16">您正在使用微信支付</h4>
  <p class="pt5 color_9">请根据提示完成支付操作</p>
  <div class="plr30">
    <div class="pt10 lh24 fz14 bg_f color_9 mt20 pb10 br5 tl plr30">
      <p>
        <span>订单内容：</span><!--{$payorder.title}-->
      </p>
      <p>
        <span>支付单号：</span><!--{$payorder.paynum}-->
      </p>
      <p>
        <span>支付金额：</span> ¥<b class="color_f40"><!--{$payorder.amount}--></b> 元
      </p>
    </div>
  </div>
</div>
<script type="text/javascript">
//调用微信JS api 支付
function jsApiCall() {
    WeixinJSBridge.invoke(
        'getBrandWCPayRequest',
        <!--{$jsApiParameters}-->,
        function(res){
            WeixinJSBridge.log(res.err_msg);
            
        }
    );
}

//唤醒微信支付
function callpay() {
    if (typeof WeixinJSBridge == "undefined"){
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
        }
        else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
            document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
        }
    }
    else{
        jsApiCall();
    }
}
$(function(){
    callpay();
    _reqPayResult();
});

//支付结果请求
function _reqPayResult() {
    $.ajax({
        type: "POST",
        url: WAP_APPFILE+"&c=pay&a=checkpay",
        cache: false,
        data: {
              paynum:"<!--{$payorder.paynum}-->"
        },
        dataType: "json",
        success: function($data) {
            var $json = eval($data);
            var $response = $json.response;
            var $result = $json.result;
            if ($response == "1") {
                if ($result == "10") { //成功
                    window.location.href = WAP_APPFILE+"&c=pay&a=show&paynum=<!--{$payorder.paynum}-->&forward=<!--{$forward|urlencode}-->";
                }
                else if ($result == "11") { //失败
                    window.location.href = WAP_APPFILE+"&c=pay&a=show&paynum=<!--{$payorder.paynum}-->&forward=<!--{$forward|urlencode}-->";
                }
                else {
                    setTimeout(function(){
                      _reqPayResult();
                    }, 1000);
                }
            }
            else {

            }
        },
        error: function() {

        }
    });
}
</script>
</body>
</html>