<%@ Page Title="" Language="C#" MasterPageFile="../BaseMaster.Master" CodeBehind="UserDetail.aspx.cs" Inherits="WAP2P.Web.PC.Admin.Member.UserDetail" %>

<asp:Content ID="Content1" ContentPlaceHolderID="header" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <form class="auto" method="post" action="" onsuccess="parent.$.jPopupEdit.close(true);">
        <div class="m-editbar">
            <input type="submit" class="btn-larger c-priority iconfont" value="&#xe684; 保存" />
            <input type="button" class="btn-larger c-normal iconfont" value="&#xe634; 关闭" onclick="parent.$.jPopupEdit.close();" />
        </div>
        <div class="m-content m-editcontent">
            <table class="m-info" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <th width="15%" rowspan="3">会员头像</th>
                    <td width="35%" rowspan="3">
                        <div id="faceResult" class="mb10">
                            <% =string.IsNullOrWhiteSpace(Model.Face) ? string.Empty : string.Format("<img src=\"{0}\", alt=\"\" />", Model.Face) %>
                        </div>
                        <div class="pl136">
                            <input type="hidden" name="face" id="face" value="<% =Model.Face.HtmlEncode() %>" />
                        </div>
                        <input type="file" id="faceFile" />
                        <em>请上传尺寸为 <i class="fcred-3">120 X 120 像素</i> 的头像</em>
                    </td>
                    <th width="15%">会员账户</th>
                    <td width="35%">
                        <input type="text" tabindex="1" name="name" class="w150" maxlength="30" data-vtype="custom" placeholder="请输入账户名称" data-vmsg="会员账户必需以字母开头，且只能包含字母、数字和下划线。" data-vreg="^[a-zA-Z][-_a-zA-Z0-9_]*$" value="<% =Model.Name.HtmlEncode() %>" <% =IsNew ? string.Empty : " disabled=\"disabled\"" %> />
                    </td>
                </tr>
                <tr>
                    <th>登录密码</th>
                    <td>
                        <input type="password" name="password" tabindex="2" class="w150" placeholder="请输入用于登录的密码" maxlength="50" <% =IsNew ? "data-vtype=\"must\" data-vmsg=\"请输入登录密码\"" : string.Empty %> />
                        <% =IsNew ? string.Empty : "<em>不填将不会修改现有密码</em>" %>
                    </td>
                </tr>
                <tr>
                    <th>推荐号</th>
                    <td>
                        <% =IsNew ? "保存后生成" : Model.GetRecommendNo() %>
                    </td>
                </tr>
                <tr>
                    <th>会员昵称</th>
                    <td><input type="text" name="nickname"  tabindex="3" class="w150" placeholder="请输入会员的昵称" maxlength="50" value="<% =Model.Nickname.HtmlEncode() %>" /></td>
                    <th>所在区域</th>
                    <td><span id="area"></span></td>
                </tr>
                <tr>
                    <th>手机号码</th>
                    <td>
                        <% =CurrentAdmin.HavePermission("会员管理","会员账号管理","设置") || IsNew ? string.Format("<input type=\"text\" name=\"phone\" class=\"w150\" maxlength=\"20\" placeholder=\"请输入手机号码\" value=\"{0}\" data-vtype=\"phone\" data-vmsg=\"请输入正确的手机号码\" {1} />",Model.Phone,IsNew ? string.Empty : " data-vmust=\"false\"") : CurrentAdmin.HavePermission("会员管理","查看联系方式","手机") ? Model.Phone : Model.Phone.HidePart() %>
                        <% =!IsNew && CurrentAdmin.HavePermission("会员管理","会员认证管理","审核") && Model.PhoneValid == WAP2P.Member.User.BaseInfoValidStatus.WaitValid ? "<input type=\"button\" data-type=\"phone\" class=\"js-quickValid btn-larger c-priority iconfont\" value=\"&#xe605; 手机快速认证\" />" : string.Empty %>
                        <input type="hidden" name="oldPhone" value="<% =Model.Phone.HtmlEncode() %>" />
                    </td>
                    <th>电子邮箱</th>
                    <td>
                        <% =CurrentAdmin.HavePermission("会员管理","会员账号管理","设置") || IsNew ? string.Format("<input type=\"text\" name=\"email\" class=\"w150\" maxlength=\"100\" placeholder=\"请输入邮箱地址\" value=\"{0}\" data-vtype=\"email\" data-vmsg=\"请输入正确的邮箱\" {1} />",Model.Email,IsNew ? string.Empty : " data-vmust=\"false\"") : CurrentAdmin.HavePermission("会员管理","查看联系方式","邮箱") ? Model.Email : Model.Email.HidePart() %> 
                        <% =!IsNew && CurrentAdmin.HavePermission("会员管理","会员认证管理","审核") && Model.EmailValid == WAP2P.Member.User.BaseInfoValidStatus.WaitValid ? "<input type=\"button\" data-type=\"email\" class=\"js-quickValid btn-larger c-priority iconfont\" value=\"&#xe605; 邮箱快速认证\" />" : string.Empty %>
                        <input type="hidden" name="oldEmail" value="<% =Model.Email.HtmlEncode() %>" />
                    </td>
                </tr>
                <tr>
                    <th>所属会员类型</th>
                    <td><ruson:Select runat="server" ID="userTypeId" TipsText="请选择" data-vtype="must" data-vmsg="请选择会员类型"></ruson:Select></td>
                    <th>所属会员组</th>
                    <td>
                        <select id="upGroupId" name="UpGroupId"></select>
                        <span class="pl30 g-hide">到期时间：
                            <input type="text" name="upGroupExpires" class="ui-date ui-datetime" value="<% =Model.UpGroupExpires.ToDateTimeString() %>" /></span>
                    </td>
                </tr>
                <%if(IsNew || CurrentAdmin.HavePermission("会员管理","会员账号管理","设置")){ %>
                <tr>
                    <th>是否锁定账户</th>
                    <td><% =HtmlHelper.CheckBox("isLock", "锁定", Model.IsLock) %></td>
                    <th>推荐人账号</th>
                    <td>
                        <input type="text" name="recommendBy" id="recommendBy" placeholder="选择或输入推荐人账号" class="w150 g-valign" maxlength="30" value="<% =Model.RecommendBy == 0 ? string.Empty : WAP2P.Member.User.LoadOrNew(Model.RecommendBy).Name.HtmlEncode() %>" />
                        <input type="button" class="btn-base c-normal iconfont g-valign" value="&#xe60f;" onclick="$.jPopupEdit('选择推荐人账号', '../Common/UserSelect.aspx?radio=true&fn=selectRecommend');" />
                        <script>
                            function selectRecommend(obj) {
                                if (obj && obj.users && obj.users.length)
                                    $('#recommendBy').val(obj.users[0].name);
                            }
                        </script>
                    </td>
                </tr>
                <tr>
                    <th>所属业务员账号</th>
                    <td>
                        <input type="text" name="saleById" id="saleById" class="w150 g-valign" placeholder="选择或输入业务人员" maxlength="30" value="<% = IsNew ? CurrentAdmin.Name : WAP2P.Sys.Admin.LoadOrNew(WAP2P.Member.UserAdminMapping.GetUserSale(Model.Id)).Name %>" />
                        <input type="button" class="btn-base c-normal iconfont g-valign" value="&#xe60f;" onclick="$.jPopupEdit('选择业务员账号', '../Common/AdminSelect.aspx?radio=true&fn=selectSale');" />
                        <script>
                            function selectSale(obj) {
                                if (obj && obj.admins && obj.admins.length)
                                    $('#saleById').val(obj.admins[0].name);
                            }
                        </script>
                        <span class="pl30"><% = IsNew || WAP2P.Member.UserAdminMapping.GetUserSale(Model.Id) == 0 ? string.Empty : string.Format("分配时间：{0}", WAP2P.Member.UserAdminMapping.LoadOrNew(Model.Id).SaleStartAt.ToDateString()) %></span>
                    </td>
                    <th>所属客服账号</th>
                    <td>
                        <input type="text" name="serviceById" id="serviceById" class="w150  g-valign" placeholder="选择或输入客服人员" maxlength="30" value="<% = IsNew ? CurrentAdmin.IsService ? CurrentAdmin.Name : string.Empty : WAP2P.Sys.Admin.LoadOrNew(WAP2P.Member.UserAdminMapping.GetUserService(Model.Id)).Name.HtmlEncode() %>" />
                        <input type="button" class="btn-base c-normal iconfont  g-valign" value="&#xe60f;" onclick="$.jPopupEdit('选择客服帐号', '../Common/AdminSelect.aspx?radio=true&service=true&fn=selectService');" />
                        <script>
                            function selectService(obj) {
                                if (obj && obj.admins && obj.admins.length)
                                    $('#serviceById').val(obj.admins[0].name);
                            }
                        </script>
                        <span class="pl30"><% =WAP2P.Member.UserAdminMapping.GetUserService(Model.Id) == 0 ? string.Empty : string.Format("分配时间：{0}", WAP2P.Member.UserAdminMapping.LoadOrNew(Model.Id).ServiceStartAt.ToDateString()) %></span>
                    </td>
                </tr>
                    <%} %>
                <tr>
                    <th>连续登录错误次数</th>
                    <td>
                        <input type="text" name="loginErrorCount" value="<% =Model.LoginErrorCount %>" class="w60 ui-int" data-vtype="number" data-vmsg="请输入正确的数据值" />
                        次
                        <em style="<% =GlobalSetting.Get<int>(GlobalSetting.Keys.Security.LoginErrorLockN) == 0 ? "display:none;": string.Empty %>">连续登录错误 <% =GlobalSetting.Get<int>(GlobalSetting.Keys.Security.LoginErrorLockN) %> 次后，将在 <% =GlobalSetting.Get<int>(GlobalSetting.Keys.Security.LoginErrorLockTime) %> 分钟内禁止登录</em>
                    </td>
                    <th>连续支付错误次数</th>
                    <td>
                        <input type="text" name="payErrorCount" value="<% =Model.PayErrorCount %>" class="w60 ui-int" data-vtype="number" data-vmsg="请输入正确的数据值" />
                        次
                        <em style="<% =GlobalSetting.Get<int>(GlobalSetting.Keys.Security.PayErrorLockN) == 0 ? "display:none;": string.Empty %>">连续支付错误 <% =GlobalSetting.Get<int>(GlobalSetting.Keys.Security.PayErrorLockN) %> 次后，将在 <% =GlobalSetting.Get<int>(GlobalSetting.Keys.Security.PayErrorLockTime) %> 分钟内禁止支付</em>
                    </td>
                </tr>
                <tr>
                    <th>注册情况</th>
                    <td>
                        <% =Model.CreateAt.ToDateTimeString() %><br />
                        <% =string.IsNullOrEmpty(Model.RegIP) ? "由管理员创建" : Area.GetLocationString(Model.RegIP) + " " + Model.RegIP  %>
                    </td>
                    <th>最后登陆情况</th>
                    <td><% =Model.LastLoginAt.ToDateTimeString() %><br />
                        <% =Area.GetLocationString(Model.LastLoginIP) %> <% =Model.LastLoginIP %>
                    </td>
                </tr>
                <tr>
                    <th>积分</th>
                    <td><% =Model.Score %> 分</td>
                    <th>登陆次数</th>
                    <td><% =Model.LoginCount %> 次</td>
                </tr>
                <tr>
                    <th>个性签名</th>
                    <td colspan="3">
                        <textarea name="signature"><% =Model.Signature.HtmlEncode() %></textarea>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script src="<% =this.ImportJsCss("../../res/core/scripts/areadata.js") %>"></script>
    <script>
        //会员类型，会员组。
        var group = $('#upGroupId');
        var defaultGroupId = 0;

        var userGroupChange = function () {
            var val = group.val();
            if (val == '' || parseInt(val) == defaultGroupId) {
                group.next().hide();
            } else {
                group.next().show();
            }
        };
        group.change(userGroupChange);

        var userTypeChange = function () {
            $.ajax({
                url: '?action=getUserGroup',
                data: { userType: $('#userTypeId').val() },
                dataType: 'json',
                beforeSend: function () {
                    group[0].length = 0;
                    group.append('<option value="">加载中..</option>');
                },
                success: function (res) {
                    group[0].length = 0;
                    group.append('<option value="">默认组</option>');
                    $.each(res, function (i, n) {
                        group.append('<option value="' + n.Id + '"' + (n.Id == <% =Model.UpGroupId.HasValue ? Model.UpGroupId.Value : -1 %> ? ' selected="selected"' : '') + '>' + n.Name + '</option>');
                        if (n.IsDefault) defaultGroupId = n.Id;
                    });                    
                    userGroupChange();
                }
            });
        };
            $('#userTypeId').change(userTypeChange);
            userTypeChange();

            $('#area').cascade({ data: areadata, names: ['provinceId', 'cityId', 'areaId'], emptyTip: '全部', values: [<% =Model.ProvinceId %>, <% =Model.CityId %>, <% =Model.AreaId %>] });

        setTimeout(function() {
            $('#faceFile').uploadify({
                width: 120,
                height: 32,
                multi: false,
                removeTimeout: 0,
                swf: '../res/uploadify/uploadify.swf?v=<% =CryptoHelper.Random(100000,999999) %>',
                uploader: '../res/uploadify/SwfUpload.aspx?type=image&width=120&height=120',
                buttonClass:'iconfont',
                buttonText: '&#xe629; 上传头像',
                fileTypeExts: '<% =WAP2P.Web.PC.Admin.Res.uploadify.SwfUpload.AllowImages %>',
                formData: {
                    <% =WAP2P.Web.Admin.Membership.CookieName %> : '<% =Request.Cookies[WAP2P.Web.Admin.Membership.CookieName].Value %>'
                },
                onUploadSuccess: function(res, data) {
                    eval('var d = ' + data);
                    if (d.Success) {
                        $('#face').val(d.Message).trigger('blur');
                        $('#faceResult').html('<img src="' + d.Message + '" />');
                    } else {
                        $.jError(d.Message);
                    }
                }
            });  
        }, 10);

        $('.js-quickValid').on('click',function(){
            var me = $(this);
            $.ajax({
                url: '?action=quickValid',
                data: { type: me.attr('data-type'), id:<% =Model.UserId %>},
                dataType: 'json',
                success: function (res) {
                    if(res.Success){
                        $.jSuccess('快速认证成功',function(){
                            me.remove();
                        });
                    }
                }
            });
        });

    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server">
</asp:Content>
