(function(win, doc) { var md5=window.md5||{};!function(){function r(r){return C(t(A(r),r.length*S))}function t(r,t){r[t>>5]|=128<>>9<<4)+14]=t;for(var n=1732584193,h=-271733879,u=-1732584194,A=271733878,d=0;d16&&(e=t(e,r.length*S));for(var o=Array(16),a=Array(16),c=0;16>c;c++)o[c]=909522486^e[c],a[c]=1549556828^e[c];var h=t(o.concat(A(n)),512+n.length*S);return t(a.concat(h),640)}function f(r,t){var n=(65535&r)+(65535&t),e=(r>>16)+(t>>16)+(n>>16);return e<<16|65535&n}function u(r,t){return r<>>32-t}function A(r){for(var t=Array(),n=(1<>5]|=(r.charCodeAt(e/S)&n)<>5]>>>e%32&n);return t}function C(r){for(var t=m?"0123456789ABCDEF":"0123456789abcdef",n="",e=0;e<4*r.length;e++)n+=t.charAt(r[e>>2]>>e%4*8+4&15)+t.charAt(r[e>>2]>>e%4*8&15);return n}function i(r){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="",e=0;e<4*r.length;e+=3)for(var o=(r[e>>2]>>8*(e%4)&255)<<16|(r[e+1>>2]>>8*((e+1)%4)&255)<<8|r[e+2>>2]>>8*((e+2)%4)&255,a=0;4>a;a++)n+=8*e+6*a>32*r.length?s:t.charAt(o>>6*(3-a)&63);return n}function g(r){function t(r,t){var n=r<>>32-t;return n}function n(r){var t,n,e="";for(t=7;t>=0;t--)n=r>>>4*t&15,e+=n.toString(16);return e}function e(r){r=r.replace(/\r\n/g,"\n");for(var t="",n=0;ne?t+=String.fromCharCode(e):e>127&&2048>e?(t+=String.fromCharCode(e>>6|192),t+=String.fromCharCode(63&e|128)):(t+=String.fromCharCode(e>>12|224),t+=String.fromCharCode(e>>6&63|128),t+=String.fromCharCode(63&e|128))}return t}var o,a,c,h,f,u,A,d,C,i=new Array(80),g=1732584193,v=4023233417,l=2562383102,m=271733878,s=3285377520;r=e(r);var S=r.length,b=new Array;for(a=0;S-3>a;a+=4)c=r.charCodeAt(a)<<24|r.charCodeAt(a+1)<<16|r.charCodeAt(a+2)<<8|r.charCodeAt(a+3),b.push(c);switch(S%4){case 0:a=2147483648;break;case 1:a=r.charCodeAt(S-1)<<24|8388608;break;case 2:a=r.charCodeAt(S-2)<<24|r.charCodeAt(S-1)<<16|32768;break;case 3:a=r.charCodeAt(S-3)<<24|r.charCodeAt(S-2)<<16|r.charCodeAt(S-1)<<8|128}for(b.push(a);b.length%16!=14;)b.push(0);for(b.push(S>>>29),b.push(S<<3&4294967295),o=0;oa;a++)i[a]=b[o+a];for(a=16;79>=a;a++)i[a]=t(i[a-3]^i[a-8]^i[a-14]^i[a-16],1);for(h=g,f=v,u=l,A=m,d=s,a=0;19>=a;a++)C=t(h,5)+(f&u|~f&A)+d+i[a]+1518500249&4294967295,d=A,A=u,u=t(f,30),f=h,h=C;for(a=20;39>=a;a++)C=t(h,5)+(f^u^A)+d+i[a]+1859775393&4294967295,d=A,A=u,u=t(f,30),f=h,h=C;for(a=40;59>=a;a++)C=t(h,5)+(f&u|f&A|u&A)+d+i[a]+2400959708&4294967295,d=A,A=u,u=t(f,30),f=h,h=C;for(a=60;79>=a;a++)C=t(h,5)+(f^u^A)+d+i[a]+3395469782&4294967295,d=A,A=u,u=t(f,30),f=h,h=C;g=g+h&4294967295,v=v+f&4294967295,l=l+u&4294967295,m=m+A&4294967295,s=s+d&4294967295}var C=n(g)+n(v)+n(l)+n(m)+n(s);return C.toLowerCase()}function v(r){var t,n,e,o,a,c,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(e=r.length,n=0,t="";e>n;){if(o=255&r.charCodeAt(n++),n==e){t+=h.charAt(o>>2),t+=h.charAt((3&o)<<4),t+="==";break}if(a=r.charCodeAt(n++),n==e){t+=h.charAt(o>>2),t+=h.charAt((3&o)<<4|(240&a)>>4),t+=h.charAt((15&a)<<2),t+="=";break}c=r.charCodeAt(n++),t+=h.charAt(o>>2),t+=h.charAt((3&o)<<4|(240&a)>>4),t+=h.charAt((15&a)<<2|(192&c)>>6),t+=h.charAt(63&c)}return t}function l(r,t){for(var n="",e=0,o=r.length,a=t.length;o>e&&!(e>=a);e++)n+=String.fromCharCode(r.charCodeAt(e)^t.charCodeAt(e));return n}md5.xor=l,md5.sha1=g,md5.hex_md5=r,md5.base64encode=v;var m=0,s="",S=8}();; var cssStyle = ".dw-mini-popup-wrap{position:fixed;right:-380px;bottom:0;width:300px;height:426px;background:#fff;box-shadow:0 0 3px 0 #dcdcdc;*border:1px solid #f6f6f6;font-family:\"Microsoft Yahei\";z-index:1001;text-align:left}.dw-mini-popup-wrap.show{right:0}.dw-mini-popup{position:relative;width:100%;height:100%}.dw-mini-popup ul{list-style:none;margin:0;padding:0}.dw-mini-popup a{text-decoration:none}.dw-mini-popup .footer-shadow{position:absolute;left:0;width:100%;bottom:0;background-color:#000;background-color:rgba(0,0,0,.8);filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=80);color:#fff;font:12px/24px Simsun;text-align:center}.dw-mini-popup .news-image{display:block;width:100%;border:0}.dw-mini-popup .news-link{position:relative;display:block;color:#333;overflow:hidden}.dw-mini-popup .dw-popup-title{height:40px;padding-left:10px;background:#e94646;overflow:hidden}.dw-popup-title .popup-title{float:left;height:100%}.dw-popup-title .dw-popup-hide{float:right;width:8px;height:40px;padding:0 10px;background:url(http://pub.ouj.com/common//newsPopup/assets/popup_hide_daaa1a4.png) no-repeat center;cursor:pointer}.dw-popup-title .dw-popup-hide:hover{background-color:#ed6c6c}.dw-popup-title .web-address{float:left;cursor:pointer}.dw-popup-title .dw-popup-icon{float:left;height:40px;width:26px;background:url(http://pub.ouj.com/common//newsPopup/assets/dw_mini_popup_logo_558e01d.png) no-repeat center}.dw-popup-title .popup-title .dw-name{float:left;width:60px;height:20px;background:url(http://pub.ouj.com/common//newsPopup/assets/dw_big_text_1c49840.png) no-repeat center;margin:10px 5px;color:#fff}.dw-popup-title .popup-title .dw-popup-tip{float:left;margin-top:18px;*margin-top:16px;font:12px/1 SimSun;color:#ffc0c0}.dw-mini-popup .dw-mini-popup-nav{border-bottom:1px solid #e3e3e3;background:#fafafa;font-size:14px;line-height:33px;text-align:center}.dw-mini-popup .dw-mini-popup-nav .dw-mini-nav-list{height:34px;margin:0 -30px 0 0}.dw-mini-popup .dw-mini-popup-nav .dw-mini-nav-item{position:relative;display:inline-block;*display:inline;*zoom:1;margin-right:30px;color:#333;cursor:pointer}.dw-mini-popup .dw-mini-popup-nav .have-award:after{content:'';position:absolute;left:-5px;top:0;height:100%;width:42px;background:#fafafa url(http://pub.ouj.com/common//newsPopup/assets/kadow_active_41043b5.gif) no-repeat left center}.dw-mini-popup .dw-mini-popup-nav .dw-mini-nav-item.active{border-bottom:2px solid #e94646;font-weight:700;color:#e94646}.dw-mini-popup .dw-mini-popup-content{overflow:hidden}.dw-mini-news-panel{display:none}.dw-mini-news-panel.active{display:block}.popup-vital-news{padding:10px 10px 0}.popup-vital-news .big-news-wrap{width:278px;height:156px;position:relative}.popup-vital-news .big-news-wrap .big-news{display:block;height:100%;overflow:hidden}.popup-vital-news .big-news-wrap .footer-shadow{height:24px}.popup-vital-news .main-news-wrap{overflow:hidden;margin-top:10px}.popup-vital-news .main-news-wrap .middle-news-wrap{float:left;width:116px}.middle-news-wrap .middle-news-item{position:relative;height:78px;margin-bottom:10px;overflow:hidden}.middle-news-wrap .middle-news-item .zhibo-icon{position:absolute;top:0;right:0;font-size:12px;font-style:normal;font:12px/1 Simsun;padding:3px;color:#fff;line-height:1;z-index:9;background-color:#e94646}.middle-news-wrap .news-link{height:100%}.middle-news-wrap .middle-news-item .footer-shadow{height:24px}.popup-vital-news .main-news-wrap .text-news-wrap{float:left;width:150px;margin-left:10px;font-size:0;color:#333;overflow:hidden}.text-news-list li{overflow:hidden;*zoom:1}.text-news-list .first-news a{font-size:14px;font-weight:700;line-height:24px;color:#e94646}.text-news-list a{display:block;height:24px;font-size:12px;line-height:24px;color:#333;overflow:hidden;text-overflow:clip;*zoom:1}.text-news-list a:hover{color:#e94646;text-decoration:underline}.text-news-list .type-news{font-family:SimSun}.text-news-list .type-news i{float:left}.text-news-list .type-news.normal-type i,.text-news-list .type-news.red-type i{width:2px;height:2px;margin:13px 5px 0 0;background-color:#f60}.text-news-list .type-news.red-type a{color:#e94646}.text-news-list .type-news.video-type i,.text-news-list .type-news.image-type i{width:20px;height:24px;background-color:#ff7d1a}.text-news-list .type-news.video-type i{background:url(http://pub.ouj.com/common//newsPopup/assets/news_type_video_c0c01d2.png) no-repeat left center}.text-news-list .type-news.image-type i{background:url(http://pub.ouj.com/common//newsPopup/assets/news_type_image_90a12e7.png) no-repeat left center}.popup-videos-wrap .dw-mini-video-list{margin-right:-10px;padding:10px 10px 0;border-bottom:1px solid #e3e3e3;font-family:Simsun;overflow:hidden}.popup-videos-wrap .dw-mini-video-item{float:left;width:134px;margin-right:10px}.popup-videos-wrap .dw-mini-video-item .play-icon{position:absolute;width:16px;height:16px;background-image:url(http://pub.ouj.com/common//newsPopup/assets/play_icon_efee776.png);left:5px;top:50px}.popup-videos-wrap .news-image{height:73px}.popup-videos-wrap .news-title{margin:0;height:32px;font:12px/32px PingFang sc,\"Helvetica Neue\",Helvetica,Tahoma,Arial,SimSun,TW-Sung,\"WenQuanYi Bitmap Song\",\"AR PL UMing CN\",\"AR PL UMing HK\",\"AR PL UMing TW\",\"AR PL UMing TW MBE\",serif;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width:100%}.popup-videos-wrap .more-news{font:12px/25px Simsun;text-align:center}.more-news .news-link{color:#333}.more-news .news-link:hover{color:#e94646}.popup-photo-gallery{font-family:Simsun}.popup-photo-gallery .big-text-news{height:38px;margin-top:3px;font-size:14px;font-weight:700;line-height:38px;text-align:center;overflow:hidden}.big-text-news .news-link{color:#e94646}.popup-photo-gallery .dw-mini-video-list{margin-right:-10px;padding:0 10px;border-bottom:1px solid #e3e3e3;overflow:hidden}.popup-photo-gallery .dw-mini-video-item{float:left;width:134px;margin-right:10px}.popup-photo-gallery .news-image{height:92px}.popup-photo-gallery .news-title{height:36px;margin:7px 0;font-size:12px;line-height:18px;overflow:hidden;width:100%}.popup-photo-gallery .more-news{font-size:12px;line-height:25px;text-align:center}.popup-kadou-wrap{padding:5px 15px 0}.popup-kadou-wrap .base-btn{display:block;border:0;padding:0;margin:0 auto;background-color:transparent;outline:0}.popup-kadou-wrap .kadou-box{height:228px;overflow:hidden}.popup-kadou-wrap .kadou-info-box .kadou-info{text-align:center;font-size:0;line-height:30px;margin-bottom:3px}.popup-kadou-wrap .kadou-info-box .kadou-icon{display:inline-block;*display:inline;*zoom:1;width:20px;height:20px;vertical-align:middle;background:url(http://pub.ouj.com/common//newsPopup/assets/kadou_icon_0a28d35.png) no-repeat center}.popup-kadou-wrap .kadou-info-box .kadou-num{display:inline-block;*display:inline;*zoom:1;vertical-align:middle;font-size:14px;line-height:30px;color:#333;font-style:normal}.popup-kadou-wrap .kadou-info-box .daliy-lottery{width:100%;height:36px;line-height:36px;text-align:center;font-size:14px;color:#fff;cursor:pointer;border-radius:3px;background-color:#ffb018}.popup-kadou-wrap .kadou-info-box .daliy-lottery.lottery-finished{background-color:#c8c8c8}.popup-kadou-wrap .not-login-box{margin-top:10px}.popup-kadou-wrap .not-login-box .login-btn{width:100%;height:34px;border:1px solid #e94646;line-height:34px;text-align:center;font-size:14px;color:#ec6969;cursor:pointer;border-radius:3px}.popup-kadou-wrap .not-login-box .register-btn{width:100%;height:26px;line-height:36px;text-align:center;font-size:12px;color:#333;cursor:pointer;overflow:hidden}.popup-kadou-wrap .box-hd{*zoom:1}.popup-kadou-wrap .box-hd:before,.popup-kadou-wrap .box-hd:after{content:'';display:table;line-height:0}.popup-kadou-wrap .box-hd:after{clear:both}.popup-kadou-wrap .box-hd h3{float:left;margin:0;font-size:14px;line-height:40px;color:#999;font-weight:400}.popup-kadou-wrap .box-hd a{float:right;padding-right:13px;font-size:14px;line-height:40px;color:#999;background:url(http://pub.ouj.com/common//newsPopup/assets/arrow_icon_8526d9c.png) no-repeat right center}.popup-kadou-wrap .task-list li{margin-bottom:7px;height:24px;font-size:12px;line-height:24px;*zoom:1}.popup-kadou-wrap .task-list li a{vertical-align:top}.popup-kadou-wrap .task-list li.last-task{margin-bottom:0}.popup-kadou-wrap .task-list li:before,.popup-kadou-wrap .task-list li:after{content:\"\";display:table;line-height:0}.popup-kadou-wrap .task-list li:after{clear:both}.popup-kadou-wrap .task-list .task-name{float:left;white-space:nowrap;word-wrap:normal;overflow:hidden;text-overflow:ellipsis;text-align:left;color:#333;width:213px;line-height:24px;text-decoration:none}.popup-kadou-wrap .task-list .state-finished,.popup-kadou-wrap .task-list .state-notyet,.popup-kadou-wrap .task-list .state-ing{float:right;width:53px;height:22px;border:1px solid #e94646;text-align:center;color:#fff;background-color:#e94646;line-height:22px;border-radius:2px;cursor:pointer}.popup-kadou-wrap .task-list .state-ing:hover,.popup-kadou-wrap .task-list .state-notyet:hover,.popup-kadou-wrap .task-list .state-finished:hover{opacity:.8}.popup-kadou-wrap .task-list .state-notyet{color:#e94646;background-color:transparent}.popup-kadou-wrap .task-list .state-finished{border:1px solid #bebebe;background-color:transparent;color:#c6c6c6}.popup-kadou-wrap .exchange-list{font-size:0;margin-right:-4px}.popup-kadou-wrap .exchange-list li{display:inline-block;*display:inline;*zoom:1;vertical-align:top;width:62px;height:62px;border:1px solid #bebebe;margin-right:4px}.popup-kadou-wrap .exchange-list li a,.popup-kadou-wrap .exchange-list li img{position:relative;display:block;width:100%;height:100%}.popup-kadou-wrap .exchange-list .exchange-gold{position:absolute;left:0;bottom:0;width:100%;height:17px;font-size:12px;line-height:17px;color:#fff;text-align:center;background:url(http://pub.ouj.com/common//newsPopup/assets/shadow_icon_f3abc38.png) repeat-x;font-style:normal}.dw-mini-popup-littleboy{width:60px;height:90px;position:absolute;bottom:0;left:-52px;cursor:pointer;background:url(http://pub.ouj.com/common//newsPopup/assets/dw_news_littleboy_15b83cd.png) no-repeat}.dw-mini-popup-littleboy:hover{animation:boybounce .8s 1 ease backwards}@keyframes boybounce{0%,100%,20%,50%,80%{-webkit-transform:translateY(0);transform:translateY(0)}40%{-webkit-transform:translateY(-12px);transform:translateY(-12px)}60%{-webkit-transform:translateY(-5px);transform:translateY(-5px)}}.dw-min-popup-dancer{position:fixed;width:52px;height:75px;right:-60px;bottom:50px;border:0;cursor:pointer;z-index:9999;background:url(http://pub.ouj.com/common//newsPopup/assets/dw_min_popup_dancer_2f54c22.png) no-repeat}.dw-min-popup-dancer:hover{background-image:url(http://pub.ouj.com/common//newsPopup/assets/dw_min_popup_dancer_64a930f.gif)}.dw-min-popup-dancer.show{right:0}.dw-mini-popup-award{position:absolute;left:0;right:0;top:40px;bottom:0}.dw-mini-popup-award .dw-mini-award-bg{position:absolute;left:0;top:0;width:100%;height:100%;background:url(http://pub.ouj.com/common//newsPopup/assets/award-bg_7aa0bad.png) repeat}.dw-mini-popup-award .dw-mini-award-warp{position:absolute;left:50%;top:50%;width:230px;height:122px;margin-left:-115px;margin-top:-61px;background-color:#fff;z-index:9}.dw-mini-popup-award .dw-mini-award-msg{width:170px;margin:16px auto 0;font-size:13px;font-weight:700;line-height:1.6;color:#000;text-align:center}.dw-mini-popup-award .dw-mini-award-link{display:block;width:80px;height:30px;margin:16px auto 0;font-size:13px;line-height:30px;color:#fff;text-align:center;background-color:#ed5454;text-decoration:none;cursor:pointer}"; var template = function(obj){ var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; with(obj||{}){ __p+='
\r\n
\r\n \r\n
\r\n \r\n \r\n
\r\n \r\n\r\n \r\n
\r\n
    \r\n
  • \r\n 要闻\r\n
  • \r\n
  • \r\n 图库\r\n
  • \r\n
  • \r\n 金豆\r\n
  • \r\n
\r\n
\r\n \r\n\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n
\r\n \r\n\r\n\r\n\r\n \r\n
\r\n \r\n
\r\n\r\n \r\n
\r\n
\r\n \r\n\r\n \r\n \r\n \r\n\r\n
'; } return __p; }; var vitalNewsTpl = function(obj){ var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; with(obj||{}){ __p+='\r\n \r\n \r\n
\r\n \r\n \r\n \r\n\r\n \r\n
\r\n \r\n
\r\n \r\n\r\n
'; } return __p; }; var tukuTpl = function(obj){ var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; with(obj||{}){ __p+='\r\n
\r\n \r\n
\r\n'; } return __p; }; var kaTpl = function(obj){ var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; with(obj||{}){ __p+='
\r\n '; if(isLogin){ __p+='\r\n \r\n '; }else{ __p+='\r\n \r\n '; } __p+='\r\n\r\n
\r\n
\r\n

金豆任务

\r\n 更多\r\n
\r\n \r\n
\r\n
\r\n\r\n
\r\n
\r\n

热门兑换

\r\n 更多\r\n
\r\n\r\n \r\n
'; } return __p; }; 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("") .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);