window.cfg_nil_img = window.cfg_nil_img || window.cfg_game_nilImg; /*** function tryParseCookie() { try { var _appInfo = $.cookie("ncg_app_info"); if (_appInfo) { _appInfo = window.atob(_appInfo); if (_appInfo && /[{][^{]*appId[^}]+[}]/i.test(_appInfo)) { _appInfo = JSON.parse(_appInfo); if (_appInfo && _appInfo.appId) { _appInfo.channelAppId = _appInfo.appId; } window.__APPINFO = $.extend({}, window.__APPINFO || {}, _appInfo); window.__oldFeedbackParms = $.extend({}, window.__oldFeedbackParms || {}, _appInfo); } } } catch (_error) { console.error(_error); } if (appId) { window.__APPINFO = $.extend({}, window.__APPINFO, {channelAppId: appId, appId: appId}); window.__oldFeedbackParms = $.extend({}, window.__oldFeedbackParms, {channelAppId: appId, appId: appId}); } }; ***/ $.wbJsRequired2(["Promise", "IntersectionObserver", cfg_root_js + "/min/FastClick.min.js"], function () { FastClick.attach(document.body); if (window.DATracker) { window.DATracker.pageview_attributes = {pageSourceType: "miniActivityPage"}; } var _isIos = /ios|iphone/i.test(navigator.userAgent); var _isAndroid = /android/i.test(navigator.userAgent); window.getJsonFromResponse = function (res) { var json = null; if (res) { if (typeof res === "string" && res.indexOf("{") >= 0) { try { json = JSON.parse(res); } catch (e) { json = null; } } else if (res instanceof Object) { try { json = Object.assign({}, res); } catch (e) { json = null; } } } return json; }; var _platform = /(ios)|(iphone)/i.test(navigator.userAgent) ? "ios" : "aos"; var __UID = ""; var _gamePageId; var _game; var _dialogSelectors = {cancel: null, confirm: null}; var _activityDataMap = {}; var _giftDataMap = {}; var _dpGameCenterUrl = cfg_game_root + "/dp-sdk/webview"; window.prizeNullDefault = [cfg_resource_root + "/images/webview/ico_prize_null_0_2x.png", cfg_resource_root + "/images/webview/ico_prize_null_1_2x.png"]; if (/gamePageId=([1-9]\d*)/i.test(location.search)) { _gamePageId = RegExp.$1; } /** function (request) { request.setRequestHeader("channelappid", appId || window.__oldFeedbackParms && window.__oldFeedbackParms.channelAppId || ''); request.setRequestHeader("channeltoken", window.__oldFeedbackParms && window.__oldFeedbackParms.channelUserToken || ''); }; **/ function updatePageView(_data) { var _bgList = []; _data.images = _data.images.split(";"); $(_data.images).each(function (_i, _url) { var _item = {}; var _src = _url.replace(/rect=(\d+)x(\d+)&?/i, function (_$, _$1, _$2) { _item.width = _$1; _item.height = _$2; return ""; }); _item.src = _src + "?imageView&thumbnail=0x" + Math.floor(window.innerWidth * window.devicePixelRatio); if (_item.width && _item.height) { _item.minHeight = Math.floor(_item.height / _item.width) + "%"; } _bgList.push(_item); }); _data.images = _bgList; document.title = _data.name || "网易云游戏"; if (window.NCGObject && window.NCGObject.setPageTitle) { try { window.NCGObject.setPageTitle(document.title); } catch (_error) { } } $(_data.videos || []).each(function (i, item) { item.cssStyle = (item.cssStyle || '').replace(/(\d+([.]\d+)?)rem/img, function (_str, _$1) { return Number(_$1) / 2 + "rem "; }).replace(/(\d+([.]\d+)?)px/img, function (_str, _$1) { return _$1 !== '1' ? (Math.floor(Number(_$1)) / 100 + "rem ") : '1px'; }); }); $(_data.clickItems || []).each(function (i, item) { item.cssStyle = (item.cssStyle || '').replace(/(\d+([.]\d+)?)rem/img, function (_str, _$1) { return Number(_$1) / 2 + "rem "; }).replace(/(\d+([.]\d+)?)px/img, function (_str, _$1) { return _$1 !== '1' ? (Math.floor(Number(_$1)) / 100 + "rem ") : '1px'; }); }); $(".g-flexScroll-scroll .flexScroll-inner").empty().append($("#J-page-tmpl").tmpl(_data)).hide(); window.updateLazyLoad(document, true); $("[data-clickType=1]").attr("data-clickURI", _data.channelGameId); $(".g-flexScroll-scroll .flexScroll-inner").fadeIn(function () { if (_data.haveDownloadButton) { $(".flex-input").slideDown(200); } else { $(".flex-input").hide(); } }); if (!_game || (_game.gameId != _data.channelGameId)) { _game = null; $.customAjax(cfg_game_root + "/yun/webview/game/detail", { gameId: _data.channelGameId, op: _platform }, {postJson: true/**, beforeSend: beforeSend**/}).always(function (_res) { if (_res && _res.code == 200) { _game = _res.result; updateGameStatus(); } }); } }; function getActivityDetail(_id) { return new Promise(function (resolve, reject) { if (_activityDataMap[_id]) { resolve({activity: _activityDataMap[_id]}); return; } $.customAjax(cfg_game_root + "/yun/webview/activity-detail", {activityId: _id, op: "aos"}, { postJson: true/**, beforeSend: beforeSend***/ }).always(function (_res) { if (_res && _res.code == 200) { resolve({activity: _res.result}); } else { reject(); } }); }); }; function uidReady(_u) { __UID = __UID || _u || ""; }; function updateGameDownloadBtnText() { if (_game) { var _text = "下载游戏"; if (!_game.downloadURL) { _text = '敬请期待'; } else if (_isIos) { _text = "进入游戏"; } else { if (_game.localStatus == 1) { _text = "启动游戏"; } else if (_game.localStatus == 4 || _game.localStatus == 3) { _text = "安装游戏"; } else { _text = "下载游戏"; } } $(".g-flexScroll .flex-input .w-btn-download").attr("data-content-text", _text); } }; function updateGameStatus() { if (!_game) { return; } if (window.NCGObject && window.NCGObject.getGameListStatus) { var _newGame = _game; try { var _tmp = JSON.parse(window.NCGObject.getGameListStatus(JSON.stringify([_game]))); if ($.isArray(_tmp)) { _tmp = _tmp[0] } else if (!$.isPlainObject(_tmp)) { _tmp = null; } if (_tmp) { _newGame = $.extend(_newGame, _tmp); } } catch (_error) { } _game = _newGame; } else { _game.localStatus = 0; } updateGameDownloadBtnText(); }; function openGame(_actionType) { if (!_game) { $.customDialog("缺少该游戏的信息"); return; } else if (!_game.downloadURL) { $.customToast("敬请期待"); } if (window.NCGObject && window.NCGObject.openGame) { var _json = JSON.stringify(_game); if (_game.localStatus == 1 || _actionType == 1) { window.NCGObject.openGame(_json); } else if (_game.localStatus == 4 || _game.localStatus == 3 || _actionType == 4 || _actionType == 3) { window.NCGObject.installGame(_json); } else { window.NCGObject.startDownloadGame(_json); window.NCGObject && _isAndroid && $.customDialog("游戏已经开始下载,你可以进入游戏中心查看下载进度。", { confirm: { text: "进入游戏中心", click: function () { location.href = _dpGameCenterUrl + "?game_TrackReferrer=mini_downloadTips_btn"; } } }); } } else { location.href = _game.downloadURL; } }; function tapDialogBtns(_cbData) { if (_cbData && _cbData.index == 0) { _dialogSelectors.cancel && $.isFunction(_dialogSelectors.cancel.click) && _dialogSelectors.cancel.click(); dismissWinningDialog(); } else if (_cbData && _cbData.index == 1) { _dialogSelectors.confirm && $.isFunction(_dialogSelectors.confirm.click) && _dialogSelectors.confirm.click(); dismissWinningDialog(); } };window.showWinningResultDialog = function showWinningResultDialog(_Dialogdata) { _Dialogdata = _Dialogdata || {}; _dialogSelectors.confirm = _Dialogdata.confirm; var _btnTxts = []; if (_dialogSelectors.confirm) { _dialogSelectors.cancel = _Dialogdata.cancel || {txt: "取消", click: null}; _btnTxts = _btnTxts.concat(_dialogSelectors.cancel.txt, _dialogSelectors.confirm.txt); } var _resultPopo = $(".g-page:last .g-winning-result"); var _inner = _resultPopo.find(".winning-result"); if (_Dialogdata.prizeType == 1) { _resultPopo.addClass("g-winning-result-no").removeClass("g-winning-result-has"); } else { _resultPopo.addClass("g-winning-result-has").removeClass("g-winning-result-no"); } if (_Dialogdata.hiddenCancelBtn) { _inner.find(".result-btn-ignore").hide(); _inner.find(".result-btn-warnning").css("float", "none"); } else { _inner.find(".result-btn-ignore").show(); _inner.find(".result-btn-warnning").css("float", "none"); } _resultPopo.fadeIn("fast", function () { _inner.find(".msg-title").text(_Dialogdata.title); _inner.find(".msg-txt").text(_Dialogdata.message); _inner.find(".msg-img").attr("src", _Dialogdata.prizeImg)[_Dialogdata.prizeImg ? "show" : "hide"](); _inner.find(".result-btn-ignore").text(_Dialogdata.cancel && _Dialogdata.cancel.txt || "取消"); _inner.find(".result-btn-warnning").text(_Dialogdata.confirm && _Dialogdata.confirm.txt || "确认"); }); $(".g-page:last .g-winning-result").unbind().bind("click", function () { dismissWinningDialog(); return false; }); $(".g-page:last .g-winning-result .winning-result").unbind().bind("click", function (_e) { var _target = $(_e.target); try { if (_target.is(".result-btn-ignore")) { tapDialogBtns({index: 0}); } else if (_target.is(".result-btn-warnning")) { tapDialogBtns({index: 1}); } else if (_target.is(".result-cls")) { tapDialogBtns({index: 0}); } } catch (_error) { console && console.error(_error); } return false; }); }; window.dismissWinningDialog = function dismissWinningDialog() { _dialogSelectors = {cancel: null, confirm: null}; $(".g-winning-result").fadeOut("fast"); }; function setBtnDisabled(_text, _id, _disabled) { var _attr = {"data-content-text-new": _text}; if (_disabled) { _attr["data-disable"] = 1; } $(".ui-btn[data-clickURI=" + _id + "]").attr(_attr); }; function joinActivityCB(_activityId, _res) { var _activityData = _activityDataMap[_activityId]; var _tmpCB = function () { $(".g-winning").hide(); try { if (_res && _res.code == 200 && _res.result && _res.result.type >= 0) { if (_activityData.rechargeType != 4) { setBtnDisabled("已参加", _activityId); _activityData.alreadyJoin = true; } _activityDataMap[_activityId] = _activityData; if (_res.result.type == 0) { window.showWinningResultDialog({ prizeType: 1, message: "很遗憾,什么都没抽中,再去看看其他活动碰碰运气吧", cancel: { txt: "取消", click: function () { } }, confirm: { txt: "确定", click: function () { } } }); return; } var _prizeTypeIsVirtual = _res.result.type == 2; var _prizeIsVoucher = _res.result.type == 3; var _messageT = "获得" + (_res.result.prizeName || "奖品") + "!"; var _message = (_prizeTypeIsVirtual ? ("奖品兑换码为:" + _res.result.exchangeCode) : (_prizeIsVoucher && '奖品已放入您的账户中,请至「我的代金券」页面查看。' || "奖品将在活动结束后寄送给您,请您尽快确认地址以免意外")); var _prizeId = _res.result.prizeId; var _prizeImg = null; $(_activityData.activitPrizeList).each(function () { if (this.prizeId == _prizeId) { _prizeImg = this.prizeImageUrl; return false; } }); if (_prizeTypeIsVirtual) { window.showWinningResultDialog({ prizeType: 2, title: _messageT, message: _message, prizeImg: _prizeImg, hiddenCancelBtn: _prizeIsVoucher, cancel: { txt: "取消", click: function () { } }, confirm: { txt: "复制", click: function () { $.JSCopyString(_res.result.exchangeCode, function () { $.customToast("复制成功,请您参照活动规则尽快完成奖品兑换"); }); } } }); } else { window.showWinningResultDialog({ prizeType: 2, title: _messageT, message: _message, prizeImg: _prizeImg, cancel: { txt: "以后再说", click: function () { _res.result.type == 2 && $.customToast('您可稍后前往"游戏中心 我的活动"对应奖品列表确认地址,请尽快确认以免奖品无法发放'); } }, confirm: { txt: _prizeIsVoucher && "查看奖品" || "确认地址", click: function () { var _url = _dpGameCenterUrl + "/address/?activityId=" + _activityId; if (_prizeIsVoucher) { _url = _dpGameCenterUrl + "/my-voucher-list?voucherId=" + _res.result.payVoucherId } location.href = _url; } } }); } } else if (_res && (_res.code == 4412 || _res.code == 4409 || _res.code == 4410)) { setBtnDisabled("来晚了", _activityId); $.customDialog(_res.code == 4409 && "游戏已停用,无法参加,如有疑问请联系客服。" || "活动已结束,请下次再来。", { confirm: { text: "我知道了", click: function () { } } }); _activityData.activityState = 4; } else if (_res && (_res.code == 4403 || _res.code == 4417 || _res.code == 4419)) { var _message = _res && _res.msg || "请先下载并安装游戏,参照活动规则参与活动抽奖"; var _cancelCB = function () { }; showActivityJionTipsDialog(_message, _cancelCB); } else if (_res && _res.code == 4421) { setBtnDisabled("已参加", _activityId); _activityData.alreadyJoin = true; $.customDialog("您已经参加了该活动。", { confirm: { text: "前往查看", click: function () { location.href = _dpGameCenterUrl + "/my-joined-activity-list?game_TrackReferrer=mini_activity_joined"; } } }); } else { $.customToast(_res && _res.msg || "参加失败"); } } catch (_error) { console && console.error(_error); } }; setTimeout(function () { $(".g-winning").fadeOut(200, _tmpCB); }, 2000); }; function showActivityJionTipsDialog(_messageT, _cancel, _confirm) { var _message = "请先下载更新并安装游戏,参照活动规则参与活动抽奖"; var _confirmTxt = "下载"; if (window.NCGObject) { if (_game.localStatus == 1) { _message = "请先启动并登录游戏,参照活动规则参与活动抽奖"; _confirmTxt = "启动"; } else if (_game.localStatus == 3 || _game.localStatus == 4) { _confirmTxt = "安装"; _message = "请先安装游戏,参照活动规则参与活动抽奖"; } else if (_game.localStatus == 2) { return $.customToast("请等待游戏下载完成并安装"); } else if (_game.localStatus == 5) { _confirmTxt = "更新"; _message = "请先下载更新并安装游戏,参照活动规则参与活动抽奖"; } else if (_game.localStatus == 0 || _game.localStatus == 201 || _game.localStatus == 202) { _confirmTxt = "下载"; _message = "请先下载并安装游戏,参照活动规则参与活动抽奖"; if (/NeteaseMusic/i.test(navigator.userAgent)) { _message = "请先安装游戏并保证云音乐客户端版本最新,依活动规则参与活动"; } } } $.customDialog(_messageT || _message, { cancel: {text: "取消", click: _cancel || null}, confirm: {text: _confirmTxt, click: _confirm || openGame} }); }; function joinActivity(_id) { getActivityDetail(_id).then(function (_data) { _activityDataMap[_id] = _data.activity || {}; if (_activityDataMap[_id].alreadyJoin || _activityDataMap[_id].activityState == 4 || _activityDataMap[_id].activityState == 3 || _activityDataMap[_id].activityState == 1) { var _text = "活动已结束,请下次再来。"; var _btnText = "我知道了"; var _click = null; if (_activityDataMap[_id].alreadyJoin) { _text = "您已经参加了该活动。"; _btnText = "前往查看"; _click = function () { location.href = _dpGameCenterUrl + "/my-joined-activity-list?game_TrackReferrer=mini_activity_joined" }; } if (_activityDataMap[_id].activityState == 1) { _text = "活动还未上架,请下次再来。"; } $.customDialog(_text, {confirm: {text: _btnText, click: _click}}); return; } checkLoginAndOauthStatus().then(function (_res) { return showCaptchaView(); }, function (_res) { if (_res && _res.hasOwnProperty("login") && !_res.login) { window.__ChannelGotoLogin(function(){ joinActivity(_id); }); } else { showActivityJionTipsDialog(); } }).then(function (_data) { if (_data && _data.validateCode) { $(".g-winning").show(); $.customAjax(cfg_game_root + "/yun/webview/activity-join", { activityId: _id, answer: _data.validateCode, op: "aos" }, {postJson: true/**, beforeSend: beforeSend***/}).always(joinActivityCB.bind(window, _id)); } }, function (_data) { console && console.log(_data); }).catch(function (err) { console.error(err); }); }, function () { $.customToast("当前活动不存在"); }); }; function showGiftJionTipsDialog(_messageT, _cancel, _confirm) { var _message = "未下载与安装,或安装的不是本游戏中心版本,请下载安装后再领取礼包。"; var _confirmTxt = "下载"; if (window.NCGObject) { if (_game.localStatus == 1) { _confirmTxt = "启动"; _message = "请启动并登录游戏后再领取礼包。"; } else if (_game.localStatus == 3 || _game.localStatus == 4) { _confirmTxt = "安装"; _message = "请安装游戏后再领取礼包。"; } else if (_game.localStatus == 2) { return $.customToast("请等待游戏下载完成并安装"); } else if (_game.localStatus == 5) { _confirmTxt = "更新"; _message = "请更新游戏后再领取礼包。"; } else if (_game.localStatus == 0 || _game.localStatus == 201 || _game.localStatus == 202) { _confirmTxt = "下载"; } } $.customDialog(_messageT || _message, { cancel: {text: "取消", click: _cancel || null}, confirm: {text: _confirmTxt, click: _confirm || openGame} }); }; function fetchGiftCB(_id, _codeRes) { $.customDialog("closeShowLoading"); var _giftId = _id; var _gift = _giftDataMap[_giftId]; if (!(_codeRes && _codeRes.code == 200)) { $.customToast(_codeRes && _codeRes.code == 4409 && "游戏已停用,无法领取,如有疑问请联系客服。" || "~服务器开小差了~"); return; } if (_codeRes && _codeRes.result != '' && _codeRes.code == 200) { _gift = $.extend(_gift, {code: _codeRes.result, status: 2}); _giftDataMap[_giftId] = _gift; $.customDialog('恭喜您,领取成功!\r\n' + '您的礼包码为:\r\n' + _codeRes.result, { cancel: {text: "取消"}, confirm: { text: "复制", click: function () { copyGiftCode(_gift); } } }); } else { if (_codeRes && _codeRes.code == 401) { $.customToast("~领取失败:验证码错误,请重新点击领取!"); return; } $.customToast(_codeRes.code == 4409 && "游戏已停用,无法领取,如有疑问请联系客服。" || "~领取失败,请稍后重试!"); } }; function copyGiftCode(_gift) { if (_gift && _gift.code) { $.JSCopyString(_gift.code, function () { $(document).trigger("nativeCopyGiftCodeDone", {copyData: _gift, copyType: "giftCode"}); }); } };$(document).bind("nativeCopyGiftCodeDone", function (_event, _data) { if (_data && _data.copyType == "giftCode") { showGiftJionTipsDialog("复制成功,启动游戏后根据提示即可兑换礼包码。"); } }); function fetchGift(_id) { _giftDataMap[_id] = _giftDataMap[_id] || {giftId: _id}; getGiftDetail(_id).then(function (_data) { _giftDataMap[_id] = _data.gift; if (_giftDataMap[_id].status == 2) { $.customDialog("您已经领取过。", { confirm: { text: "前往查看", click: function () { location.href = _dpGameCenterUrl + "/my-gift-list?pageType=react&game_TrackReferrer=mini_gift_fetched" } } }); return; } checkLoginAndOauthStatus().then(function (_res) { return showCaptchaView(); }, function (_res) { if (_res && _res.hasOwnProperty("login") && !_res.login) { window.__ChannelGotoLogin(function(){ fetchGift(_id); }); } else { var _s = null; if (_res && !_res.oauthStatus) { _s = "您还未登录游戏,请先启动游戏完成登录后领取礼包"; } showGiftJionTipsDialog(_s); } }).then(function (_data) { if (_data && _data.validateCode) { $.customDialog("showLoading"); $.customAjax(cfg_game_root + "/yun/webview/gift/fetch-code", { giftId: _id, gameId: _game.gameId, answer: _data.validateCode, op: "aos" }, {postJson: true/**, beforeSend: beforeSend***/}).always(fetchGiftCB.bind(window, _id)); } }, function (_data) { }).catch(function (err) { console.error(err); }); }, function () { $.customToast("获取礼包信息失败"); }); }; function getGiftDetail(_id) { return new Promise(function (resolve, reject) { var _gift = _giftDataMap[_id]; if (_gift && _gift.type) { resolve({gift: _gift}); return; } $.customAjax(cfg_game_root + "/yun/webview/gift/detail", {giftId: _id, op: "aos"}, { postJson: true/***, beforeSend: beforeSend***/ }).always(function (_res) { if (_res && _res.code == 200) { resolve({gift: _res.result.gift}); } else { reject(); } }); }); }; function initNECaptchaByOpt(_opt) { clearTimeout(initNECaptchaByOpt.__timer); if (!window.NECaptcha) { initNECaptchaByOpt.__timer = setTimeout(function () { initNECaptchaByOpt(_opt); }, 20); return; } showCaptchaView._nECaptchaObj = new NECaptcha(_opt); }; function checkLoginAndOauthStatus() { var _fun = function (resolve, reject) { $.customAjax(cfg_game_root + "/yun/webview/game/authed", {gameId: _game.gameId}, { postJson: true/**, beforeSend: beforeSend***/ }).always(function (_res) { if (_res) { if (_res.code == 200 && _res.result) { resolve({oauthStatus: _res.result}); } else { reject({oauthStatus: _res.result}); } } else { $.customToast("请稍后重试"); reject({error: "checkOauthStatusError"}); } }); }; var _promise = new Promise(function (resolve, reject) { if (__UID) { $.customAjax(cfg_game_root + "/api/web/check_login", null, {/***beforeSend: beforeSend***/}).always(function (_res) { if (!(_res.status === 600 || _res && _res.code == 600) && $.isPlainObject(_res)) { _fun(resolve, reject); } else { reject({login: false}); } }); } else { reject({login: false}); } }); return _promise; }; function showCaptchaView() { var _promise = new Promise(function (resolve, reject) { showCaptchaView._resolve = resolve; showCaptchaView._reject = reject; $.customDialog("showLoading"); var _open = function () { if (showCaptchaView._nECaptchaObj) { showCaptchaView._nECaptchaObj.refresh(); $.customDialog("closeLoading"); } else { $.cachedScript("https://c.dun.163yun.com/js/c.js", function () { try { var opts = { element: $(".g-captcha").empty().get(0), captchaId: "d5bcda5ec155487cb1293360ea395c27", width: Math.floor(Math.min(window.innerWidth - 20, 320)), mode: "embed", initCallback: function () { setTimeout(function () { $(".g-captcha:visible").css({"padding-top": ($(".ncpt_puzzle_bg:first").height() + 30)}); if (window.useCaptchaData && $.isFunction(window.useCaptchaData.onCaptchaPageShow)) { try { window.useCaptchaData.onCaptchaPageShow(); } catch (_error) { console && console.error(_error); } } }, 20); $.customDialog("closeLoading"); }, verifyCallback: function (_res) { if (_res && _res.value && _res.validate) { $.customDialog("close"); showCaptchaView._resolve({validateCode: _res.validate}); } } }; initNECaptchaByOpt(opts); } catch (_error) { console && console.error(_error); } }); } ; }; $.customDialog($(".g-captcha"), { title: "滑动验证", open: function () { $(this).show(); _open(); }, clickCloseButton: function () { showCaptchaView._reject({error: "cancelVerify"}); } }); }); return _promise; }; function checkGameOauthStatus() { var _promise = new Promise(function (resolve, reject) { $.customDialog("showLoading"); $.customAjax(cfg_game_root + "/yun/webview/game/authed", {gameId: _game.gameId}, {postJson: true}).always(function (_res) { $.customDialog("closeShowLoading"); if (_res) { if (_res.code == 200 && _res.result) { resolve({oauthStatus: _res.result}); } else { reject({oauthStatus: _res.result}); } } else { $.customToast("请稍后重试"); reject({error: "checkOauthStatusError"}); } }); }); return _promise; }; function clickAction(_e) { if (!clickAction._typeArray) { clickAction._typeArray = ["", "download", "act", "gift", "link"]; } var _wself = $(this); var _type = _wself.attr("data-clickType"); var _uri = _wself.attr("data-clickURI"); if (_wself.is(".w-btn-download")) { window.hubbleDATrack("bottomDownloadClick", { templateid: _gamePageId, gameid: _game.gameId, gamename: _game.gameName }); } else { window.hubbleDATrack("aelementClick", { templateid: _gamePageId, gameid: _game.gameId, gamename: _game.gameName, elementclass: _wself.attr("data-clickItems-seq"), elementtype: clickAction._typeArray[Number(_type)] || '' }); } if (_type == 1) { openGame(); } else if (_type == 2) { if (_isIos) { $.customToast("请用Android手机app查看"); return false; } joinActivity(_uri); } else if (_type == 3) { if (_isIos) { $.customToast("请用Android手机app查看"); return false; } fetchGift(_uri); } else if (_type == 4) { if (_uri.indexOf('/dp-sdk/webview') >= 0) { if (_isIos) { $.customToast("请用Android手机app查看"); return false; } } location.href = _uri; } }; function initVideo(_e) { var _wself = $(this); window.hubbleDATrack("videoPlayClick", { templateid: _gamePageId, gameid: _game.gameId, gamename: _game.gameName, elementclass: _wself.attr("data-videos-seq") }); _wself.removeClass("ui-video-init").append($("#J-video-tmpl").tmpl({videoUrl: _wself.attr("data-src") || _wself.attr("data-testSrc")})); _wself.find("video").get(0).play(); }; function init() { /**tryParseCookie();**/ if (window.location.search.indexOf('qatestsiri=1') >= 0) { $.customDialog(window.__APPINFO && window.__APPINFO.appId); } if (_gamePageId) { if (_isIos) { $.cachedScript(cfg_game_root + "/c/ios-ncgobject-js?201811022", function () { setTimeout(function () { if (window.location.search.indexOf('qatestsiri=1') >= 0) { alert($.cookie("ncg_app_info")); } if (!window.APPINFO && window.NCGObject && window.NCGObject.getAppInfo) { console.log('window.NCGObject.getAppInfo'); window.NCGObject.getAppInfo(); } }, 200); }); } if (!__UID) { window.__ChannelGetUserId && window.__ChannelGetUserId(uidReady); } else { uidReady(); } $.get(window.cfg_game_root + "/mini-page", {gamePageId: _gamePageId}).always(function (_res) { var _result; if (_res && _res.code == 200) { _result = _res.result; } _result && updatePageView(_result); }); } else if (!/[?&]backendPreview=1&?/i.test(location.search)) { location.replace(_dpGameCenterUrl + "?game_TrackReferrer=mini_not_aos"); } }; function merageNativeData(_gameId, _nativeGameData) { var _webGame = _game; _webGame.oldLocalStatus = _webGame.localStatus; _webGame = $.extend(_webGame, { gameId: _gameId, androidPackageName: _nativeGameData.androidPackageName, localStatus: _nativeGameData.localStatus, progress: (_nativeGameData.hasOwnProperty("progress") && _nativeGameData.progress >= 0) ? _nativeGameData.progress : (_webGame.progress || 0) }); return _webGame; };$(document).delegate(".ui-video-init", "click", initVideo).delegate("[data-clickType]", "click", clickAction); document.addEventListener("gameDownloadingNotify", function (_event) { var _nativeGameData = _event.detail; if (_nativeGameData.gameId || _nativeGameData.androidPackageName) { if (_nativeGameData.gameId) { _game = merageNativeData(_nativeGameData.gameId, _nativeGameData); if (_game.localStatus == 202) { $.customDialog(_game.gameName + "安装包在下载过程中似乎发生了损坏,可能导致无法正常安装游戏,建议重新下载安装包。", { cancel: {text: "取消"}, confirm: { text: "重新下载", click: function () { openGame(2); } } }); } updateGameDownloadBtnText(); } } }, false); document.addEventListener("visibilitychange", function () { if (document.visibilityState != "hidden") { updateGameStatus(); } }, false); document.addEventListener("gameCenterVisibleStateChange", function (_e) { if (!_e || !_e.detail || !_e.detail.hasOwnProperty("visible")) { return; } updateGameStatus(); }, false); window.addEventListener('message', function (event) { if (event.data && event.data.indexOf("{") >= 0) { try { var _new = JSON.parse(event.data); updatePageView(_new); } catch (_error) { } } }, false); if(window.channelSdkJsLoaded){ init(); }else{ document.addEventListener('channelSdkJsLoaded', function(){ init(); }, false); } });