<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Custom_List.aspx.cs" Inherits="RM.Web.WeiXin.Custom_List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Src="~/UserControl/PageControl.ascx" TagName="PageControl" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_Title")%></title>
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="../Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <link href="../Training/Exam/Themes/Css/ExamGlobal.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        #handleIcon { display: none; background: url("../Images/loading.gif") no-repeat scroll 7px 2px #FFFFFF; left: 45%; padding: 6px 5px 6px 40px; position: absolute; top: 45%; z-index: 3000; }
        .answerBar { display: none; position: absolute; }
        .tipArrow { position: relative; width: 20px; z-index: 0; left: 400px; bottom: 162px; }
        .tipArrow * { display: block; font-family: "SimSun"; font-size: 16px; height: 16px; line-height: 1.231; overflow: hidden; font-style: normal; }
        .ar_boderLine { color: #CCC; }
        .ar_bg { margin: -15px 0 0 0 !important; color: #FFF !important; }
        /*配置微信开发者平台账户信息*/
        .div-body * { line-height: normal; }
        .menuLoginWeixin, .answerBar { color: #666; font: 14px/24px "Microsoft YaHei"; font-size: 14px; }
        #hiddenMask { overflow: hidden; height: 300px; position: absolute; width: 100%; display: none; z-index: 10; }
        #masking { display: none; opacity: 0.2; position: absolute; width: 100%; height: 100%; z-index: 8; background-color: Black; }
        .loginWeixinContainer { width: 250px; }
        .text-rightLi { text-align: right; }
        .menuLoginWeixin { text-align: left; padding: 10px 50px; background-color: #b2f494; position: relative; top: -164px; display: none; }
        .menuLoginTitle { font-weight: bold; }
        .oprater_link { padding: 5px 12px; margin: 0 5px; font-size: 9pt; background: url('/Themes/Images/buttons.png') no-repeat 0px -0px; transition: none !important; color: White !important; border-radius: 3px; background-position: 0px -250px; }
        .oprater_link:hover { text-decoration: underline; background-position: 0 -200px; }
        input { width: 155px; height: 23px; line-height: 25px; border: 1px solid #CCC; font-family: "Microsoft YaHei"; color: #666; padding: 0 3px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset; transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s; }
        input:focus { border-color: rgba(82, 168, 236, 0.8); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(82, 168, 236, 0.6); }
        .loginWeixinContainer li, .loginPrompt li, .hcf_Congainer li { line-height: 30px; }
        .loginWeixinContainer, .loginPrompt { display: inline-block; vertical-align: top; }
        .loginPrompt { padding-left: 30px; }
        .keywords { color: #fd5b78; padding: 0 2px; }
        .inputPromptTxt { display: inline-block; vertical-align: middle; width: 85px; text-align: right; }
        #masking { display: none; opacity: 0.2; position: absolute; width: 100%; height: 100%; z-index: 8; background-color: Black; }
        #glob_EditBar { display: none; }
    </style>
</head>
<body>
    <div id="masking">
    </div>
    <div id="glob_EditBar">
        <ul>
            <li style="text-align: center; color: #666;" id="isLoadTxt"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_syesxsngnfgdxxdygdjs")%></li>
            <li>
                <textarea id="glob_Edit" class="textarea_Txt glob_Tarea" style="border: 1px solid #CCC;
                    font-family: 'Microsoft YaHei'; color: Black; padding: 0 3px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
                    transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s; width: 500px; padding: 5px;"></textarea></li>
            <li style="text-align: right; color: #666;"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_hkysr")%><span style="font-weight: bold;
                font-size: 10pt; padding: 0 3px;" id="glob_PromptTxt">150</span><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_font")%></li>
        </ul>
    </div>
    <div id="hiddenMask">
        <div id="menuLogin" class="menuLoginWeixin">
            <h3 class="menuLoginTitle">
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_qnpzwxgzptkfzzhxx")%></h3>
            <ul class="loginWeixinContainer">
                <li><span class="inputPromptTxt">AppId：</span><input id="menuLogin_AppId" type="text"
                    value="wx603b65d01e212f96" /></li>
                <li><span class="inputPromptTxt">AppSecret：</span><input id="menuLogin_AppSecret"
                    type="text" value="2415eab5dd449c13383db1c9c8dd7505" />
                </li>
                <li class="text-rightLi"><a id="menuLogin_Submit" href="javascript:;" class="oprater_link">
                   <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_bcdfwq")%></a> </li>
            </ul>
            <ul class="loginPrompt">
                <li>1、<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_xycw")%><span class="keywords"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_fwh")%></span>，<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_dwxht")%><span class="keywords"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_gjgn")%></span>&gt;<span
                    class="keywords"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_kfms")%></span><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_xlhqxx")%></li>
                <li>2、<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_dycpzzhhmwxzcdl")%></li>
            </ul>
        </div>
    </div>
    <form id="form1" runat="server">
    <div class="btnbartitle">
        <div>
            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_Title")%>
        </div>
    </div>
    <div class="btnbarcontetn">
        <div style="text-align: right;">
            <a class="button green" id="getUserData" href="javascript:;" title="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_mrxtbhqyhsj")%>">
                <span class="icon-botton" style="background: url('/Themes/images/16/email_go.png') no-repeat scroll 0px 4px;">
                </span><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_gxyhsj")%></a> <a class="button green" id="speedyAnswer" href="javascript:;" title="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_ksplhfsyesxndxx")%>">
                    <span class="icon-botton" style="background: url('/Themes/images/16/email_go.png') no-repeat scroll 0px 4px;">
                    </span><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_ksplhf")%></a>
        </div>
    </div>
    <div class="div-body">
        <%=pageHtml.ToString() %>
    </div>
    <uc1:PageControl ID="PageControl1" runat="server" />
    </form>
    <div class="answerBar" id="answerBar">
        <div contenteditable="true" id="editor" spellcheck="false" class="input_Editor">
        </div>
        <div class="input_OpraterBar">
            <span class="input_EditTxtPop"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_hkysr")%><span class="input_EditTxtCount" id="editPrompt">150</span><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_font")%></span>
            <a href="javascript:;" class="input_EditOk" id="editOK" key="<%=token %>" title="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_font")%>">
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_fs")%></a>
        </div>
        <div class="tipArrow">
            <em class="ar_boderLine">◆</em> <span class="ar_bg">◆</span></div>
    </div>
    <div id="handleIcon">
         <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_loading")%></div>
