<%@ Page Title="" Language="C#" MasterPageFile="~/Master/UserMaster.master" CodeBehind="OnlineRecharge.aspx.cs" Inherits="WAP2P.Web.PC.User.Account.OnlineRecharge" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div class="m-userbox">
        <dl class="ui-tab">
            <%= maxRechargeAmount.HasValue && maxRechargeAmount.Value == 0 ? string.Empty : WAP2P.Sys.OnlinePayment.FindActive().Count() > 0 ? string.Format("<dt><a href=\"OnlineRecharge{0}\" class=\"on\">在线充值</a></dt>",PageBase.PageExt) : string.Empty %>
            <%= maxRechargeAmount.HasValue && maxRechargeAmount.Value == 0 ? string.Empty : WAP2P.Sys.OfflinePayment.FindActive().Count() > 0 ? string.Format("<dt><a href=\"OfflineRecharge{0}\">线下充值</a></dt>",PageBase.PageExt) : string.Empty %>
            <dt><a href="RechargeList<% =PageBase.PageExt %>">充值记录</a></dt>
            <dd>
                <div class="form-big m-account">
                    <form class="js-vsum js-auto" method="post" action="<% =Request.RawUrl.UrlEncodeParam() %>" data-onsuccess="successForm();">
                        <div class="input-big mt20 g-ohide">
                            <ruson:Repater runat="server" ID="rptList" ItemType="WAP2P.Sys.OnlinePayment">
                                <HeaderTemplate>
                                    <span class="leftfont g-left">充值渠道</span>
                                    <div class="ui-radio g-left account-radiobox js-online">
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <label>
                                        <input type="radio" name="paymentPlatform" data-vtype="group" data-vmin="1" data-vmsg="请选择支付方式" value="<%# Item.CallCode.HtmlEncode() %>" data-isdirect="<%# Item.Direct %>" data-bankcode="" data-payname="<%# Item.Name %>" />
                                        <img src="<%# Item.PlatformLogo %>" title="<%# Item.Name %>" alt="<%# Item.Name %>" disabled="disabled" />
                                    </label>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </div>
                                </FooterTemplate>
                            </ruson:Repater>
                            <asp:Repeater runat="server" ID="rptBankDirectList">
                                <HeaderTemplate>
                                    <%# directPayment == null ? string.Empty : string.Format("<span class=\"leftfont g-left\">网银渠道<br /><lable id=\"payPlatformName\">{0}</lable></span>", directPayment.Name) %>
                                    <div class="ui-radio g-left account-onlinebank js-onlinebank">
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <label>
                                        <input type="radio" name="paymentPlatform" data-vtype="group" data-vmin="1" data-vmsg="请选择支付方式" value="<%# directPayment.CallCode.HtmlEncode() %>" data-isdirect="<%# directPayment.Direct %>" data-bankcode="<%# Eval("Value") %>" />
                                        <img src="<%# WAP2P.Web.Extensions.GetBankLogo(Eval("Key").ToString()) %>" title="<%# Eval("Key").ToString() %>" disabled="disabled" />
                                    </label>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </div>
                                </FooterTemplate>
                            </asp:Repeater>
                        </div>
                        <input type="hidden" id="payName" name="payName" />
                        <div class="g-clear"></div>
                        <div class="input-big">
                            <label class="leftfont">可用余额</label>
                            <span class="fs16"><%= WAP2P.Account.UserAccount.LoadOrNew(CurrentUser.Id).AvaliableSum.ToMoneyString() %></span> 元
                        </div>
                        <div class="input-big">
                            <label class="leftfont">充值金额</label>
                            <input type="text" class="text js-amount ui-float input-moneyicon" id="amount" placeholder="请输入您要充值的金额" name="amount" data-vtype="money" data-vmsg="请输入正确的充值金额" />
                        </div>
                        <div class="btn-submits mt10 ml204">
                            <input type="submit" value="提 交" class="btn-bbord fs16 c-normal w258 js-submit" />
                            <div class="w258"><em class="m-sumtip js-vsum"></em></div>
                        </div>
                    </form>
                </div>
            </dd>
        </dl>
    </div>
    <script type="text/template" id="payTip">
        <div class="mt20 mb20 fa g-fcenter">
            <h3 style="font-size: 24px;">请您在新打开的网上银行页面上完成付款</h3>
            <p>付款完成前请不要关闭此窗口。</p>
            <p class="mb20">完成付款后请根据您的情况点击下面的按钮：</p>
            <a class="g-inblock btn-nobord c-important" id="js-success" href="/User/Account/RechargeList<% =PageExt %>">已完成付款</a>
            <a class="g-inblock btn-nobord c-normal" id="js-failure" href="javascript:void(0);" onclick="$(document.body).dialog('destroy')">付款遇到问题</a>
        </div>
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script>
        function successForm(){
            var payPlatofrm = $('input[name=paymentPlatform]:checked'),
                parameter = '&payName=' + payPlatofrm.val() + '&orderAmount=' + $('#amount').val() + window['ajaxResponseData'].Message;
            
            window.open('/OnlinePayment/?action=userPay' + parameter + '&bankCode=' + payPlatofrm.attr('data-bankCode'));
            $.jPopupHtml(document.getElementById('payTip').innerHTML, '温馨提示', 500, false);
        };

        $('.js-online input[name=paymentPlatform]').on('click', function () {
            $('.js-onlinebank input[name=paymentPlatform]').parent('.on').removeClass('on');
            $('#payName').val($(this).attr('data-payName'));
        });
        $('.js-onlinebank input[name=paymentPlatform]').on('click', function () {
            $('.js-online input[name=paymentPlatform]').parent('.on').removeClass('on');
            $('#payName').val($('#payPlatformName').text());
        });
    </script>
</asp:Content>
