<%@ Page Title="" Language="C#" MasterPageFile="~/Master/UserMaster.master" AutoEventWireup="true" CodeBehind="PromotionList.aspx.cs" Inherits="WAP2P.Web.PC.User.Reward.PromotionList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div class="m-userbox m-buserbox">
        <table class="m-safecenter" id="js-tbReward">
            <ruson:Repater runat="server" ID="rptList" ItemType="WAP2P.BorrowLoan.Promotion">
                <ItemTemplate>
                    <tr>
                        <td class="g-fleft pl10">
                            <div class="safecenter-style">
                                <h4><a href="/Promotion/Detail<%# PageExt %>?id=<%# Item.Id %>" target="_blank" class="t-promotionlink"><%# Item.Name.LeftX(25) %></a></h4>
                                <p><%# Item.RewardDesc.LeftX(40) %></p>
                            </div>
                        </td>
                        <td class="g-fright pr10">
                            <input type="button" value="加载中.." class="btn-nobord c-disable w100 js-getReward" style="display:<%# Item.IsDisplay ? string.Empty : "none;" %>" data-id="<%# Item.Id %>" disabled="disabled" />
                        </td>
                    </tr>
                </ItemTemplate>
                <EmptyTemplate>
                    <tr>
                        <td colspan="2" class="g-fleft">暂无活动。</td>
                    </tr>
                </EmptyTemplate>
            </ruson:Repater>
            <tr class="pager">
                <td colspan="2" class="g-noneborder">
                    <div class="ui-pages g-fright"><ruson:Pager runat="server" ID="pages" CssClass="pages" ShowPageSizeSelect="false" /></div>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script>
        $('.js-getReward').each(function (i, n) {
            n = $(n);
            $.get('?action=getStatus&id=' + n.attr('data-id'), function (res) {
                if (res.Success) {
                    n.attr('value', res.Message);
                    switch (res.Message) {
                        case '领取奖励':
                            n.removeAttr('disabled').removeClass('c-disable').addClass('c-normal');
                            break;
                        case '已领取':
                            n.removeClass('c-disable').addClass('c-important');
                            break;
                    }                    
                }
            }, 'json');
        });

        $('#js-tbReward').on('click', '.js-getReward', function () {
            var me = $(this);
            if (me[0].disabled) return;
            $.get('?action=getReward&id=' + me.attr('data-id'), function (res) {
                if (res.Success) {
                    me.attr('value', '已领取').removeClass('c-normal').addClass('c-important').attr('disabled', 'disabled');
                } else {
                    $.jError(res.Message);
                }
            }, 'json');
        });
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server"></asp:Content>
