<?php
setNcCookie("goods_id", $_GET['goods_id'],'36000');
setNcCookie("number", $_GET['number'],'36000');
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>确认订单</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <link rel="shortcut icon" href="./favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/mshop/css/sm.min.css">
    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/mshop/css/sm-extend.min.css">
    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/mshop/css/common.css"/>
    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/mshop/css/page/check_orders.css"/>
</head>
<body>
<div class="page-group">
    <div class="page page-current" id="check_orders">
        <header class="bar bar-nav">
            <span class="icon icon-left pull-left back"></span>
            <h1 class="title">确认订单</h1>
        </header>
        <div class="balance pay_btn">
            <div class="row balance_box">
                <div class="col-33"></div>
                <div class="col-33">
                    应付：<span class="this_price ">￥<span id="altogether"><?php echo $output['payinfo']['goods_amount'];?></span></span>
                </div>
                <div class="col-33 balance_btn">
                    <input type="submit" id="wxpay" value="去付款"/>
                </div>
            </div>
        </div>
        <!-- 这里是页面内容区 -->
        <div class="content">
            <div class="list-block">
                <ul>
                    <?php
                    $check_orders = new tpl_check_orders($output);
                    $check_orders->check_addres();
                    ?>
                    <li class="br"></li>
                    <li class="brs"></li>

                    <div class="list-block">
                        <ul>
                            <li class="item-content">
                                <div class="item-media"><i class="icon icon-f7"></i></div>
                                <div class="item-inner">
                                    <div class="item-title">
                                        <span class="hb_icon"></span>
                                        红包支付
                                    </div>
                                    <div class="item-after">
                                        <label class="label-switch">
                                            <input type="checkbox" checked>
                                            <div class="checkbox"></div>
                                        </label>
                                    </div>
                                </div>
                            </li>
                            <li class="item-content">
                                <div class="item-media"><i class="icon icon-f7"></i></div>
                                <div class="item-inner">
                                    <div class="item-title">
                                        <span class="wx_icon"></span>
                                        微信支付
                                    </div>
                                    <div class="item-after">
                                        <span class="check_icon"></span>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>


                    <li class="brs"></li>

                    <div class="list-block media-list products_content">
                        <ul>
                            <li>
                                <a href="<?php
                                $herf = MOBILE_SITE_URL.'/index.php?client_type=wap&act=goods_common&goods_id='.$output['goods_list'][0]['goods_id'].'&goods_commonid='.$output['common_info']['goods_commonid'];
                                echo $herf;
                                ?>" class="item-link item-content external">
                                    <div class="item-media"><img src="<?php echo $output['summary'][0]['goods_image_url']?>" style='width: 4rem;'></div>
                                    <div class="item-inner" id="products_content_list">
                                        <div class="item-text"><?php echo $output['summary'][0]['goods_mobile_name'];?></div>
                                        <div class="item-subtitle"><?php echo $output['summary'][0]['goods_spec'];?></div>
                                        <div class="item-title-row">
                                            <div class="item-title this_price">¥<?php echo $output['summary'][0]['goods_price'];?></div>
                                            <div class="item-after products_number">x<?php echo $output['goods_list'][0]['goods_num'];?></div>
                                        </div>
                                    </div>
                                </a>
                            </li>
                        </ul>
                    </div>
                    <li class="brs"></li>


                    <div class="list-block reckon">
                        <ul>
                            <li class="item-content">
                                <div class="item-media"><i class="icon icon-f7"></i></div>
                                <div class="item-inner">
                                    <div class="item-title">
                                        商品总价
                                    </div>
                                    <div class="item-after price">
                                        ¥ <?php echo $output['payinfo']['goods_amount'];?>
                                    </div>
                                </div>
                            </li>
                            <li class="item-content">
                                <div class="item-media"><i class="icon icon-f7"></i></div>
                                <div class="item-inner">
                                    <div class="item-title">
                                        红包抵扣
                                    </div>
                                    <div class="item-after lost_price">
                                        - <span class="price_br">¥ <?php echo $output['payinfo']['available_pred'];?></span>
                                    </div>
                                </div>
                            </li>
                            <li class="item-content">
                                <div class="item-media">
                                    <i class="icon icon-f7"></i>
                                </div>
                                <div class="item-inner">
                                    <div class="item-title">
                                        运费
                                    </div>
                                    <div class="item-after price">
                                        + <span class="price_br">¥ <?php echo $output['payinfo']['freight'];?></span>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </ul>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/mshop/js/common/zepto.min.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/mshop/js/common/sm.min.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/mshop/js/common/sm-extend.min.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/mshop/js/common/zepto.touchWipe.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/mshop/js/common/common.js"></script>
<script type="text/javascript">
    var datas=<?php
    $tpl = new tpl_check_orders($output);
    $tpl->return_data();
    ?>
</script>
<script type="text/javascript">
    var callbackdata=null;
    $('#wxpay').on('click',function(){
        $.showPreloader();
        var postDate=datas.datas;
        $.ajax({
            type:'POST',
            dataType:'json',
            url:"http://192.168.0.17//mobile/index.php?client_type=wap&act=member_buy&op=step_second",
            data:postDate,
            success:function(data){
                callbackdata=data.datas.param.data;
                console.log(callbackdata);
                $.hidePreloader();
                callpay();
            },
            error:function(){
                $.hidePreloader();
                $.toast("网络错误");
            }
        })
    });

    //调用微信JS api 支付
    function jsApiCall()
    {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',callbackdata,
            function(res){
                alert(res.err_code+res.err_desc+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();
        }
    }
</script>
</body>
</html>


