{layout:default} {class:Shop.Admin.user.Default}
<lbhead>
    <title><%=Tag("会员管理")%>-<%=site.title%></title>
</lbhead>
<lbfile>
    <link href="<%=site.AdminAssetsPath %>/plugins/daterangepicker/daterangepicker.css" rel="stylesheet">
</lbfile>
<lbpath>
    <h3 class="text-themecolor m-b-0 m-t-0"><%=Tag("会员管理")%></h3>
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="<%=site.AdminPath %>/Ajax/ajax_admin.aspx?__Action=MenuJump&pid=0"><%=Tag("管理首页")%></a></li>
        <li class="breadcrumb-item active"><%=Tag("会员管理")%> <%=su.Description%></li>
    </ol>
</lbpath>
<lbbody>
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-9 m-b-10">
                        <%if (PageReturnMsg == ""){%>
                        <button class="btn btn-info" onclick="Edit(0)"><i class="ti-plus"></i> <%=Tag("添加")%></button>
                        <button class="btn btn-danger" onclick="DeleteConfirm()"><i class="ti-trash"></i> <%=Tag("删除")%></button>
                        <button class="btn btn-default" onclick="WriteSMS('')"><i class="ti-mobile"></i> <%=Tag("手机短信")%></button>
                        <button class="btn btn-default" onclick="EditMoney('')"><i class="ti-money"></i> <%=Tag("调资金")%></button>
                        <button class="btn btn-default" onclick="EditPoint('')"><i class="ti-id-badge"></i> <%=Tag("调积分")%></button>
                        <button class="btn btn-default" onclick="SendCard(311,'<%=Tag("购物卡")%>','')"><i class="ti-credit-card"></i> <%=Tag("购物卡")%></button>
                        <button class="btn btn-default" onclick="SendCard(312,'<%=Tag("代金券")%>','')"><i class="ti-gift"></i> <%=Tag("代金券")%></button>
                        <%
                        if (Shop.LebiAPI.Service.Instanse.Check("plugin_usercsv")){
                        %>
                        <button class="btn btn-default" onclick="Export()"><i class="ti-export"></i> <%=Tag("导出")%></button>
                        <%}%>
                        <%}%>
                    </div>
                    <div class="col-md-3 m-b-10">
                        <div class="input-group">
                            <input type="text" id="key" name="key" value="<%=key %>" class="form-control" onkeydown="if(event.keyCode==13){search_();}">
                            <div class="input-group-append">
                                <button type="button" class="btn btn-primary" onclick="search_();"><i class="ti-search"></i></button>
                                <button class="btn btn-default" onclick="SearchWindow();"><i class="ti-filter"></i></button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="table-responsive sorttable">
                    <table class="table table-hover no-wrap">
                        <thead>
                            <tr class="no-wrap">
                                <th class="selectAll" style="width:40px">
                                    <a href="javascript:void(0);" onclick="$('input[name=\'sid\']').attr('checked',!$(this).attr('checked'));$(this).attr('checked',!$(this).attr('checked'));"><%=Tag("全选")%></a>
                                </th>
                                <th>
                                    <%=Tag("ID")%>
                                </th>
                                <th style="width:15%">
                                    <div class="th-inner sort <%=OrderByName(OrderBy," UserNameDesc","icon")%>" onclick="OrderBy('<%=OrderByName(OrderBy,"UserNameDesc")%>');"><%=Tag("会员帐号")%></div>
                                </th>
                                <th style="width:10%">
                                    <div class="th-inner sort <%=OrderByName(OrderBy," RealNameDesc","icon")%>" onclick="OrderBy('<%=OrderByName(OrderBy,"RealNameDesc")%>');"><%=Tag("姓名")%></div>
                                </th>
                                <th>
                                    <%=Tag("短信")%>
                                </th>
                                <th>
                                    <div class="th-inner sort <%=OrderByName(OrderBy," UserLevelDesc","icon")%>" onclick="OrderBy('<%=OrderByName(OrderBy,"UserLevelDesc")%>');"><%=Tag("等级")%></div>
                                </th>
                                <th>
                                    <div class="th-inner sort <%=OrderByName(OrderBy," MoneyDesc","icon")%>" onclick="OrderBy('<%=OrderByName(OrderBy,"MoneyDesc")%>');"><%=Tag("余额")%>(<%=DefaultCurrency.Msige%>)</div>
                                </th>
                                <th>
                                    <div class="th-inner sort <%=OrderByName(OrderBy," PointDesc","icon")%>" onclick="OrderBy('<%=OrderByName(OrderBy,"PointDesc")%>');"><%=Tag("积分")%></div>
                                </th>
                                <%if (domain3admin)
                                { %>
                                <th>
                                    <%=Tag("站点") %>
                                </th>
                                <%} %>
                                <th>
                                    <%=Tag("标签") %>
                                </th>
                                <th>
                                    <div class="th-inner sort <%=OrderByName(OrderBy," Time_LastDesc","icon")%>" onclick="OrderBy('<%=OrderByName(OrderBy,"Time_LastDesc")%>');"><%=Tag("最后登陆")%></div>
                                </th>
                                <th>
                                    <%=Tag("操作")%>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <%foreach (DB.LebiShop.Lebi_User model in models){%>
                            <tr ondblclick="Edit(<%=model.id %>);">
                                <td>
                                    <label class="custom-control custom-checkbox">
                                        <input type="checkbox" id="checkbox<%=model.id %>" name="sid" value="<%=model.id %>" class="custom-control-input">
                                        <span class="custom-control-label"></span>
                                    </label>
                                </td>
                                <td>
                                    <%=model.id%>
                                </td>
                                <td title="<%=Tag(" 昵称")%>
                                    ：<%=model.NickName %>">
                                    <%=model.UserName %>
                                </td>
                                <td>
                                    <%=model.RealName %>
                                </td>
                                <td>
                                    <a href="javascript:void(0);" onclick="Write('<%=model.UserName %>');"><i class="ti-email" title="<%=Tag("发信息")%>"></i></a>
                                </td>
                                <td>
                                    <%=Shop.Bussiness.EX_User.TypeName(model.UserLevel_id, CurrentLanguage.Code)%>
                                </td>

                                <td>
                                    <%=FormatMoney(model.Money) %>
                                </td>
                                <td>
                                    <%=model.Point %>
                                </td>
                                <%if (domain3admin){ %>
                                <td><%if (site.SiteCount > 1){ %><%=SiteName(model.Site_id,model.DT_id, CurrentLanguage.Code)%><%} %></td>
                                <%} %>
                                <td id="User_Tags<%=model.id %>" onclick="Tags(<%=model.id%>);">
                                    <%=Shop.Bussiness.EX_User.User_Tags(model.User_Tags_ids) %>
                                </td>
                                <td>
                                    <%=FormatTime(model.Time_Last) %>
                                </td>
                                <td>
                                    <div class="menu">
                                        <a href="user_edit.aspx?id=<%=model.id %>" target="_blank"><%=Tag("编辑")%></a>
                                        | <a href="javascript:void(0)" onclick="EditPassword(<%=model.id %>);"><%=Tag("改密")%></a>
                                        | <a href="login.aspx?id=<%=model.id %>" target="_blank"><%=Tag("管理")%></a>
                                    </div>
                                </td>
                            </tr>
                            <%} %>
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    <div class="col-12">
                        <nav aria-label="Page navigation">
                            <%=PageString%>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </div>
