var m_SystemTagCache = [];                  //系统所有标签缓存
var m_NowSelectFriendTags = "";             //查询条件--当前选中的标签数据
var m_sendList = [];                        //群发列表(失效参数)
var m_isImg = 1;                        //文字 1，图片2
var m_imgName = "";
var m_imgMsgId = "";
var m_wechatIdList = "";// 客服拥有的微信列表
var m_wechatIdList1 = "";//群发记录
var m_sendgroup = [];//群发列表
var m_GroupSendRecord;//群发记录缓存
$(function () {
    //新建群发页面初始化数据 查询按钮绑定事件
    initData();
    //样式初始化
    massSendcss();
    $(function () { $("[data-toggle='tooltip']").tooltip(); });
});

function massSendcss() {

    //键盘抬起事件，判断文本框内容为空，是否显示清空按钮
    $("#txtQueryTagKey").keyup(function () {
        if ($("#txtQueryTagKey").val() == "") {
            $("#SearchTagByTremClose").hide();
        } else {
            $("#SearchTagByTremClose").show();
        }
    });
    //键盘按下事件，判断文本框内容为空，是否显示清空按钮
    $("#txtQueryTagKey").keydown(function () {
        if (event.keyCode == "13") {   //判断如果按下的是回车键则执行查询
            if ($.trim($("#txtQueryTagKey").val()) == "") {
                $("#SearchTagByTremClose").hide();
            } else {
                $("#SearchTagByTremClose").show();
            }
            BindTagTree();
        }
    });
    $(".left").css({
        height: $(window).height()
    });
    $(".right").css({
        height: $(window).height()
    });
    $(".friends-menu").css({
        height: $(window).height()
    });
    $(".tiplist").css({
        height: $(window).height() - 105
    });
    $(".friends-table").css({
        height: $(window).height() - 107
    });
    $(".infor-detailed-m").css({
        height: $(window).height() - 57
    });
    $(".level1>a").click(function () {
        $(this).toggleClass("current").next().toggle(300)
    })
    $(".talk-content").css({
        height: $(window).height() - 110
    });
    $("#DivFooter").css({
        width: $(window).width() - 243
    });
    $(".sendlist").css({
        height: $(window).height() - 120
    });
}

$(window).resize(function () {
    massSendcss();
});

//===============================================新建群发====================================start//
//新建群发页面初始化数据 查询按钮绑定事件
function initData() {
    //绑定对应权限下的微信号
    homeObj.getallwechatbyauth();
    //绑定本人管辖微信号列表
    homeObj.getwechatlist();
    //好友分组
    homeObj.getgroupval();
    //绑定标签
    homeObj.gettagtree();

    //键盘抬起事件，判断文本框内容为空，是否显示清空按钮
    $("#txtQueryTagKey").keyup(function () {
        if ($("#txtQueryTagKey").val() == "") {
            $("#SearchTagByTremClose").hide();
        } else {
            $("#SearchTagByTremClose").show();
        }
    });
}

//绑定本人管辖微信号列表回调（新建群发）
function AsyncGetWechatListResult(jsonResult) {
    if (jsonResult.success) {
        var objselectQueryWechat = $("#selectQueryWechat");
        objselectQueryWechat.empty();//清空
        objselectQueryWechat.append("<option value='' wid=''>全部微信号</option>");

        if (jsonResult.wechats.length > 0) {
            for (var i = 0; i < jsonResult.wechats.length; i++) {
                var item = jsonResult.wechats[i];
                if (null != item.uin && "" != item.uin) {
                    m_wechatIdList += (item.uin + ",");
                    var sendjson = {
                        uin: item.uin,
                        friends: []
                    };
                    m_sendgroup.push(sendjson);
                    //微信是否有备注
                    var content = $.trim(item.remark) != "" ? "(" + item.remark + ")" : "";
                    objselectQueryWechat.append("<option value='" + item.uin + "' wid='" + item.wid + "'>" + item.nickname + content + "</option>");
                }
            }
        } else {
            $("#emptyTips").html("您还没有登录微信");
        }
    } else {
        ShowError("myPageAlert", "获取数据异常：" + jsonResult.error);
    }

    $(".loadingcover").hide();
    $(".loading").hide();
    $("#divNoData").show();
}

