document.body.addEventListener("touchstart", function () { }, false); FastClick.attach(document.body); var _pageSourceFrom = "browser"; var _gameType = 2; var _isYiXIN = false; var _isUnicom = false; var _isIos = /iphone|ipad/i.test(navigator.userAgent); var _from = null; if (/from=([^&=]+)/i.test(location.search)) { _from = RegExp.$1; } if (navigator.userAgent.indexOf("NeteaseComic") >= 0) { _gameType = 3; _pageSourceFrom = "manhua"; } else if (/yixin/i.test(navigator.userAgent)) { _gameType = 1; _isYiXIN = true; _pageSourceFrom = "yixin"; } else if (/unicom/i.test(navigator.userAgent)) { _isUnicom = true; _gameType = 2; _pageSourceFrom = "liantong"; } var _isAosSDK = /YXGameSDK/i.test(navigator.userAgent); if (_isAosSDK || _isYiXIN) { _gameType = 1; _pageSourceFrom = "xuanfuqiu"; } if (_from == "unicom") { _gameType = 2; _pageSourceFrom = "liantong"; } else if (_from == "wymm") { _gameType = 3; _pageSourceFrom = "manhua"; } else if (_from == "yixin") { _gameType = 1; _pageSourceFrom = "yixin"; } var _showQrcod = !(/android/i.test(navigator.userAgent)); var _adTopics = [{ name: "武动乾坤", link: "https://manhua.163.com/source/4610644654650092027", img: "http://nosdn-yx.127.net/yxgame/78a0a2f122a94de7858931440939bb6e.jpeg" }, { name: "斗罗大陆", link: "https://manhua.163.com/source/4573238801760108343", img: "http://nosdn-yx.127.net/yxgame/2b22d48f48254b53a888295efc70c8ee.jpg" }, { name: "帝少别太猛", link: "https://manhua.163.com/source/4808133871500117914", img: "http://nosdn-yx.127.net/yxgame/b87661841f3d405a94d3b5ecdc855141.jpg" }]; var _topicsList = [{ name: "幽冥诡匠", link: "https://manhua.163.com/source/5108295818580343008", img: "http://nosdn-yx.127.net/yxgame/6763a72acc224648bcd85950356f090d.jpg" }, { name: "元尊", link: "https://manhua.163.com/source/5120932159120128638", img: "http://nosdn-yx.127.net/yxgame/e4cb7e24d1794d56a6fbf178dcf86dbe.jpg" }, { name: "这个男友太会撩", link: "https://manhua.163.com/source/4886099943680354529", img: "http://nosdn-yx.127.net/yxgame/79c61b623481484ca00ba2f558b059a6.jpg" }, { name: "厄运之王", link: "https://manhua.163.com/source/4771945676810120861", img: "http://nosdn-yx.127.net/yxgame/5510cf28706f4928af66263c8a313367.jpg" }, { name: "我是人类,更是吸血鬼", link: "https://manhua.163.com/source/5043514892150354047", img: "http://nosdn-yx.127.net/yxgame/bcbba93f3b1b4324949d4351f94baf55.jpg" }, { name: "我在后宫当巨巨", link: "https://manhua.163.com/source/4844371285780343897", img: "http://nosdn-yx.127.net/yxgame/fff3570e7b0c456ba6fc0186b9446117.jpg" }, { name: "控妹狂战记", link: "https://manhua.163.com/source/4751245936130130207", img: "http://nosdn-yx.127.net/yxgame/a750f29b0aba4f3597e8fa366bb551cf.jpg" }, { name: "老司机食用手册", link: "https://manhua.163.com/source/5063790584350353051", img: "http://nosdn-yx.127.net/yxgame/d66a885b55a44606b7f0987e0f70259e.jpg" }, { name: "讨喜笨王妃", link: "https://manhua.163.com/source/4376930639940112883", img: "http://nosdn-yx.127.net/yxgame/094903b8e4094970b1b714833230f1b3.jpg" }, { name: "吾乃不死神", link: "https://manhua.163.com/source/4639712296520118385", img: "http://nosdn-yx.127.net/yxgame/5b3c2799ba424ec7a17f7e0ba624f2d6.jpg" }, { name: "爱我吧,苏东坡", link: "https://manhua.163.com/source/4961322651750342291", img: "http://nosdn-yx.127.net/yxgame/e10bedeed832407e90119e7715bb113a.jpg" }, { name: "掉进书里当神受", link: "https://manhua.163.com/source/4996723140190119392", img: "http://nosdn-yx.127.net/yxgame/b2516dfe12ba46d9bc2e3d9d811663d2.jpg" }, { name: "天才医仙", link: "https://manhua.163.com/source/4577380875630090313", img: "http://nosdn-yx.127.net/yxgame/9833a0cd51b64467b09322f1b36d8e43.jpeg" }, { name: "永恒至尊", link: "https://manhua.163.com/source/4828421593230128690", img: "http://nosdn-yx.127.net/yxgame/bd590536e6b64eba9deeb7932ca802df.jpg" }, { name: "我才不会被女孩子欺负呢", link: "https://manhua.163.com/source/4316808069910049882", img: "http://nosdn-yx.127.net/yxgame/e33d0219fc224321ae5a30116536b6e3.jpeg" }]; function getGameList(_type) { _type = _type || _gameType; var _resutl = null; $.get(cfg_game_root + "/comics/games", {gameType: _type}).success(function (_res) { if (_res && _res.code == 200) { _resutl = _res; } }).always(function () { DATracker.track("pageclick", {type: _pageSourceFrom}); if (!_resutl) { console && console.error("接口无数据"); return; } $(".game-list-wraper").empty().append($("#J-gameList-model").tmpl(_resutl.result, { showQrcod: !_isIos && _showQrcod, isYixin: _isYiXIN, pageSourceFrom: _pageSourceFrom })); if (_showQrcod) { $('[data-insert=qrcode]').each(function () { var _wself = $(this); var _url = _wself.attr('data-href'); if (_url.indexOf('/c/apk-url-open?download') < 0) { if (_url.indexOf("?") >= 0) { _url = _url + "&view_from=qrcode"; } else { _url = _url + "?view_from=qrcode"; } _url = "http://open.game.163.com/c/apk-url-open?download=" + encodeURIComponent(_url); if (_isAosSDK) { _url = _url + "&outyxgamesdk=true"; } _wself.attr("data-href", _url); } _wself.qrcode({text: _url, width: 100, height: 100, correctLevel: 1}); }); } }); }; function getActivityList() { var _resutl = null; $.get(cfg_game_root + "/comics/activities").success(function (_res) { if (_res && (_res.code == 600 || _res.code == 200)) { _resutl = _res; } }).always(function () { if (!_resutl) { console && console.error("接口无数据"); return; } $(".activity-list").empty().append($("#J-activityList-model").tmpl(_resutl.result)); }); }; function toJoinActivity(_type, _dom) { $.mask(); var _msg = "参加失败,请稍后重试"; $.ajax({ type: "post", url: cfg_game_root + "/comics/prize", contentType: "application/json", data: JSON.stringify({activityType: _type}), dataType: "json", processData: false }).success(function (_res) { if (_res && _res.code == 200 && _res.result.code && _res.result.status == 2) { _msg = null; $(_dom).attr("data-jsonValue", JSON.stringify(_res.result)).addClass("ui-btn-disabled").text("已领取").attr("data-joined", 1); showPrizeDialog(_res.result); } else if (_res && _res.code == 600) { _msg = null; window.window.g_isLogin = false; gotoUrsLogin(); } else { _msg = _res.msg || _msg; } }).error(function () { }).always(function () { $.mask("close"); if (_msg) { $('html, body').animate({scrollTop: $(".game-list").offset().top}, 200); } }); }; function gotoUrsLogin(_url) { _url = _url || location.href; if ($.singlePageApp) { var _state = $.singlePageApp.getLocationState(); _url = _url || _state && _state.url || ''; } _url = _url.indexOf(":\/\/") > 0 ? _url : location.href; location.href = cfg_game_root + "/game-center/login?then=" + encodeURIComponent(_url); }; function showPrizeDialog(_prize) { $(".ui-popDialog-prize").dialog({ "title": "", "modal": true, "width": "auto", "dialogClass": "ui-dialog-prizeAlert", "minWidth": 300, resizable: !!0, show: {effect: "drop", duration: 200, direction: "up"}, hide: {effect: "drop", duration: 200, direction: "up"}, open: function () { var _wself = $(this); _wself.find(".prize-name").text(_prize.prizeName || ''); _wself.find(".prize-code-str").text(_prize.code || ''); $(".js-copy,.prize-code").clipboardCopy({ copy: function () { return $.trim($(".ui-popDialog-prize .prize-code-str").text()); }, afterCopy: function () { $.toast("已复制到剪贴板"); } }); }, close: function () { $(".js-copy,.prize-code").clipboardCopy("destroy"); } }); }; function openUrl(_url, _opener) { (_opener && _opener.location && _opener.location.href && _opener || window).location.href = _url; }; function renderTopics() { $(_topicsList).each(function (_i, _item) { _item.seq = _i + 1; }); $(_adTopics).each(function (_i, _item) { _item.seq = _i + 1; }); $("#J-wymm-topics .swiper-wrapper").empty().append($("#J-topics-model").tmpl(_topicsList, {viewType: "worklist"})); $("#J-wymm-topics-pop .swiper-wrapper").empty().append($("#J-topics-model").tmpl(_adTopics, {viewType: "pop_worklist"})); $("#J-wymm-topics,#J-wymm-topics-pop").each(function () { var _wself = $(this); $(this).swiper({ slidesPerView: "auto", freeMode: true, direction: 'horizontal', spaceBetween: _wself.is("#J-wymm-topics") ? 10 : 0, slidesOffsetAfter: 0, preventLinksPropagation: true, preventClicks: true, preventClicksPropagation: true, scrollbar: '.swiper-scrollbar', scrollbarHide: false, lazyLoading: true, lazyLoadingInPrevNext: true, watchSlidesProgress: true, watchSlidesVisibility: true, autoplayDisableOnInteraction: false, grabCursor: true, autoResize: false, calculateHeight: true, updateOnImagesReady: true, onTap: function (_swiper, _event) { var _wself = $(_swiper.clickedSlide); var _type = _wself.attr("data-viewType"); var _evtName = "works click"; var _seq = _wself.attr("data-seq"); var _link = _wself.find("a").attr("href"); if (_type == "pop_worklist") { _evtName = "rewardworkclick"; } _wself.data("trackeventdone", 1); DATracker.track(_evtName, {name: _seq}, function () { _wself.data("trackeventdone", 0); _wself.trigger("click"); }); } }) }); $(window).bind("resize", function () { if ($("#J-wymm-topics .swiper-wrapper").width() >= 640) { $("#J-wymm-topics .swiper-wrapper .swiper-slide").css("width", "7rem"); } else { $("#J-wymm-topics .swiper-wrapper .swiper-slide").css("width", "24%"); } $("#J-wymm-topics").swiper() && $("#J-wymm-topics").swiper().update(); }).trigger("resize"); };$(document).delegate(".ui-widget-overlay", "click", function () { $(".ui-popDialog-prize:visible").length && $(".ui-popDialog-prize").dialog("close"); }); $(".ui-popDialog-prize").bind("click", function (_e) { _e.stopImmediatePropagation(); }); $(document).delegate('[data-needLogin="1"]', "click", function () { var _wself = $(this); if (!_wself.is(".w-activity .ui-btn")) { return false; } if (_isIos) { $.toast("活动仅限安卓用户,iOS用户敬请期待"); return false; } var _isJoined = _wself.is("[data-joined=1]"); var _json = JSON.parse(_wself.attr("data-jsonValue")); if (_isJoined) { showPrizeDialog(_json); } else { DATracker.track("getrewardclick", {name: _json.type}, function () { toJoinActivity(_json.type, _wself); }); } return false; }); $(document).delegate('[data-view="qrcode"]', "click", function () { var _url = $(this).attr("data-href"); $.alert('

', { title: "查看大图", open: function () { var _dialogDom = $(this).find("p"); _dialogDom.qrcode({ text: _url, width: _dialogDom.width(), height: _dialogDom.height(), correctLevel: 0 }); } }); return false; }); $(document).delegate(".ui-game", "click", function (_e) { if (_isIos) { $.toast("活动仅限安卓用户,iOS用户敬请期待"); return false; } var _target = $(_e.target); if (_target.is(".ui-btn")) { DATracker.track("downloadclick", {name: $(this).attr('data-gameName')}, function () { openUrl(_target.attr("href")); }); } else { openUrl($(this).attr('data-href')); } }); var _timer = null; var _hasReportRuleShow = false; var _reportCB = function (_show) { DATracker.track("ruleshow", {bubblestatus: _show ? 1 : 0}); }; var _timeoutTimer = setTimeout(function () { $(window).unbind("scroll"); _hasReportRuleShow = true; _reportCB(false); }, 300000); $(window).bind("scroll", function () { _timer = setTimeout(function () { var _h = document.documentElement.scrollTop + window.innerHeight; var _h2 = $(".activity-rules").offset().top; if (_h > _h2 && !_hasReportRuleShow) { $(window).unbind("scroll"); _hasReportRuleShow = true; clearTimeout(_timeoutTimer); _reportCB(true); } }, 20); }); if (_gameType != 3) { renderTopics(); } else { $(".wymm-topics").remove(); } getGameList(_gameType); getActivityList();