<%@ Page Title="" Language="C#" MasterPageFile="~/Master/UserMaster.master" CodeBehind="AutoBidList.aspx.cs" Inherits="WAP2P.Web.PC.User.Loan.AutoBidList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div class="m-userbox m-buserbox pb50">
        <div class="m-prompt pl10 pr10 mt20">
            <div class="prompt-left g-left mt10">
                联系专属客服：<div class="mt10 fs14 g-fcenter"><% =CurrentUser.GetService() %></div>
            </div>
            <div class="prompt-small g-right">
                <p>系统允许添加多套智能投标方案，您可以通过成为高级会员已添加更多的投标方案，已提高投资命中率。</p>
                <p>详细情况具体请查看 <a href="/Help/" target="_blank">帮助中心</a>。</p>
            </div>
        </div>
        <div class="mt30">
            <p class="m-infotip ml10 mb10 mr10"><% =userGroup.AutoBid ? string.Format("您所在会员组的智能投标优先级为{0}，最大{1}套方案。", userGroup.AutoBidPriority, userGroup.AutoBidMaxRecored) : string.Format("<strong>您当前所在组不支持智能投标，您可以考虑<a href=\"/User/Info/UserGroupUp{0}\">升级会员组</a>。</strong>",PageExt) %></p>
            <asp:Repeater runat="server" ID="rptList" ItemType="WAP2P.BorrowLoan.AutoBid">
                <ItemTemplate>
                    <div class="m-autobid">
                        <div class="autobid-box">
                            <div class="t-borrowbidinfor">
                                <h4><%# Item.EstimatedAmount.HasValue ? string.Format("{0}", Item.Name) : string.Format("<a href=\"AutoBidDetail{0}?id={1}\">{2}</a>", PageExt, Item.Id, Item.Name) %></h4>
                                <p>添加时间：<%# Item.CreateAt.ToDateTimeString() %></p>
                                <ul>                                    
                                    <li>借款期限：<span class="fcblue-2"><%# Item.ValidDateMin.HasValue ? Item.ValidDateMin + "月" + (Item.ValidDateMax.HasValue ? " - " : "以上") : string.Empty %><%# Item.ValidDateMax.HasValue ? Item.ValidDateMax + "月" + (Item.ValidDateMin.HasValue ? string.Empty : "以内") : string.Empty %></span></li>
                                    <li>借款利率：<span class="fcblue-2"><%# Item.ValidInterestMin.HasValue ? (Item.ValidInterestMin * 100).ToInterestString() + "%" : "不限" %><%# Item.ValidInterestMax.HasValue ? " - " + (Item.ValidInterestMax * 100).ToInterestString() + "%" : string.Empty %></span></li>
                                    <%# Item.EstimatedAmount.HasValue ? string.Format("<li>认购 <span class=\"fcblue-2\">{0}</span> 元，已投中 <span class=\"fcblue-2\">{1}</span> 元</li>", Item.EstimatedAmount.ToMoneyString(), Item.BidedAmount.ToMoneyString()) : string.Empty %>
                                </ul>
                            </div>
                            <ruson:Space runat="server" ID="oper" Visible="false">
                                <div class="ui-toggle js-toggle" style="right: 60px;">
                                    <label class="<%# Item.Active ? "on" : string.Empty %>">
                                        <input type="checkbox" onchange="setActive(this);" data-id="<%# Item.Id %>" <%# Item.Active ? "checked=\"checked\"" : string.Empty %> />
                                    </label>
                                </div>
                                <div class="ui-toggle" >
                                    <a class="del" href="javascript:void(0);" data-id="<%# Item.Id %>">删除</a>
                                </div>
                            </ruson:Space>                            
                            <div class="autobid-ranking">
                                该方案排名：<span class="fcred-3 fs36"><%# Item.Active ? Item.GetQueueIndex().ToString() : "*" %></span> 位
                                <p>上次投标成功时间：<%# Item.LastSuccessBid.ToDateTimeString("从未") %></p>
                            </div>
                        </div>
                    </div>
                </ItemTemplate>
            </asp:Repeater>        
            <div class="m-autobid" runat="server" id="add" visible="false">
                <a href="AutoBidDetail<% =PageExt %>" class="autobid-box g-fcenter pt10 pb20 m-dashedborder">
                    <i class="iconfont fs50 g-block">&#xe628;</i>
                    添加新的智能投标方案
                </a>
            </div> 
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script>
        function setActive(dom) {
            dom = $(dom);
            $.ajax({
                type: 'get',
                url: location.href,
                cache: false,
                data: { action: 'setActive', id: dom.attr('data-id'), t: dom[0].checked ? '1' : '0' },
                dataType: 'json',
                success: function (res) {
                    dom.toggle('changeClick', res.Success);
                    if (res.Message) {
                        $.jError(res.Message);
                    }
                }
           });
        }

        $('.ui-toggle a.del').on('click', function () {
            var me = $(this);

            $.jConfirm('确定删除这条智能投标方案？',function(){
                    $.ajax({
                        type:'get',
                        url: '?action=del',
                        dataType: 'json',
                        data: { id: $('.ui-toggle a.del').attr('data-id') },
                        success: function (res) {
                            if (res.Success)
                                me.closest('.m-autobid').remove();                            
                        }
                    })
                }
            );
        });
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server">
</asp:Content>