//绑定对应权限下的微信号（群发记录）
function AsyncGetAllWechatByAuthResult(jsonResult) {
    if (jsonResult.success) {
        var objselectQueryWechat = $("#selectQueryWechat1");
        objselectQueryWechat.empty();//清空
        objselectQueryWechat.append("<option value='' wid=''>全部微信号</option>");

        if (jsonResult.wechats.length > 0) {
            for (var i = 0; i < jsonResult.wechats.length; i++) {
                var item = jsonResult.wechats[i];
                if (null != item.uin && "" != item.uin) {
                    m_wechatIdList1 += (item.uin + ",");
                    var count = $.trim(item.remark) == "" ? "" : "(" + item.remark + ")";
                    objselectQueryWechat.append("<option value='" + item.uin + "' wid='" + item.wid + "'>" + item.nickname + count + "</option>");
                }
            }
            m_wechatIdList1 = m_wechatIdList1.substring(0, m_wechatIdList1.length - 1);
        } else {
            $("#emptyTips").html("您还没有登录微信");
        }
    } else {
        ShowError("myPageAlert", "获取数据异常：" + jsonResult.error);
    }

    $(".loadingcover").hide();
    $(".loading").hide();
    $("#divNoData").show();
}

// 群发->好友分组绑定
function AsyncGetGroupValResult(jsonResult) {
    if (jsonResult.success) {
        if (jsonResult.wechats.length > 0) {
            var paraitem = jsonResult.wechats;
            for (var i = 0; i < paraitem.length; i++) {
                if (paraitem[i].key == "friendgroup") {
                    var groupitem = $.parseJSON(paraitem[i].valus);
                }
            }
            var colorsitem = "";
            if (paraitem.length == "2") {
                for (var j = 0; j < paraitem.length; j++) {
                    if (paraitem[j].key == "friendgroupcolor") {
                        colorsitem = $.parseJSON(jsonResult.wechats[j].color);
                    }
                }
            }
            var strallgroup = "";
            var strallhisgroup = "";
            strallhisgroup += "<li onclick=\"SelecthisGroup('好友分组','')\"><a href=\"#\"><span class=\"fgroup-color\"></span>好友分组</a></li>";
            for (var i = 0; i < groupitem.length; i++) {
                var itemcolor = "";
                if (colorsitem.length > 0) {
                    itemcolor = colorsitem[i];
                }
                strallhisgroup += "<li onclick=\"SelecthisGroup('" + groupitem[i] + "','" + itemcolor + "')\"><a href=\"#\"><span class=\"fgroup-color\" style=\"background:" + itemcolor + ";\"></span>" + groupitem[i] + "</a></li>";
            }
            $("#MassGroup").html(strallhisgroup);
        }
    }
}
//选择好友分组时
function SelecthisGroup(groupname, groupcolor) {
    $("#selectReport").html(groupname);
    if (groupcolor.length > 1) {
        //选择有颜色的分组
        $("#selectReport").css("border-left", "5px solid " + groupcolor + "");
    } else {
        //选择默认好友分组无颜色
        $("#selectReport").css("border-left", "");
    }
}
//---------------------------标签--------------------------start//
function AsyncGetTagTreeResult(jsonResult) {
    if (jsonResult.success) {
        m_SystemTagCache = jsonResult.list;
        BindTagTree(jsonResult);
    }
}
//绑定左侧标签树
function BindTagTree() {
    $("#txtQueryTagKey").val($.trim($("#txtQueryTagKey").val()));
    var strQueryKey = $("#txtQueryTagKey").val();

    var strTreeContent = "<ul class=\"tiplist\">";//树型菜单内容
    for (var i = 0; i < m_SystemTagCache.length; i++) {
        var jsonItem = m_SystemTagCache[i];
        var strGroupId = jsonItem.tgid;
        var nGroupType = Number(jsonItem.type);
        var strTagType = nGroupType == 1 ? "【互斥】" : "";

        var bIsQuery = false;
        var strTreeGroupHtml = "";
        strTreeGroupHtml += "<li class=\"level1\">";
        //父级标签组
        strTreeGroupHtml += "<a href=\"#\" class=\"current\"><span>" + jsonItem.tgname + strTagType + "</span></a>";
        strTreeGroupHtml += "<ul class=\"level2\" style=\"display: block;\">";
        for (var j = 0; j < jsonItem.tag.length; j++) {
            var tagItem = jsonItem.tag[j];
            if (strQueryKey.length == 0 || tagItem.tname.indexOf(strQueryKey) >= 0) {
                bIsQuery = true;
                strTreeGroupHtml += "<li id=\"liTag_" + tagItem.tid + "\" class=\"taggroup" + strGroupId + "\" onclick=\"ChangeFansTags('" + tagItem.tid + "','" + nGroupType + "','" + strGroupId + "');\"><span style=\"background:" + tagItem.color + ";\"></span><a href=\"#\"><span>" + tagItem.tname + "</span></a></li>";
            }
        }
        strTreeGroupHtml += "</ul>";
        strTreeGroupHtml += "</li>";

        if (bIsQuery) {
            strTreeContent += strTreeGroupHtml;
        }
    }
    strTreeContent += "</ul>";
    $("#divFriendSelectTag").html(strTreeContent);

    massSendcss();
}