</lbbody>
<lbscripts>
    <script src="<%=site.AdminAssetsPath %>/plugins/moment/moment.js"></script>
    <script src="<%=site.AdminAssetsPath %>/plugins/daterangepicker/daterangepicker.js"></script>
    <script>
        $(document).ready(function () {
            var li = $(".datalist .menu");
            $(li).each(function (i) {
                var _this = this;
                $(_this).find(".showmenu").mouseover(function () {
                    $(".datalist .menu .submenu").hide();
                    var divindex = $(".datalist .menu").find(".submenu")[i];
                    $(divindex).show();
                    $(divindex).mouseleave(function () {
                        $(divindex).hide();
                    });
                });
            });
        });
        function search_(scurl) {
            var key = $("#key").val();
            if(scurl==undefined || scurl=='')
                scurl='<%=su.URL %>';
            window.location = "?key=" + escape(key) + "&OrderBy=<%=OrderBy%>&"+scurl;
        }
        function OrderBy(url) {
            MsgBox(4, "<%=Tag("正在排序，请稍后")%> ……", url+"&<%=su.URL %>");
        }
        function Edit(id) {
            window.location = "user_edit.aspx?id=" + id;
        }
        function DeleteConfirm() {
            $("#Modal-Confirm").modal("show");
            $("#Confirm-Content").html("<%=Tag("确认要删除吗？")%>");
            $("#Modal-Confirm .btn-success.btn-ok").attr("onclick", "Delete();");
        }
        function Delete() {
            $("#Modal-Confirm").modal("hide");
            var ids = GetChkCheckedValues("sid");
            var postData = { "ids": ids };
            var url = "<%=site.AdminPath %>/ajax/ajax_user.aspx?__Action=User_Del";
            RequestAjax(url,postData,function(){MsgBox(1, "<%=Tag("操作成功")%>", "?")});
        }
        function Write(User_Name) {
            var ids = GetChkCheckedValues("sid");
            if (User_Name !=""){
                var url_ = "message_write_window.aspx?User_Name="+User_Name+"&<%=su.URL %>";
            }else{
                var url_ = "message_write_window.aspx?ids="+ids+"&<%=su.URL %>";
            }
            $("#EditModal").modal("show");
            $.ajax({
                url: url_,
                type: "GET",
                cache: false,
                data: {},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function WriteSMS(User_Name) {
            var ids = GetChkCheckedValues("sid");
            if (User_Name !=""){
                var url_ = "sms_write_window.aspx?User_Name="+User_Name+"&<%=su.URL %>";
            }else{
                var url_ = "sms_write_window.aspx?ids="+ids+"&<%=su.URL %>";
            }
            $("#EditModal").modal("show");
            $.ajax({
                url: url_,
                type: "GET",
                cache: false,
                data: {},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function EditPassword(id) {
            $("#EditModal").modal("show");
            $.ajax({
                url: "userpassword_edit_window.aspx",
                type: "GET",
                cache: false,
                data: {id:id},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function EditMoney(User_Name) {
            var title_ = "<%=Tag("添加资金")%>";
            var ids = GetChkCheckedValues("sid");
            if (User_Name !=""){
                var url_ = "usermoney_edit_window.aspx?User_Name="+User_Name+"&<%=su.URL %>";
            }else{
                var url_ = "usermoney_edit_window.aspx?ids="+ids+"&<%=su.URL %>";
            }
            $("#EditModal").modal("show");
            $.ajax({
                url: url_,
                type: "GET",
                cache: false,
                data: {title:title_},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function EditPoint(User_Name) {
            var title_ = "<%=Tag("添加积分")%>";
            var ids = GetChkCheckedValues("sid");
            if (User_Name !=""){
                var url_ = "UserPoint_Edit_window.aspx?User_Name="+User_Name+"&<%=su.URL %>";
            }else{
                var url_ = "UserPoint_Edit_window.aspx?ids="+ids+"&<%=su.URL %>";
            }
            $("#EditModal").modal("show");
            $.ajax({
                url: url_,
                type: "GET",
                cache: false,
                data: {title:title_},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function SendCard(id,title_,User_Name) {
            var title_ = "<%=Tag("购物卡")%>";
            if (id ==312)
                var title_ = "<%=Tag("代金券")%>";
            var ids = GetChkCheckedValues("sid");
            if (User_Name !=""){
                var url_ = "usercard_edit_window.aspx?cardtype="+id+"&User_Name="+User_Name+"&<%=su.URL %>";
            }else{
                var url_ = "usercard_edit_window.aspx?cardtype="+id+"&ids="+ids+"&<%=su.URL %>";
            }
            $("#EditModal").modal("show");
            $.ajax({
                url: url_,
                type: "GET",
                cache: false,
                data: {title:title_},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function SearchWindow() {
            $("#EditModal").modal("show");
            $.ajax({
                url: "user_search_window.aspx?callback=search_&<%=su.URL %>",
                type: "GET",
                cache: false,
                data: {},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function Tags(id) {
            $("#EditModal").modal("show");
            $.ajax({
                url: "tags_update_window.aspx",
                type: "GET",
                cache: false,
                data: { id: id },
            }).done(function (result) {
                $("#EditModal .modal-content").html(result);
            });
        }
        <%if (Shop.LebiAPI.Service.Instanse.Check("plugin_usercsv")){  %>
        function Export(){
            var ids = GetChkCheckedValues("sid");
            if (ids == ""){
                MsgBox(2, "<%=Tag("请先选择")%>", "");
                return;
            }
            var title_ = "<%=Tag("批量导出")%>";
            $("#EditModal").modal("show");
            $.ajax({
                url: "<%=site.AdminPath %>/plugin/Lebi.UserCsv/export_window.aspx",
                type: "GET",
                cache: false,
                data: { ids: ids},
            }).done(function (result) {
                $("#EditModal .modal-content").html(result);
            });
        }
        <%} %>
    </script>
</lbscripts>