<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PushWeixin.aspx.cs" Inherits="Web.User.PushWeixin" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <title>推送至微信公众号</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!--#include file="../Css/head.htm"-->
    <!--#include file = "../Css/userCssEdit.htm" -->
    <style>
        .nsy-wechatmsg-wrap {
            float: left;
            width: 300px;
            height: 511px;
        }

            .nsy-wechatmsg-wrap + div {
                margin-left: 300px;
            }

        .nsy-wechatmsg-item {
            position: relative;
            padding: 10px;
            border: 1px solid #d5d5d5;
            margin-top: -1px;
            cursor: pointer;
        }

            .nsy-wechatmsg-item > .first {
                height: 125px;
            }

            .nsy-wechatmsg-item > .other {
                height: 70px;
            }

        .nsy-wechatmsg-content {
            position: relative;
        }

        .nsy-wechatmsg-img {
            overflow: hidden;
            background-color: #999;
            background-repeat: no-repeat;
            background-size: cover;
            background-position: center center;
        }

        .nsy-wechatmsg-item > .first .nsy-wechatmsg-content,
        .nsy-wechatmsg-item > .first .nsy-wechatmsg-img {
            height: 125px;
            line-height: 125px;
        }

        .nsy-wechatmsg-item > .other .nsy-wechatmsg-content {
            height: 70px;
        }

        .nsy-wechatmsg-item > .other .nsy-wechatmsg-img {
            float: right;
            width: 70px;
            height: 70px;
            margin-left: 15px;
            line-height: 70px;
        }

        .nsy-wechatmsg-title {
            font-size: 14px;
            font-weight: normal;
            overflow: hidden;
        }

        .nsy-wechatmsg-item > .first .nsy-wechatmsg-title {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 28px;
            padding: 0 10px;
            line-height: 28px;
            color: #fff;
            background-color: rgba(0,0,0,.5);
        }

        .nsy-wechatmsg-item > .other .nsy-wechatmsg-title {
            float: left;
            width: 112px;
            max-height: 48px;
            margin-top: 6px;
            line-height: 24px;
        }

        .nsy-wechatmsg-img {
            text-align: center;
            vertical-align: middle;
            color: #fff;
        }

            .nsy-wechatmsg-img .default {
                vertical-align: middle;
            }

        .nsy-wechatmsg-cover {
            display: none;
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 40px;
            padding: 0 10px;
            line-height: 40px;
            color: #fff;
            background-color: rgba(0,0,0,.3);
        }

        .nsy-wechatmsg-item > div:hover .nsy-wechatmsg-cover {
            display: block;
        }

        .nsy-wechatmsg-icon {
            margin: 0 10px;
            color: #fff;
        }

            .nsy-wechatmsg-icon:hover {
                color: #fff;
            }

        .nsy-wechatmsg-add {
            display: block;
            border: 1px dotted #d5d5d5;
            line-height: 100px;
            text-align: center;
            color: #eee;
        }

            .nsy-wechatmsg-add i {
                vertical-align: middle;
            }
    </style>
    <script type="text/javascript" src="../Wpedt/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        //声明编辑器
        var listTxt;
        var contentTxt;

        function checkAll() {
            //点击推送按钮时，将推送显示信息设置为空
            if (confirm("您确认要推送至微信号吗？")) {
                var itit1 = document.getElementById("intactTitle").value;
                var descript1 = document.getElementById("tbDescript").value;
                var itit2 = document.getElementById("txtAuthor").value;
                if (itit1 == "") {
                    alert("标题不能为空!");
                    return false;
                }
                if (descript1 == "") {
                    alert("摘要不能为空!");
                    return false;
                }
                if (itit2 == "") {
                    alert("作者不能为空!");
                    return false;
                }
                return true;
            }
            else {
                return false;
            }

        }

        function checkAllSave() {
            //点击推送按钮时，将推送显示信息设置为空
            if (confirm("您确认要保存推送记录吗？")) {
                var itit1 = document.getElementById("intactTitle").value;
                var descript1 = document.getElementById("tbDescript").value;
                var itit2 = document.getElementById("txtAuthor").value;
                if (itit1 == "") {
                    alert("标题不能为空!");
                    return false;
                }
                if (descript1 == "") {
                    alert("摘要不能为空!");
                    return false;
                }
                if (itit2 == "") {
                    alert("作者不能为空!");
                    return false;
                }
                //判断内容是否为空
                var etxtisempty = contentTxt.isEmpty();
                if (etxtisempty) {
                    alert("文章内容不能为空！");
                    return false;
                } else {
                    //获取文章内容
                    var gettxttitle = contentTxt.html();
                    var contxt = document.getElementById("content1");
                    contxt.value = gettxttitle;
                }
                return true;
            }
            else {
                return false;
            }

        }

        KindEditor.ready(function (K) {
            var editor = K.editor({
                uploadJson: '../Wpedt/UserEditor/aspnet/upload_json.ashx',
                fileManagerJson: '../Wpedt/UserEditor/aspnet/file_manager_json.ashx',
                allowFileManager: true
            });

            K('#uploadimg').click(function () {
                editor.loadPlugin('zdyimage', function () {
                    editor.plugin.zdyimageDialog({
                        zdyimageUrl: K('#imageName').val(),
                        clickFn: function (url) {
                            K('#imageName').val(K.formatUrl(url, 'domain'));
                            editor.hideDialog();
                            change();//加载预览图片
                        }
                    });
                });
            });

        });

        function change() {
            var arr = $("#imageName").val();
            if (arr != "") {
                $("#pho").attr('src', arr);
            }
        }

        //列表批量操作前检查选中行并读取id,title字符串 （ isConfirm：true|false,是否提示）
        function SelectCheck(ctlName, isConfirm) {
            var objs = document.getElementById(ctlName);
            var j = 0;
            var idstr = "";
            if (objs != null) {
                if (objs.rows[0].cells[0].children[0].children.length > 0) {
                    for (i = 0; i < objs.rows[0].children.length; i++) {

                        if (objs.rows[0].cells[i].children[0].children[0].checked == true) {
                            idstr = idstr + objs.rows[0].cells[i].children[0].attributes["ListValue"].nodeValue + ",";
                            j += 1;
                        }

                    }
                }
                else {
                    alert("已经发送成功！为防止误操作导致重复推送，请关闭当前页面后再操作。");
                    return false;
                }
                document.getElementById("hfidstr").value = idstr;

            }
        }

        // 关闭弹出层 刷新栏目设置
        function divClose() {
            parent.$.fancybox.close();
            //parent.jQuery.triggerSelect();
            //parent.location="manageNews.aspx";
        }

        function delayClose() {
            //setTimeout("divClose()",3000);
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="main-content-inner">
            <div class="breadcrumbs" id="breadcrumbs">

                <ul class="breadcrumb">
                    <li>
                        <i class="ace-icon fa fa-home home-icon"></i>
                        <a href="#">Home</a>
                    </li>

                    <li class="active">
                        <a href="#">推送至微信公众号</a>
                    </li>
                </ul>
                <!-- /.breadcrumb -->
            </div>
            <div class="page-content">
                <div class="hr6"></div>
                <div class="row">
                    <div class="col-xs-12">
                        <input type="hidden" id="loadtext" runat="server" />
                        <input type="hidden" id="hiddenid" runat="server" />
                        <div class="nsy-wechatmsg-wrap">
                            <div class="nsy-wechatmsg">
                                <asp:Repeater ID="list" runat="server" OnItemCommand="list_ItemCommand">
                                    <HeaderTemplate>
                                        <div class="nsy-wx">
                                            <ul class="nsy-wx-ul">
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <div class="nsy-wechatmsg-item nsy-wechatmsg-item02" id="edit" runat="server" commandname="edit" commandargument='<%# Eval("pkid")%>'>
                                            <div class="first" style="display: none;">
                                                <div class="nsy-wechatmsg-content">
                                                    <h3 class="nsy-wechatmsg-title"><%# Eval("intactTitle")%></h3>
                                                    <div class="nsy-wechatmsg-img" style='<%# "background-image: url("+ Eval("imageUrl")+");" %>'>
                                                        <i class="default fa fa-picture-o fa-3x"></i>
                                                    </div>
                                                </div>
                                                <div class="nsy-wechatmsg-cover">
                                                    <a class="nsy-wechatmsg-icon js-up" title="上移" href="javascript:void(0);">
                                                        <i class="fa fa-arrow-up"></i>
                                                    </a>
                                                    <a class="nsy-wechatmsg-icon js-down" title="下移" href="javascript:void(0);">
                                                        <i class="fa fa-arrow-down"></i>
                                                    </a>
                                                    <asp:LinkButton ID="delete1" runat="server" commandname="delete1"  commandargument='<%# Eval("pkid")%>' class="nsy-wechatmsg-icon js-del pull-right"><i class="fa fa-trash"></i></asp:LinkButton>
                                                    <asp:LinkButton ID="edit1" runat="server" commandname="edit"  commandargument='<%# Eval("newsid")%>' class="nsy-wechatmsg-icon  pull-right"><i class="fa fa-pencil"></i></asp:LinkButton>
                                                </div>
                                            </div>
                                            <div class="other">
                                                <div class="nsy-wechatmsg-content">
                                                    <h3 class="nsy-wechatmsg-title"><%# Eval("intactTitle")%></h3>
                                                    <div class="nsy-wechatmsg-img" style='<%# "background-image: url("+ Eval("imageUrl")+");" %>'>
                                                        <i class="default fa fa-picture-o fa-2x"></i>
                                                    </div>
                                                </div>
                                                <div class="nsy-wechatmsg-cover">
                                                    <a class="nsy-wechatmsg-icon js-up" title="上移" href="javascript:void(0);">
                                                        <i class="fa fa-arrow-up"></i>
                                                    </a>
                                                    <a class="nsy-wechatmsg-icon js-down" title="下移" href="javascript:void(0);">
                                                        <i class="fa fa-arrow-down"></i>
                                                    </a>
                                                    
                                                    <asp:LinkButton ID="delete2" runat="server" commandname="delete2"  commandargument='<%# Eval("pkid")%>'  class="nsy-wechatmsg-icon js-del pull-right"><i class="fa fa-trash"></i></asp:LinkButton>
                                                    <asp:LinkButton ID="edit2" runat="server" commandname="edit"  commandargument='<%# Eval("newsid")%>' class="nsy-wechatmsg-icon  pull-right"><i class="fa fa-pencil"></i></asp:LinkButton>
                                                </div>
                                            </div>
                                        </div>
                                    </ItemTemplate>
                                    <FooterTemplate></ul></div></FooterTemplate>
                                </asp:Repeater>

                            </div>
                            <hr />
                            <asp:Button ID="ok" CssClass="btn btn-sm btn-primary btn-block " style="width:45%;" runat="server" Text="推 送" OnClientClick="return checkAll();" OnClick="ok_Click"></asp:Button>&nbsp;
                            <asp:Button ID="record" CssClass="btn btn-sm btn-primary btn-block " style="width:45%;" runat="server" Text="推送记录"></asp:Button>
                        </div>
                        <div class="row">
                            
                                <input type="hidden" value="1" id="sortid" />
                                <input type="hidden" value="1" id="editid" />
                            
                            <div class="col-xs-12">
                                <table class="edit-table" id="Table1">
                                    <tr>
                                        <th>标题：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="intactTitle" runat="server" CssClass="input-md w3" MaxLength="20"></asp:TextBox>&nbsp;&nbsp;<span class="lgrey">标题不超过20个字</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>作者：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="txtAuthor" runat="server" CssClass="input-md w3" MaxLength="20"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>封面：
                                        </th>
                                        <td>
                                            <div class="addpicnews-div pull-left">
                                                <img alt="" src="../images/uploadfiles/default.jpg" runat="server" id="pho" class="pull-left img" width="220" height="160" />
                                            </div>
                                            <p class="fn-pt30">
                                                <a id="uploadimg" href="javascript:void(0);" class="blue">上传图片</a>
                                            </p>
                                            <p class="fn-pt30">
                                                <span class="lgrey">封面若未上传，则会使用默认封面</span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>摘要：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="tbDescript" runat="server" Width="400px" TextMode="MultiLine" Height="90px" MaxLength="100" CssClass="input-md"></asp:TextBox>
                                            <p>
                                                <span class="lgrey">摘要不超过100个字</span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>文章内容：</th>
                                        <td>
                                            <%--<asp:TextBox ID="txtContent" runat="server" Width="400px" TextMode="MultiLine" Height="200px" CssClass="input-md"></asp:TextBox>--%>
                                            <textarea name="content" style="width: 100%; height: 530px; visibility: hidden;"></textarea>
                                            <input id="content1" type="hidden" name="content1" runat="server" />
                                            <input id="content2" type="hidden" name="content2" runat="server" visible="false" />
                                        </td>
                                    </tr>
                                    <tr style="display: none;">
                                        <th>正文链接：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="tburl" runat="server" CssClass="input-md w3"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div class="row">
                            <div class="action-field text-center">
                                <%--<asp:Button ID="ok" CssClass="btn" runat="server" Text="推 送" OnClientClick="return checkAll();" OnClick="ok_Click"></asp:Button>--%>
                                <asp:Button ID="save" CssClass="btn btn-sm btn-primary" runat="server" Text="保  存" OnClientClick="return checkAllSave();" OnClick="save_Click" CommandName="save" CommandArgument='<%# Eval("pkid")%>'></asp:Button>
                                &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="button" class="btn btn-sm btn-primary" value="关 闭" onclick="parent.$.fancybox.close();" />&nbsp;
                <p style="padding-top: 10px;">
                    <asp:Label ID="labMsg" runat="server" Text="" ForeColor="Red"></asp:Label>
                </p>
                               <p> <asp:Label ID="labNewsid" runat="server" Text="" Visible="false"></asp:Label></p>
                            </div>

                        </div>
                        <input id="imageName" type="hidden" name="imageName" runat="server" value="" />
                    </div>
                </div>
            </div>
        </div>
        <%--<div class="edit-func-box func-box">
            <div class="hd b">推送至微信公众号</div>
            
        </div>--%>
        <!--#include file="../Css/foot.htm"-->
        <script type="text/javascript" language="javascript">

            KindEditor.ready(function (K) {
                debugger; var editor = K.create('textarea[name="content"]');
                //编辑时加载内容
                var initcontxt = document.getElementById("content1").value;
                editor.insertHtml(initcontxt);

                //var text = contentTxt.text();
                //var contxt = document.getElementById("content2");
                //contxt.value = text;

                contentTxt = editor;
            });

        </script>

        <script type="text/javascript">
            //插入文章内容分页标记
            function InsertPagingTag() {
                contentTxt.focus();
                contentTxt.insertHtml("<button id=\"ZDSOFTPAGINGTAG\">分页标记</button>");
                contentTxt.focus();
            }
        </script>
        <script>
            var items = $(".nsy-wechatmsg-item"),
			item_num = $(".nsy-wechatmsg-item").length;
            if ($(".nsy-wechatmsg-img").css("background-image") != "none") {
                $(".nsy-wechatmsg-img").find(".default").hide();
            }
            $(".js-up").click(function () {
                var $index = $(this).parents(".nsy-wechatmsg-item").index();
                if ($index > 0) {
                    $index--;
                    $(this).parents(".nsy-wechatmsg-item").insertBefore($(".nsy-wechatmsg-item:eq(" + $index + ")"));
                }
                lintReset();
            });
            $(".js-down").click(function () {
                var $index = $(this).parents(".nsy-wechatmsg-item").index();
                if ($index < item_num) {
                    $index++;
                    $(this).parents(".nsy-wechatmsg-item").insertAfter($(".nsy-wechatmsg-item:eq(" + $index + ")"));
                }
                lintReset();
            });
            $(".js-del").click(function () {
                if (confirm("您确认要删除推送记录吗？")) {
                    $(this).parents(".nsy-wechatmsg-item").remove();
                    lintReset();
                }
                else {
                    return false;
                }
            });
            function lintReset() {
                $(".nsy-wechatmsg-item:eq(0)").find(".first").show().next().hide();
                $(".nsy-wechatmsg-item:eq(0)").siblings().find(".first").hide().next().show();
            }
            lintReset();
        </script>
        <script type="text/javascript">

            jQuery(function ($) {

                $('[data-rel=popover]').popover({ container: 'body' })

                $("#record").click(function () {
                    return true;
                }).fancybox({
                    'width': 690,
                    'height': 620,
                    'hideOnOverlayClick': false,
                    'href': 'pushRecord.aspx',
                 'padding': '0'
             });
         })

    </script>
    </form>
</body>
</html>