</body>
<script type="text/javascript">
    $(function () {
        //阻止事件冒泡
        function stopBubble(e) {
            if (e && e.stopPropagation)
                e.stopPropagation();
            else
                window.event.cancelBubble = true;
        }
        divresize(90);
        var currStateObj; //当前正在操作的行对象
        $('.toAnswer').click(function (e) {
            stopBubble(e);
            var currObj = $(this);
            var thisOffset = $(this).offset();
            var asBarWidth = $("#answerBar").width();
            $("#answerBar").css({ left: thisOffset.left - asBarWidth + currObj.width() + 10, top: thisOffset.top + currObj.height() + 7 }).stop().fadeIn(300, function () {
                $('#editOK').attr('data', currObj.attr('data'));
                document.getElementById('editor').focus();
                currStateObj = $(currObj).closest('tr'); //把当前对象保存
            });
            $(window).one('click', function () {
                $("#answerBar").stop().fadeOut(300);
            });
        });
        var hiddenMask = $('#hiddenMask');
        //检测是否有token
        if (!$('#editOK').attr('key')) {//没有关于微信app配置信息
            hiddenMask.css('display', 'block');
            $("#menuLogin").css('display', 'block').stop().animate({ top: 0 }, 500);
            $('#masking').css('display', 'block');
            $('#menuLogin_Submit').click(function () {
                //发送POST请求，数据也是json格式。但数值部分需要转换为字符串
                $.post("/WeiXin/SetMenu.ashx",
                { dotype: "GetToken", appId: $('#menuLogin_AppId').val(), appSecret: $('#menuLogin_AppSecret').val() },
                 function (result) {
                     $("#menuLogin").stop().animate({ top: -93 }, 500, function () {
                         hiddenMask.css('display', 'none');
                         $(this).css('display', 'none');
                         $('#masking').css('display', 'none');
                     });
                     $('#editOK').attr('key', result);
                 });
            });
        }

        //文本框提示
        $("#editor").keyup(function (e) {
            var e = e || window.event; //获取事件对象
            var key = e.keyCode || e.which || e.charCode; //获取键盘码
            var length = 0;
            var dataHtml = $(this).html() == "" ? "" : jQuery.trim($(this).html().replace(/<[^>].*?>/g, "").replace(/&nbsp;/g, ""));
            if (dataHtml.length > 0) {
                length = dataHtml.length;
            }
            $("#editPrompt").text(150 - length);
            if (key == 13 && e.ctrlKey) {
                $("#editOK").click();
            }
        });

        //确定发送事件
        $("#editOK").click(function () {
            var clickObj = $(this);
            var sourHtml = $("#editor").html();
            var dataHtml = sourHtml == "" ? "" : jQuery.trim(sourHtml.replace(/<[^>].*?>/g, "").replace(/&nbsp;/g, ""));
            if (dataHtml.length < 1) {
                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Ques_textValNull")%>', 2000, 3);
                return false;
            } else if (dataHtml.length > 150) {
                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("AnswerInfomation_hfnrbyxcg")%>', 2000, 3);
                return false;
            } else if (!clickObj.attr('data') || clickObj.attr('data') == '' || !clickObj.attr('key') || clickObj.attr('key') == '') {
                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("QuesNaire_WebFormatErr")%>', 2000, 3);
                return false;
            }
            $.ajax({
                url: "/WeiXin/AnswerInfomation.ashx",
                type: "post",
                data: { "dI": clickObj.attr('data'), "tK": clickObj.attr('key'), "aS": dataHtml },
                dataType: "text",
                success: function (data) {
                    if (data == 0) {
                        showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Int_hfsucc")%>', 2000, 4);
                        currStateObj.find('.isAnswerState').html("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("S")%>");
                        $("#editor").html('');
                    } else//清空数据
                    {
                        showTipsMsg(data, 4000, 5);
                    }
                },
                error: function () {
                    showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("File_Exam")%>', 2000, 3);
                }
            });
        });
        $(".getHistory").click(function () {
            var key = $(this).attr('data');
            var url = "/WeiXin/HistoryData.aspx?Key=" + key;
            top.openDialog(url, 'HistoryData', '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet_ulist")%> - <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_xxjh")%>', 382, 540, 50, 50);
        });
        $("#answerBar").click(function (e) {
            stopBubble(e);
        });
        //批量快速回复
        var glob_PromptTxt = $("#glob_PromptTxt"); //批量回复提示输入文字
        var glob_Edit = $("#glob_Edit"); //批量回复框
        var glob_isLoadTxt = $("#isLoadTxt"); //批量回复当前状态文字
        $("#glob_Edit").keyup(function () {
            if (jQuery.trim($(this).val()).length < 1) {
                return;
            }
            glob_PromptTxt.text(150 - (jQuery.trim($(this).val()).length));
        });
        //获取用户数据
        $("#getUserData").click(function () {
            $.ajax({
                url: "/WeiXin/CreateWeiXinUserInfo.ashx",
                type: "post",
                dataType: "text",
                success: function (data) {
                    if (data == 1) {
                        top.showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("True")%>', 2000, 4);
                        Loading(true);
                        window.location.reload();
                    } else if (data == 0) {
                        top.showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_hqyhsjycqjcndwl")%>', 4000, 5);
                    } else
                        top.showTipsMsg(data, 4000, 5);
                },
                error: function () {
                    top.showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("File_Exam")%>', 2000, 3);
                }
            });
        });
        var isload = false; //表示当前是否正在异步加载
        //快速回复
        $("#speedyAnswer").click(function () {
            top.art.dialog({
                id: 'art_speedyAnswer',
                title: '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("File_Exam")%> - <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_kshfesxsnhnjhgdyh")%>',
                content: document.getElementById('glob_EditBar'),
                button: [{
                    name: '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("OK")%>',
                    callback: function () {
                        if (isload) return false;
                        var glob_EditContext = jQuery.trim(glob_Edit.val());
                        if (glob_EditContext.length < 1) {
                            top.showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Mall_incontent")%>', 1500, 3);
                            return false;
                        }
                        else if (glob_EditContext.length > 150) {
                            top.showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("AnswerInfomation_hfnrbyxcg")%>', 1500, 3);
                            return false;
                        }
                        isload = true;
                        glob_isLoadTxt.css('color', '#04b700').text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_loading")%>...');
                        //验证通过
                        $.ajax({
                            url: "/WeiXin/SpeedyAnswerInfomation.ashx",
                            type: "post",
                            data: { "aC": glob_EditContext },
                            dataType: "json",
                            success: function (data) {
                                isload = false;
                                glob_isLoadTxt.css('color', '#666').text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_syesxsngnfgxxdyhdjsdbxx")%>');
                                if (data) {
                                    if (data.dataError || data.errorDataBase) {
                                        if (data.dataError > 0 || data.errorDataBase > 0) {
                                            top.showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_kshfczyc")%>：" + (data.dataError ? data.dataError : 0) + "<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_twxsjfssb")%>，" + (data.errorDataBase ? data.errorDataBase : 0) + "<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_tsjgxdsjksb")%>", 4000, 3);
                                            return false;
                                        }
                                        top.showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Int_hfsucc")%>", 2000, 4);
                                        glob_Edit.val('');
                                    } else {
                                        top.showTipsMsg(data, 2000, 5);
                                    }
                                } else
                                    top.showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("File_Exam")%>', 2000, 3);
                            },
                            error: function () {
                                isload = false;
                                glob_isLoadTxt.css('color', '#666').text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Custom_List_syesxsngnfgxxdyhdjsdbxx")%>');
                                top.showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("File_Exam")%>', 2000, 3);
                            }
                        });
                        return false;
                    },
                    focus: true
                },
                {
                    name: '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Close")%>',
                    callback: function () {
                        return true;
                    }
                }]
            });
        });
    });
</script>
</html>
