<!--{include file="<!--{$tplpath}-->block_header.tpl"}-->
<!-------------------------------------- 头部结束 -------------------------------------->
<link rel="stylesheet" href="<!--{$skinpath}-->assets/css/main.css">

<!-------------------------------------- 主体开始 -------------------------------------->
<style>

    .bind-form label {
        display: inline-block;
        *zoom: 1;
        *display: inline;
        width: 60px;
        font-size: 14px;
        margin-left: 20px;
    }
</style>
<div class="page-main user-main">
    <div class="container">
        <!--{if !empty($check)}-->
        <div class="row">
            <div class="span4">
                <div class="uc-box uc-sub-box">
                    <div class="uc-nav-box">
                        <div class="box-hd">
                            <h3 class="title">个人中心</h3>
                        </div>
                        <div class="box-bd">
                            <ul class="uc-nav-list J_navList">
                                <li   class="active"><a class="J_noRandom" href="index.php?c=user">我的个人中心</a></li>
                                <li><a class="J_noRandom" href="./index.php?c=user&a=user_info">个人信息</a></li>
                                <li><a class="J_noRandom" href="./index.php?c=user&a=profit">我的收益</a></li>
                                <li><a class="J_noRandom" href="index.php?c=user&a=share">我的推广</a></li>
                                <li><a class="J_noRandom" href="./index.php?c=user&a=user_address">收货地址</a></li>
                                <li><a class="J_noRandom" href="./index.php?c=user&a=user_edit">修改密码</a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="uc-nav-box">
                        <div class="box-hd">
                            <h3 class="title">订单中心</h3>
                        </div>
                        <div class="box-bd">
                            <ul class="uc-nav-list J_navList">
                                <li><a class="J_noRandom" href="./index.php?c=user&a=order_list">我的订单</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="span16">
                <div class="uc-box uc-main-box">
                    <div class="uc-content-box order-list-box">
                        <div class="box-hd">
                            <h1 class="title">余额充值</h1>
                        </div>
                        <div class="box-bd" style="margin-top: 5%;">

                            <div class="bind-form">
                                <input class="input-text J_addressInput" type="number" id="recharge_price" name="recharge_price" placeholder="充值金额" value="" style="height: 20px; width: 180px;">
                                <input type="hidden" id="user_id" value="<!--{$data.id}-->"/>
                            </div>
                            <div class="action" style="margin-left: 20px; margin-top: 5%;">
                                <a class="btn btn-primary" href="javascript:void(0)" id="pay">充值</a>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--{else}-->
        <a class="btn btn-primary" href="./index.php?c=user&a=login">去登录</a>
        <!--{/if}-->
    </div>
</div>

<script>
    $(function(){
        $("#pay").bind("click", function(){ //提交

            $price = $('#recharge_price').val();
            if($price==''){
                alert('充值金额不能为空');
                return false;
            }
            if(isNaN($price)){
                alert('充值金额类型错误');
                return false;
            }
            $id = $('#user_id').val();;
            $.ajax({
                type: "POST",
                url: "index.php?c=user&a=ajaxaddorder",
                cache: false,
                data: {price:$price,member_id:$id},
                dataType: "json",
                success: function (data) {
                    var json = eval(data);
                    var response = json.response;
                    var order_number = json.order_number;
                    var order_name = json.order_name;
                    var oeder_price = json.oeder_price;
                    var result =json.result;
                    host = window.location.host;
                    var url = 'source/plugin/alipay/alipayapi.php';
                    if (response == "1") {
                        var parames = new Array();
                        parames.push({name: "WIDout_trade_no", value: order_number});
                        parames.push({name: "WIDsubject", value: order_name});
                        parames.push({name: "WIDtotal_fee", value: oeder_price});
                        parames.push({name: "WIDbody", value: '客户充值余额'});
                        Post(url, parames);
                        return false;

                    } else {
                        alert(result);
                    }
                },

            });
        });


        /*
     *功能： 模拟form表单的提交
     *参数： URL 跳转地址 PARAMTERS 参数
     */
        function Post(URL, PARAMTERS) {
            //创建form表单
            var temp_form = document.createElement("form");
            temp_form.action = URL;
            //如需打开新窗口，form的target属性要设置为'_blank'
            temp_form.target = "_self";
            temp_form.method = "post";
            temp_form.style.display = "none";
            //添加参数
            for (var item in PARAMTERS) {
                var opt = document.createElement("input");
                opt.name = PARAMTERS[item].name;
                opt.value = PARAMTERS[item].value;
                temp_form.appendChild(opt);
            }
            document.body.appendChild(temp_form);
            //提交数据
            temp_form.submit();
        }

    });
</script>


<!--{include file="<!--{$tplpath}-->botton.tpl"}-->