//判断标签是否存在
function TagIsExists(tid) {
    var strContent = "|" + tid + "|";
    return m_NowSelectFriendTags.indexOf(strContent) >= 0;
}

//选中、释放标签
function ChangeFansTags(tid, ishc, groupid) {
    var objLiClickTag = $("#liTag_" + tid);
    if (objLiClickTag.hasClass("active")) {
        //删除标签操作
        $("#liTag_" + tid).removeClass("active");
        m_NowSelectFriendTags = SuperReplace(m_NowSelectFriendTags, "|" + tid + "|", "|");
        m_NowSelectFriendTags = SuperReplace(m_NowSelectFriendTags, "||", "|");
    } else {
        //选择标签操作
        if (ishc == "1") {
            $(".taggroup" + groupid).removeClass("active");
            //移除此互斥标签组内所有标签
            for (var i = 0; i < m_SystemTagCache.length; i++) {
                if (m_SystemTagCache[i].tgid == groupid) {
                    //移除组内所有标签
                    for (var j = 0; j < m_SystemTagCache[i].tag.length; j++) {
                        m_NowSelectFriendTags = SuperReplace(m_NowSelectFriendTags, "|" + m_SystemTagCache[i].tag[j].tid + "|", "|");
                    }
                    break;
                }
            }
        }
        $("#liTag_" + tid).addClass("active");
        if (!TagIsExists(tid)) {
            m_NowSelectFriendTags += "|" + tid + "|";
            m_NowSelectFriendTags = SuperReplace(m_NowSelectFriendTags, "||", "|");
        }
    }
    if (m_NowSelectFriendTags == "|")
        m_NowSelectFriendTags = "";

    getSendList();
}
//点击清空按钮时清空内容和隐藏按钮
function ClearQueryTagKey() {
    $("#txtQueryTagKey").val("");
    $("#SearchTagByTremClose").hide();
}
//---------------------------标签--------------------------end//
//获取群发成员列表
function getSendList() {
    $(".loading").show();
    $(".loadingcover").show();
    $("#ulSendlist").empty();
    m_sendList = [];
    for (var j in m_sendgroup) {
        var sendItem = m_sendgroup[j];
        sendItem.friends = [];
    }
    var uin = $("#selectQueryWechat").val();
    if (uin == null || uin == "") {
        if (m_wechatIdList.length > 0) {
            uin = m_wechatIdList.substring(0, m_wechatIdList.length - 1);
        }
    }
    var selectReport = $("#selectReport").html() == "好友分组" ? "" : $("#selectReport").html();
    if (null != uin && "" != uin) {
        var strJson = $.toJSON({
            //wechatkey: $("#selectQueryWechat").find("option:selected").attr("wid"),
            uin: uin,
            group: selectReport,
            sex: $("#selectQueryGender").val(),
            point: $.trim($("#txtQueryPostion").val()),
            remarkname: $.trim($("#txtSendGroupRemark").val()),
            frompid: $.trim($("#txtQueryfrientID").val()),
            topid: $.trim($("#txtQueryfrientMinID").val()),
            tags: m_NowSelectFriendTags,
        });

        homeObj.getfriendsbycondition(strJson);
    } else {
        ShowMsg("myPageAlert", "请您选择要群发的微信号！");
        $("#divNoData").show();
        $("#btnSend").attr("disabled", true);
        $(".loadingcover").hide();
        $(".loading").hide();
    }
}

