<%@ Page Title="" Language="C#" MasterPageFile="~/Master/MainMaster.master" CodeBehind="ReservationDetail.aspx.cs" Inherits="WAP2P.Web.PC.Borrow.ReservationDetail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div class="m-page">
        <div class="m-container g-ohide mt10">
            <div class="m-crumbs">
                <ul class="g-left">
                    <li><a href="/"><i class="iconfont">&#xe630;</i> 首页</a> &nbsp;>&nbsp;</li>
                    <li><a href="/Borrow/">投资列表</a> &nbsp;>&nbsp;</li>
                    <li><% =reservation.Name %></li>
                </ul>                
            </div>
        </div>

        <div class="m-container m-globalbox g-ohide m-detailbid mt10">
            <h5 class="darailbid-title g-ohide m-boborder pt15 pb15 pl10">
                <span class="fs18 g-left"><% =reservation.Name %></span>
                <span class="g-right title-time js-time mr10"></span>
            </h5>

            <div class="g-left wg9 g-ohide m-rightborder">
                <ul class="darailbid-baselist">
                    <li class="wgm3 g-noneborder">
                        <span class="g-block mt30">预约总额</span>
                        <span class="fs32 fcblue-3"><% =reservation.Amount.ToMoneyString() %></span>
                        <span>元</span>
                    </li>
                    <li class="wg2">
                        <span class="g-block mt30">预计利率</span>
                        <span class="fs24"><% =(reservation.Interest * 100).ToInterestString() %></span>
                        <span>%</span>
                    </li>
                    <li class="wg2">
                        <span class="g-block mt30">预计期限</span>
                        <span class="fs24"><% =reservation.LoanDate %></span>
                        <span><% =reservation.LoanDateUnit.GetDescription() %></span>
                    </li>
                    <li class="wg2">
                        <span class="g-block mt30">保证金比例</span>
                        <span class="fs24"><% =(reservation.BailRate * 100).ToInterestString() %></span>
                        <span>%</span>
                    </li>
                </ul>
                <div class="g-clear pa15 g-ohide fcblack-1">
                    <div class="ui-bidspeed g-left wg3 mt5"><span style="width:0;" class="g-block js-stepw"></span></div>
                    <div class="g-right g-fleft wgm6 pl5">
                        当前已完成 <span class="js-stepl">0%</span> ，共有 <span class="js-binUserCount">0</span> 人预约，剩余可预约金额 <span class="js-canAmount">0</span> 元。
                    </div>
                </div>
                <div class="darailbid-box">
                    <div class="detailbid-photo g-left">
                        <img src="<% =reservation.GetCover() %>" height="158" />
                    </div>
                    <ul class="darailbid-list g-right">
                        <li>预约编号：<% =reservation.Id %></li>
                        <li>预约协议：《<a href="/Agreement/?type=reservation" target="_blank"><% =PageBase.SiteName %>预约协议</a>》</li>
                        <li>还款方式：<% =WAP2P.Web.Extensions.GetRepaymentName(reservation.Repayment) %></li>
                        <li>发布时间：<% =reservation.CreateAt %></li>
                        <li class="m-bidOther">
                            <span>预约成功如未进行投标，将扣除 <i class="fcred-3"><% =(reservation.BailDeductionRate * 100).ToInterestString() %>%</i> 预约保证金。</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="g-right wg3 g-ohide">
                <form class="js-auto js-vtip" method="post" action="ajax<% =PageExt %>?action=success" data-onsuccess="member.pay('<% =(int)WAP2P.Account.AccountActionType.交纳预约保证金 %>', '<% =string.Format("amount=' + $('#amount').val() + '&rid={0}", reservation.Id) %>', function () { common.pageTip('<% =PageBase.TipType.Success %>', '恭喜预约成功！', '/User/Loan/ReservationList' + gconfig.pageExt, '我的预约记录'); });">
                    <%--未登录--%>
                    <ruson:Space ID="userLogin" runat="server" Visible="false">
                        <div class="detailbid-usermoenytext">
                            <span class="g-left fs16">可用余额：</span>
                            <a class="g-right btn-bordsmall c-normal" href="/User/Account/OnlineRecharge<% =PageBase.PageExt %>">充 值</a>
                        </div>
                        <div class="detailbid-usermoeny">
                            <a href="javascript:void(0);" onclick="member.miniLogin(function(){location.href = '<% =string.Format("/Borrow/ReservationDetail{0}?id={1}",PageBase.PageExt,reservation.Id) %>'});return false;">登录</a> 后即可见
                        </div>
                        <input type="text" class="detailbid-userbidinput ml5 w200 disable" placeholder="请在登录后输入预约金额" disabled="disabled" />
                        <ul class="detailbid-userbidlist mt20">                            
                            <li>起投金额：<% =string.Format("{0}", reservation.MinAmount > 0 ? reservation.MinAmount.ToMoneyString() + " 元" : "不限") %> </li>
                            <li>最大预约金额：<% =string.Format("{0}",reservation.MaxAmount > 0 ? reservation.MaxAmount.ToMoneyString() + " 元" : "不限") %></li>
                        </ul>
                        <a class="g-block btn-nobord c-important w218 mt20 pt5 pb5" target="_blank" href="/User/Register<% =PageBase.PageExt %>">还没有账号？立刻注册</a>
                    </ruson:Space>
                    <%--实名认证或手机号码认证--%>
                    <ruson:Space ID="authentication" runat="server" Visible="false">
                        <div class="detailbid-usermoenytext">
                            <span class="g-left fs16">可用余额：</span>
                            <a class="g-right btn-bordsmall c-normal" href="/User/Account/OnlineRecharge<% =PageBase.PageExt %>">充 值</a>
                        </div>
                        <div class="detailbid-usermoeny">
                            <span class="fs24"><% =avaliableSum.ToMoneyString() %></span> 元
                        </div>
                        <input type="text" class="detailbid-userbidinput w218 disable" placeholder="请完成认证后输入投资金额" disabled="disabled" />
                        <ul class="detailbid-userbidlist mt20">                            
                            <li>起投金额：<% =string.Format("{0}", reservation.MinAmount > 0 ? reservation.MinAmount.ToMoneyString() + " 元" : "不限") %> </li>
                            <li>最大预约金额：<% =string.Format("{0}",reservation.MaxAmount > 0 ? reservation.MaxAmount.ToMoneyString() + " 元" : "不限") %></li>
                        </ul>
                        <%= CurrentUser.RealNameValid != WAP2P.Member.User.BaseInfoValidStatus.ValidSuccess ? string.Format("<a class=\"g-block btn-nobord c-important w218 mt10\" href=\"/User/Info/RealName{0}\">立刻完成实名认证</a>", PageExt) : string.Empty %>
                        <%= CurrentUser.PhoneValid != WAP2P.Member.User.BaseInfoValidStatus.ValidSuccess ? string.Format("<a class=\"g-block btn-nobord c-important w218 mt5\" href=\"/User/Info/Phone{0}\"> 立刻绑定手机号码</a>", PageExt) : string.Empty %>
                    </ruson:Space>
                    <%--已经结束--%>
                    <ruson:Space ID="custom" runat="server" Visible="false">
                        <div class="detailbid-usermoenytext">
                            <span class="g-left fs16">可用余额：</span>
                            <a class="g-right btn-bordsmall c-normal" href="/User/Account/OnlineRecharge<% =PageBase.PageExt %>">充 值</a>
                        </div>
                        <div class="detailbid-usermoeny">
                            <span class="fs24"><% =avaliableSum.ToMoneyString() %></span> 元
                        </div>
                        <div class="detailbid-usermoeny fs18 fcgery-3 g-fbold">
                            该预约已经结束
                        </div>
                        <ul class="detailbid-userbidlist mt20">                            
                            <li>起投金额：<% =string.Format("{0}", reservation.MinAmount > 0 ? reservation.MinAmount.ToMoneyString() + " 元" : "不限") %> </li>
                            <li>最大预约金额：<% =string.Format("{0}",reservation.MaxAmount > 0 ? reservation.MaxAmount.ToMoneyString() + " 元" : "不限") %></li>
                        </ul>
                        <a class="g-block btn-nobord c-normal w218 mt20 pt5 pb5" href="/Borrow/">看看别的项目</a>
                    </ruson:Space>
                    <%--已预约--%>
                    <ruson:Space ID="hasbeen" runat="server" Visible="false">
                        <div class="detailbid-usermoenytext">
                            <span class="g-left fs16">可用余额：</span>
                            <a class="g-right btn-bordsmall c-normal" href="/User/Account/OnlineRecharge<% =PageBase.PageExt %>">充 值</a>
                        </div>
                        <div class="detailbid-usermoeny">
                            <span class="fs24"><% =avaliableSum.ToMoneyString() %></span> 元
                        </div>
                        <div class="detailbid-usermoeny fs18 fcgery-3 g-fbold">
                            您已成功预约
                        </div>
                        <ul class="detailbid-userbidlist mt20">                            
                            <li>起投金额：<% =string.Format("{0}", reservation.MinAmount > 0 ? reservation.MinAmount.ToMoneyString() + " 元" : "不限") %> </li>
                            <li>最大预约金额：<% =string.Format("{0}",reservation.MaxAmount > 0 ? reservation.MaxAmount.ToMoneyString() + " 元" : "不限") %></li>
                        </ul>
                        <a class="g-block btn-nobord c-normal w218 mt20 pt5 pb5" href="/Borrow/">看看别的项目</a>
                    </ruson:Space>
                    <%--当前会员组不支持预约--%>
                    <ruson:Space ID="nonsupport" runat="server" Visible="false">
                        <div class="detailbid-usermoenytext">
                            <span class="g-left fs16">可用余额：</span>
                            <a class="g-right btn-bordsmall c-normal" href="/User/Account/OnlineRecharge<% =PageBase.PageExt %>">充 值</a>
                        </div>
                        <div class="detailbid-usermoeny">
                            <span class="fs24"><% =avaliableSum.ToMoneyString() %></span> 元
                        </div>
                        <div class="detailbid-usermoeny fs18 fcgery-3 g-fbold">
                            所在会员组不支持预约
                        </div>
                        <ul class="detailbid-userbidlist mt20">                            
                            <li>起投金额：<% =string.Format("{0}", reservation.MinAmount > 0 ? reservation.MinAmount.ToMoneyString() + " 元" : "不限") %> </li>
                            <li>最大预约金额：<% =string.Format("{0}",reservation.MaxAmount > 0 ? reservation.MaxAmount.ToMoneyString() + " 元" : "不限") %></li>
                        </ul>
                        <a class="g-block btn-nobord c-normal w218 mt20 pt5 pb5" href="/User/Info/UserGroupUp<% =PageExt %>" target="_blank">升级会员组</a>
                    </ruson:Space>
                    <%--按金额预约--%>
                    <ruson:Space ID="amountBid" runat="server" Visible="false">
                        <div class="detailbid-usermoenytext">
                            <span class="g-left fs16">可用余额：</span>
                            <a class="g-right btn-bordsmall c-normal" href="/User/Account/OnlineRecharge<% =PageBase.PageExt %>">充 值</a>
                        </div>
                        <div class="detailbid-usermoeny">
                            <span class="fs24"><% =avaliableSum.ToMoneyString() %></span> 元
                        </div>
                        <input type="text" 
                            class="detailbid-userbidinput ml5 w200 input-moneyicon"
                            placeholder="请输入您需预约的金额"
                            id="amount" 
                            data-vmin="<% =reservation.MinAmount.ToJsString() %>" 
                            data-vmax="<% =(reservation.MaxAmount.HasValue ? reservation.MaxAmount : reservation.Amount) %>" 
                            data-vtype="money|range|fun|ajax" 
                            data-vmsg="请输入正确的投资金额|最低 <% =reservation.MinAmount.ToMoneyString() %> 元 最高 <% = reservation.MaxAmount.HasValue ? reservation.MaxAmount.ToMoneyString() +" 元" : "不限制" %>|请输入<% =reservation.StepAmount.ToMoneyString() %>的整数倍金额|可用余额不足" 
                            data-vfun="checkStep" 
                            data-vurl="?action=amountCheck" />
                        <ul class="detailbid-userbidlist">
                            <li>起投金额：<% =string.Format("{0}", reservation.MinAmount > 0 ? reservation.MinAmount.ToMoneyString() + " 元" : "不限") %> </li>
                            <li>最大预约金额：<% =string.Format("{0}",reservation.MaxAmount > 0 ? reservation.MaxAmount.ToMoneyString() + " 元" : "不限") %></li>
                            <li class="ui-vcheckbox js-tip">
                                <label><input type="checkbox" name="protocol1" checked="checked" value="1" data-vtype="group" data-vmin="1" data-vmsg="您需要同意用户协议。" />同意《<a target="_blank" href="/Agreement/?type=reservation"><% =SiteName %>预约协议</a>》</label>
                            </li>
                        </ul>

                        <div class="btn-submits mt10">
                            <input type="submit" class="btn-bbord fs16 c-normal w252" value="立刻预约" data-success-text="预约中" />
                            <div class="w252"><em class="m-sumtip js-vsum"></em></div>
                        </div>
                    </ruson:Space>
                </form>
                <a class="detailbid-userhelpline" target="_blank" href="/Help/ServiceList<% =PageBase.PageExt %>">操作遇到了问题？联系客服</a>
            </div>
            
        </div>

        <div class="m-container g-ohide mt20 mb20">
            <dl class="ui-tab detailbid-borrowtab">
                <dt><a href="#reservationDetail" class="on">借款详情</a></dt>
                <dt><a href="#reservationLog">预约记录</a></dt>
                <dd class="pa20" id="reservationDetail"><% =reservation.Detail %></dd>
                <dd class="pa20 g-hide" id="reservationLog" data-content-ajax="ajax<% =PageExt %>?action=reservationLog&reservationId=<% =reservation.Id %>"></dd>
            </dl>
        </div>

    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script>
        $(function () {
            getReservationInfo(<% =reservation.Id %>);
        });
        function getReservationInfo(id) {
            $.ajax({
                dataType: 'json',
                cache: false,
                url: 'ajax<% =PageExt %>',
                data: { action: 'reservationInfo', ids: id },
                success: function (res) {
                    if (res.length) {
                        $.each(res, function (i, n) {
                            $('.js-stepw').css('width', n.data.step);
                            $('.js-stepl').css('left', n.data.step).html(n.data.step);
                            $('.js-binUserCount').html(n.data.bidUserCount);
                            $('.js-canAmount').html(n.data.canAmount);
                            commonUi.timedown($('.js-time'), n.data.time);
                        });
                    }
                }
            });
        }

        function checkStep(val) {
            if (<% =reservation.StepAmount.HasValue ? "false" : "true" %>) return true;

            val = parseFloat(val.replace(/,/ig, ''));
            if (isNaN(val)) return false;

            return val % <% =(reservation.StepAmount ?? 0).ToJsString() %> == 0;
        }
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server">
</asp:Content>
