|
@@ -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);
|