function AsyncGetFriendsByConditionResult(jsonResult) {
    if (jsonResult.success) {
        $("#divNoData").hide();
        var list = jsonResult.result.list;
        if (list.length > 0) {
            $("#btnSend").attr("disabled", false);
            for (var i in list) {
                var item = list[i];
                var displayname = item.nickname.length > 8 ? item.nickname.substr(0, 8) + ".." : item.nickname;
                //<img src="' + item.headimgurl + '" width="30" onerror="nofind()"/>
                //data-rel=\"popover\" data-trigger=\"hover\" data-placement=\"top\" data-content=\"" + hovercontent + "\"
                var domItemStr = '\
                    <li data-rel="popover" data-trigger="hover"data-placement="top" data-content="' + item.nickname + '" id="' + item.pid + '">\
                        <span style="cursor: pointer;">' + item.pid + "-" + displayname + '</span>\
                        <i class="fa fa-close" onclick="ShowDelete(\'' + item.pid + '\',\'' + item.nickname + '\')"></i>\
                    </li>';
                var domItem = $(domItemStr);
                $("#ulSendlist").prepend(domItem);

                for (var j in m_sendgroup) {
                    var sendItem = m_sendgroup[j];
                    if (sendItem.uin == item.uin) {
                        var jsonUser = {
                            pid: item.pid,
                            username: item.username
                        };
                        sendItem.friends.push(jsonUser);
                    }
                }
            }
        } else {
            $("#emptyTips").html("没有数据");
            $("#btnSend").attr("disabled", true);
        }
    } else {
        if (jsonResult.error.indexOf("no find wechat") > -1) {
            ShowError("myPageAlert", "请先登录客服微信。");
        } else {
            ShowError("myPageAlert", "获取数据异常：" + jsonResult.error);
        }
    }
    $('#ulSendlist li[data-rel=popover]').popover();
    $(".loadingcover").hide();
    $(".loading").hide();
}

//删除
function ShowDelete(domid, nikename) {
    //$("#hidPublicAppId").val(domid);
    //$("#spDeletePublicName").html(nikename);
    //$("#DeleteModal").modal("show");

    //从缓存中删除

    for (var i in m_sendgroup) {
        var key = "";
        for (var j in m_sendgroup[i].friends) {
            var sendgroupitem = m_sendgroup[i].friends[j];
            var value = sendgroupitem.pid;
            if (value == domid) {
                key = j;
                break;
            }
        }
        if (key != "") {
            m_sendgroup[i].friends.splice(parseInt(key), 1);
        }
    }
    $("#" + domid).remove();
    $(".popover.fade.top.in").remove();
    if ($("#ulSendlist").children('li').length <= 0) {
        $("#divNoData").show();
        $("#btnSend").attr("disabled", true);
    }
}

