<%@ Page Title="" Language="C#" MasterPageFile="~/Master/MainMaster.master" CodeBehind="TransferDetail.aspx.cs" Inherits="WAP2P.Web.PC.Borrow.TransferDetail" %>
<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/TransferList<% =PageExt %>">债权列表</a> &nbsp;>&nbsp;</li>
                    <li><% =borrow.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">
                <img src="../Res/core/Images/default/tico.jpg" style="width: 60px; height: 18px;" class="g-left mr10" />
                <span class="fs18 g-left"><% =transfer.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"><% =transfer.UpDownAmount.ToMoneyString() %></span>
                        <span>元</span>
                    </li>
                    <li class="wg2">
                        <span class="g-block mt30">债权价值</span>
                        <span class="fs24"><% =transfer.Amount.ToMoneyString() %></span>
                        <span>元</span>
                    </li>
                    <li class="wg2">
                        <span class="g-block mt30">预计收益</span>
                        <span class="fs24"><% =transfer.Interest.ToMoneyString() %></span>
                        <span>元</span>
                    </li>
                    <li class="wg2">
                        <span class="g-block mt30">剩余期数</span>
                        <span class="fs24"><% =transfer.PeriodCount %></span>
                        <span>期</span>
                    </li>
                </ul>
                <div class="g-clear pa15 g-ohide fcblack-1" id="js-status">
                    <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-userCount">0</span> 人投资，剩余可投资金额 <% =(transfer.Amount - transfer.BidAmountCount).ToMoneyString() %> 元。
                    </div>
                </div>
                <div class="darailbid-box">
                    <div class="detailbid-photo g-left">
                        <img src="<% =borrow.GetCover() %>" height="158" />
                    </div>
                    <ul class="darailbid-list g-right">
                        <li>项目编号：<% =borrow.BusId %></li>
                        <li>借 款 人：<% =borrow.Nickname %></li>
                        <li>债权协议：《<a href="<% =string.Format("/Agreement/?id={0}&type=transfer", transfer.Id) %>" target="_blank"><% =SiteName %>债权协议</a>》</li>
                        <li>还款方式：<% =WAP2P.Web.Extensions.GetRepaymentName(borrow.Repayment) %></li>
                        <li>出 让 人：<% =transfer.Nickname %></li>
                        <li>借款开始时间：<% =borrow.FullVerifyAt.ToDateString() %></li>
                        <li>借款结束时间：<% =WAP2P.BorrowLoan.Receive.FindByBorrow(borrow.Id).Where(item => item.BidId == transfer.BidId).OrderByDescending(item => item.Period).First().ShouldRepayAt.ToDateString() %></li>
                        <li class="m-bidOther">
                            <% =borrow.VouchCompanyId.HasValue ? string.Format("<span><i class=\"iconfont fs20 fcgreen-3\">&#xe649;</i> {0}</span>", borrow.VouchCompanyName) : string.Empty %>
                            <% =borrow.WebSafeType != WAP2P.BorrowLoan.Borrow.WebSafe.None ? string.Format("<span><i class=\"iconfont fs20 fcblue-3\">&#xe648;</i> {0}</span>", borrow.WebSafeType.GetDescription()) : string.Empty %>
                        </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() + '&id={0}", id) %>', function () { common.pageTip('<% =PageBase.TipType.Success %>', '恭喜购买债权成功！', '/User/Loan/TransferBidList' + 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/TransferDetail{0}?id={1}",PageBase.PageExt,id) %>'});return false;">登录</a> 后即可见
                        </div>
                        <input type="text" class="detailbid-userbidinput ml5 w200 disable" placeholder="请在登录后输入投资金额" disabled="disabled" />
                        <a class="g-block btn-nobord c-important w218 mt40 pt5 pb5" 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 %></span> 元
                        </div>
                        <input type="text" class="detailbid-userbidinput w218 disable" placeholder="请完成认证后输入投资金额" disabled="disabled" />                        
                        <%= CurrentUser.RealNameValid != WAP2P.Member.User.BaseInfoValidStatus.ValidSuccess ? string.Format("<a class=\"g-block btn-nobord c-important w218 mt20\" 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 mt20\" href=\"/User/Info/Phone{0}\"> 立刻绑定手机号码</a>", PageExt) : string.Empty %>
                    </ruson:Space>
                    <%--结束--%>
                    <ruson:Space ID="completed" 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 %></span> 元
                        </div>
                        <div class="detailbid-usermoeny fs18 fcgery-3 g-fbold">
                            转让已结束
                        </div>                        
                        <a class="g-block btn-nobord c-normal w218 mt40 pt5 pb5" href="/Borrow/TransferList<% =PageExt %>">看看别的项目</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" id="js-avaliable"><% =avaliableSum %></span> 元
                        </div>
                        <input type="text" 
                            class="detailbid-userbidinput ml5 w200 input-moneyicon" 
                            placeholder="请输入您需购买的金额" 
                            id="amount" maxlength="10" autocomplete="off"
                            data-vmin="<% =borrowType.TransferCanMultiBuyer ? 1 : transfer.UpDownAmount %>" data-vmax="<% =transfer.UpDownAmount - transfer.BidAmountCount %>" data-vtype="money|range|ajax" data-vmsg="请输入正确的投资金额|最低 <% =(borrowType.TransferCanMultiBuyer ? 1 : transfer.UpDownAmount).ToMoneyString() %> 元 <% =string.Format("，最高 {0} 元", (transfer.UpDownAmount - transfer.BidAmountCount).ToMoneyString()) %>|可用余额不足" data-vurl="?action=amountCheck" />
                        <ul class="detailbid-userbidlist">
                            <li>预计收益：<span id="js-expectedInterest">0.00</span> 元</li>
                            <li class="ui-vcheckbox js-tip mt20">
                                <label><input type="checkbox" name="protocol1" checked="checked" value="1" data-vtype="group" data-vmin="1" data-vmsg="您需要同意用户协议。" />同意《<a target="_blank" href="/Agreement/?type=userreg"><% =SiteName %>投资协议</a>》</label>
                            </li>
                        </ul>
                        <div class="btn-submits mt20">
                            <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>
    <div class="m-container g-ohide mt20 mb20">
            <dl class="ui-tab detailbid-borrowtab">
                <dt><a href="#borrowdetail" class="on">借款详情</a></dt>
                <dt><a href="#borrowrecord">投标记录</a></dt>
                <dt><a href="#borrowrepay">还款情况</a></dt>
                <dt><a href="#borrowhold">债权持有</a></dt>
                <dt><a href="#borrowtransfer">转让记录</a></dt>
                <dd class="pa20" id="borrowdetail" data-content-ajax="ajax<% =PageExt %>?action=borrowInfo&borrowId=<% =borrowId %>"></dd>
                <dd class="pa20 g-hide" id="borrowrecord" data-content-ajax="ajax<% =PageExt %>?action=bid&borrowId=<% =borrowId %>"></dd>
                <dd class="pa20 g-hide" id="borrowrepay" data-content-ajax="ajax<% =PageExt %>?action=repay&borrowId=<% =borrowId %>"></dd>
                <dd class="pa20 g-hide" id="borrowhold" data-content-ajax="ajax<% =PageExt %>?action=receive&borrowId=<% =borrowId %>"></dd>
                <dd class="pa20 g-hide" id="borrowtransfer" data-content-ajax="ajax<% =PageExt %>?action=transfer&borrowId=<% =borrowId %>"></dd>
            </dl>
        </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script>
        $.ajax({
            dataType: 'json',
            cache: false,
            url: 'ajax<% =PageExt %>',
            data: { action: 'transfersInfo', ids: '<% =transfer.Id %>' },
            success: function (res) {
                if (res.length) {
                    $.each(res, function (i, n) {
                        var dom = $('#js-status');
                        dom.find('.js-stepw').css('width', n.data.step);
                        dom.find('.js-stepl').html(n.data.step);
                        dom.find('.js-userCount').html(n.data.bidUserCount);
                        commonUi.timedown($('.js-time'), n.data.time);
                    });
                }
            }
        });

        function getInterest(amount) {
            var res = 0;
            var val = parseFloat(amount.replace(/,/g, ''));
            if (!isNaN(val)) {
                res = (val / <% =transfer.UpDownAmount.ToJsString()  %>) * (<% =transfer.UpDownAmount.ToJsString()  %> / <% =transfer.Amount.ToJsString()  %> * <% =transfer.Interest.ToJsString()  %>)
            }
            return finance.toMoneyString(finance.roundx(res, 2));
        };

        $(function () {
            var amountChange = function () {
                var val = $('#amount').val();
                if (val) $('#js-expectedInterest').html(getInterest(val));
            };
            $('#amount').keyup(amountChange);            

            var amount = $('#amount'), avaliable = $('#js-avaliable');
            if (avaliable.length && amount.length && !amount[0].disabled) {
                var canBid = Math.min(parseFloat(avaliable.text().replace(/,/ig, '')), parseFloat(amount.attr('data-vmax').replace(/,/ig, '') || '9999999'))
                amount.val(finance.toMoneyString(canBid));
                amountChange();
            }
        });
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server">
</asp:Content>
