Ver código fonte

调整右下角弹窗

DW-PC\DW 5 anos atrás
pai
commit
53709a5ca6

+ 1 - 9
公共资源/src/_testNewsPop.html

@@ -9,15 +9,7 @@
 </head>
 
 <body>
-    <script src="./dwUDBBind/dwUDBBind.js"></script>
-    <script>
-        function dwbind() {
-            dwUDBBind.isBind().done(function () {
-                console.log(1111)
-            })
-        }
-        dwbind()
-    </script>
+    <script src="./newsPopup/newsPopup-test.js"></script>
 </body>
 
 </html>

+ 1 - 1
公共资源/src/dwFoot/duowanFooter.js

@@ -89,7 +89,7 @@
             var withoutGem = document.getElementById("dw-footer-without-gem");
             var mobi = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
             if (!withoutGem && !mobi) {
-                this.getScript('//pub.dwstatic.com/common/newsPopup/newsPopup.js')
+                this.getScript('//pub.dwstatic.com/common/newsPopup/newsPopup.js?201907')
             }
             withoutGem = null;
         },

+ 5 - 1
公共资源/src/js/dwudbproxy-new.js

@@ -300,7 +300,7 @@
             if (checkBind) {
                 /**清除cookie*/
                 Util.removeCookie('lg_bind', {
-                    domain: 'duowan.com',
+                    domain: '.duowan.com',
                     path: '/'
                 })
                 this.bindCallbacks = $.Callbacks('memory')
@@ -500,6 +500,10 @@
                         data.delCookieURL,
                         function () {
                             if(dwClientIncompatible.isClient()){
+                                Util.removeCookie('dw_client_rewriteDomainCookie',{
+                                    domain: '.duowan.com',
+                                    path: '/'
+                                })
                                 window.external.Logout()
                             }
                             Util.logoutCallbacks.fire()

+ 471 - 0
公共资源/src/newsPopup/newsPopup-test.js

@@ -0,0 +1,471 @@
+(function(win, doc) {
+    __inline("./md5.js");
+
+    var cssStyle = __inline("./css/miniPopup.css");
+    var template = __inline("./tpl/wrap.tmpl");
+    var vitalNewsTpl = __inline("./tpl/vitalNews.tmpl");
+    var tukuTpl = __inline("./tpl/tuku.tmpl");
+    var kaTpl = __inline("./tpl/ka.tmpl");
+    var _BUSY_STORAGE_ = "dw_mini_popup_busy_status";
+    var _NORMAL_STORAGE_ = "dw_mini_popup_status";
+
+    var plainFunction = function() {};
+    var allData = {}; //所有数据
+
+    var Util = {
+        getCookie: function(key) {
+            var arr,
+                reg = new RegExp("(^| )" + key + "=([^;]*)(;|$)");
+            if ((arr = doc.cookie.match(reg))) return unescape(arr[2]);
+            else return null;
+        },
+        setCookie: function(key, value, day) {
+            day = day || 1; //天数
+            var cookie =
+                key +
+                "=" +
+                escape(value) +
+                "; max-age=" +
+                day * 24 * 60 * 60 +
+                "; domain=duowan.com; path=/";
+            doc.cookie = cookie;
+        },
+        getScript: function(url, callback) {
+            var head = document.getElementsByTagName("head")[0];
+            var script = document.createElement("script");
+            script.type = "text/javascript";
+            script.src = url;
+            var done = false;
+            script.onload = script.onreadystatechange = function() {
+                if (
+                    !this.readyState ||
+                    this.readyState == "complete" ||
+                    this.readyState == "loaded"
+                ) {
+                    callback();
+                    head.removeChild(script);
+                }
+            };
+            head.appendChild(script);
+        },
+
+        isLogin: function() {
+            return Util.getCookie("yyuid") || Util.getCookie("lg_uid");
+        },
+
+        encodePwd: function(random, pwd) {
+            var k1 = md5.sha1(random);
+            var k2 = md5.sha1(k1);
+
+            var v = md5.xor(md5.xor(pwd, k2), k1);
+            return md5.base64encode(v);
+        },
+        // 16点至凌晨2点
+        isBusyTime: function() {
+            var hour = new Date().getHours();
+            return hour >= 16 || hour < 2;
+        }
+    };
+
+    var NewsPopup = {
+        popupUI: null,
+        newsWrap: null, //新闻区域
+        dancer: null, //招手的小人
+        hideButton: null, //右上角关闭按钮
+        navBar: null, //导航栏
+        littleboy: null, //不动的小人
+        popupTimer: null, // 16点定时弹出的定时器
+        firstTuku: true,
+        firstKa: true,
+
+        initDom: function(data) {
+            var option = null;
+            var isBusy = Util.isBusyTime();
+            //忙时默认打开,闲时默认关闭
+            if (isBusy) {
+                option = ClosedOption.getBusy();
+                allData.option = parseInt(option) == 0 ? 0 : 1;
+            } else {
+                option = ClosedOption.get();
+                allData.option = parseInt(option) == 1 ? 1 : 0;
+            }
+
+            this.popupUI = $(template(data));
+            this.vitalNews = this.popupUI.find(".popup-vital-news");
+            this.tuku = this.popupUI.find(".popup-photo-gallery");
+            this.newsWrap = this.popupUI.find(".dw-mini-popup");
+            this.navlist = this.popupUI.find(".dw-mini-nav-item");
+            this.newsPanel = this.popupUI.find(".dw-mini-news-panel");
+            this.hideButton = this.popupUI.find(".dw-popup-hide");
+            this.navBar = this.popupUI.find(".dw-mini-nav-list");
+            this.littleboy = this.popupUI.find(".dw-mini-popup-littleboy");
+            this.dancer = this.popupUI.find(".dw-min-popup-dancer");
+            this.award = this.popupUI.find(".dw-mini-popup-award");
+
+            //添加dom
+            this.addEvent()
+                .append()
+                .openTimer();
+        },
+        //首屏新闻
+        getVitalNewsData: function(callback) {
+            $.when(
+                $.ajax({
+                    url: "//tips.duowan.com/tnews",
+                    dataType: "jsonp"
+                }),
+                $.ajax({
+                    url: "//plus.duowan.com/zhibo/list",
+                    dataType: "jsonp"
+                })
+            )
+                .done(function(ret1, ret2) {
+                    allData.news = ret1[0];
+                    allData.zhibo = ret2 && ret2[0].data && ret2[0].data[0];
+                })
+                .then(function() {
+                    callback(allData);
+                });
+        },
+        renderVitalNews: function(data) {
+            this.vitalNews.html(vitalNewsTpl(data));
+            this.navlist.eq(0).trigger("mouseover");
+        },
+        getTukuData(callback) {
+            $.ajax({
+                url: "//www.duowan.com/s/newsPopup/news.json",
+                dataType: "jsonp",
+                jsonp: "jsonp1",
+                jsonpCallback: "jsonp1"
+            }).done(function(ret) {
+                allData.gallerys = ret.gallery;
+                allData.videos = ret.video;
+                callback(allData);
+            });
+        },
+        renderTuku(tukuData) {
+            this.tuku.html(tukuTpl(tukuData));
+            this.navlist.eq(1).trigger("mouseover");
+        },
+        /**添加事件 */
+        addEvent: function() {
+            var self = this;
+
+            if (window.dwUDBProxy) {
+                dwUDBProxy.add(loadData);
+            } else {
+                Util.getScript(
+                    "//pub.dwstatic.com/common/js/dwudbproxy.js",
+                    function() {
+                        dwUDBProxy.add(loadData);
+                    }
+                );
+            }
+
+            this.hideButton.click(function() {
+                self.hideNews();
+            });
+            this.littleboy.click(function() {
+                self.hideNews();
+            });
+            this.award.children(".dw-mini-award-bg").click(function() {
+                self._ClosedKaDou();
+            });
+
+            this.dancer.click(function() {
+                self.showNews();
+            });
+
+            //金豆页面点击事件
+            this.popupUI
+                .on("click", ".login-btn", function() {
+                    if (window.dwUDBProxy) {
+                        dwUDBProxy.login(plainFunction);
+                    } else {
+                        Util.getScript(
+                            "//pub.dwstatic.com/common/js/dwudbproxy.js",
+                            function() {
+                                dwUDBProxy.login(plainFunction);
+                            }
+                        );
+                    }
+                })
+                .on("click", ".action-sign", function() {
+                    var $e = $(this);
+                    var api = "//plus.duowan.com/task/sign";
+                    var data = {
+                        shop_id: 6,
+                        time: new Date().getTime()
+                    };
+                    var password =
+                        Util.getCookie("password") ||
+                        Util.getCookie("lg_openid");
+                    data["sign"] = Util.encodePwd(
+                        password,
+                        md5.sha1($.param(data))
+                    );
+
+                    $.ajax({
+                        url: api,
+                        dataType: "jsonp",
+                        data: data
+                    }).done(function(ret) {
+                        if (ret.code == 0) {
+                            allData.ka.userInfo.gold =
+                                allData.ka.userInfo.gold * 1 +
+                                ret.data.gold * 1;
+                            $e.removeClass("action-sign state-ing")
+                                .addClass("state-finished")
+                                .text("已签到");
+                            self.popupUI
+                                .find(".kadou-info .kadou-num")
+                                .text(allData.ka.userInfo.gold / 100);
+                        }
+                    });
+                })
+                .on("click", ".btn-reward", function() {
+                    var $e = $(this);
+                    var taskid = $e.attr("data-taskid");
+                    var api =
+                        "//kaplus.duowan.com/task/reward?task_id=" + taskid;
+                    $.ajax({
+                        url: api,
+                        dataType: "jsonp"
+                    }).done(function(ret) {
+                        if (ret.code == 0) {
+                            $e.removeClass("btn-reward state-ing")
+                                .addClass("state-finished")
+                                .text("已完成");
+
+                            if ($e.hasClass("dw-mini-award-link")) {
+                                var $kadouItem = self.navlist.filter(
+                                    ".kadou-item"
+                                );
+
+                                $kadouItem
+                                    .trigger("mouseover")
+                                    .addClass("have-award");
+
+                                self.popupUI
+                                    .find(
+                                        ".task-list a[data-taskid=" +
+                                            taskid +
+                                            "]"
+                                    )
+                                    .removeClass("state-ing state-notyet")
+                                    .addClass("state-finished")
+                                    .text("已完成");
+
+                                self._ClosedKaDou();
+                            }
+                            //如果已经请求过ka数据
+                            if (allData.ka) {
+                                allData.ka.userInfo.gold =
+                                    allData.ka.userInfo.gold * 1 +
+                                    ret.data.gold * 1;
+                                self.popupUI
+                                    .find(".kadou-info .kadou-num")
+                                    .text(allData.ka.userInfo.gold / 100);
+                            }
+                        }
+                    });
+                });
+
+            this.navlist.hover(self.togglePanel);
+
+            //mouseover 图库tab 时再去请求
+            this.navlist.filter(".tuku-item").hover(function() {
+                if (!self.firstTuku) return;
+                self.firstTuku = false;
+
+                self.getTukuData(function(data) {
+                    self.renderTuku(data);
+                });
+            });
+
+            //mouseover 金豆tab 时再去请求
+            this.navlist.filter(".kadou-item").hover(function() {
+                if (!self.firstKa) return;
+
+                self.firstKa = false;
+
+                loadData();
+            });
+
+            function loadData() {
+                allData.isLogin = Util.isLogin();
+
+                $.when(
+                    $.ajax({
+                        url: "//plus.duowan.com/popup",
+                        data: { task_num: 4 },
+                        dataType: "jsonp"
+                    }),
+                    $.ajax({
+                        url: "//plus.duowan.com/open/GetShopGoods",
+                        dataType: "jsonp"
+                    })
+                )
+                    .done(function(ret, ret2) {
+                        ret[0].code == 0 && (allData.ka = ret[0].data);
+                        ret2[0].code == 0 &&
+                            (allData.exList = ret2[0].data.slice(0, 4));
+                    })
+                    .then(function() {
+                        $(".popup-kadou-wrap").html(kaTpl(allData));
+                    });
+            }
+
+            return this;
+        },
+
+        append: function() {
+            $("body")
+                .append("<style>" + cssStyle + "</style>")
+                .append(this.popupUI);
+
+            return this;
+        },
+        /**显示新闻 */
+        showNews: function() {
+            var self = this;
+
+            this.dancer.animate(
+                {
+                    right: "-60px"
+                },
+                200,
+                function() {
+                    self.popupUI.animate(
+                        {
+                            right: "0px"
+                        },
+                        600
+                    );
+                }
+            );
+
+            Util.isBusyTime() ? ClosedOption.setBusy(1) : ClosedOption.set(1);
+        },
+        /**隐藏新闻 */
+        hideNews: function() {
+            var self = this;
+
+            this.popupUI.animate(
+                {
+                    right: "-380px"
+                },
+                600,
+                function() {
+                    self.dancer.animate(
+                        {
+                            right: "0px"
+                        },
+                        200
+                    );
+                }
+            );
+            Util.isBusyTime() ? ClosedOption.setBusy(0) : ClosedOption.set(0);
+        },
+        /**切换panel */
+        togglePanel: function() {
+            var _this = $(this);
+            var index = _this.index();
+
+            if (_this.hasClass("active")) return;
+
+            _this.siblings(".active").removeClass("active");
+            _this.addClass("active");
+            NewsPopup.newsPanel
+                .removeClass("active")
+                .eq(index)
+                .addClass("active");
+        },
+
+        showKaDou: function(obj) {
+            this.award.find(".dw-mini-award-msg").text(obj.text);
+            this.award
+                .find(".dw-mini-award-link")
+                .attr("data-taskid", obj.taskid);
+
+            this.award.show();
+
+            this.showNews();
+        },
+
+        /** 关闭金豆奖励*/
+        _ClosedKaDou: function() {
+            var self = this;
+            this.award.hide();
+            setTimeout(function() {
+                self.navlist.filter(".kadou-item").removeClass("have-award");
+            }, 4000);
+        },
+
+        /**16点左右弹出弹窗 */
+        openTimer: function() {
+            if (!Util.isBusyTime()) {
+                var self = this;
+                var now = new Date();
+                var minutes =
+                    (15 - now.getHours()) * 60 + (60 - now.getMinutes());
+                var duration = minutes * 60 * 1000;
+                // var duration = 5 * 1000;
+                console.log("minutes:", minutes);
+                this.popupTimer = setTimeout(function() {
+                    self.getVitalNewsData(function(data) {
+                        self.renderVitalNews(data);
+                        self.showNews();
+                    });
+                }, duration);
+            }
+
+            return this;
+        }
+    };
+
+    /**根据用户操作读写cookie
+     * 每天16:00到第二天2:00强制展开
+     * 凌晨2点以后强制保持关闭状态,至16:00
+     */
+    var ClosedOption = {
+        getBusy: function() {
+            var ret = Util.getCookie(_BUSY_STORAGE_);
+            return ret;
+        },
+        setBusy: function(option) {
+            Util.setCookie(_BUSY_STORAGE_, option, 1 / 3);
+        },
+        get: function() {
+            var ret = Util.getCookie(_NORMAL_STORAGE_);
+            return ret;
+        },
+        /**option:0 / 1 */
+        set: function(option) {
+            Util.setCookie(_NORMAL_STORAGE_, option, 365);
+        }
+    };
+
+    var init = function() {
+        NewsPopup.getVitalNewsData(function(data) {
+            NewsPopup.initDom(data);
+            NewsPopup.renderVitalNews(data);
+        });
+
+        //暴露全局变量给其他地方调用
+        window.dwMiniNewsPopup = {
+            showKaDou: function(obj) {
+                NewsPopup.showKaDou(obj);
+            }
+        };
+    };
+
+    //判断是否有引入jquery
+    if (typeof $ == "undefined") {
+        Util.getScript("//pub.dwstatic.com/common/js/jquery.js", function() {
+            init();
+        });
+    } else {
+        init();
+    }
+})(window, document);

+ 385 - 250
公共资源/src/newsPopup/newsPopup.js

@@ -1,336 +1,471 @@
-(function (win, doc) {
-    __inline("./md5.js")
+(function(win, doc) {
+    __inline("./md5.js");
 
-    var cssStyle = __inline('./css/miniPopup.css')
-    var template = __inline('./tpl/wrap.tmpl')
-    var kaTpl = __inline('./tpl/ka.tmpl')
-    var _STORAGE_ = 'dw_mini_popup_status'
-
-    var plainFunction = function () { }
-    var allData = {}//所有数据
+    var cssStyle = __inline("./css/miniPopup.css");
+    var template = __inline("./tpl/wrap.tmpl");
+    var vitalNewsTpl = __inline("./tpl/vitalNews.tmpl");
+    var tukuTpl = __inline("./tpl/tuku.tmpl");
+    var kaTpl = __inline("./tpl/ka.tmpl");
+    var _BUSY_STORAGE_ = "dw_mini_popup_busy_status";
+    var _NORMAL_STORAGE_ = "dw_mini_popup_status";
 
+    var plainFunction = function() {};
+    var allData = {}; //所有数据
 
     var Util = {
-        getCookie: function (key) {
-            var arr, reg = new RegExp("(^| )" + key + "=([^;]*)(;|$)");
-            if (arr = doc.cookie.match(reg))
-                return unescape(arr[2])
-            else
-                return null
+        getCookie: function(key) {
+            var arr,
+                reg = new RegExp("(^| )" + key + "=([^;]*)(;|$)");
+            if ((arr = doc.cookie.match(reg))) return unescape(arr[2]);
+            else return null;
         },
-        setCookie: function (key, value) {
-            var day = 1//天数
-            var cookie = key + "=" + escape(value) + "; max-age=" + (day * 24 * 60 * 60 * 1000) + "; domain=duowan.com; path=/";
-            doc.cookie = cookie
+        setCookie: function(key, value, day) {
+            day = day || 1; //天数
+            var cookie =
+                key +
+                "=" +
+                escape(value) +
+                "; max-age=" +
+                day * 24 * 60 * 60 +
+                "; domain=duowan.com; path=/";
+            doc.cookie = cookie;
         },
-        getScript: function (url, callback) {
+        getScript: function(url, callback) {
             var head = document.getElementsByTagName("head")[0];
-            var script = document.createElement('script')
-            script.type = "text/javascript"
-            script.src = url
+            var script = document.createElement("script");
+            script.type = "text/javascript";
+            script.src = url;
             var done = false;
-            script.onload = script.onreadystatechange = function () {
-
-                if ((!this.readyState) || this.readyState == "complete" || this.readyState == "loaded") {
-                    callback()
-                    head.removeChild(script)
+            script.onload = script.onreadystatechange = function() {
+                if (
+                    !this.readyState ||
+                    this.readyState == "complete" ||
+                    this.readyState == "loaded"
+                ) {
+                    callback();
+                    head.removeChild(script);
                 }
-            }
+            };
             head.appendChild(script);
         },
 
-        isLogin: function () {
-            return Util.getCookie('yyuid') || Util.getCookie('lg_uid');
+        isLogin: function() {
+            return Util.getCookie("yyuid") || Util.getCookie("lg_uid");
         },
 
-        encodePwd: function (random, pwd) {
+        encodePwd: function(random, pwd) {
             var k1 = md5.sha1(random);
             var k2 = md5.sha1(k1);
 
             var v = md5.xor(md5.xor(pwd, k2), k1);
             return md5.base64encode(v);
+        },
+        // 16点至凌晨2点
+        isBusyTime: function() {
+            var hour = new Date().getHours();
+            return hour >= 16 || hour < 2;
         }
-    }
+    };
 
     var NewsPopup = {
         popupUI: null,
-        newsWrap: null,//新闻区域
-        dancer: null,//招手的小人
-        hideButton: null,//右上角关闭按钮
-        navBar: null,//导航栏
-        littleboy: null,//不动的小人
-
+        newsWrap: null, //新闻区域
+        dancer: null, //招手的小人
+        hideButton: null, //右上角关闭按钮
+        navBar: null, //导航栏
+        littleboy: null, //不动的小人
+        popupTimer: null, // 16点定时弹出的定时器
+        firstTuku: true,
         firstKa: true,
 
-        init: function (data) {
-            this.popupUI = $(template(data))
-            this.newsWrap = this.popupUI.find('.dw-mini-popup')
-            this.navlist = this.popupUI.find('.dw-mini-nav-item')
-            this.newsPanel = this.popupUI.find('.dw-mini-news-panel')
-            this.hideButton = this.popupUI.find('.dw-popup-hide')
-            this.navBar = this.popupUI.find('.dw-mini-nav-list')
-            this.littleboy = this.popupUI.find('.dw-mini-popup-littleboy')
-            this.dancer = this.popupUI.find('.dw-min-popup-dancer')
-            this.award = this.popupUI.find('.dw-mini-popup-award')
+        initDom: function(data) {
+            var option = null;
+            var isBusy = Util.isBusyTime();
+            //忙时默认打开,闲时默认关闭
+            if (isBusy) {
+                option = ClosedOption.getBusy();
+                allData.option = parseInt(option) == 0 ? 0 : 1;
+            } else {
+                option = ClosedOption.get();
+                allData.option = parseInt(option) == 1 ? 1 : 0;
+            }
+
+            this.popupUI = $(template(data));
+            this.vitalNews = this.popupUI.find(".popup-vital-news");
+            this.tuku = this.popupUI.find(".popup-photo-gallery");
+            this.newsWrap = this.popupUI.find(".dw-mini-popup");
+            this.navlist = this.popupUI.find(".dw-mini-nav-item");
+            this.newsPanel = this.popupUI.find(".dw-mini-news-panel");
+            this.hideButton = this.popupUI.find(".dw-popup-hide");
+            this.navBar = this.popupUI.find(".dw-mini-nav-list");
+            this.littleboy = this.popupUI.find(".dw-mini-popup-littleboy");
+            this.dancer = this.popupUI.find(".dw-min-popup-dancer");
+            this.award = this.popupUI.find(".dw-mini-popup-award");
 
             //添加dom
-            this.addEvent().append()
+            this.addEvent()
+                .append()
+                .openTimer();
         },
-        getData: function (callback) {
-            var option = ClosedOption.get()
-
-            allData.option = (parseInt(option) == 0 ? 0 : 1)
-
-
+        //首屏新闻
+        getVitalNewsData: function(callback) {
             $.when(
                 $.ajax({
-                    url: '//tips.duowan.com/tnews',
+                    url: "//tips.duowan.com/tnews",
                     dataType: "jsonp"
                 }),
                 $.ajax({
-                    url: '//www.duowan.com/s/newsPopup/news.json',
-                    dataType: "jsonp",
-                    jsonp: 'jsonp1',
-                    jsonpCallback: "jsonp1"
-                }),
-                $.ajax({
-                    url: '//plus.duowan.com/zhibo/list',
+                    url: "//plus.duowan.com/zhibo/list",
                     dataType: "jsonp"
                 })
-            ).done(function (ret1, ret2, ret3, ret4) {
-                allData.news = ret1[0]
-                allData.gallerys = ret2[0].gallery
-                allData.videos = ret2[0].video
-                allData.zhibo = ret3 && ret3[0].data && ret3[0].data[0]
-            }).then(function () {
-                callback(allData)
-            })
+            )
+                .done(function(ret1, ret2) {
+                    allData.news = ret1[0];
+                    allData.zhibo = ret2 && ret2[0].data && ret2[0].data[0];
+                })
+                .then(function() {
+                    callback(allData);
+                });
+        },
+        renderVitalNews: function(data) {
+            this.vitalNews.html(vitalNewsTpl(data));
+            this.navlist.eq(0).trigger("mouseover");
+        },
+        getTukuData(callback) {
+            $.ajax({
+                url: "//www.duowan.com/s/newsPopup/news.json",
+                dataType: "jsonp",
+                jsonp: "jsonp1",
+                jsonpCallback: "jsonp1"
+            }).done(function(ret) {
+                allData.gallerys = ret.gallery;
+                allData.videos = ret.video;
+                callback(allData);
+            });
+        },
+        renderTuku(tukuData) {
+            this.tuku.html(tukuTpl(tukuData));
+            this.navlist.eq(1).trigger("mouseover");
         },
         /**添加事件 */
-        addEvent: function () {
-            var self = this
+        addEvent: function() {
+            var self = this;
 
             if (window.dwUDBProxy) {
-                dwUDBProxy.add(loadData)
+                dwUDBProxy.add(loadData);
             } else {
-                Util.getScript('//pub.dwstatic.com/common/js/dwudbproxy.js', function () {
-                    dwUDBProxy.add(loadData)
-                })
+                Util.getScript(
+                    "//pub.dwstatic.com/common/js/dwudbproxy.js",
+                    function() {
+                        dwUDBProxy.add(loadData);
+                    }
+                );
             }
 
-            this.hideButton.click(function () {
-                self.hideNews()
-            })
-            this.littleboy.click(function () {
-                self.hideNews()
-            })
-            this.award.children('.dw-mini-award-bg').click(function () {
-                self._ClosedKaDou()
-            })
-
+            this.hideButton.click(function() {
+                self.hideNews();
+            });
+            this.littleboy.click(function() {
+                self.hideNews();
+            });
+            this.award.children(".dw-mini-award-bg").click(function() {
+                self._ClosedKaDou();
+            });
 
-            this.dancer.click(function () {
-                self.showNews()
-            })
+            this.dancer.click(function() {
+                self.showNews();
+            });
 
             //金豆页面点击事件
-            this.popupUI.on('click', '.login-btn', function () {
-                if (window.dwUDBProxy) {
-                    dwUDBProxy.login(plainFunction)
-                } else {
-                    Util.getScript('//pub.dwstatic.com/common/js/dwudbproxy.js', function () {
-                        dwUDBProxy.login(plainFunction)
-                    })
-                }
-            }).on("click", ".action-sign", function () {
-                var $e = $(this);
-                var api = "//plus.duowan.com/task/sign"
-                var data = {
-                    shop_id: 6,
-                    time: (new Date()).getTime()
-                };
-                var password = Util.getCookie('password') || Util.getCookie("lg_openid")
-                data["sign"] = Util.encodePwd(password, md5.sha1($.param(data)));
-
-                $.ajax({
-                    url: api,
-                    dataType: 'jsonp',
-                    data: data
-                }).done(function (ret) {
-                    if (ret.code == 0) {
-                        allData.ka.userInfo.gold = allData.ka.userInfo.gold * 1 + ret.data.gold * 1
-                        $e.removeClass('action-sign state-ing').addClass('state-finished').text('已签到')
-                        self.popupUI.find('.kadou-info .kadou-num').text(allData.ka.userInfo.gold / 100)
+            this.popupUI
+                .on("click", ".login-btn", function() {
+                    if (window.dwUDBProxy) {
+                        dwUDBProxy.login(plainFunction);
+                    } else {
+                        Util.getScript(
+                            "//pub.dwstatic.com/common/js/dwudbproxy.js",
+                            function() {
+                                dwUDBProxy.login(plainFunction);
+                            }
+                        );
                     }
                 })
-            }).on("click", ".btn-reward", function () {
-                var $e = $(this)
-                var taskid = $e.attr("data-taskid")
-                var api = "//kaplus.duowan.com/task/reward?task_id=" + taskid
-                $.ajax({
-                    url: api,
-                    dataType: 'jsonp'
-                }).done(function (ret) {
-                    if (ret.code == 0) {
-                        $e.removeClass('btn-reward state-ing').addClass('state-finished').text('已完成')
-
-                        if ($e.hasClass('dw-mini-award-link')) {
-                            var $kadouItem = self.navlist.filter('.kadou-item')
-
-                            $kadouItem.trigger('mouseover').addClass('have-award')
-
-                            self.popupUI.find('.task-list a[data-taskid=' + taskid + ']').removeClass('state-ing state-notyet').addClass('state-finished').text('已完成')
-
-                            self._ClosedKaDou()
-                        }
-                        //如果已经请求过ka数据
-                        if (allData.ka) {
-                            allData.ka.userInfo.gold = allData.ka.userInfo.gold * 1 + ret.data.gold * 1
-                            self.popupUI.find('.kadou-info .kadou-num').text(allData.ka.userInfo.gold / 100)
+                .on("click", ".action-sign", function() {
+                    var $e = $(this);
+                    var api = "//plus.duowan.com/task/sign";
+                    var data = {
+                        shop_id: 6,
+                        time: new Date().getTime()
+                    };
+                    var password =
+                        Util.getCookie("password") ||
+                        Util.getCookie("lg_openid");
+                    data["sign"] = Util.encodePwd(
+                        password,
+                        md5.sha1($.param(data))
+                    );
+
+                    $.ajax({
+                        url: api,
+                        dataType: "jsonp",
+                        data: data
+                    }).done(function(ret) {
+                        if (ret.code == 0) {
+                            allData.ka.userInfo.gold =
+                                allData.ka.userInfo.gold * 1 +
+                                ret.data.gold * 1;
+                            $e.removeClass("action-sign state-ing")
+                                .addClass("state-finished")
+                                .text("已签到");
+                            self.popupUI
+                                .find(".kadou-info .kadou-num")
+                                .text(allData.ka.userInfo.gold / 100);
                         }
-                    }
+                    });
                 })
-            })
+                .on("click", ".btn-reward", function() {
+                    var $e = $(this);
+                    var taskid = $e.attr("data-taskid");
+                    var api =
+                        "//kaplus.duowan.com/task/reward?task_id=" + taskid;
+                    $.ajax({
+                        url: api,
+                        dataType: "jsonp"
+                    }).done(function(ret) {
+                        if (ret.code == 0) {
+                            $e.removeClass("btn-reward state-ing")
+                                .addClass("state-finished")
+                                .text("已完成");
+
+                            if ($e.hasClass("dw-mini-award-link")) {
+                                var $kadouItem = self.navlist.filter(
+                                    ".kadou-item"
+                                );
+
+                                $kadouItem
+                                    .trigger("mouseover")
+                                    .addClass("have-award");
+
+                                self.popupUI
+                                    .find(
+                                        ".task-list a[data-taskid=" +
+                                            taskid +
+                                            "]"
+                                    )
+                                    .removeClass("state-ing state-notyet")
+                                    .addClass("state-finished")
+                                    .text("已完成");
+
+                                self._ClosedKaDou();
+                            }
+                            //如果已经请求过ka数据
+                            if (allData.ka) {
+                                allData.ka.userInfo.gold =
+                                    allData.ka.userInfo.gold * 1 +
+                                    ret.data.gold * 1;
+                                self.popupUI
+                                    .find(".kadou-info .kadou-num")
+                                    .text(allData.ka.userInfo.gold / 100);
+                            }
+                        }
+                    });
+                });
 
-            this.navlist.hover(self.togglePanel)
-                .eq(0).trigger('mouseover')
+            this.navlist.hover(self.togglePanel);
 
-            //mouseover 金豆tab 时再去请求
-            this.navlist.filter('.kadou-item').hover(function () {
+            //mouseover 图库tab 时再去请求
+            this.navlist.filter(".tuku-item").hover(function() {
+                if (!self.firstTuku) return;
+                self.firstTuku = false;
+
+                self.getTukuData(function(data) {
+                    self.renderTuku(data);
+                });
+            });
 
-                if (!self.firstKa) return
+            //mouseover 金豆tab 时再去请求
+            this.navlist.filter(".kadou-item").hover(function() {
+                if (!self.firstKa) return;
 
-                self.firstKa = false
+                self.firstKa = false;
 
-                loadData()
-            })
+                loadData();
+            });
 
             function loadData() {
-                allData.isLogin = Util.isLogin()
-
-                $.when($.ajax({
-                    url: '//plus.duowan.com/popup',
-                    data: { task_num: 4 },
-                    dataType: 'jsonp'
-                }), $.ajax({
-                    url: '//plus.duowan.com/open/GetShopGoods',
-                    dataType: 'jsonp'
-                })).done(function (ret, ret2) {
-                    ret[0].code == 0 && (allData.ka = ret[0].data)
-                    ret2[0].code == 0 && (allData.exList = ret2[0].data.slice(0, 4))
-                }).then(function () {
-                    // console.log(allData.ka)
-                    $('.popup-kadou-wrap').html(kaTpl(allData))
-                })
+                allData.isLogin = Util.isLogin();
+
+                $.when(
+                    $.ajax({
+                        url: "//plus.duowan.com/popup",
+                        data: { task_num: 4 },
+                        dataType: "jsonp"
+                    }),
+                    $.ajax({
+                        url: "//plus.duowan.com/open/GetShopGoods",
+                        dataType: "jsonp"
+                    })
+                )
+                    .done(function(ret, ret2) {
+                        ret[0].code == 0 && (allData.ka = ret[0].data);
+                        ret2[0].code == 0 &&
+                            (allData.exList = ret2[0].data.slice(0, 4));
+                    })
+                    .then(function() {
+                        $(".popup-kadou-wrap").html(kaTpl(allData));
+                    });
             }
 
-            return this
+            return this;
         },
 
-        append: function () {
-            $('body').append('<style>' + cssStyle + '</style>')
-                .append(this.popupUI)
+        append: function() {
+            $("body")
+                .append("<style>" + cssStyle + "</style>")
+                .append(this.popupUI);
+
+            return this;
         },
         /**显示新闻 */
-        showNews: function () {
-            var self = this
-
-            this.dancer.animate({
-                right: "-60px"
-            }, 200, function () {
-                self.popupUI.animate({
-                    right: "0px"
-                }, 600)
-            })
-
-            ClosedOption.set(1)
+        showNews: function() {
+            var self = this;
+
+            this.dancer.animate(
+                {
+                    right: "-60px"
+                },
+                200,
+                function() {
+                    self.popupUI.animate(
+                        {
+                            right: "0px"
+                        },
+                        600
+                    );
+                }
+            );
+
+            Util.isBusyTime() ? ClosedOption.setBusy(1) : ClosedOption.set(1);
         },
         /**隐藏新闻 */
-        hideNews: function () {
-            var self = this
-
-            this.popupUI.animate({
-                right: "-380px"
-            }, 600, function () {
-                self.dancer.animate({
-                    right: "0px"
-                }, 200)
-            })
-
-            ClosedOption.set(0)
+        hideNews: function() {
+            var self = this;
+
+            this.popupUI.animate(
+                {
+                    right: "-380px"
+                },
+                600,
+                function() {
+                    self.dancer.animate(
+                        {
+                            right: "0px"
+                        },
+                        200
+                    );
+                }
+            );
+            Util.isBusyTime() ? ClosedOption.setBusy(0) : ClosedOption.set(0);
         },
         /**切换panel */
-        togglePanel: function () {
-            var _this = $(this)
-            var index = _this.index()
-
-            if (_this.hasClass('active')) return
-
-
-            _this.siblings('.active').removeClass('active')
-            _this.addClass('active')
-
-            NewsPopup.newsPanel.removeClass('active')
-                .eq(index).addClass('active')
-                .find('img[data-src]').each(function (i, img) {
-                    $(img).attr('src', $(img).data('src')).removeAttr('data-src')
-                })
+        togglePanel: function() {
+            var _this = $(this);
+            var index = _this.index();
+
+            if (_this.hasClass("active")) return;
+
+            _this.siblings(".active").removeClass("active");
+            _this.addClass("active");
+            NewsPopup.newsPanel
+                .removeClass("active")
+                .eq(index)
+                .addClass("active");
         },
 
-        showKaDou: function (obj) {
-
-            this.award.find('.dw-mini-award-msg').text(obj.text)
-            this.award.find('.dw-mini-award-link').attr('data-taskid', obj.taskid)
+        showKaDou: function(obj) {
+            this.award.find(".dw-mini-award-msg").text(obj.text);
+            this.award
+                .find(".dw-mini-award-link")
+                .attr("data-taskid", obj.taskid);
 
-            this.award.show()
+            this.award.show();
 
-            this.showNews()
+            this.showNews();
         },
 
         /** 关闭金豆奖励*/
-        _ClosedKaDou: function () {
-            var self = this
-            this.award.hide()
-            setTimeout(function () {
-                self.navlist.filter('.kadou-item').removeClass('have-award')
+        _ClosedKaDou: function() {
+            var self = this;
+            this.award.hide();
+            setTimeout(function() {
+                self.navlist.filter(".kadou-item").removeClass("have-award");
             }, 4000);
+        },
+
+        /**16点左右弹出弹窗 */
+        openTimer: function() {
+            if (!Util.isBusyTime()) {
+                var self = this;
+                var now = new Date();
+                var minutes =
+                    (15 - now.getHours()) * 60 + (60 - now.getMinutes());
+                var duration = minutes * 60 * 1000;
+                // var duration = 5 * 1000;
+                console.log("minutes:", minutes);
+                this.popupTimer = setTimeout(function() {
+                    self.getVitalNewsData(function(data) {
+                        self.renderVitalNews(data);
+                        self.showNews();
+                    });
+                }, duration);
+            }
+
+            return this;
         }
-    }
+    };
 
-    /**根据用户操作读写cookie*/
+    /**根据用户操作读写cookie
+     * 每天16:00到第二天2:00强制展开
+     * 凌晨2点以后强制保持关闭状态,至16:00
+     */
     var ClosedOption = {
-        get: function () {
-            var ret = Util.getCookie(_STORAGE_)
+        getBusy: function() {
+            var ret = Util.getCookie(_BUSY_STORAGE_);
+            return ret;
+        },
+        setBusy: function(option) {
+            Util.setCookie(_BUSY_STORAGE_, option, 1 / 3);
+        },
+        get: function() {
+            var ret = Util.getCookie(_NORMAL_STORAGE_);
             return ret;
         },
         /**option:0 / 1 */
-        set: function (option) {
-            Util.setCookie(_STORAGE_, option)
+        set: function(option) {
+            Util.setCookie(_NORMAL_STORAGE_, option, 365);
         }
-    }
-
-
-
-    var init = function () {
-        NewsPopup.getData(function (data) {
-            NewsPopup.init(data)
-
-            //暴露全局变量给其他地方调用
-            window.dwMiniNewsPopup = {
-                showKaDou: function (obj) {
-                    NewsPopup.showKaDou(obj)
-                }
+    };
+
+    var init = function() {
+        NewsPopup.getVitalNewsData(function(data) {
+            NewsPopup.initDom(data);
+            NewsPopup.renderVitalNews(data);
+        });
+
+        //暴露全局变量给其他地方调用
+        window.dwMiniNewsPopup = {
+            showKaDou: function(obj) {
+                NewsPopup.showKaDou(obj);
             }
-        })
-    }
+        };
+    };
 
     //判断是否有引入jquery
-    if (typeof $ == 'undefined') {
-        Util.getScript('//pub.dwstatic.com/common/js/jquery.js', function () {
-            init()
-        })
+    if (typeof $ == "undefined") {
+        Util.getScript("//pub.dwstatic.com/common/js/jquery.js", function() {
+            init();
+        });
     } else {
-        init()
+        init();
     }
-
-})(window, document)
+})(window, document);

+ 25 - 0
公共资源/src/newsPopup/tpl/tuku.tmpl

@@ -0,0 +1,25 @@
+<div class="big-text-news">
+    <a href="<%= news['line8']&&news['line8'].url %>?wen" class="news-link" title="<%= news['line8']&&news['line8'].title %>"
+        target="_blank">
+        <%= news['line8']&&news['line8'].title %>
+    </a>
+</div>
+<div class="dw-mini-videos-wrap">
+    <ul class="dw-mini-video-list">
+        <% for(var i =0;i<4;i++){
+            var galleryitem = gallerys[i]    
+        %>
+            <li class="dw-mini-video-item">
+                <a href="<%= galleryitem.link %>?wen" class="news-link" title="<%= galleryitem.title %>" target="_blank">
+                <img src="<%= galleryitem.picsrc %>" class="news-image" />
+                <p class="news-title">
+                    <%= galleryitem.title %>
+                </p>
+            </a>
+                <% } %>
+            </li>
+    </ul>
+</div>
+<div class="more-news">
+    <a href="http://tu.duowan.com/tu?wen" class="news-link" target="_blank">点击查看更多></a>
+</div>

+ 70 - 0
公共资源/src/newsPopup/tpl/vitalNews.tmpl

@@ -0,0 +1,70 @@
+<!--大图新闻{-->
+    <div class="big-news-wrap">
+        <a href="<%= news.headpic1&&news.headpic1.url %>?wen" class="big-news news-link" title="<%= news.headpic1&&news.headpic1.title %>"
+            target="_blank">
+            <img src="<%= news.headpic1&&news.headpic1.img %>" class="news-image" />
+            <span class="footer-shadow"><%= news.headpic1&&news.headpic1.title %></span>
+        </a>
+    </div>
+    <!--}大图新闻-->
+    <div class="main-news-wrap">
+        <!--左侧中图新闻{-->
+        <div class="middle-news-wrap">
+            <ul class="middle-news-list">
+                <% if(zhibo){%>
+                 <li class="middle-news-item">
+                    <i class="zhibo-icon">直播</i>
+                    <a href="<%= zhibo.url %>?wen" class="news-link" title="<%= zhibo.room_name %>"
+                        target="_blank">
+                        <img src="<%= zhibo.room_thumb %>" class="news-image" />
+                        <span class="footer-shadow"><%= zhibo.room_name %></span>
+                    </a>
+                </li>
+                <%}%>
+                <li class="middle-news-item">
+                    <a href="<%= news.headpic2&&news.headpic2.url %>?wen" class="news-link" title="<%= news.headpic2&&news.headpic2.title %>"
+                        target="_blank">
+                        <img src="<%= news.headpic2&&news.headpic2.img %>" class="news-image" />
+                        <span class="footer-shadow"><%= news.headpic2&&news.headpic2.title %></span>
+                    </a>
+                </li>
+                <li class="middle-news-item">
+                    <a href="<%= news.headpic3&&news.headpic3.url %>?wen" class="news-link" title="<%= news.headpic3&&news.headpic3.title %>"
+                        target="_blank">
+                        <img src="<%= news.headpic3&&news.headpic3.img %>" class="news-image" />
+                        <span class="footer-shadow"><%= news.headpic3&&news.headpic3.title %></span>
+                    </a>
+                </li>
+            </ul>
+        </div>
+        <!--}左侧中图新闻-->
+
+        <!--无图新闻列表{-->
+        <div class="text-news-wrap">
+            <ul class="text-news-list">
+                <% 
+                    for(var i = 1;i<=7;i++){
+                        var newsitem = news['line'+i]
+                        if(i==1){
+                %>
+                    <li class="first-news">
+                        <a href="<%= newsitem.url%>?wen" title="<%= newsitem.title %>" target="_blank">
+                            <%= newsitem.title %>
+                        </a>
+                        <% }else{ %>
+                    </li>
+                    <li class="type-news <%= newsitem.type+'-type' %>">
+                        <i class="type-icon"></i>
+                        <a href="<%= newsitem.url %>?wen" title="<%= newsitem.title %>" target="_blank">
+                            <%= newsitem.title %>
+                        </a>
+                    </li>
+                    <% 
+                    }
+                } 
+                %>
+            </ul>
+        </div>
+        <!--}无图新闻列表-->
+
+    </div>

+ 3 - 128
公共资源/src/newsPopup/tpl/wrap.tmpl

@@ -19,10 +19,7 @@
                 <li class="dw-mini-nav-item">
                     要闻
                 </li>
-                <!--<li class="dw-mini-nav-item">
-                    视频
-                </li>-->
-                <li class="dw-mini-nav-item">
+                <li class="dw-mini-nav-item tuku-item">
                     图库
                 </li>
                 <li class="dw-mini-nav-item kadou-item">
@@ -35,134 +32,12 @@
         <!--新闻内容 -->
         <div class="dw-mini-popup-content">
             <div class="dw-mini-news-panel popup-vital-news">
-                <!--大图新闻{-->
-                <div class="big-news-wrap">
-                    <a href="<%= news.headpic1&&news.headpic1.url %>?wen" class="big-news news-link" title="<%= news.headpic1&&news.headpic1.title %>"
-                        target="_blank">
-                        <img data-src="<%= news.headpic1&&news.headpic1.img %>" class="news-image" />
-                        <span class="footer-shadow"><%= news.headpic1&&news.headpic1.title %></span>
-                    </a>
-                </div>
-                <!--}大图新闻-->
-                <div class="main-news-wrap">
-                    <!--左侧中图新闻{-->
-                    <div class="middle-news-wrap">
-                        <ul class="middle-news-list">
-                            <% if(zhibo){%>
-                             <li class="middle-news-item">
-                                <i class="zhibo-icon">直播</i>
-                                <a href="<%= zhibo.url %>?wen" class="news-link" title="<%= zhibo.room_name %>"
-                                    target="_blank">
-                                    <img data-src="<%= zhibo.room_thumb %>" class="news-image" />
-                                    <span class="footer-shadow"><%= zhibo.room_name %></span>
-                                </a>
-                            </li>
-                            <%}%>
-                            <li class="middle-news-item">
-                                <a href="<%= news.headpic2&&news.headpic2.url %>?wen" class="news-link" title="<%= news.headpic2&&news.headpic2.title %>"
-                                    target="_blank">
-                                    <img data-src="<%= news.headpic2&&news.headpic2.img %>" class="news-image" />
-                                    <span class="footer-shadow"><%= news.headpic2&&news.headpic2.title %></span>
-                                </a>
-                            </li>
-                            <li class="middle-news-item">
-                                <a href="<%= news.headpic3&&news.headpic3.url %>?wen" class="news-link" title="<%= news.headpic3&&news.headpic3.title %>"
-                                    target="_blank">
-                                    <img data-src="<%= news.headpic3&&news.headpic3.img %>" class="news-image" />
-                                    <span class="footer-shadow"><%= news.headpic3&&news.headpic3.title %></span>
-                                </a>
-                            </li>
-                        </ul>
-                    </div>
-                    <!--}左侧中图新闻-->
-
-                    <!--无图新闻列表{-->
-                    <div class="text-news-wrap">
-                        <ul class="text-news-list">
-                            <% 
-                                for(var i = 1;i<=7;i++){
-                                    var newsitem = news['line'+i]
-                                    if(i==1){
-                            %>
-                                <li class="first-news">
-                                    <a href="<%= newsitem.url%>?wen" title="<%= newsitem.title %>" target="_blank">
-                                        <%= newsitem.title %>
-                                    </a>
-                                    <% }else{ %>
-                                </li>
-                                <li class="type-news <%= newsitem.type+'-type' %>">
-                                    <i class="type-icon"></i>
-                                    <a href="<%= newsitem.url %>?wen" title="<%= newsitem.title %>" target="_blank">
-                                        <%= newsitem.title %>
-                                    </a>
-                                </li>
-                                <% 
-                                }
-                            } 
-                            %>
-                        </ul>
-                    </div>
-                    <!--}无图新闻列表-->
-
-                </div>
-
+                
             </div>
-
-            <!--视频新闻{-->
-            <!--<div class="dw-mini-news-panel popup-videos-wrap">
-                <div class="videos-wrap">
-                    <ul class="dw-mini-video-list">
-                        <% for(var i =0;i<6;i++){
-                            var videoitem = videos[i]    
-                        %>
-                            <li class="dw-mini-video-item">
-                                <a href="<%= videoitem.link %>?wen" class="news-link" title="<%= videoitem.title %>" target="_blank">
-                                    <i class="play-icon"></i>
-                                    <img class="news-image" data-src="<%= videoitem.picsrc %>" />
-                                    <p class="news-title">
-                                        <%= videoitem.title %>
-                                    </p>
-                                </a>
-                            </li>
-                            <% } %>
-                    </ul>
-                </div>
-                <div class="more-news">
-                    <a href="http://video.duowan.com/yule/?wen" class="news-link" target="_blank">
-                点击查看更多>
-            </a>
-                </div>
-            </div>-->
-            <!--}视频新闻-->
-
             
             <!--图库新闻{-->
             <div class="dw-mini-news-panel popup-photo-gallery">
-                <div class="big-text-news">
-                    <a href="<%= news['line8']&&news['line8'].url %>?wen" class="news-link" title="<%= news['line8']&&news['line8'].title %>"
-                        target="_blank">
-                        <%= news['line8']&&news['line8'].title %>
-                    </a>
-                </div>
-                <div class="dw-mini-videos-wrap">
-                    <ul class="dw-mini-video-list">
-                        <% for(var i =0;i<4;i++){
-                            var galleryitem = gallerys[i]    
-                        %>
-                            <li class="dw-mini-video-item">
-                                <a href="<%= galleryitem.link %>?wen" class="news-link" title="<%= galleryitem.title %>" target="_blank">
-                                <img data-src="<%= galleryitem.picsrc %>" class="news-image" />
-                                <p class="news-title">
-                                    <%= galleryitem.title %>
-                                </p>
-                            </a>
-                                <% } %>
-                            </li>
-                    </ul>
-                </div>
-                <div class="more-news">
-                    <a href="http://tu.duowan.com/tu?wen" class="news-link" target="_blank">点击查看更多></a>
-                </div>
+
             </div>
             <!--}图库新闻-->