//弹出群发模态框
function creatAndSend() {
    if (!homeObj.getbisformalcus())
    {
        ShowError("myPageAlert", "试用用户暂时不允许群发！");
        return;
    }
    if ($("#ulSendlist").children('li').length > 5000) {
        ShowError("myPageAlert", "最多只能群发5000个好友！");
    } else {
        $("#SendModal").modal("show");
        $("#sendCount").html($("#ulSendlist").children('li').length);
    }
}

//群发发送方法
function startSend() {
    if ($("#sendName").val() == "") {
        ShowError("myPageAlert", "请填写群发名称！");
        return;
    }
    var content = "";
    if (m_isImg == 1) {
        if ($("#sendContent").val() == "") {
            ShowError("myPageAlert", "请填写群发内容！");
            return;
        }
        content = $("#sendContent").val().replace(/"/gm, '').replace(/'/gm, '');
        masssend(content);
    } else {
        SendfileMsg();
    }
}

// 发送
function masssend(content) {
    var strParaJson = $.toJSON({
        gname: $("#sendName").val(),
        content: content,
        interval: $("#selInterval").val(),
        friends: JSON.stringify(m_sendList),
        type: m_isImg,
        msgid: m_imgMsgId,
        sendgroup: m_sendgroup
    });
    homeObj.groupsendmsg(strParaJson);
    $(".loading").show();
    $(".loadingcover").show();
}

function AsyncGroupSendMsgResult(jsonResult) {
    if (jsonResult.success) {
        ShowMsg("myPageAlert", "发送成功！");
        $("#sendName").val('');
        $("#sendContent").val('');
        $("#selInterval")[0].selectedIndex = 1;
    } else {
        if (jsonResult.error.indexOf("busy") > -1) {
            ShowError("myPageAlert", "发送失败：" + "系统繁忙，正在处理上次群发！");
        } else if (jsonResult.error == "no content") {
            ShowError("myPageAlert", "发送失败：" + "发送内容为空，内容可能被关键词过滤！");
        } else {
            ShowError("myPageAlert", "发送失败：" + jsonResult.error);
        }
    }
    $("#SendModal").modal("hide");
    $(".loadingcover").hide();
    $(".loading").hide();
}
//===============================================新建群发====================================end//
function showNewSend() {
    $("#DivFooter").hide();
}
function showRules() {
    $("#DivFooter").hide();
}
//=========================================查询群发历史记录=================================start//
function showSendHistory() {
    $("#DivFooter").show();
    BindData();
}

function qunfa() {
    nPageIndex = 0;
    nPageSize = 10;
    nPageCount = 0;
    $("#DivFooter").empty();
    BindData();
}
function BindData() {
    var uin = $("#selectQueryWechat1").val();
    if (uin == "") {
        uin = m_wechatIdList1;
    }
    $(".loading").show();
    $(".loadingcover").show();
    $("#tbHistoryData").empty();
    var strParaJson = $.toJSON({
        uin: uin,
        gname: $("#txtQuerySendName").val(),
        pageindex: nPageIndex,
        pagesize: nPageSize
    });
    homeObj.getgroupsendlist(strParaJson);
}

function AsyncGetGroupSendListResult(jsonResult) {
    if (jsonResult.success) {
        m_GroupSendRecord = jsonResult;
        if (jsonResult.result.list.length > 0) {
            nPageCount = Math.ceil(Number(jsonResult.result.total) / nPageSize);
            var title = '\
            <tr>\
                <th>序号</th>\
                <th>群发名称</th>\
                <th>群发内容</th>\
                <th>所属人员(微信号)</th>\
                <th>当前状态</th>\
                <th>开始时间</th>\
                <th>结束时间</th>\
                <th>发送人数</th>\
                <th>已处理</th>\
                <th>失败</th>\
				<th>操作</th>\
            </tr>';
            $("#tbHistoryData").append(title);
            for (var index in jsonResult.result.list) {
                var item = jsonResult.result.list[index];
                var statrstr = "";
                switch (Number(item.state)) {
                    case 0:
                        statrstr = "准备发送";
                        break;
                    case 1:
                        statrstr = "正在发送";
                        break;
                    case 2:
                        statrstr = "发送完成";
                        break;
                    case 3:
                        statrstr = "停止发送";
                        break;
                    case 4:
                        statrstr = "取消发送";
                        break;
                }
                var content = item.content;
                if (item.content.length > 20) {
                    content = item.content.substr(0, 20) + "...";
                }
                var strErrorRecord = "";
                if (item.errorlist.length > 2) {
                    var strErrorRecord = "<a style=\"color:#09bb07;cursor:pointer;\" onclick=\"FailDetailed('" + index + "')\">详细</a>";
                }

                var Name = (item.cusname + '(' + item.nickname + ')').length > 18 ? (item.cusname + '(' + item.nickname + ')').substring(0, 17) + ".." : item.cusname + '(' + item.nickname + ')';
                var itemDom = '\
                <tr>\
                    <td>'+ (Number(index) + 1) + '</td>\
                    <td>' + item.gname + '</td>\
                    <td>' + content + '</td>\
                    <td>' + Name + '</td>\
                    <td>' + statrstr + '&nbsp;&nbsp;&nbsp;&nbsp;'
                    + (item.state == "1" ? "<button id=\"btnStartSend\" type=\"button\" onclick=\"cancelSend('" + item.uin + "','" + item.gid + "')\">取消</button>" : "")
                    + '</td>\
                    <td>' + item.starttime + '</td>\
                    <td>' + item.endtime + '</td>\
                    <td>' + item.sendcount + '</td>\
                    <td>' + item.okcount + '</td>\
                    <td>' + item.errorcount + '</td>\
					<td>' + strErrorRecord + '</td>\
                </tr>';
                $("#tbHistoryData").append(itemDom);
            }

            $("#DivFooter").html(GetPageFootStr(nPageIndex, jsonResult.result.total));
            $("#DivFooter").show();
        }
    } else {
        ShowError("myPageAlert", "获取数据异常：" + jsonResult.error);
    }
    $(".loadingcover").hide();
    $(".loading").hide();
}

function cancelSend(uin, id) {
    $(".loading").show();
    $(".loadingcover").show();
    var strParaJson = $.toJSON({
        uin: uin,
        groupsendid: id
    });
    homeObj.canclegroupsned(strParaJson);
}

function AsyncCancleGroupSnedResult(jsonResult) {
    if (jsonResult.success) {
        ShowMsg("myPageAlert", "取消成功！");
        BindData();
    } else {
        if (jsonResult.error.indexOf("no send") > -1) {
            ShowError("myPageAlert", "没有正在进行的群发！");
        } else {
            ShowError("myPageAlert", "取消失败：" + jsonResult.error);
        }
    }
    $(".loadingcover").hide();
    $(".loading").hide();
}

//选择发送图片消息
function SelectImageMsg() {
    $("#HidUploadContentLength").val("");
    var strLocalImgUrlJson = $.parseJSON(homeObj.selectpicmsgfile());

    if (strLocalImgUrlJson[3].length > 0) {
        ShowError("myPageAlert", strLocalImgUrlJson[3]);
        return;
    }
    var strImagePath = strLocalImgUrlJson[0];
    if (strImagePath.length > 0) {
        m_imgName = strImagePath;
        $("#imgSendImageMsg").attr("src", strImagePath);
        $("#HidUploadContentLength").val(strLocalImgUrlJson[2]);
        $("#imgSendImageMsg").show();
    }
}
//发送文件(上传到服务端)
function SendfileMsg() {
    var uin = $("#selectQueryWechat").val();
    if (m_imgName.length == 0) {
        if ($("#sendContent").val() == "") {
            ShowError("myPageAlert", "请选择群发图片！");
            return;
        }
    }
    var strParaJson = $.toJSON({
        uin: uin,
        file: m_imgName
    });
    homeObj.sendimgmessage(strParaJson);
}

//文件上传到服务端回调
function AsyncSendImgMessageResult(jsonResult) {
    if (jsonResult.success) {
        //发送消息
        if ($("#divMsg" + jsonResult.msgid).length > 0) {
            $("#divMsg" + jsonResult.msgid).remove();
        }
        m_imgMsgId = jsonResult.msgid;
        var nameArr = jsonResult.filename.split("\\");
        masssend(nameArr[nameArr.length - 1]);
    } else {
        ShowError("myPageAlert", "发送文件信息异常：" + jsonResult.error);
    }
}

//区分选择的发送文本还是图片
function selContentType(isimg) {
    m_isImg = isimg;
    $("#selInterval").empty();
    if (isimg == 1) {
        $("#selInterval").html('\
            <option value="5">5秒</option>\
            <option selected value="10">10秒</option>\
            <option value="20">20秒</option>\
            <option value="30">30秒</option>\
            <option value="40">40秒</option>\
            <option value="50">50秒</option>\
            <option value="60">60秒</option>\
         ');
    } else {
        $("#selInterval").html('\
            <option value="5">5秒</option>\
            <option selected value="10">10秒</option>\
            <option value="20">20秒</option>\
            <option value="30">30秒</option>\
            <option value="40">40秒</option>\
            <option value="50">50秒</option>\
            <option value="60">60秒</option>\
         ');
    }
}
//重置按钮清空所有文本框等值
function replacement() {
    $("#ulSendlist").empty();
    $("#btnSend").attr("disabled", true);
    $("#divNoData").show();
    $("#selectReport").html("好友分组");
    $("#selectReport").css("border-left", "");
    $("#selectQueryGender").val("");
    $("#txtQueryPostion").val("");
    $("#txtSendGroupRemark").val("");
    $("#txtQueryfrientID").val("");
    $("#txtQueryfrientMinID").val("")
}

//=========================================查询群发历史记录=================================end//

//群发记录查看失败详细
function FailDetailed(index) {
    var strContent = "";
    var itemSelectRecord = m_GroupSendRecord.result.list[index];
    var strErrorList = itemSelectRecord["errorlist"];
    if (strErrorList.length < 0) {
        return;
    }
    var strErrorItem = "";
    if (strErrorList.indexOf(",") != -1) {
        strErrorItem = strErrorList.replace('[', '').replace(']', '').split(",");
        for (var i = 0; i < strErrorItem.length; i++) {
            var stritem = strErrorItem[i].replace('"', '').replace('"', '')
            var SingleItem = stritem.split("|");
            var strError = "";
            var strremarkname = SingleItem[3] == '"' ? "" : SingleItem[3];
            strError = SingleItem[0] == 1 ? "加入黑名单" : "删除好友";
            strContent += "<tr>";
            strContent += "<td>" + (i + 1) + "</td>";
            strContent += "<td>" + SingleItem[1] + "</td>";
            strContent += "<td>" + SingleItem[2] + "</td>";
            strContent += "<td>" + strremarkname + "</td>";
            strContent += "<td>" + strError + "</td>";
            strContent += "</tr>";
        }
    } else {
        if (strErrorList.indexOf("|") != -1) {
            strErrorItem = strErrorList.replace('[', '').replace(']', '').replace('"', '');
            var SingleItem = strErrorItem.split("|");
            var strError = "";
            var strremarkname = SingleItem[3] == '"' ? "" : SingleItem[3];
            strremarkname = strremarkname.replace('"', '');
            strError = SingleItem[0] == 1 ? "加入黑名单" : "删除好友";
            strContent += "<tr>";
            strContent += "<td>" + (1) + "</td>";
            strContent += "<td>" + SingleItem[1] + "</td>";
            strContent += "<td>" + SingleItem[2] + "</td>";
            strContent += "<td>" + strremarkname + "</td>";
            strContent += "<td>" + strError + "</td>";
            strContent += "</tr>";
        }
    }

    $("#tbSendGroupError").html(strContent);
    $("#modgroupsendError").modal("show");
}