setTimeout(() => {
(function () {
    function IndexActivity() {
        this.body = $("body")
        this.baseurl = 'https://zj87.jxt.zj.gov.cn/webapi/'
        this.tjurl = 'extSmePartyBook/listMonthActive'
        this.hdurl = "extSmePartyBook/mainPageList";
        this.calendarshow = $("#calendarshow")
        this.zqfcalendar = $("#zqf-calendar")
        this.todyatime = $("#todyatime")
        this.activitynum = $("#activity-num")
        this.activityhtml = $("#activityhtml")
        this.iactivity = $(".riqi")
        this.activitytj=$(".activity-tj")
        this.activitytitle=$(".activity-title")
        this.today=""
        this.tjpostData = {
            DATE: ''
        }
        this.hdpostData = {
            pageNum: 1,
            pageSize: 2,
            ACTIVEDATE: ''
        }
    }
    IndexActivity.prototype = {
        init: function () {
            var _this = this
            _this.calendarShow()
            _this.tjpostData.DATE = _this.getTjDatedatetime()
            var d=new Date()
            _this.today=d.getDate()
            _this.todyatime.html(_this.getTjDateshowtime())
            _this.hdpostData.ACTIVEDATE = _this.getTjDatelistdate()
            // _this.getActivityList()
            return _this
        },
        bind_event: function () {
            var _this = this
            _this.clickDateTd();
            _this.getTj() //统计
            this.hideActivity();
            return _this
        },
        calendarShow: function () {
            var _this = this
            jeDate("#calendarshow", {
                isShow: false,
                format: "YYYY-MM-DD hh:mm:ss",
                donefun: function (obj) {
                }
            });
        },
        getTj: function () {
            var _this = this
            $.getJSON("/zj87/zxqy/calendarLists.json",
            function (data) {
                if (+data.status === 1) {
                    $("#calendarshow .daystable td.normal i").each(function () {
                        var day = $(this).attr("data-day")
                        var datalist = data.body.mouthList
                    })
                   
                    $.each(data.body.mouthList, function (index, item) {
                        if (item.COUNT) {
                            var classname = ".dateicon" + item.DAY
                            $("#calendarshow .daystable td.normal").find(classname).addClass("active").html(item.COUNT)
                        }
                        if(item.DAY==_this.today){
                            _this.activitynum.text(item.COUNT)
                        }
                    })
                }
            }
          );
        },
        getActivityList: function () {
            var _this = this
            Method.$post(_this.baseurl + _this.hdurl, _this.hdpostData, function (data) {
                if (+data.status === 1) {

                    _this.activitynum.text(data.body.total)
                    _this.activitytitle.children("b").text(data.body.total)
                    layui.use("laytpl", function () {
                        layui.laytpl(activitytmp.innerHTML).render(data.body.list, function (html) {
                            $("#activityhtml").html(html)
                        });
                    });
                }
            })


        },
        // 点击日期td获取活动
        clickDateTd: function () {
            var _this = this
            _this.calendarshow.on("mouseover", "td.normal", function () {
                $("#calendarshow").find("td").removeClass("action")
                $('#calendarshow tr td .riqi').removeClass('current');      
              $(this).find('.riqi').has('.piaofu ul li').addClass('current');
                var yyyymm = $(this).children().children("p").attr("data-ymd")
                var m = yyyymm.split("-")[1]
                var d = yyyymm.split("-")[2]
                    m = m < 10 ? m.substring(1, 2) : m
                    d = d < 10 ? d.substring(1, 2) : d
                // 设置时间
                if ($(this).children('i').text()) {
                    _this.todyatime.html(m + "月" + d + "日")
                    _this.iactivity.addClass("active")
                    _this.activitytj.addClass("active")                   
                    _this.getActivityList()
                }
                else{
                    _this.iactivity.removeClass("active");
                    _this.activitytj.removeClass("active")
                    _this.todyatime.html(m + "月" + d + "日")
                    _this.activitynum.text(0)
                }
            })
        },

        // 鼠标移开隐藏活动
        hideActivity: function () {
            var _this = this
            _this.zqfcalendar.on("mouseleave", function () {
              $('#calendarshow tr td .riqi').removeClass('current');
                if(_this.iactivity.hasClass("active")){
                    _this.iactivity.removeClass("active")
                    _this.activitytj.removeClass("active")
                }
            })
        },


      
      
      
        // 获取统计当前月份
        getTjDateshowtime: function () {
            var _this = this
            var d = new Date()
            var year = d.getFullYear()
            var m = d.getMonth() + 1
            var dd = d.getDate()
            var showtime = m + "月" + dd + "日"

            return showtime
        },
        getTjDatedatetime: function () {
            var _this = this
            var d = new Date()
            var year = d.getFullYear()
            var m = d.getMonth() + 1
            var dd = d.getDate()
            if (m < 10) {
                m = "0" + m
            }
            if (dd < 10) {
                dd = "0" + dd
            }
            var datetime = year + "-" + m
            return datetime
        },
        getTjDatelistdate: function () {
            var _this = this
            var d = new Date()
            var year = d.getFullYear()
            var m = d.getMonth() + 1
            var dd = d.getDate()

            if (m < 10) {
                m = "0" + m
            }
            if (dd < 10) {
                dd = "0" + dd
            }

            var listdate = year + "-" + m + "-" + dd
            return listdate
        }

    }
    var indexActivity = new IndexActivity()
    indexActivity.init().bind_event()
})(jQuery)
}, 3000);
