<%@ Page Title="" Language="C#" MasterPageFile="~/Master/UserMaster.master" CodeBehind="UserGroupUp.aspx.cs" Inherits="WAP2P.Web.PC.User.Info.UserGroupUp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div class="m-userbox m-buserbox">
        <div class="m-prompt mt20 pl10 pr10">
            <div class="prompt-left g-left mt10">
                您当前所在会员组：           
                <span class="fcred-3 g-fbold fs16 g-fcenter mt10 mb5 g-block"><% =userGroup.Name %></span>
                <span class="fs12 ff-songti g-fcenter fcblack-1 g-block">到期时间：<% =CurrentUser.UpGroupExpires == null  ? "长期" : CurrentUser.UpGroupExpires.ToDateString() %></span>
            </div>
            <div class="prompt-small g-right">
                <p>信用等级是我平台根据您上传的基本资料、借款资料结合线下风控调查结果，综合评定的信用属性，也是帮助投资人判断违约风险的重要依据之一。</p>
                <p>详细情况具体请查看 <a href="/Help/" target="_blank">帮助中心</a>。</p>                
            </div>
        </div>
        <ul class="m-usergroupup mt20 ml10 mr10">
            <ruson:Repater runat="server" ID="rptList" ItemType="WAP2P.Sys.UserGroup">
                <ItemTemplate>
                    <li>
                        <div class="usergroupup-photo g-left">
                            <img src="<%# Item.GetIcon() %>" />
                        </div>
                        <div class="usergroupup-info g-left js-upOrder">
                            <h5 class="fs18 pl10 mt5 js-ginfo" data-id="<%# Item.Id %>"><%# Item.Name %></h5>
                            <p class="pl10 pr10">
                                <%# Item.Description.LeftX(110) %>
                            </p>
                            <div class="g-ohide pt5 pl10">
                                <div class="ui-radio g-left js-radio">
                                    <%# Item.CanUpByScore ? string.Format(@"<label><input type=""radio"" name=""type{0}"" value=""score""{1} />积分兑换</label>", Item.Id, " checked=\"checked\"") : string.Empty %>
                                    <%# Item.CanUpByAmount ? string.Format(@"<label><input type=""radio"" name=""type{0}"" value=""amount""{1} />现金兑换</label>", Item.Id, Item.CanUpByScore ? string.Empty : " checked=\"checked\"") : string.Empty %>
                                </div>
                                <select class="g-left js-score" style="<%# Item.CanUpByScore ? string.Empty : "display:none;" %>">
                                    <asp:Repeater runat="server" ID="rptByScore">
                                        <ItemTemplate>
                                            <option value="<%# Eval("Key") %>"><%# Eval("Key") %> 个月（<%# Eval("Value") %> 分）</option>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </select>
                                <select class="g-left js-amount" style="<%# Item.CanUpByAmount && !Item.CanUpByScore ? string.Empty : "display:none;" %>">
                                    <asp:Repeater runat="server" ID="rptByAmount">
                                        <ItemTemplate>
                                            <option value="<%# Eval("Key") %>" data-money="<%# Eval("Value") %>"><%# Eval("Key") %> 个月（<%# ((decimal)Eval("Value")).ToMoneyString() %> 元）</option>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </select>
                                <a href="javascript:void(0);"  class="btn-bordsmall c-normal g-block ff-songti fs12 g-right mr10 mt5 js-btnOrder"><i class="iconfont fs14">&#xe635;</i> 订 购</a>
                            </div>
                        </div>
                    </li>
                </ItemTemplate>
            </ruson:Repater>
        </ul>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script>
        $('.js-upOrder :radio').click(function() {
            var me = $(this), ctr = me.closest('.js-upOrder');
            ctr.find('select').hide().filter('.js-' + me.val()).show();
        });

        $('.js-upOrder .js-btnOrder').click(function() {
            var ctr = $(this).closest('.js-upOrder'), info = ctr.find('.js-ginfo'), type = ctr.find('.js-radio :checked'), sel = ctr.find('.js-' + type.val() + ' :selected');
            $.jConfirm('您确定要' + type.parent().text() + '【<span class="fcred-2">' + info.text() + '</span>】' + sel.text() + '吗？', function() {
                switch(type.val()) {
                    case 'amount':
                        member.pay('<% =(int)WAP2P.Account.AccountActionType.会员升级支出 %>', 'amount=' + sel.attr('data-money') + '&toGroup=' + info.attr('data-id') + '&month=' + sel.val(), function () {
                            location.href = location.href;
                        });
                        break;
                    case 'score':
                        $.ajax({
                            type: 'get',
                            url: '?',
                            cache: false,
                            dataType: 'json',
                            data: { action: 'upGroup', toGroup: info.attr('data-id'), month: sel.val() },
                            success: function (res) {
                                if (res.Success) {
                                    $.jSuccess('订购成功', function() { location.href = location.href; });
                                } else {
                                    $.jError(res.Message);
                                }
                            }
                        });
                        break;            
                }
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server">
</asp:Content>
