(function outer(modules, cache, entry) { function newRequire(name, jumped) { var module = cache[name]; if (!module) { var moduleData = modules[name]; if (!moduleData) return; var exports = {}; module = cache[name] = { exports: exports }; moduleData[0]((function(x) { let v = x; for (let key of Object.keys(moduleData[1])) if (key.includes(x)) { v = moduleData[1][key]; break; } return newRequire(v || x); }), module, exports); } return module.exports; } for (var i = 0; i < entry.length; i++) newRequire(entry[i]); return newRequire; })({ 1: [ (function(require, module, exports) { class HttpCli { constructor() { this.cachemsg = []; this._needretry = false; this._retrycount = 3; this._retryms = 3e3; this._runningcount = 0; this._maxrunning = 10; } httpGet(url, cbRes, cbErr, maxTry) { return this.httpsend({ url: url, cbRes: cbRes, cbErr: cbErr, maxTry: maxTry }); } httpPost(url, urldata, cbRes, cbErr, maxTry) { return this.httpsend({ url: url, urldata: urldata, cbRes: cbRes, cbErr: cbErr, smethod: "POST", maxTry: maxTry }); } httpsend({url: url, urldata: urldata, cbRes: cbRes, cbErr: cbErr, smethod: smethod, isretry: isretry, contentType: contentType, maxTry: maxTry, responseType: responseType}) { let options = { smethod: "GET", isretry: false, maxTry: this._retrycount }; let requestData = Object.assign(options, arguments[0]); if (this._runningcount < this._maxrunning) return this._httpsend(requestData); console.log("[http]running/max:" + this._runningcount + "/" + this._maxrunning); console.log("[http]url:" + url); if (!isretry) { this._addToRequestCache(requestData); return null; } } _httpsend(data) { if (!jc.plat.webRequest && "undefined" != typeof wx && wx.request) return this._wxRequest(data); if ("undefined" != typeof XMLHttpRequest) return this._webRequest(data); return null; } _wxRequest({url: url, urldata: urldata, cbRes: cbRes, cbErr: cbErr, smethod: smethod, isretry: isretry, contentType: contentType, maxTry: maxTry, responseType: responseType}) { console.log("[vivo] wxrequest: " + JSON.stringify({ url: url, urldata: urldata, cbRes: cbRes, cbErr: cbErr, smethod: smethod, isretry: isretry, contentType: contentType, maxTry: maxTry, responseType: responseType })); this._runningcount++; let requestData = arguments[0]; let self = this; let jsobj = urldata ? JSON.parse(urldata) : null; let ct = contentType || "application/json"; let xhr = wx.request({ url: url, data: jsobj, method: smethod, header: { "content-type": ct, "Cache-Control": "no-cache" }, success: function(res) { console.log("[wx]request success!" + res.statusCode); if (res.statusCode >= 200 && res.statusCode < 400) { let restext = JSON.stringify(res.data); if (responseType && "json" === responseType) try { cbRes && cbRes(JSON.parse(restext)); } catch (err) { cbErr && cbErr(-1, "parse json error"); } else cbRes && cbRes(restext); } else !requestData.isretry && self._needretry ? self._addToRequestCache(arguments[0]) : cbErr && cbErr(res.statusCode, res.msg); }, fail: function(res) { console.log("[wx]request fail!" + JSON.stringify(res)); !requestData.isretry && self._needretry ? self._addToRequestCache(requestData) : cbErr && cbErr(-1, res.msg); }, complete: function() { self._runningcount--; console.log("[wx]request complete!"); } }); return xhr; } _webRequest({url: url, urldata: urldata, cbRes: cbRes, cbErr: cbErr, smethod: smethod, isretry: isretry, contentType: contentType, maxTry: maxTry, responseType: responseType}) { let requestData = arguments[0]; this._runningcount++; let self = this; let urlReal = "GET" === smethod ? this._appendMoreParam(url, urldata) : url; urlReal += urlReal.indexOf("?") >= 0 ? "&__t=" + new Date().getTime() : "?__t=" + Date.now(); let xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (4 === xhr.readyState) { self._runningcount--; if (xhr.status >= 200 && xhr.status < 400) { let response = xhr.responseText; console.log("[webrequest]request success!" + response); if (responseType && "json" === responseType) try { cbRes && cbRes(JSON.parse(response)); } catch (err) { cbErr && cbErr(-1, "parse json error"); } else cbRes && cbRes(response); } else { console.log("[webrequest] error! " + url + "|" + urldata + "|" + xhr.status); !requestData.isretry && self._needretry ? self._addToRequestCache(requestData) : cbErr && cbErr(xhr.status, xhr.statusText); } } }; xhr.onerror = function() { console.log("xhr.onerror"); self._runningcount--; }; xhr.open(smethod, urlReal, true); contentType && xhr.setRequestHeader("content-type", contentType); "POST" === smethod ? xhr.send(this._parsePostData(urldata)) : xhr.send(); return xhr; } _appendMoreParam(url, data) { let paramStr = ""; if (data) { if ("string" === typeof data) paramStr = data; else for (let key in data) { "" !== paramStr && (paramStr += "&"); paramStr += key + "=" + data[key]; } "" !== paramStr && (paramStr = (-1 === url.indexOf("?") ? "?" : "&") + paramStr); } return url + paramStr; } _parsePostData(data) { let dataStr = ""; if ("string" === typeof data) dataStr = data; else for (var key in data) { "" != dataStr && (dataStr += "&"); dataStr += key + "=" + data[key]; } return dataStr; } _addToRequestCache(obj) { if (!obj.retry_count) { obj.retry_count = 1; obj.passtime = 0; } obj.originCbRes = obj.cbRes; obj.cbRes = (restext => { obj.originCbRes && obj.originCbRes(restext); this.cachemsg.remove(obj); }); obj.originCbErr = obj.cbErr; obj.cbErr = ((errcode, errmsg) => { obj.retrying = false; obj.passtime = 0; obj.retry_count++; if (obj.retry_count >= obj.maxTry) { obj.originCbErr && obj.originCbErr(errcode, errmsg); this.cachemsg.remove(obj); } }); this.cachemsg.push(obj); } _retry() { this.cachemsg.length > 0 && this.cachemsg.forEach(obj => { if (obj.retrying) return; obj.passtime += this._retryms; let bneedretry = obj.passtime >= obj.retry_count * this._retryms; if (bneedretry && !obj.retrying) { obj.retrying = true; obj.isretry = true; this.httpsend(obj); } }); } setRetryCount(count) { this.retrycount = count; } setRetryInterval(millsec) { if (millsec != this._retryms) { this._retryms = millsec; if (this._retry_tid) { clearInterval(this._retry_tid); this._retry_tid = 0; } } this._retry_tid || (this._retry_tid = setInterval(this._retry.bind(this), this._retryms)); } setNeedRetry(needretry) { this._needretry = needretry; } } module.exports = HttpCli; }), {} ], 2: [ (function(require, module, exports) { var httpcli = require("./httpcli"); module.exports = { getInstance() { if (!this._instance) { this._instance = new httpcli(); this._instance.setRetryInterval(3e3); this._instance.setNeedRetry(true); } return this._instance; }, httpGet(url, cbRes, cbErr) { return this.httpsend({ url: url, cbRes: cbRes, cbErr: cbErr, smethod: "GET" }); }, httpPost(url, urldata, cbRes, cbErr, contentType) { contentType = contentType || "text/plain;charset=UTF-8"; return this.httpsend({ url: url, urldata: urldata, cbRes: cbRes, cbErr: cbErr, smethod: "POST", contentType: contentType }); }, httpsend({url: url, urldata: urldata, cbRes: cbRes, cbErr: cbErr, smethod: smethod, contentType: contentType, maxTry: maxTry, responseType: responseType}) { return this.getInstance().httpsend({ url: url, urldata: urldata, cbRes: cbRes, cbErr: cbErr, smethod: smethod, contentType: contentType, maxTry: maxTry, responseType: responseType }); }, JSON_parse(text) { try { return JSON.parse(text); } catch (err) { console.log(err); return null; } } }; }), { "./httpcli": 1 } ], 3: [ (function(require, module, exports) { var signals = require("./signals"); var notification = { _signals: [], _cachebinds: {}, _findSignal: function(eEvent) { var i, signal; for (i = this._signals.length; i--; ) { signal = this._signals[i]; if (signal.event === eEvent) return signal; } return null; }, createBinding: function(eEvent, fnListener, oTarget) { var signal = this._findSignal(eEvent); null === signal && (signal = this._findSignal(null)); if (null === signal) { signal = new signals.Signal(); this._signals.push(signal); } if (signal) { signal.event = eEvent; return signal.add(fnListener, oTarget); } }, removeBinding: function(oBinding) { var bindings = oBinding instanceof Array ? oBinding : [ oBinding ]; for (var i = bindings.length; i--; ) { var one = bindings[i], signal = one.getSignal(); one.detach(); signal && 0 == signal.getNumListeners() && (signal.event = null); } }, on(eEvent, fnListener, oTarget) { let obj = this._cachebinds[eEvent]; if (!obj) { obj = []; this._cachebinds[eEvent] = obj; } let ob = obj.find(element => element.listener == fnListener && element.target == oTarget); if (ob) return ob.binding; let bd = this.createBinding(eEvent, fnListener, oTarget); ob = { listener: fnListener, target: oTarget, binding: bd }; obj.push(ob); return bd; }, off(eEvent, fnListener, oTarget) { let obj = this._cachebinds[eEvent]; if (!obj) return; let idx = obj.findIndex(element => element.listener == fnListener && element.target == oTarget); if (idx < 0) return; let ob = obj[idx]; this.removeBinding(ob.binding); obj.splice(idx, 1); }, emit: function(eEvent) { var signal = this._findSignal(eEvent); signal && signal.dispatch.apply(this, arguments); } }; module.exports = notification; }), { "./signals": 4 } ], 4: [ (function(require, module, exports) { (function(global) { function SignalBinding(signal, listener, isOnce, listenerContext, priority) { this._listener = listener; this._isOnce = isOnce; this.context = listenerContext; this._signal = signal; this._priority = priority || 0; } SignalBinding.prototype = { active: true, params: null, execute: function(paramsArr) { var handlerReturn, params; if (this.active && !!this._listener) { params = this.params ? this.params.concat(paramsArr) : paramsArr; handlerReturn = this._listener.apply(this.context, params); this._isOnce && this.detach(); } return handlerReturn; }, detach: function() { return this.isBound() ? this._signal.remove(this._listener, this.context) : null; }, isBound: function() { return !!this._signal && !!this._listener; }, isOnce: function() { return this._isOnce; }, getListener: function() { return this._listener; }, getSignal: function() { return this._signal; }, _destroy: function() { delete this._signal; delete this._listener; delete this.context; }, toString: function() { return "[SignalBinding isOnce:" + this._isOnce + ", isBound:" + this.isBound() + ", active:" + this.active + "]"; } }; function validateListener(listener, fnName) { if ("function" !== typeof listener) throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}", fnName)); } function Signal() { this._bindings = []; this._prevParams = null; var self = this; this.dispatch = function() { Signal.prototype.dispatch.apply(self, arguments); }; } Signal.prototype = { VERSION: "1.0.0", memorize: false, _shouldPropagate: true, active: true, _registerListener: function(listener, isOnce, listenerContext, priority) { var prevIndex = this._indexOfListener(listener, listenerContext), binding; if (-1 !== prevIndex) { binding = this._bindings[prevIndex]; if (binding.isOnce() !== isOnce) throw new Error("You cannot add" + (isOnce ? "" : "Once") + "() then add" + (isOnce ? "Once" : "") + "() the same listener without removing the relationship first."); } else { binding = new SignalBinding(this, listener, isOnce, listenerContext, priority); this._addBinding(binding); } this.memorize && this._prevParams && binding.execute(this._prevParams); return binding; }, _addBinding: function(binding) { var n = this._bindings.length; do { --n; } while (this._bindings[n] && binding._priority <= this._bindings[n]._priority); this._bindings.splice(n + 1, 0, binding); }, _indexOfListener: function(listener, context) { var n = this._bindings.length, cur; while (n--) { cur = this._bindings[n]; if (cur._listener === listener && cur.context === context) return n; } return -1; }, has: function(listener, context) { return -1 !== this._indexOfListener(listener, context); }, add: function(listener, listenerContext, priority) { validateListener(listener, "add"); return this._registerListener(listener, false, listenerContext, priority); }, addOnce: function(listener, listenerContext, priority) { validateListener(listener, "addOnce"); return this._registerListener(listener, true, listenerContext, priority); }, remove: function(listener, context) { validateListener(listener, "remove"); var i = this._indexOfListener(listener, context); if (-1 !== i) { this._bindings[i]._destroy(); this._bindings.splice(i, 1); } return listener; }, removeAll: function() { var n = this._bindings.length; while (n--) this._bindings[n]._destroy(); this._bindings.length = 0; }, getNumListeners: function() { return this._bindings.length; }, halt: function() { this._shouldPropagate = false; }, dispatch: function(params) { if (!this.active) return; var paramsArr = Array.prototype.slice.call(arguments), n = this._bindings.length, bindings; this.memorize && (this._prevParams = paramsArr); if (!n) return; bindings = this._bindings.slice(); this._shouldPropagate = true; do { n--; } while (bindings[n] && this._shouldPropagate && false !== bindings[n].execute(paramsArr)); }, forget: function() { this._prevParams = null; }, dispose: function() { this.removeAll(); delete this._bindings; delete this._prevParams; }, toString: function() { return "[Signal active:" + this.active + " numListeners:" + this.getNumListeners() + "]"; } }; var signals = Signal; signals.Signal = Signal; if ("undefined" !== typeof module && module.exports) { console.log("[signals]module.exports"); module.exports = signals; } else if ("function" === typeof define && define.amd) { console.log("[signals]define.amd"); console.log(define); define((function() { return signals; })); } else { console.log("[signals]global"); global["signals"] = signals; } })(this); }), {} ], 5: [ (function(require, module, exports) { var dateutils = require("../utils/dateutils"); module.exports = { set: function(key, value) { try { jc.plat.setLocalStorage(key, value); return true; } catch (err) { console.log(err); } return false; }, get: function(key) { return jc.plat.getLocalStorage(key); }, setjson: function(key, value) { this.set(key, JSON.stringify(value)); }, getjson: function(key) { let str = this.get(key); if (str) try { return JSON.parse(str); } catch (err) {} return null; }, remove: function(key) { jc.plat.removeStorage(key); }, hasItem: function(key) { var result = jc.plat.getItem(key); if (jc.channelID == jc.channel.WECHAT) { if ("" == result && "number" != typeof result) return false; return true; } if (null == result || void 0 == result) return false; return true; }, setData: function(key, value) { var data = {}; data[key] = value; console.log("storage====set== " + JSON.stringify(data)); return this.set(key, JSON.stringify(data)); }, getStringData: function(key) { console.log("storage====get== start" + key); var result = jc.plat.getItem(key); if (!result) return "0"; var data = null; try { data = JSON.parse(result); } catch (err) { console.log(err); } console.log("storage====get== " + data); if (!data) return "0"; console.log("storage====get== " + data[key]); return data[key]; }, setStorage: function(skey, svalue, successcb, failcb, timeorign_type, time_value) { var bok = this.set(skey, svalue); if (timeorign_type && time_value) { let sk = skey + "_expired"; let sv = { tm_tp: timeorign_type, tm_val: time_value, tm_now: dateutils.getCurrSeconds() }; this.setjson(sk, sv); } bok ? successcb && successcb() : failcb && failcb(-1, 0, "storage kev/value failed!k/v:" + skey + "/" + svalue); }, setStorages: function(kvlist, successcb, failcb) { let bok = true; kvlist.forEach(element => { this.set(element.key, element.value) || (bok = false); }); bok ? successcb && successcb() : failcb && failcb(-1, 0, "storage kvlist failed!" + JSON.stringify(kvlist)); }, getStorage: function(key, successcb, failcb) { let value = this.get(key); let sk = key + "_expired"; let tv = this.getjson(sk); if (tv) { let sec = dateutils.expiredSeconds(tv.tm_tp, tv.tm_val, tv.tm_now); sec <= 0 ? successcb && successcb(null, sec, key) : successcb && successcb(value, sec, key); } else successcb && successcb(value); }, getStorages: function(keylist, successcb, failcb) { let lst = []; keylist.forEach(element => { let v = this.get(element); lst.push({ key: element, value: v }); }); successcb && successcb(lst); } }; }), { "../utils/dateutils": 23 } ], 6: [ (function(require, module, exports) { class UrlBuilder { constructor(url) { this.orginurl = url; this.baseurl = url; this.checked = false; } addKV(key, value) { if ("undefined" == typeof value) return this; this._checkurl(); let str = encodeURIComponent(key) + "=" + encodeURIComponent(value); this.baseurl += str; return this; } clear() { this.baseurl = this.orginurl; this.checked = false; } _checkurl() { if (this.checked) this.baseurl += "&"; else { -1 === this.baseurl.indexOf("?") ? this.baseurl += "?" : this.baseurl += "&"; this.checked = true; } } } module.exports = UrlBuilder; }), {} ], 7: [ (function(require, module, exports) { let eventList = {}; const Events = Object.freeze({ RECEIVE_AWARD: "receive_award", RECEIVE_INVITE_AWARD: "receive_invite_award", RECEIVE_ONLINE_AWARD: "receive_online_award", RECEIVE_SIGN_AWARD: "receive_sign_award", SIGN_FEEDBACK: "sign_feedback", RECEIVE_BOOKMARK_AWARD: "receive_bookmark_award", RECEIVE_WXKF_AWARD: "receive_wxkf_award", VOICE_RECOVER: "voice_recover", LAYER_SHOW: "jclayer_show", LAYER_CLOSE: "jclayer_close", BANNER_RESHOW: "banner_reshow", APP_SHOW: "jcapp_show", APP_HIDE: "jcapp_hide", AD_VIDEO_LIMITED: "advideo_limited", RECEIVE_LUCKY_AWARD: "receive_lucky_award", LUCKY_FEEDBACK: "lucky_feedback", AD_VIDEO_CLOSED: "advideo_closed", AUDIO_INTERRUPT_BEGIN: "audio_interrupt_begin", AUDIO_INTERRUPT_END: "audio_interrupt_end", RECORD_START: "record_start", RECORD_STOP: "record_stop", RECORD_ERROR: "record_error", RECORD_PAUSE: "record_pause", RECORD_RESUME: "record_resume", RECORD_FEEDBACK: "record_feedback", RECORD_SHARE_FEEDBACK: "record_share_feedback", GOTO_APP_RESULT: "goto_app_result", PROMOTION_DATA_READY: "promotion_data_ready", PROMOTION_PANEL_CLOSED: "promotion_panel_closed", PROMOTION_PANEL_OPEN: "promotion_panel_open", GOODS_EXCHANGE_BUY: "goods_exchange_buy", GOODS_EXCHANGE_SELECTED_UPDATE: "goods_exchange_selected_update", GOODS_EXCHANGE_SUCCESS: "goods_exchange_success", BANNER_MANUAL_SHOW: "banner_manual_show", BANNER_MANUAL_HIDE: "banner_manual_hide" }); module.exports = { on(name, self, cb) { let cbArr = eventList[name]; Array.isArray(cbArr) ? cbArr.push({ self: self, cb: cb }) : eventList[name] = [ { self: self, cb: cb } ]; }, remove(name, target) { let cbArr = eventList[name]; Array.isArray(cbArr) && (eventList[name] = cbArr.filter(({self: self, cb: cb}) => target !== self)); }, emit(name, data, issinglecall) { let cbArr = eventList[name]; if (Array.isArray(cbArr)) if (issinglecall && cbArr.length > 0) { let obj = cbArr[cbArr.length - 1]; obj && obj.cb && obj.cb.call(obj.self, data); } else cbArr.map(({self: self, cb: cb}) => { cb.call(self, data); }); }, find: name => null != eventList[name], Events: Events }; }), {} ], 8: [ (function(require, module, exports) { let _global = "undefined" === typeof window ? global : window; _global.jc = _global.jc || {}; _global._jc = _global.jc || {}; require("./utils/extend"); var jccloud = require("./service/jccloud"); var jcgamelog = require("./service/jcgamelog"); var jclogin = require("./service/jclogin"); var jcshare = require("./service/jcshare"); var jcAD = require("./service/jcAD"); var jcStat = require("./service/jcstat"); var jcNotify = require("./service/jcnotify"); var jcmail = require("./service/jcmail"); var jcadshare = require("./service/jcadsharectrl"); var jclog = require("./service/jclog"); var jcrecharge = require("./service/jcrecharge"); var jcrank = require("./service/jcrank"); var jcevent = require("./jc-event"); var jcgoods = require("./service/jcgoods"); var storage = require("./common/storage"); var storageutils = require("./utils/storageutils"); var strutils = require("./utils/strutils"); var httpClient = require("./common/httpclient"); var plat = require("./platform/plat"); const notification = require("./common/notification"); const _GAME_LOCALUUID = "jc_game_localuuid"; const _GAME_INFO_HANDLER_BINDING = "jc_gameinfo_handler_binding"; const _GAME_INFO_HANDLER_UNBINDING = "jc_gameinfo_handler_unbinding"; const JC_CLOUD_URL = "cloud"; const JC_GAMELOG_URL = "gamelog"; const JC_LOGIN_URL = "login"; const JC_NOTIFY_URL = "notify"; const JC_SVC_URL = "service"; const JC_STAT_URL = "stat"; const JC_GAMELIST_URL = "service"; const JC_MAIL_URL = "gamemail"; const JS_RECHARGE = "game1008-pay"; const JC_GHOST_URL = "ghost"; jc.gg = jc.gg || {}; var JCFW = { cloud: jccloud, gamelog: jcgamelog, login: jclogin, share: jcshare, ad: jcAD, stat: jcStat, notify: jcNotify, mail: jcmail, recharge: jcrecharge, rank: jcrank, goods: jcgoods, adshare: jcadshare, cclog: jclog, ccstorage: storageutils, event: jcevent, plat: plat, storage: storage, httpClient: httpClient, channelID: 6e3, localUUID: "", systemInfo: null, lauchInfo: null, shareInfo: {}, _handlers: [], _inited: false, _dayvideocount: -1, channel: { WECHAT: 6001, QQ_PLAY: 6002, OPPO: 6003, VIVO: 6004, FB: 6501, BAIDU: 6005, TT: 6006, QQ_MINI: 6007, TEST: 6e3, HUAWEI: 6008, XIAOMI: 6009, CRAZY_GAME: 7003, IWEI: 7004, QUCIKSDK: 8001, IQIYI: 7011, GAMEDOG: 7012, XIAOQI: 7013, QUNHEI: 7014, SD: 7028, NATIVE_XIAOMI: 7103 }, __getUrl(isoffical, key, env) { let pre = key; isoffical || (pre += "-test"); let str = "https://" + pre + ".kingsome.cn/webapp/index.php"; env && (str += "?publish_env=dev"); return str; }, init({channelid: channelid, gameid: gameid, isoffical: isoffical, response: response, env: env, adparam: adparam, cfgsuccesscb: cfgsuccesscb, cfgfailcb: cfgfailcb, jcdev: jcdev, appid: appid}) { this.channelID = parseInt(channelid); this.sharecfg || (this.sharecfg = {}); if (this._inited) { this.rsp != response && (this.rsp = response); this._loadConfig(cfgsuccesscb, cfgfailcb); return; } strutils.initStringPrototype(); this.rsp = response; this.gameID = parseInt(gameid); this.isOffical = isoffical; this._checkListener(); this.plat.init(this, this.channelID, appid); this.gamelog.init(this.channelID, this.gameID, isoffical, this, this.__getUrl(isoffical, JC_GAMELOG_URL, jcdev)); this.cloud.init(this.channelID, this.gameID, isoffical, this, this.__getUrl(isoffical, JC_CLOUD_URL, jcdev)); this.login.init(this.channelID, this.gameID, isoffical, this, env, this.__getUrl(isoffical, JC_LOGIN_URL, jcdev)); this.share.init(this.channelID, this.gameID, isoffical, this, this.__getUrl(isoffical, JC_SVC_URL, jcdev)); this.ad.init(this.channelID, this.gameID, isoffical, this, adparam); this.stat.init(this.channelID, this.gameID, isoffical, this, this.__getUrl(isoffical, JC_STAT_URL, jcdev)); this.notify.init(this.channelID, this.gameID, isoffical, this, this.__getUrl(isoffical, JC_NOTIFY_URL, jcdev)); this.mail.init(this.channelID, this.gameID, isoffical, this, this.__getUrl(isoffical, JC_MAIL_URL, jcdev)); this.recharge.init(this.channelID, this.gameID, isoffical, this, this.__getUrl(isoffical, JS_RECHARGE, jcdev)); this.rank.init(this.channelID, this.gameID, isoffical, this, this.__getUrl(isoffical, JC_GHOST_URL)); this.goods.init(this.channelID, this.gameID, isoffical, this, this.__getUrl(isoffical, JC_GHOST_URL)); this.adshare.init(this, isoffical); this.cclog.init(this, isoffical); this.ccstorage.init(this, isoffical, this.cloud); this._loadLocalID(); this._loadLaunchInfo(); this._loadSystemInfo(); this._loadConfig(cfgsuccesscb, cfgfailcb); this._handleInit(this.channelID, this.gameID, isoffical); this._inited = true; }, updateChannel(channelID) { this.channelID = channelID; this.gamelog.channelid = this.channelID; }, bindController(man) { this.plat && this.plat.bindController(man); }, __handleLogined() { this.cacheuser ? this.updateUser(this.cacheuser.info, this.cacheuser.success, this.cacheuser.fail) : this.initShareConfig(); }, loginUser({success: success, fail: fail, ex_param: ex_param, cfgsuccess: cfgsuccess, cfgfail: cfgfail}) { console.log("loginUser"); success && (this._login_successcb = success); fail && (this._login_failcb = fail); cfgsuccess && (this.sharecfg.successcb = cfgsuccess); cfgfail && (this.sharecfg.failcb = cfgfail); if (this.logined) { this._login_successcb && this._login_successcb(this.accountobj); this.__handleLogined(); return 0; } if (this._logining) return 1; this._logining = true; this.login.loginPT(res => { this._logining = false; this.logined = true; this.setAccountID(res.account_id, res.session_id, res); this.rank.setAvatar(res.avatar_url); this.setNickName(res.nickname); this.setServerTime(res.server_time); this.gamelog.logLoginSuccess(res, this.login.login_costtime); this.gamelog.logSystemInfo(this.systemInfo); this.shareInfo && this.shareInfo.type && this.shareInfo.param && this.share.acceptDailyInvite(this.shareInfo.param, this.shareInfo.inviter, () => {}, () => {}); if (this.shareInfo && this.shareInfo.inviter) { this.share.acceptAchivementInvite([ [ 1001, 100 ] ], this.shareInfo.inviter); this.gamelog.logShareInvite(this.shareInfo.inviter, this.shareInfo.type, this.shareInfo.id, this.shareInfo.param); } this.rsp && this.rsp.onLogin && this.rsp.onLogin(res); this._login_successcb && this._login_successcb(res); this.__handleLogined(); this.adshare.loginOver(); }, (neterr, logicerr, errmsg) => { this._logining = false; this.gamelog.logLoginFailed(neterr, logicerr, errmsg); this.rsp && this.rsp.onLoginFail && this.rsp.onLoginFail(neterr, logicerr, errmsg); this._login_failcb && this._login_failcb(neterr, logicerr, errmsg); this.sharecfg.failcb && this.sharecfg.failcb(neterr, logicerr, errmsg); }, ex_param); return 0; }, loginUserByToken({token: token, success: success, fail: fail}) { console.log("loginUserByToken:" + token); return this.loginUser({ success: success, fail: fail, token: token }); }, logout: function() { this.logined = false; this.login.clear(); }, updateUser(allinfo, successcb, failcb) { console.log("updateUser"); if (!this.logined) { this.cacheuser || (this.cacheuser = {}); this.cacheuser.info = allinfo; this.cacheuser.success = successcb; this.cacheuser.fail = failcb; return; } this.cacheuser = null; let userinfo = allinfo && allinfo.userInfo; if (userinfo) { this.gamelog.logAuthSuccess(userinfo); this.setUserInfo(userinfo); } else { this.gamelog.logAuthFail(); this.setUserInfo(null); } if (!allinfo || !userinfo) { this.rsp && this.rsp.onUpdateUserFail && this.rsp.onUpdateUserFail(0, -1e4, "info is NULL"); failcb && failcb(0, -1e4, "info is NULL"); return 0; } if (this._userupdating) return 1; this._userupdating = true; this.login.updatePTInfo(userinfo, allinfo, obj => { this._userupdating = false; this.rsp && this.rsp.onUpdateUser && this.rsp.onUpdateUser(obj); successcb && successcb(obj); }, (neterr, logicerr, errmsg) => { this._userupdating = false; this.rsp && this.rsp.onUpdateUserFail && this.rsp.onUpdateUserFail(neterr, logicerr, errmsg); failcb && failcb(neterr, logicerr, errmsg); }); return 0; }, getUserInfo(btninfo, successcb, failcb) { this.plat && this.plat.getUserInfo && this.plat.getUserInfo(btninfo, (res, err, exobj) => { err < 0 ? failcb && failcb(0, err, "getuserinfo err") : err > 0 ? this.updateUser(res, successcb, failcb) : successcb && successcb(null, exobj); }); }, destoryAuthComponent() { this.plat && this.plat.destoryAuth && this.plat.destoryAuth(); }, initGlobalConfig(successcb, failcb) { this.maincfg || (this.maincfg = {}); if (this.maincfg.info) { successcb && successcb(this.maincfg.info); return; } successcb && (this.maincfg.successcb = successcb); failcb && (this.maincfg.failcb = failcb); this.cloud.getServerConfig(cfg => { console.log("get server config"); console.log(JSON.stringify(cfg)); this._handleCfg(cfg); this.rsp && this.rsp.onServerConfig && this.rsp.onServerConfig(cfg); this.maincfg.successcb && this.maincfg.successcb(cfg); }, (neterr, logicerr, errmsg) => { this.rsp && this.rsp.onServerConfigFail && this.rsp.onServerConfigFail(neterr, logicerr, errmsg); this.maincfg.failcb && this.maincfg.failcb(neterr, logicerr, errmsg); }); }, initShareConfig(successcb, failcb, bforce) { if (this.sharecfg.info && !bforce) { successcb && successcb(this.sharecfg.info); return; } successcb && (this.sharecfg.successcb = successcb); failcb && (this.sharecfg.failcb = failcb); this.cloud.initShareConfig(cfg => { this.adshare.loadShareConfig && this.adshare.loadShareConfig(cfg); this.plat && this.plat.PTInitShare && this.plat.PTInitShare(this.adshare._commonshareinfo); this.rsp && this.rsp.onShareConfig && this.rsp.onShareConfig(cfg); this.sharecfg.info = cfg; jc.gg.sharecfg = cfg; this.sharecfg.successcb && this.sharecfg.successcb(cfg); }, (neterr, logicerr, errmsg) => { this.rsp && this.rsp.onShareConfigFail && this.rsp.onShareConfigFail(neterr, logicerr, errmsg); this.sharecfg.failcb && this.sharecfg.failcb(neterr, logicerr, errmsg); }, bforce); }, initPlayerData(successcb, failcb) { this.playerdata || (this.playerdata = {}); if (this.playerdata.info) { successcb && successcb(this.playerdata.info); return; } successcb && (this.playerdata.successcb = successcb); failcb && (this.playerdata.failcb = failcb); if (this.playergetting) return; this.playergetting = true; this.cloud.getStorage("player_data", cfg => { this.playergetting = false; cfg ? this.playerdata.info = cfg : this.playerdata.info || (this.playerdata.info = {}); jc.gg.playerdata = this.playerdata.info; this.rsp && this.rsp.onPlayerData && this.rsp.onPlayerData(this.playerdata.info); this.playerdata.successcb && this.playerdata.successcb(this.playerdata.info); }, (neterr, logicerr, errmsg) => { this.playergetting = false; this.rsp && this.rsp.onPlayerDataFail && this.rsp.onPlayerDataFail(neterr, logicerr, errmsg); this.playerdata.failcb && this.playerdata.failcb(neterr, logicerr, errmsg); }); }, savePlayerData(successcb, failcb) { this.cloud.setStorage("player_data", this.playerdata.info, successcb, failcb); }, acceptInvite(info) { info.daily && this.share.acceptDailyInvite(info.daily.id, this.shareInfo.inviter); info.achivement && this.share.acceptAchivementInvite(info.achivement.idlist, this.shareInfo.inviter); }, shareNormal(content, imgurl, sharetype, shareparam, extrainfo, successcb, failcb, imgindex) { this.plat && this.plat.commonShare ? this.plat.commonShare(imgurl, content, sharetype, shareparam, (param, tokenid) => { this.gamelog.logShare(sharetype, tokenid, param, null, imgindex); this.rsp && this.rsp.onShare && this.rsp.onShare(content, imgurl, sharetype, shareparam, extrainfo); successcb && successcb(); }, (err, param, tokenid) => { let serr = "" + err; this.gamelog.logShare(sharetype, tokenid, param, serr, imgindex); this.rsp && this.rsp.onShareFail && this.rsp.onShareFail(content, imgurl, sharetype, shareparam, extrainfo); failcb && failcb(err); }, extrainfo) : failcb && failcb(-1e3); }, shareCapture(content, capture_rect, sharetype, shareparam, extrainfo, successcb, failcb, imgindex) { this.plat && this.plat.captureShare ? this.plat.captureShare(capture_rect, content, sharetype, shareparam, (param, tokenid, dtime) => { this.gamelog.logShare(sharetype, tokenid, param, null, imgindex, dtime); this.rsp && this.rsp.onShare && this.rsp.onShare(content, capture_rect, sharetype, shareparam, extrainfo); successcb && successcb(); }, (err, param, tokenid, dtime) => { let serr = "" + err; this.gamelog.logShare(sharetype, tokenid, param, serr, imgindex, dtime); this.rsp && this.rsp.onShareFail && this.rsp.onShareFail(content, capture_rect, sharetype, shareparam, extrainfo); failcb && failcb(err); }, extrainfo) : failcb && failcb(-1e3); }, makeShareParam(sharetype, shareparam, extrainfo) { let str = ""; "string" == typeof shareparam ? str = shareparam : "object" == typeof shareparam && (str = JSON.stringify(shareparam)); this._tmpuuid = this.makeUUID(); let qstr = "inviter_id=" + this.accountID + "&activity_param=" + str + "&localuuid=" + this._tmpuuid + "&sharetype=" + sharetype; if (extrainfo) { qstr += "&"; qstr += extrainfo; } return qstr; }, simpleShare(successcb, failcb, typestr, exparam) { let stype = typestr || "normal"; let info = this.adshare.getShareInfo(stype); this.plat && this.plat.commonShare && this.plat.commonShare(info.imgurl, info.title, stype, exparam, (param, tokenid, dtime) => { this.gamelog.logShare(stype, tokenid, param, null, info.imgindex, dtime); this.rsp && this.rsp.onShare && this.rsp.onShare(info.title, info.imgurl, stype, param, exparam); successcb && successcb(); }, (err, param, tokenid, dtime) => { let serr = "" + err; this.gamelog.logShare(stype, tokenid, param, serr, info.imgindex, dtime); this.rsp && this.rsp.onShareFail && this.rsp.onShareFail(info.title, info.imgurl, stype, param, exparam); failcb && failcb(err); }); }, ADShare(stype, param, cb) { if (this._istestmode) { cb && cb(true, 0, 0); return; } return this.adshare.AD_Share(stype, param, (isok, errcode, flag, isaderr, isdiff) => { 2 == flag && (this.isWatchAd = false); cb && cb(isok, errcode, flag, isaderr, isdiff); if (2 == flag && !isaderr) { let data = { isOK: isok, errCode: errcode }; this.event.emit(this.event.Events.AD_VIDEO_CLOSED, data); } }); }, ADShareCommon(stype, param, cb) { if (jc.channelID === jc.channel.TEST) { cb && cb(true, 0, 0); return; } if (this._istestmode) { cb && cb(true, 0, 0); return; } return this.adshare.AD_Share_Common(stype, param, cb); }, ADWatch(adid, adname, successcb, failcb) { console.log(`play video ad: ${adid}`); this.isWatchAd = true; let sname = adname || adid; if (this._istestmode) { this.rsp && this.rsp.onADFinish && this.rsp.onADFinish(sname); successcb && successcb(); return; } if (this._offad) { failcb && failcb(null, true); return; } this.ad.showRewardAD(sname, (currid, res, realadid) => { this.gamelog.logAdvInfo(realadid, sname); this.rsp && this.rsp.onADFinish && this.rsp.onADFinish(sname); successcb && successcb(); }, (currid, res, iserr, realadid) => { res && this.gamelog.logAdvInfo(realadid, sname, res); this.rsp && this.rsp.onADFail && this.rsp.onADFail(sname, res); failcb && failcb(res, iserr); }, (currid, res, realadid) => { this.gamelog.logAdvInfo(realadid, sname, null, 0, 1); }, adid); }, ADsWatch(adlst, adname, successcb, failcb) { if (this._istestmode) { this.rsp && this.rsp.onADFinish && this.rsp.onADFinish(adname); successcb && successcb(); return; } if (this._offad) { failcb && failcb(null, true); return; } this.ad.randomRewardADShow(adlst, adname, (currid, res, realadid) => { let sname = adname || realadid; this.gamelog.logAdvInfo(realadid, sname); this.rsp && this.rsp.onADFinish && this.rsp.onADFinish(sname); successcb && successcb(); }, (currid, res, iserr, realadid) => { let sname = adname || realadid; res && this.gamelog.logAdvInfo(realadid, sname, res); this.rsp && this.rsp.onADFail && this.rsp.onADFail(sname, res); failcb && failcb(res, iserr); }, (currid, res, realadid) => { this.gamelog.logAdvInfo(realadid, sname, null, 0, 1); }); }, ADBanner_init(adid, adname) { if (this._offbanner) return; adid || (adid = this._bannerids); if (!adid) return false; if (adid instanceof Array) adid.forEach(element => { this.ad.hasBannerAD(element) || this.ad.addBannerAD(element, element); }); else { let name = adname || adid; this.ad.hasBannerAD(name) || this.ad.addBannerAD(adid, name); } return true; }, ADBanner_Show(adname, successcb, failcb, adid, breload) { if (this._offbanner) return ""; let id = adid; id || (id = this._randomBannerAD()); this.ad.switchBannerAD(id, true, () => { this.gamelog.logAdvInfo(id, adname, null, 1); }, (name, err, advid) => { this.gamelog.logAdvInfo(id, adname, err, 1); }, breload); return id; }, ADBanner_Hide(adname) { if (this._offbanner) return; this.ad.switchBannerAD(adname, false); }, ADBanner_ShowEx(adid, adname, successcb, failcb, adwidth) { if (this._offbanner) return null; let id = adid; id || (id = this._randomBannerAD()); return this.ad.showBannerAD(id, () => { this.gamelog.logAdvInfo(id, adname, null, 1); successcb && successcb(); }, (name, err, advid) => { this.gamelog.logAdvInfo(id, adname, err, 1); failcb && failcb(); }, () => { this.gamelog.logAdvInfo(id, adname, null, 1, 1); }, adwidth, this._bannertimeout); }, ADBanner_Destroy(obj, realdestroy) { try { realdestroy || this.channelID === this.channel.QQ_MINI ? this.ad.destroyObj(obj, true) : this.ad.hideAD(obj); } catch (err) {} }, ADBanner_Switch(bshow) { bshow ? this.event.emit(this.event.Events.BANNER_MANUAL_SHOW) : this.event.emit(this.event.Events.BANNER_MANUAL_HIDE); }, ADInsert_Show(adid, adname, successcb, failcb) { if (this._offinsert) return; if (!Object.values) { failcb && failcb(adname, null, true, adid); return; } let id = this.ad.simpleInsertADShow(adid, successcb, failcb); id && this.gamelog.logAdvInfo(id, adname, null, 2); }, _randomBannerAD() { if (0 == this._bannerids.length) return null; if (1 == this._bannerids.length) { this._last_rand_ad = this._bannerids[0]; return this._bannerids[0]; } let lst = null; if (this._last_rand_ad) { lst = []; for (let i = 0; i < this._bannerids.length; i++) this._bannerids[i] != this._last_rand_ad && lst.push(this._bannerids[i]); } else lst = this._bannerids; let n = Math.floor(Math.random() * lst.length); this._last_rand_ad = lst[n]; return this._last_rand_ad; }, currUUID() { return this._tmpuuid; }, makeUUID() { return this.gamelog.generateUUID(); }, makeAccountID(openid) { return this.login.AccountID(openid); }, resetLocalID() { this._cleanLocalID(); this._loadLocalID(); }, addHandler(handler) { this._checkListener(); if (!handler) return false; let obj = this._handlers.find(element => element == handler); if (!obj) { this._handlers.push(handler); this._initHandler(handler); } return true; }, delHandler(handler) { if (!handler || !this._handlers) return false; let idx = this._handlers.findIndex(item => item == handler); if (idx < 0) return true; this._handlers.splice(idx, 1); return true; }, setResponse(rsp) { this.rsp = rsp; }, setADSwitch(turnoff) { this._offad = turnoff; }, setBannerADSwitch(turnoff) { this._offbanner = turnoff; }, setInsertADSwitch(turnoff) { this._offinsert = turnoff; }, setAuditSwitch(isaudit) { this.isVerify = isaudit; }, setTestModeSwitch(istestmode) { this._istestmode = istestmode; }, setVideoLimit(cnt) { this._dayvideocount = -1; "number" == typeof cnt && (this._dayvideocount = cnt); }, setStorageFlag(iscloud) { this.ccstorage.setCloudFlag(iscloud); }, getStorageFlag() { return this.ccstorage.getCloudFlag(); }, getServerNowTime() { let tm = new Date().getTime(); return this.loginSrvTime + (tm - this.loginLocalTime) / 1e3; }, getUserID() { return this.accountID; }, gameStart(startmode, extparam) { if (!this._inited) return; switch (startmode) { case 0: this.gamelog.logStartGame(extparam); break; case 1: this.gamelog.logRestartGame(extparam); break; case 2: this.gamelog.logTryAgain(extparam); } this._handleGameStart(startmode, extparam); }, gameOver(score, bsuccess, extparam) { if (!this._inited) return; this.gamelog.logGameover(extparam, score, bsuccess ? 1 : 0); this._handleGameOver(score, bsuccess, extparam); }, gameShow(showinfo) { if (!this._inited) return; this.gamelog.logShow(); this._handleGameShow(showinfo); }, gameHide() { if (!this._inited) return; this.gamelog.logHide(); this._handGameHide(); }, gameUseItem(itemid, itemcount, reson, extparam) { if (!this._inited) return; this.gamelog.logUseItem(itemid, itemcount, reson, extparam); }, gameGetItem(itemid, itemcount, reson, extparam) { if (!this._inited) return; this.gamelog.logProductItem(itemid, itemcount, reson, extparam); }, gameVibrate() { return this.plat && this.plat.PTVibrateShort && this.plat.PTVibrateShort(); }, gameVibrateLong() { return this.plat && this.plat.PTVibrateLong && this.plat.PTVibrateLong(); }, gameStartRecord(duration, cb) { return this.plat && this.plat.PTStartRecord && this.plat.PTStartRecord(duration, cb); }, gameStopRecord(cb) { return this.plat && this.plat.PTStopRecord && this.plat.PTStopRecord(cb); }, gameIsRecording() { return this.plat && this.plat.PTIsRecording && this.plat.PTIsRecording(); }, setAccountID(accountid, sessionid, exobj) { this.accountID = accountid; this.sessionID = sessionid; this.accountobj = exobj; exobj && exobj.wid && (this.weakID = exobj.wid); exobj && exobj.sid && (this.strongID = exobj.sid); exobj && exobj.ptid && (this.ptID = exobj.ptID); this.share.setAccountID(accountid, sessionid, exobj); this.gamelog.setAccountID(accountid, sessionid, exobj); this.login.setAccountID(accountid, sessionid, exobj); this.cloud.setAccountID(accountid, sessionid, exobj); this.ad.setAccountID(accountid, sessionid, exobj); this.stat.setAccountID(accountid, sessionid, exobj); this.notify.setAccountID(accountid, sessionid, exobj); this.mail.setAccountID(accountid, sessionid, exobj); this.recharge.setAccountID(accountid, sessionid, exobj); this._handleAccountID(accountid, sessionid, exobj); }, setLocalUUID(uuid) { this.localUUID = uuid; this.gamelog.setLocalUUID(uuid); this.cloud.setLocalUUID(uuid); this.login.setLocalUUID(uuid); this.share.setLocalUUID(uuid); this.ad.setLocalUUID(uuid); this.stat.setLocalUUID(uuid); this.notify.setLocalUUID(uuid); this.mail.setLocalUUID(uuid); this.recharge.setLocalUUID(uuid); this._handleLocalID(uuid); }, setNickName(nickname) { if (nickname && "" != nickname && this.nickName != nickname) { this.nickName = nickname; this.gamelog.setNickName(nickname); this.cloud.setNickName(nickname); this.login.setNickName(nickname); this.share.setNickName(nickname); this.ad.setNickName(nickname); this.stat.setNickName(nickname); this.notify.setNickName(nickname); this.mail.setNickName(nickname); this.recharge.setNickName(nickname); this._handleNickName(nickname); } this.rank.setNickName(nickname); }, setFromAppID(appid, scene, paramobj) { this.lastscene = scene; if (appid) { this.fromID = appid; this.gamelog.setFromAppID(appid); this.cloud.setFromAppID(appid); this.login.setFromAppID(appid); this.share.setFromAppID(appid); this.ad.setFromAppID(appid); this.stat.setFromAppID(appid); this.notify.setFromAppID(appid); this.mail.setFromAppID(appid); this.recharge.setFromAppID(appid); } paramobj && (this.lauchparam = paramobj); this._handleLauchInfo(scene, appid, paramobj); }, setSystemInfo(info) { this.systemInfo = info; this.gamelog.setSystemInfo(info); this.cloud.setSystemInfo(info); this.login.setSystemInfo(info); this.share.setSystemInfo(info); this.ad.setSystemInfo(info); this.stat.setSystemInfo(info); this.notify.setSystemInfo(info); this.mail.setSystemInfo(info); }, setUserInfo(info) { this._userinfo || (this._userinfo = {}); this.login.appendUserInfo(this._userinfo, info); this._userinfo.nickName ? this.setNickName(this._userinfo.nickName) : this._userinfo.nickname && this.setNickName(this._userinfo.nickname); this.share.setUserInfo(this._userinfo); this.cloud.setUserInfo(this._userinfo); this.rank.setUserInfo(this._userinfo); this._loadShareConfig(info); this._handleUserInfo(this._userinfo); }, setServerTime(srvtime) { if (!srvtime) return; this.loginSrvTime = srvtime; this.loginLocalTime = new Date().getTime(); this.notify.setServerTime(srvtime, this.loginLocalTime); this._handleServerTime(srvtime, this.loginLocalTime); }, _loadLocalID() { let id = storage.get(_GAME_LOCALUUID); let bneedsave = false; if (!id) { id = this.makeUUID(); bneedsave = true; } this.setLocalUUID(id); bneedsave && this._saveLocalID(); }, _saveLocalID() { storage.set(_GAME_LOCALUUID, this.localUUID) || setTimeout(this._saveLocalID.bind(this), 5e3); }, _cleanLocalID() { storage.remove(_GAME_LOCALUUID); }, _loadLaunchInfo() { this.plat && this.plat.getLaunchInfo ? this.lauchInfo = this.plat.getLaunchInfo() : this.lauchInfo = null; this.gamelog.handlelaunch(this.lauchInfo, (sharetype, shareparam, shareuuid, inviterid, fromid, fromscene, launchobj) => { this.shareInfo.type = sharetype; this.shareInfo.param = shareparam; this.shareInfo.id = shareuuid; this.shareInfo.inviter = inviterid; console.log("[shareinfo]"); console.log(JSON.stringify(this.shareInfo)); this.setFromAppID(fromid, fromscene, launchobj); }); }, _loadSystemInfo() { if (this.plat && this.plat.getSystemInfo) { let info = this.plat.getSystemInfo(); this.gamelog.logLaunchSystemInfo(info); this.setSystemInfo(info); } else if (this.plat && this.plat.getSystemInfoAsync) { let self = this; this.plat.getSystemInfoAsync((function(info) { self.gamelog.logLaunchSystemInfo(info); self.setSystemInfo(info); }), (function() {})); } }, _loadConfig(cfgsuccesscb, cfgfailcb) { this.initGlobalConfig(cfgsuccesscb, cfgfailcb); }, _loadShareConfig(info) { info ? this.initShareConfig(null, null, true) : this.sharecfg.info || this.initShareConfig(); }, _initHandler(obj) { this.gameID && obj.onJCInit && obj.onJCInit(this.channelID, this.gameID, this.isOffical); this.accountID && this.sessionID && obj.onJCAccountID && obj.onJCAccountID(this.accountID, this.sessionID, this.accountobj); this.localUUID && obj.onJCLocalUUID && obj.onJCLocalUUID(this.localUUID); this.nickName && obj.onJCNickName && obj.onJCNickName(this.nickName); this._userinfo && obj.onJCUserInfo && obj.onJCUserInfo(this._userinfo); this.fromID && obj.onJCLaunchInfo && obj.onJCLaunchInfo(this.scene, this.fromID, this.lauchparam); }, _handleInit(channelid, gameid, isoffical) { this._handlers.forEach(element => { element.onJCInit && element.onJCInit(channelid, gameid, isoffical); }); }, _handleAccountID(accountid, sessionid, exobj) { this._handlers.forEach(element => { element.onJCAccountID && element.onJCAccountID(accountid, sessionid, exobj); }); }, _handleLocalID(localuuid) { this._handlers.forEach(element => { element.onJCLocalUUID && element.onJCLocalUUID(localuuid); }); }, _handleNickName(nickname) { this._handlers.forEach(element => { element.onJCNickName && element.onJCNickName(nickname); }); }, _handleUserInfo(userinfo) { this._handlers.forEach(element => { element.onJCUserInfo && element.onJCUserInfo(userinfo); }); }, _handleLauchInfo(lauchscene, lauchfromid, launchparam) { this._handlers.forEach(element => { element.onJCLaunchInfo && element.onJCLaunchInfo(lauchscene, lauchfromid, launchparam); }); }, _handleServerTime(servertime, localtime) { this._handlers.forEach(element => { element.onJCServerTime && element.onJCServerTime(servertime, localtime); }); }, _handleGameStart(startmode, extparam) { this._handlers.forEach(element => { element.onJCGameStart && element.onJCGameStart(startmode, extparam); }); }, _handleGameOver(score, bsuccess, extparam) { this._handlers.forEach(element => { element.onJCGameOver && element.onJCGameOver(score, bsuccess, extparam); }); }, _handleGameShow(showinfo) { showinfo && showinfo.scene && (this.lastscene = showinfo.scene); this._handlers.forEach(element => { element.onJCGameShow && element.onJCGameShow(showinfo); }); this.event.emit(this.event.Events.APP_SHOW, showinfo); }, _handGameHide(hideinfo) { this._handlers.forEach(element => { element.onJCGameHide && element.onJCGameHide(hideinfo); }); this.event.emit(this.event.Events.APP_HIDE); }, _handleNotifyMsgs(lst, notifyobj) { this._handlers.forEach(element => { element.onJCNotifyMsg && element.onJCNotifyMsg(lst, notifyobj); }); }, _checkListener() { this._listenerID || (this._listenerID = notification.on(_GAME_INFO_HANDLER_BINDING, (msgid, handler) => { this.addHandler(handler); }, this)); this._unlistenerID || (this._unlistenerID = notification.on(_GAME_INFO_HANDLER_UNBINDING, (msgid, handler) => { this.delHandler(handler); }, this)); }, _handleCfg(cfg) { if (!cfg) return; jc.gg.basecfg = cfg; jc.gg.extcfg = {}; this.maincfg.info = cfg; this.maincfg.info.openAD ? this.setADSwitch(false) : this.setADSwitch(true); this.maincfg.info.openAdBanner ? this.setBannerADSwitch(false) : this.setBannerADSwitch(true); this.maincfg.info.openADInsert ? this.setInsertADSwitch(false) : this.setInsertADSwitch(true); this.maincfg.info.isTestMode ? this.setTestModeSwitch(true) : this.setTestModeSwitch(false); this.maincfg.info.blackTech ? this.setAuditSwitch(false) : this.setAuditSwitch(true); if (cfg.ext_json_cfg) try { let extCfg = JSON.parse(cfg.ext_json_cfg); jc.gg.extcfg = extCfg; console.log(jc.gg.extcfg); } catch (err) { console.log("parse ext cfg error", err); } this.setVideoLimit(this.maincfg.info.video_count); this._bannerids = this.maincfg.info.wxBannerAdId ? this.maincfg.info.wxBannerAdId.split("|") : []; this._bannertimeout = this.maincfg.info.wxBannerOvertime ? this.maincfg.info.wxBannerOvertime : 0; if (this.maincfg.info.banner_cfg) try { this.maincfg.info.bannerCfg = JSON.parse(this.maincfg.info.banner_cfg); } catch (err) {} this.maincfg.info.statInvTime && this.stat.setHeart(this.maincfg.info.statInvTime); "number" == typeof this.maincfg.info.share_waitsec && this.plat && (this.plat.SHARE_TIME = 1e3 * this.maincfg.info.share_waitsec); }, logout: function() { this.logined = false; this.login.clear(); }, canIShare(stype) { return !!this._offad || this.adshare.checkAdShareCommon(); }, gotoJCApp(appid, apppath, param_kvlst, cb, env) { let exobj = { accountId: this.accountID, sessionId: this.sessionID, gameId: this.gameID, channelId: this.channelID }; param_kvlst && param_kvlst instanceof Array && param_kvlst.forEach(element => { exobj[element.key] = element.value; }); this.plat ? this.plat.PTGotoApp(appid, apppath, exobj, cb, this.gameID, env) : cb && cb(-1e3); } }; Object.assign(_global.jc, JCFW); _global.cc && (cc.jc = _global.jc); module.exports = _global.jc; }), { "./common/httpclient": 2, "./common/notification": 3, "./common/storage": 5, "./jc-event": 7, "./platform/plat": 9, "./service/jcAD": 10, "./service/jcadsharectrl": 11, "./service/jccloud": 12, "./service/jcgamelog": 13, "./service/jcgoods": 14, "./service/jclog": 15, "./service/jclogin": 16, "./service/jcmail": 17, "./service/jcnotify": 18, "./service/jcrank": 19, "./service/jcrecharge": 20, "./service/jcshare": 21, "./service/jcstat": 22, "./utils/extend": 24, "./utils/storageutils": 25, "./utils/strutils": 26 } ], 9: [ (function(require, module, exports) { var Plat_egret = { SHARE_FAIL: 25, SHARE_TIME: 3e3, shareCount: {}, getLaunchInfo: () => null, getSystemInfo: () => null, getUserInfo(btninfo, cb) {}, destoryAuth() {}, setUserInfo(dstinfo, ptinfo) { dstinfo.nickname = ptinfo.nickName; dstinfo.country = ptinfo.country; dstinfo.province = ptinfo.province; dstinfo.city = ptinfo.city; dstinfo.avatar_url = ptinfo.avatarUrl; dstinfo.sex = ptinfo.gender; }, setTokenInfo(dstinfo, tokeninfo) { if (tokeninfo && tokeninfo.rawData) { dstinfo.rawData = tokeninfo.rawData; dstinfo.signature = tokeninfo.signature; dstinfo.encryptedData = tokeninfo.encryptedData; dstinfo.iv = tokeninfo.iv; } }, init(owner, channelid, appId) { this._owner = owner; this._ptid = channelid; this.platUid = ""; this.platUserName = ""; }, bindController(ctrl) { this._man = ctrl; }, commonShare(aimg, atitle, stype, param, successcb, failcb, exinfo) { var st = new Date().getTime(); let sp = this._owner.makeShareParam(stype, param, exinfo); let uuid = this._owner.currUUID(); let img = aimg; !img && this._exshareinfo && (img = this._exshareinfo.imgurl); let title = atitle; !title && this._exshareinfo && (title = this._exshareinfo.title); this.PTShare(title, img, sp); this._checkShareRes(st, stype, sp, uuid, successcb, failcb); }, captureShare(rc, title, stype, param, successcb, failcb, exinfo) { var st = new Date().getTime(); let sp = this._owner.makeShareParam(stype, param, exinfo); let uuid = this._owner.currUUID(); this.PTShareCapture(title, rc, sp); this._checkShareRes(st, stype, sp, uuid, successcb, failcb); }, _checkShareRes(starttime, sharetype, param, tokenid, successcb, failcb) { if (!this._man) { try { failcb && failcb(-100, param, tokenid); } catch (err) {} return; } this._man.scheduleOnce(() => { let dt = new Date().getTime() - starttime; console.log(dt); void 0 == this.shareCount[sharetype] && (this.shareCount[sharetype] = false); if (false == this.shareCount[sharetype] && 100 * Math.random() > this.SHARE_FAIL) { this.shareCount[sharetype] = true; try { failcb && failcb(-1, param, tokenid, dt); } catch (err) {} return; } if (dt > this.SHARE_TIME) try { successcb && successcb(param, tokenid, dt); } catch (err) {} else try { failcb && failcb(-2, param, tokenid, dt); } catch (err) {} }, .5); }, PTInitShare(normalinfo) {}, PTShare(content, imgurl, param, successcb, failcb) { successcb && successcb(); }, PTShareCapture(content, rc, param, successcb, failcb) { successcb && successcb(); }, PTOpenKF(cb, info) {}, PTCreateGameClubButton(nleft, ntop, nwidth) {}, PTShowToast(str, icon) { egret.ExternalInterface.call("showToast", str); }, PTGotoApp(appid, apppath, exobj, cb, qdid, env, acontent) {}, PTLogin(info, successcb, failcb) { var self = this; egret.ExternalInterface.addCallback("sendUidToJS", (function(message) { console.log("login message from native: " + message); let obj = JSON.parse(message); let loginData = { successcb: successcb, failcb: failcb }; Object.assign(loginData, obj); self._owner.login.login(loginData); })); egret.ExternalInterface.addCallback("loginOut", (function(message) { console.log("login out from native: " + message); this.reloadGame(); })); egret.ExternalInterface.addCallback("loginCancel", (function(message) { console.log("login cancel from native: " + message); failcb && failcb(-1, 0, "user cancel"); })); egret.ExternalInterface.call("getUid", ""); }, PTSetClipboardData: function(content, successcb, failcb) {}, PTGetClipboardData: function(successcb, failcb) {}, PTPreviewImage(imgurl, successcb, failcb) {}, PTInitADService() {}, PTCreateBannerAD: (adid, st) => null, PTCreateVideoAD: adid => null, PTCreateInsertAD: adid => null, PTSetVideoADCallback(adobj, adowner, cb) {}, PTVibrateShort(successcb, failcb) { egret.ExternalInterface.call("vibrate", "0"); }, PTVibrateLong(successcb, failcb) { egret.ExternalInterface.call("vibrate", "1"); }, PTOpenDataContext: () => null, PTPostOpenMsg(msg) {}, saveRankData(nscore, nmoney, stitle) {}, showRankData() {}, hideRankData() {}, prevRankPage() {}, nextRankPage() {}, PTADWatch(adid, successcb, failcb) {}, setLocalStorage(key, value) { window.localStorage && localStorage.setItem(key, value); }, getLocalStorage: key => window.localStorage ? localStorage.getItem(key) : null, removeStorage(key) { window.localStorage && localStorage.removeItem(key); }, reportRoleInfo: data => new Promise((resolve, reject) => { let dataStr = JSON.stringify(data); egret.ExternalInterface.call("reportRoleInfo", dataStr); resolve(); }), reloadGame() { window.location.reload(); }, pay(data) { let str = JSON.stringify(data); return new Promise((resolve, reject) => { egret.ExternalInterface.addCallback("payResult", (function(message) { console.log("message from native: " + message); try { let data = JSON.parse(message); data.errcode ? reject && reject(data) : resolve && resolve(data); } catch (err) { reject && reject({ errcode: 101, errmsg: "\u89e3\u6790\u652f\u4ed8\u7ed3\u679c\u51fa\u9519" }); } })); egret.ExternalInterface.call("pay", str); }); } }; module.exports = Plat_egret; }), {} ], 10: [ (function(require, module, exports) { module.exports = { _calcBannerWidth(bannerwidth) { let adw = bannerwidth || this.winW; let maxw = this.owner.plat.PTBannerADMaxWidth ? this.owner.plat.PTBannerADMaxWidth() : this.winW; (adw <= 0 || adw > maxw) && (adw = maxw); return adw; }, __createAD: function(adtype, adunitid, bannerHV, owner, bannerY, bannerW) { let obj = owner; owner || (obj = { adType: adtype, adUnitId: adunitid, state: 0, hide: function() { this.ad && this.ad.hide && this.ad.hide(); } }); if (0 == adtype) { let adw = this._calcBannerWidth(bannerW); let height = jc.channelID === jc.channel.QQ_MINI ? adw / 4.12 : 125; let nhv = bannerHV || height; let realy = "number" == typeof bannerY && bannerY >= 0 ? bannerY : this.winH - nhv; let adl = (this.winW - adw) / 2; let st = null; if (obj.style) st = obj.style; else { st = { left: adl, top: realy, width: adw, height: nhv, x: adl, y: realy }; obj.style = st; } obj.ad = this.owner.plat.PTCreateBannerAD(adunitid, st); } else 1 == adtype ? obj.ad = this.owner.plat.PTCreateVideoAD(adunitid) : 2 == adtype && (obj.ad = this.owner.plat.PTCreateInsertAD(adunitid)); return obj; }, init(channelid, gameid, isoffical, owner, adparam) { this.owner = owner; this.gameid = gameid; this.channelid = channelid; this.BannerAds = []; this.InsertAds = []; this.VideoAds = []; this.cleanBannerAD(); this.cleanVideoAD(); this.owner && this.owner.plat && this.owner.plat.PTInitADService(adparam); }, setAccountID(accountid, sessionid) { this.accountid = accountid; this.sessionid = sessionid; }, setNickName(nickname) { this.nickname = nickname; }, setFromAppID(appid) { this.fromid = appid; }, setLocalUUID(uuid) { this.localid = uuid; }, setSystemInfo(info) { this.winW = info && info.windowWidth || 0; this.winH = info && info.windowHeight || 0; console.log("[ad]win:" + this.winW + "|" + this.winH); this._dtLineH = 0; info && info.statusBarHeight && (this._dtLineH = info.statusBarHeight > 30 ? 30 : 0); }, addBannerAD(advid, identifier, bannerHValue, rspCb) { var adobj = this.__createAD(0, advid, bannerHValue); if (adobj) { adobj.param = identifier; adobj.rspCb = rspCb; this.initAD(adobj); this.BannerAds.push(adobj); } return adobj; }, addInsertAD(advid, identifier) { var adobj = this.__createAD(2, advid); if (adobj) { adobj.param = identifier; adobj.rspCb = rspCb; this.initAD(adobj); this.InsertAds.push(adobj); } return adobj; }, addVideoAD(advid, identifier, rspCb) { var adobj = this.__createAD(1, advid); if (!adobj) return null; var owner = this.findVideoOwner(adobj.ad); if (owner) { owner.param = identifier; owner.rspCb = rspCb; return owner; } adobj.param = identifier; adobj.rspCb = rspCb; this.initAD(adobj); this.VideoAds.push(adobj); return adobj; }, reLoadBannerAD(identifier, advid) { let obj = this.findBannerAD(identifier); let bfinded = null != obj && void 0 != obj; !obj && advid && (obj = this.addBannerAD(advid, identifier, 0, null)); if (bfinded && obj && obj.ad) { let id = obj.adUnitId; if (id) { this.destoryAD(obj.ad); obj.adloaded = false; var adobj = this.__createAD(0, id, 0, obj); adobj && this.initAD(adobj); } } return obj; }, hasBannerAD(identifier) { let obj = this.findBannerAD(identifier); if (obj && obj.ad) return true; return false; }, hasVideoAD(identifier) { let obj = this.findVideoAD(identifier); if (obj && obj.ad) return true; return false; }, findBannerAD(identifier) { let obj = this.BannerAds.find(element => element.param == identifier); return obj; }, findInsertAD(identifier) { let obj = this.InsertAds.find(element => element.param == identifier); return obj; }, randomBannerAD() { if (0 == this.BannerAds.length) return null; let n = Math.floor(Math.random() * this.BannerAds.length); return this.BannerAds[n]; }, findVideoAD(identifier) { let obj = this.VideoAds.find(element => element.param == identifier); return obj; }, findVideoOwner(ad) { let obj = this.VideoAds.find(element => element.ad == ad); return obj; }, hideAllAD() { this.BannerAds.forEach(element => { this.hideAD(element); }); }, needLoadBannerAD() { return !!this.owner.plat.PTBannerNeedLoad && this.owner.plat.PTBannerNeedLoad(); }, switchBannerAD(identifier, bShow, successcb, failcb, breload) { this.hideAllAD(); if (bShow) { let obj = null; let param = identifier; let isrefresh = breload; if (identifier) { obj = this.findBannerAD(identifier); if (!obj) { obj = this.addBannerAD(identifier, identifier, 0, null); isrefresh = true; } } else { obj = this.randomBannerAD(); param = obj.param; } if (obj) { breload && (obj = this.reLoadBannerAD(identifier, obj.adUnitId)); let bneedload = this.needLoadBannerAD(); if (bneedload && !obj.adloaded) { obj.loadcb = loadcb; obj.successcb = successcb; obj.needshow = true; } else this.showAD(obj, successcb, failcb, isrefresh); return obj.adUnitId; } } return ""; }, simpleBannerADShow(adid, adh, ady, successcb, failcb, loadcb, adw) { let obj = this.__createAD(0, adid, adh, null, ady, adw); if (obj && obj.ad) { obj.param = adid; obj.loadcb = loadcb; obj.successcb = successcb; obj.failcb = failcb; this.initAD(obj); let bneedload = this.needLoadBannerAD(); bneedload && !obj.adloaded ? obj.needshow = true : this.showAD(obj, successcb, failcb); } return obj; }, simpleInsertADShow(adid, successcb, failcb) { let obj = this.__createAD(2, adid); if (obj && obj.ad) { this.initAD(obj); this.showAD(obj, successcb, failcb); } return obj; }, destroyAllBannerAD() { this.BannerAds.forEach(element => { this.destroyObj(element); }); this.BannerAds.length = 0; }, showBannerAD(adid, successcb, failcb, loadcb, adwidth, oversec) { let obj = null; if (oversec && "number" == typeof oversec) { this.hideAllAD(); obj = this.findBannerAD(adid); if (obj && obj.adloaded) { let dt = new Date().getTime() - obj.adloadtime; if (dt >= 1e3 * oversec) { this.destroyObj(obj, true); obj = null; } } } else this.destroyAllBannerAD(); if (obj) { let bneedload = this.needLoadBannerAD(); if (bneedload && !obj.adloaded) { obj.successcb = successcb; obj.failcb = failcb; obj.needshow = true; } else this.showAD(obj, successcb, failcb); } else { obj = this.simpleBannerADShow(adid, 0, -1, successcb, failcb, loadcb, adwidth); obj && this.BannerAds.push(obj); } return obj; }, showRewardAD(identifier, successcb, failcb, loadcb, adid) { let obj = this.findVideoAD(identifier); !obj && adid && (obj = this.addVideoAD(adid, identifier, null)); if (!obj || !obj.ad) { this.simpleRewardADShow(adid, identifier, successcb, failcb); return; } obj.successcb = successcb; obj.failcb = failcb; if (obj.adloaded) { loadcb && loadcb(obj.param, null, obj.adUnitId); this.showAD(obj); } else { obj.loadcb = loadcb; obj.needshow = true; this.loadAD(obj); } }, simpleRewardADShow(adid, adname, successcb, failcb) { this.owner.plat.PTADWatch ? this.owner.plat.PTADWatch(adid, successcb, failcb) : failcb && failcb(adname, null, true, adid); }, randomRewardADShow(adlst, adname, successcb, failcb, loadcb) { if (adlst.length > 0) { let idx = 1 === adlst.length ? 0 : Math.floor(Math.random() * adlst.length); let adid = adlst[idx]; this.showRewardAD(adid, successcb, failcb, loadcb, adid); } }, onLoadAD(obj) { obj && console.log(obj.adUnitId); obj.adloaded = true; obj.adloadtime = new Date().getTime(); obj.rspCb && obj.rspCb(100, obj); if (obj.loadcb) { obj.loadcb(obj.param, null, obj.adUnitId); obj.loadcb = null; } if (obj.needshow) { obj.needshow = false; if (0 == obj.adType) { let successcb = obj.successcb; let failcb = obj.failcb; obj.successcb = null; obj.failcb = null; this.showAD(obj, successcb, failcb); } else this.showAD(obj); } }, onErrAD(errtype, err, obj) { console.log("[AD]err:" + errtype); console.log(err); obj.adloaded = false; obj.rspCb && obj.rspCb(errtype, obj, err); if (obj.failcb) { obj.failcb(obj.param, err, true, obj.adUnitId); obj.failcb = null; } }, onFinishAD(bReward, obj, res) { if (bReward) { obj.rspCb && obj.rspCb(10, obj, res, true); if (obj.successcb) { obj.successcb(obj.param, res, obj.adUnitId); obj.successcb = null; } } else { obj.rspCb && obj.rspCb(11, obj, res, false); if (obj.failcb) { obj.failcb(obj.param, res, false, obj.adUnitId); obj.failcb = null; } } }, destoryAD(ad) { if (!ad) return; ad.state = 30; ad.destroy && ad.destroy(); }, destroyObj(obj, needremove) { if (!obj) return; if (needremove) for (let i = 0; i < this.BannerAds.length; i++) if (this.BannerAds[i] == obj) { this.BannerAds.splice(i, 1); break; } obj.successcb = null; obj.failcb = null; obj.loadcb = null; obj.rspCb = null; this.destoryAD(obj.ad); }, showAD(obj, successcb, failcb) { let ad = obj.ad; if (!ad) return; ad.state = 10; if (ad.show) try { ad.show().then(() => { successcb && successcb(obj.param, null, obj.adUnitId); }).catch(error => { console.log("[ad.show]error"); console.log(error); obj.adloaded = false; failcb && failcb(obj.param, error, true, obj.adUnitId); }); } catch (err) {} }, hideAD(obj) { let ad = obj.ad; if (!ad) return; ad.state = 20; ad.hide && ad.hide(); }, loadAD(obj) { let ad = obj.ad; if (!ad) return; ad.state = 100; obj.adloaded = false; ad.load ? ad.load() : this.onLoadAD(obj); }, initAD(obj) { let ad = obj.ad; let adtype = obj.adType; if (!ad) return; ad.onLoad && ad.onLoad(() => { this.onLoadAD(obj); }); ad.onError && ad.onError(res => { console.log("[ad]onerror:" + JSON.stringify(res)); this.onErrAD(-obj.state, res, obj); }); 0 == adtype ? ad.onResize(res => { if (res) { let nh = res.height ? res.height : res.width / 16 * 9; let nt = this.winH - nh - this._dtLineH; if (ad.style) { if (nh > 0) { ad.style.top = nt; ad.style.y = nt; } if (res.width > 0 && res.width != ad.style.width) { ad.style.left = (this.winW - res.width) / 2; ad.style.x = ad.style.left; } } } }) : 1 == adtype && this.owner.plat.PTSetVideoADCallback(ad, obj, this.onFinishAD); }, cleanBannerAD() { if (this.BannerAds.length > 0) { this.BannerAds.forEach(element => { this.destoryAD(element.ad); }); this.BannerAds.length = 0; } }, cleanVideoAD() { this.VideoAds.length > 0 && (this.VideoAds.length = 0); } }; }), {} ], 11: [ (function(require, module, exports) { var strutils = require("../utils/strutils"); var dateutils = require("../utils/dateutils"); const AD_SHARE_COMMON = "ad_share_common"; var JCADShareCtrl = { KEY: "platinfo", SHARE_FLAG: 1, AD_FLAG: 2, init(owner, isoffical) { this._owner = owner; this._isoffical = isoffical; }, loginOver() { this.loadInfo(); }, loadShareConfig(cfg) { this._rinfo || (this._rinfo = {}); for (var i = 0; i < cfg.length; i++) { var sdt = cfg[i]; let adid = sdt.ad_id; adid && (sdt.adlst = adid.split(",")); sdt.asqueue || (sdt.asqueue = []); if (sdt.ad_cd && "object" == typeof sdt.ad_cd && sdt.ad_cd.reg) { let lst = sdt.ad_cd.reg.split(","); lst.forEach(element => { let ls = element.split("-"); if (ls.length >= 2) { let obj = { is_share: "S" == ls[0] || "s" == ls[0], maxcount: parseInt(ls[1]) }; sdt.asqueue.push(obj); } }); } this._rinfo[sdt.type] = sdt; } this._commonshareinfo = this.getShareInfo("normal"); console.log("[loadShareConfig]"); console.log(cfg); }, _loadInfo(restext) { let obj = null; try { restext && (obj = JSON.parse(restext)); } catch (err) {} obj ? this._adshare = obj : this._adshare || (this._adshare = {}); this._loaded = true; }, loadInfo(datastr) { if (datastr) { this._loadInfo(datastr); return; } this._owner && this._owner.ccstorage.getStorage(this.KEY, restext => { console.log("[jcadsharectrl]loadinfo:" + restext); this._loadInfo(restext); }, (lerr, nerr, errmsg) => { console.log("[jcadsharectrl]loadinfo failed:" + lerr + "|" + nerr + "|" + errmsg); }); }, saveInfo() { this._owner && this._owner.ccstorage.setStorage(this.KEY, JSON.stringify(this._adshare), () => {}, (lerr, nerr, errmsg) => {}, 1); }, getShareInfo(stype) { let info = { imgurl: "", title: "", imgindex: -1 }; if (!this._rinfo) return info; let sdt = this._rinfo[stype]; sdt || (sdt = this._rinfo["normal"]); if (sdt && sdt.images && sdt.images.length > 0) { let ite = strutils.randomInt(sdt.images.length - 1); info.imgindex = ite; info.imgurl = sdt.images[ite]; info.title = sdt.strs[ite]; } return info; }, AD_Share(stype, param, cb) { if (!this._rinfo) { cb && cb(false, -1, 0); return false; } let sdt = this._rinfo[stype]; sdt && "4" != sdt.ad_first || (sdt = this._rinfo["adnormal"]); if (!sdt) { cb && cb(false, -2, 0); return false; } let pro = this._adshare && this._adshare[stype]; if (!pro) { pro = { adcnt: 0, srcnt: 0 }; this._adshare && (this._adshare[stype] = pro); } let isdiff = false; let isonlyshare = "2" == sdt.ad_first; let isonlyad = "3" == sdt.ad_first; let isShare = "0" == sdt.ad_first || isonlyshare; let isloop = "5" == sdt.ad_first && sdt.asqueue && sdt.asqueue.length > 0; let _checkloop = function(bnext) { bnext && pro.curr++; ("number" != typeof pro.curr || pro.curr >= sdt.asqueue.length) && (pro.curr = 0); if (sdt.asqueue.length > pro.curr) { let obj = sdt.asqueue[pro.curr]; if (obj) { isShare = obj.is_share; isShare ? sdt.share_count = obj.maxcount : sdt.ad_count = obj.maxcount; if (bnext) { pro.adcnt = 0; pro.srcnt = 0; } return true; } } return false; }; isloop && _checkloop(); if (!isShare && 0 != sdt.ad_count) { let bok = pro.adcnt < sdt.ad_count; if (!bok && isloop && _checkloop(true)) { bok = true; isdiff = false; } if (!bok && !isShare) { if (isonlyad || sdt.share_count < 0 || sdt.srcnt >= sdt.share_count) { cb && cb(false, -20, 0); return; } isShare = true; isdiff = true; } } if (isShare && 0 != sdt.share_count) { let bok = pro.srcnt < sdt.share_count; if (!bok && isloop && _checkloop(true)) { bok = true; isdiff = false; } if (!bok && isShare) { if (isonlyshare || sdt.ad_count < 0 || sdt.adcnt >= sdt.ad_count) { cb && cb(false, -10, 0); return; } isShare = false; isdiff = true; } } let self = this; let shareMe = function() { let iconUrl = ""; let sharetitle = ""; let ite = 0; if (sdt.images.length > 0) { let brand = true; let idx = 0; if (param && "object" == typeof param && "number" == typeof param.shareindex) { idx = param.shareindex; brand = false; } ite = brand ? strutils.randomInt(sdt.images.length - 1) : idx; iconUrl = sdt.images[ite]; sharetitle = sdt.strs[ite]; param && "object" == typeof param && "object" == typeof param.titleparam && "[object Array]" === Object.prototype.toString.call(param.titleparam) && (sharetitle = sharetitle.format(param.titleparam)); } let bcapture = false; sdt.ad_cd && "object" == typeof sdt.ad_cd && (bcapture = sdt.ad_cd.iscapture); var sysInfo = jc.plat.getSystemInfo(); if (bcapture) { let rc = { x: 0, y: 0, width: sysInfo.screenWidth, height: sysInfo.screenHeight }; param && "object" == typeof param && param.rc && (rc = param.rc); self._owner.shareCapture(sharetitle, rc, stype, param, "", () => { isdiff ? pro.adcnt += 1 : pro.srcnt += 1; self.saveInfo(); cb && cb(true, 1, self.SHARE_FLAG, false, isdiff); }, err => { cb && cb(false, -101, self.SHARE_FLAG, false, isdiff); }, ite); } else self._owner.shareNormal(sharetitle, iconUrl, stype, param, "", () => { isdiff ? pro.adcnt += 1 : pro.srcnt += 1; self.saveInfo(); cb && cb(true, 1, self.SHARE_FLAG, false, isdiff); }, err => { cb && cb(false, -100, self.SHARE_FLAG, false, isdiff); }, ite); }; if (isShare) shareMe(); else { let adid = sdt.ad_id; if (sdt.adlst.length > 0) { let idx = 1 == sdt.adlst.length ? 0 : Math.round(Math.random() * (sdt.adlst.length - 1)); adid = sdt.adlst[idx]; } this._owner.ADWatch(adid, stype, () => { isdiff ? pro.srcnt += 1 : pro.adcnt += 1; this.saveInfo(); cb && cb(true, 2, this.AD_FLAG, false, isdiff); }, (err, iserr) => { iserr && !isonlyad ? shareMe(true) : cb && cb(false, -200, this.AD_FLAG, iserr, isdiff); }); } return true; }, AD_Share_Common(stype, param, cb) { if (!this._rinfo) { cb && cb(false, -1, 0); return false; } let sdt = this._rinfo[stype]; sdt || (sdt = this._rinfo["adnormal"]); if (!sdt) { cb && cb(false, -2, 0); return false; } let isShare = this.checkAdShareCommon(); let pro = this._adshare[AD_SHARE_COMMON]; let self = this; let shareMe = function() { let iconUrl = ""; let sharetitle = ""; let ite = 0; if (sdt.images.length > 0) { ite = strutils.randomInt(sdt.images.length - 1); iconUrl = sdt.images[ite]; sharetitle = sdt.strs[ite]; param && "object" == typeof param && "object" == typeof param.titleparam && "[object Array]" === Object.prototype.toString.call(param.titleparam) && (sharetitle = sharetitle.format(param.titleparam)); } let bcapture = false; sdt.ad_cd && "object" == typeof sdt.ad_cd && (bcapture = sdt.ad_cd.iscapture); if (bcapture) { var sysInfo = jc.plat.getSystemInfo(); let rc = { x: 0, y: 0, width: sysInfo.screenWidth, height: sysInfo.screenHeight }; param && "object" == typeof param && param.rc && (rc = param.rc); self._owner.shareCapture(sharetitle, rc, stype, param, "", () => { pro.srcnt += 1; self.saveInfo(); cb && cb(true, 1); }, err => { cb && cb(false, -100, self.SHARE_FLAG); }, ite); } else self._owner.shareNormal(sharetitle, iconUrl, stype, param, "", () => { pro.srcnt += 1; self.saveInfo(); cb && cb(true, 1); }, err => { cb && cb(false, -100, self.SHARE_FLAG); }, ite); }; if (isShare) shareMe(); else { let adid = sdt.ad_id; if (sdt.adlst.length > 0) { let idx = 1 == sdt.adlst.length ? 0 : Math.round(Math.random() * (sdt.adlst.length - 1)); adid = sdt.adlst[idx]; } this._owner.ADWatch(adid, stype, () => { pro.adcnt += 1; this.saveInfo(); cb && cb(true, 2); }, (err, iserr) => { console.log(err, iserr); iserr ? shareMe() : cb && cb(false, -200, this.AD_FLAG); }); } return true; }, checkAdShareCommon() { let videoDayCount = 0; this._owner.maincfg && this._owner.maincfg.info && this._owner.maincfg.info["video_count"] && (videoDayCount = parseInt(this._owner.maincfg.info["video_count"])); let today = dateutils.getToday(); let pro = this._adshare && this._adshare[AD_SHARE_COMMON]; if (!pro || pro.day !== today) { pro = { adcnt: 0, srcnt: 0, day: today }; this._adshare[AD_SHARE_COMMON] = pro; } return pro.adcnt >= videoDayCount; }, getRandomVideoAdId() { let sdt = this._rinfo["adnormal"]; if (!sdt) return ""; let adid = sdt.ad_id; if (sdt.adlst.length > 0) { let idx = 1 == sdt.adlst.length ? 0 : Math.round(Math.random() * (sdt.adlst.length - 1)); adid = sdt.adlst[idx]; } return adid; } }; module.exports = JCADShareCtrl; }), { "../utils/dateutils": 23, "../utils/strutils": 26 } ], 12: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); var urlbuilder = require("../common/urlbuilder"); module.exports = { __getConfig(accountid, sessionid, channelid, gameid, actionname, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Config").addKV("a", actionname).addKV("account_id", accountid).addKV("session_id", sessionid).addKV("gameid", gameid).addKV("channel", channelid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { var kvobj = obj.KVList ? httpclient.JSON_parse(obj.KVList) : []; kvobj ? successcb && successcb(kvobj) : failcb && failcb(0, -1, "kvlist is not obj"); } else { console.log("[__getConfig]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__getConfig]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __getStorage(accountid, sessionid, token, skey, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "CloudStorage").addKV("a", "getStorage").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("access_token", token).addKV("keys", skey); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { console.log("[__getStorage]success!" + JSON.stringify(obj)); var kvobj = obj.KVList; kvobj ? successcb && successcb(kvobj) : failcb && failcb(0, -1, "kvlist is not obj"); } else { console.log("[__getStorage]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__getStorage]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __getExpireTime(accountid, sessionid, token, skey, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "CloudStorage").addKV("a", "ttl").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("access_token", token).addKV("keys", skey); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { console.log("[__getExpireTime]success!" + JSON.stringify(obj)); var ktobj = httpclient.JSON_parse(obj.KTList); ktobj ? successcb && successcb(ktobj) : failcb && failcb(0, -1, "kvlist is not obj"); } else { console.log("[__getExpireTime]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__getExpireTime]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __setStorage(accountid, sessionid, token, kvlist, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "CloudStorage").addKV("a", "setStorage").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("access_token", token); let value = JSON.stringify(kvlist); httpclient.httpPost(this.urlbd.baseurl, value, (function(restext) { let obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { console.log("[__setStorage]success!" + JSON.stringify(obj)); successcb && successcb(); } else { console.log("[__setStorage]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__setStorage]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __setExpireTime(accountid, sessionid, token, skey, origntype, timevalue, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "CloudStorage").addKV("a", "expire").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("access_token", token).addKV("keys", skey).addKV("time_origin", origntype).addKV("time_val", timevalue); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { let obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { console.log("[__delStorage]success!" + JSON.stringify(obj)); successcb && successcb(); } else { console.log("[__delStorage]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__delStorage]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __clearStorage(accountid, sessionid, token, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "CloudStorage").addKV("a", "clearStorage").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("access_token", token); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { let obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { console.log("[__clearStorage]success!" + JSON.stringify(obj)); successcb && successcb(); } else { console.log("[__clearStorage]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__clearStorage]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __delStorage(accountid, sessionid, token, skey, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "CloudStorage").addKV("a", "delKeys").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("access_token", token).addKV("keys", skey); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { let obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { console.log("[__delStorage]success!" + JSON.stringify(obj)); successcb && successcb(); } else { console.log("[__delStorage]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__delStorage]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __getShareConfig(accountid, sessionid, channelid, gameid, sex, province, city, successcb, failcb) { let str = gameid + "_" + channelid; this.urlbd.clear(); this.urlbd.addKV("c", "Config").addKV("a", "share").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("gameid", str).addKV("sex", sex).addKV("province", province).addKV("city", city); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { let obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) successcb && successcb(obj.share_info); else { console.log("[__getShareConfig]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__getShareConfig]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, init(channelid, gameid, isoffical, owner, url) { this.gameid = gameid; this.channelid = channelid; this.token = ""; this.urlbd = new urlbuilder(url); this.cfg = { _reborntype: -1, _getrewardtype: -1, _exchange_rewardtype: -1, _navigateflag: -1, _serverversion: -1, _gglFlag: -1 }; this.cfginited = false; this.sex = 0; this.province = ""; this.city = ""; console.log("[jccloud]init:" + gameid + "|" + channelid + "|" + isoffical); }, setAccountID(accountid, sessionid, resinfo) { this.accountid = accountid; this.sessionid = sessionid; if (resinfo) { this.sex = resinfo.sex; this.province = resinfo.province; this.city = resinfo.city; } }, setNickName(nickname) { this.nickname = nickname; }, setFromAppID(appid) { this.fromid = appid; }, setLocalUUID(uuid) { this.localid = uuid; }, setSystemInfo(info) {}, setUserInfo(info) { if (info) { this.sex = info.sex; this.province = info.province; this.city = info.city; } }, getConfig(successcb, failcb) { if (this._configgetting) return 1; this._configgetting = true; this.__getConfig(this.accountid, this.sessionid, this.channelid, this.gameid, "read", kvlist => { this._configgetting = false; successcb && successcb(kvlist); }, (neterr, logicerr, errmsg) => { this._configgetting = false; failcb && failcb(neterr, logicerr, errmsg); }); return 0; }, initConfig(successcb, failcb) { if (this.cfginited) { successcb && successcb(this.cfg); return 0; } this.cfginited = false; return this.getConfig(res => { if (res instanceof Array) { res.forEach(element => { "reborn" == element.key ? this.cfg._reborntype = element.value : "share_reward" == element.key ? this.cfg._getrewardtype = element.value : "exchange_reward" == element.key ? this.cfg._exchange_rewardtype = element.value : "navigate" == element.key ? this.cfg._navigateflag = element.value : "version" == element.key ? this.cfg._serverversion = element.value : "ggl" == element.key ? this.cfg._gglFlag = element.value : "festival" == element.key ? this.cfg._festivalFlag = element.value : this.cfg[element.key] = element.value; }); this.cfginited = true; successcb && successcb(this.cfg); } else failcb && failcb(0, -1, ""); }, (neterr, logicerr, errmsg) => { failcb && failcb(neterr, logicerr, errmsg); }); }, _getPrivateConfig(successcb, failcb) { if (this._pvconfiggetting) return 1; this._pvconfiggetting = true; this.__getConfig(this.accountid, this.sessionid, this.channelid, this.gameid, "readPrivate", kvlist => { this._pvconfiggetting = false; successcb && successcb(kvlist); }, (neterr, logicerr, errmsg) => { this._pvconfiggetting = false; failcb && failcb(neterr, logicerr, errmsg); }); return 0; }, initPrivateConfig(successcb, failcb) { if (this.pvcfginited) { successcb && successcb(this.pvcfg); return 0; } this.pvcfginited = false; return this._getPrivateConfig(res => { if (res instanceof Array) { this.pvcfg || (this.pvcfg = {}); res.forEach(element => { this.pvcfg[element.key] = element.value; }); this.pvcfginited = true; successcb && successcb(this.pvcfg); } else failcb && failcb(0, -1, ""); }, (neterr, logicerr, errmsg) => { failcb && failcb(neterr, logicerr, errmsg); }); }, getServerConfig(successcb, failcb, bForce) { bForce && (this.cfginited = false); return this.initConfig(successcb, failcb); }, getPrivateConfig(successcb, failcb, bForce) { bForce && (this.pvcfginited = false); return this.initPrivateConfig(successcb, failcb); }, getShareConfig(successcb, failcb) { if (this._shconfiggetting) return 1; this._shconfiggetting = true; this.__getShareConfig(this.accountid, this.sessionid, this.channelid, this.gameid, this.sex, this.province, this.city, kvlist => { this._shconfiggetting = false; successcb && successcb(kvlist); }, (neterr, logicerr, errmsg) => { this._shconfiggetting = false; failcb && failcb(neterr, logicerr, errmsg); }); }, initShareConfig(successcb, failcb, bForce) { bForce && (this.shcfginited = false); if (this.shcfginited) { successcb && successcb(this.shcfglst); return 0; } this.pvcfginited = false; return this.getShareConfig(res => { if (res instanceof Array) { this.shcfglst && (this.shcfglst.length = 0); this.shcfglst = res; this.shcfginited = true; successcb && successcb(this.shcfglst); } else failcb && failcb(0, -1, ""); }, (neterr, logicerr, errmsg) => { failcb && failcb(neterr, logicerr, errmsg); }); }, setStorage: function(skey, svalue, successcb, failcb, timeorign_type, time_value) { let obj = { key: skey, value: svalue }; if (timeorign_type && time_value) { obj.time_origin = timeorign_type; obj.time_val = time_value; } let lst = [ obj ]; this.__setStorage(this.accountid, this.sessionid, this.token, lst, successcb, failcb); }, setStorages: function(kvlist, successcb, failcb) { this.__setStorage(this.accountid, this.sessionid, this.token, kvlist, successcb, failcb); }, getStorage: function(key, successcb, failcb) { this.__getStorage(this.accountid, this.sessionid, this.token, key, kvlist => { if (kvlist.length > 0) { let obj = kvlist[0]; successcb && successcb(obj.value, obj.ttl_seconds, obj.key); } else successcb && successcb(null, -1, key); }, failcb); }, getStorages: function(keylist, successcb, failcb) { let skey = keylist.join(); this.__getStorage(this.accountid, this.sessionid, this.token, skey, successcb, failcb); }, delStorage: function(key, successcb, failcb) { this.__delStorage(this.accountid, this.sessionid, this.token, key, successcb, failcb); }, delStorages: function(keylist, successcb, failcb) { let skey = keylist.join(); this.__delStorage(this.accountid, this.sessionid, this.token, skey, successcb, failcb); }, clearStorage: function(successcb, failcb) { this.__clearStorage(this.accountid, this.sessionid, this.token, successcb, failcb); }, setExpireTime: function(key, timeorign_type, time_value, successcb, failcb) { this.__setExpireTime(this.accountid, this.sessionid, this.token, key, timeorign_type, time_value, successcb, failcb); }, setExpireTimes: function(keylist, timeorign_type, time_value, successcb, failcb) { let skey = keylist.join(); this.__setExpireTime(this.accountid, this.sessionid, this.token, skey, timeorign_type, time_value, successcb, failcb); }, getExpireTime: function(key, successcb, failcb) { this.__getStorage(this.accountid, this.sessionid, this.token, key, ktlist => { if (ktlist.length > 0) { let obj = ktlist[0]; successcb && successcb(obj.ttl_seconds, obj.key); } else successcb && successcb(-1, key); }, failcb); }, getExpireTimes: function(key, successcb, failcb) { this.__getStorage(this.accountid, this.sessionid, this.token, key, successcb, failcb); } }; }), { "../common/httpclient": 2, "../common/urlbuilder": 6 } ], 13: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); var urlbuilder = require("../common/urlbuilder"); var storage = require("../common/storage"); const JC_LOG_T = { lauch: { key: 1, subkey: 1 }, entermain: { key: 1, subkey: 2 }, show: { key: 1, subkey: 3 }, hide: { key: 1, subkey: 3 }, jumpapp: { key: 1, subkey: 4 }, loginFailed: { key: 1, subkey: 5 }, launchsysteminfo: { key: 1, subkey: 6 }, logined: { key: 11, subkey: 1 }, authed: { key: 11, subkey: 2 }, authfail: { key: 11, subkey: 3 }, startgame: { key: 11, subkey: 4 }, restartgame: { key: 11, subkey: 4 }, gameover: { key: 11, subkey: 6 }, againgame: { key: 11, subkey: 4 }, productitem: { key: 11, subkey: 8 }, useitem: { key: 11, subkey: 9 }, share: { key: 11, subkey: 10 }, inviter: { key: 11, subkey: 11 }, systeminfo: { key: 11, subkey: 20 }, advinfo: { key: 11, subkey: 21 }, vslogin: { key: 11, subkey: 24 }, vsreconnect: { key: 11, subkey: 25 }, vsroomcreate: { key: 11, subkey: 26 }, vsroomjoin: { key: 11, subkey: 27 }, vsroomleave: { key: 11, subkey: 28 }, vsroomsetstate: { key: 11, subkey: 29 }, business: { key: 11, subkey: 30 }, buttonclick: { key: 11, subkey: 31 }, msgevent: { key: 11, subkey: 32 }, msgstatistical: { key: 51, subkey: 300 } }; const _SHOW_FLAG = 2; const _HIDE_FLAG = 1; const _ONLINE_KEY = "jc_online_flags"; module.exports = { __uuid(len, radix) { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""); var uuid = [], i; radix = radix || chars.length; if (len) for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; else { var r; uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-"; uuid[14] = "4"; for (i = 0; i < 36; i++) if (!uuid[i]) { r = 0 | 16 * Math.random(); uuid[i] = chars[19 == i ? 3 & r | 8 : r]; } } return uuid.join(""); }, _buildReportUrl(typeobj) { this.urlbd.clear(); this.urlbd.addKV("c", "GameLog").addKV("a", "reportLog").addKV("gameid", this.gameid).addKV("channel", this.channelid).addKV("account_id", this.accountid).addKV("session_id", this.sessionid).addKV("access_token", this.token).addKV("wid", this.wid).addKV("sid", this.sid).addKV("ptid", this.ptid).addKV("logclass1", typeobj.key).addKV("logclass2", typeobj.subkey).addKV("localuuid", this.localid).addKV("from_appid", this.fromid).addKV("ad_channel", this.adchannel); console.log("[gamelog]"); console.log(JSON.stringify(typeobj)); return this.urlbd.baseurl; }, _buildReportUserUrl() { this.urlbd.clear(); this.urlbd.addKV("c", "GameLog").addKV("a", "reportUser").addKV("gameid", this.gameid).addKV("channel", this.channelid).addKV("account_id", this.accountid).addKV("session_id", this.sessionid).addKV("access_token", this.token); return this.urlbd.baseurl; }, _buildShowHideMsg(showflag) { let data = { str1: this.localid, str2: this.fromid, str3: this.accountid, str4: this.nickname, num1: showflag, num2: -1 }; let msg = { u: this._buildReportUrl(showflag == _SHOW_FLAG ? JC_LOG_T.show : JC_LOG_T.hide), v: JSON.stringify(data), ext: showflag }; return msg; }, _report(typeobj, valueobj, successcb, failcb) { let url = this._buildReportUrl(typeobj); let value = JSON.stringify(valueobj); var self = this; httpclient.httpPost(url, value, (function(restext) { let obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { console.log("[_report]success!" + JSON.stringify(obj)); successcb && successcb(); } else { console.log("[_report]" + url); console.log("[_report]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[_report]" + url); console.log("[_report]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); let nflag = -1; typeobj.key == JC_LOG_T.show.key && typeobj.subkey == JC_LOG_T.show.subkey && (nflag = valueobj.num1); let msg = { u: url, v: value, ext: nflag }; self.cachemsg.push(msg); })); }, _reportUser(valueobj, successcb, failcb) { let url = this._buildReportUserUrl(); let value = JSON.stringify(valueobj); var self = this; httpclient.httpPost(url, value, (function(restext) { let obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { console.log("[_reportUser]success!" + JSON.stringify(obj)); successcb && successcb(); } else { console.log("[_reportUser]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[_reportUser]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); let nflag = -1; let msg = { u: url, v: value, ext: nflag }; self.cachemsg.push(msg); })); }, _retry() { if (this.cachemsg.length > 0) { let obj = this.cachemsg[0]; var self = this; httpclient.httpPost(obj.u, obj.v, (function(restext) { if (obj.ext >= 0) { self.showflag = obj.ext; self._saveflag(self.showflag); } self.cachemsg.shift(); }), (function(errcode, errmsg) { console.log("[_retry_report]failed!" + errcode + ":" + errmsg); })); } }, _saveflag(showflag) { storage.set(_ONLINE_KEY, showflag); }, _loadflag: () => storage.get(_ONLINE_KEY), _handlelaunch(res) { if (res) { if (res.query && res.query.weixinadinfo) { let wxaddr = res.query.weixinadinfo.split("."); let ad = wxaddr[0]; ad && "" != ad && (this.fromadvid = ad); } res.query && res.query.channel && (this.adchannel = "" + res.query.channel); this.launchparam = res.query; if (res.referrerInfo && res.referrerInfo.appId) { this.setFromAppID(res.referrerInfo.appId); this.launchparam = res.referrerInfo.extraData; } else if (res.query && res.query.scene) { let str = decodeURIComponent(res.query.scene); let lst = str.split("="); lst.length >= 2 && "channel" == lst[0] ? this.adchannel = lst[1] : this.setFromAppID(str); } this.scene = res.scene ? res.scene : 0; "" == this.adchannel && "" != this.fromid && (this.adchannel = this.fromid); } }, _handleLoginInfo(res) { res.account_id && res.session_id && this.setAccountID(res.account_id, res.session_id); res && res.nickname && "" != res.nickname && this.setNickName(res.nickname); }, _handleAuthInfo(res) { res && (res.nickname && "" != res.nickname ? this.setNickName(res.nickname) : res.nickName && "" != res.nickName && this.setNickName(res.nickName)); }, generateUUID() { return this.__uuid(32, 62); }, init(channelid, gameid, isoffical, owner, url) { this.gameid = gameid; this.channelid = channelid; this.accountid = this.accountid ? this.accountid : ""; this.sessionid = this.sessionid ? this.sessionid : ""; this.token = this.token ? this.token : ""; this.localid = this.localid ? this.localid : ""; this.nickname = this.nickname ? this.nickname : ""; this.fromid = this.fromid ? this.fromid : ""; this.fromadvid = this.fromadvid ? this.fromadvid : ""; this.scene = this.scene ? this.scene : 0; this.adchannel = this.adchannel ? this.adchannel : ""; this._tempuuid = ""; this._starttime = 0; this._launchtime = 0; this.needsubmit = false; this.urlbd = new urlbuilder(url); this.showflag = this._loadflag(); this.cachemsg = []; this.showflag == _SHOW_FLAG && this.cachemsg.push(this._buildShowHideMsg(this.showflag)); this.showflag = null; setInterval(this._retry.bind(this), 5e3); console.log("[jcgamelog]init:" + gameid + "|" + channelid + "|" + isoffical); }, setSubmitFlag(bsubmit) { this.needsubmit = bsubmit; }, setAccountID(accountid, sessionid, exobj) { this.accountid && this.accountid == accountid || (this.accountid = accountid); this.sessionid && this.sessionid == sessionid || (this.sessionid = sessionid); if (exobj) { this.wid = exobj.wid; this.sid = exobj.sid; this.ptid = exobj.ptid; } }, setNickName(nickname) { this.nickname && this.nickname == nickname || (this.nickname = nickname); }, setFromAppID(appid) { this.fromid && this.fromid == appid || (this.fromid = appid); }, setLocalUUID(uuid) { this.localid && this.localid == uuid || (this.localid = uuid); }, setSystemInfo(info) {}, setToken(token) { this.token = token; }, handlelaunch(res, cb) { this._launchtime = new Date().getTime(); var param = 0; var uid = ""; var stype = 0; var invid = ""; if (res) { this._handlelaunch(res); param = res.query.activity_param ? res.query.activity_param : 0; uid = res.query.localuuid ? res.query.localuuid : ""; stype = res.query.sharetype ? res.query.sharetype : 0; invid = res.query.inviter_id ? res.query.inviter_id : ""; } this.logLauchDefault(res); cb && cb(stype, param, uid, invid, this.fromid, this.scene, this.launchparam); }, logLaunch(launch_option) { this._launchtime = new Date().getTime(); this._handlelaunch(launch_option); this.logLauchDefault(launch_option); }, logLauchDefault(launch_option) { let data = { str1: this.localid, str2: this.fromid, ext: launch_option ? JSON.stringify(launch_option) : null, str3: this.fromadvid, num1: this.scene }; this._report(JC_LOG_T.lauch, data); }, logLoginSuccess(res, costtime) { let nowtime = new Date().getTime(); let dttime = nowtime - this._launchtime; this._handleLoginInfo(res); let data = { str1: res.nickname, str2: res.unionid, str3: res.country, str4: res.province, str5: res.city, str6: this.localid, num1: costtime || 0, num2: dttime, str7: this.fromadvid }; console.log("[launchcost]" + dttime); this._report(JC_LOG_T.logined, data); }, logLoginFailed(neterr, logicerr, errmsg) { let data = { error_code_net: neterr, error_code_logic: logicerr, error_msg: errmsg }; this._report(JC_LOG_T.loginFailed, data); }, logAuthSuccess(res) { this._handleAuthInfo(res); let data = { str1: this.nickname, num1: res.gender, str3: res.country, str4: res.province, str5: res.city, str6: this.localid, str7: res.avatarUrl ? res.avatarUrl : "", str8: res.language }; this._report(JC_LOG_T.authed, data); }, logAuthFail() { let data = { str1: this.nickname, str2: this.localid }; this._report(JC_LOG_T.authfail, data); }, logShare(businessid, sharetokenid, param, err, imgidx, dtime) { let obj = { token: sharetokenid || "", error: err || "", deltatime: dtime }; let data = { str1: this.nickname, str2: JSON.stringify(obj), num1: imgidx || 0, str3: param || "", activity_id_str: "" + businessid }; this._report(JC_LOG_T.share, data); }, logShareInvite(inviterid, businessid, sharetokenid, param) { let n = 0; try { n = parseInt(businessid); } catch (err) {} let data = { str1: this.nickname, str2: inviterid, num1: n, str3: sharetokenid || sharetokenid, str4: param || "", activity_id_str: "" + businessid }; this._report(JC_LOG_T.inviter, data); }, logSysInfo(res, typeobj) { let data = { str1: res.brand, str2: res.model, str3: res.language, str4: res.version, str5: res.platform, str6: res.SDKVersion, str7: res.system, num1: res.pixelRatio, num2: res.screenWidth, num3: res.screenHeight, num4: res.windowWidth, num5: res.windowHeight, num6: res.benchmarkLevel }; this._report(typeobj, data); }, logSystemInfo(res) { if (!res) return; this.logSysInfo(res, JC_LOG_T.systeminfo); }, logLaunchSystemInfo(res) { if (!res) return; this.logSysInfo(res, JC_LOG_T.launchsysteminfo); }, logStartGame(param, startmode) { this._tempuuid = this.generateUUID(); this._starttime = new Date().getTime(); let data = { str1: this.fromid, str2: this._tempuuid, str3: param || "", str4: this.nickname, str5: this.localid, num1: startmode || 0 }; this._report(JC_LOG_T.startgame, data); }, logRestartGame(param) { this._tempuuid = this.generateUUID(); this._starttime = new Date().getTime(); let data = { str1: this.fromid, str2: this._tempuuid, str3: param || "", str4: this.nickname, str5: this.localid, num1: 1 }; this._report(JC_LOG_T.restartgame, data); }, logGameover(param, score, endflag) { let nowtime = new Date().getTime(); let data = { str1: this.fromid, str2: this._tempuuid, str3: param || "", num1: score, str4: this.nickname, str5: this.localid, num2: nowtime - this._starttime, num3: endflag || 0 }; this._report(JC_LOG_T.gameover, data); }, logTryAgain(param) { this._tempuuid = this.generateUUID(); let data = { str1: this.fromid, str2: this._tempuuid, str3: param || "", str4: this.nickname, str5: this.localid, num1: 2 }; this._report(JC_LOG_T.againgame, data); }, logShow(bIgnoreFlag) { if (!bIgnoreFlag) { let bok = !this.showflag || this.showflag == _HIDE_FLAG; if (!bok) return; this.showflag = _SHOW_FLAG; } let nowtime = new Date().getTime(); let data = { str1: this.localid, str2: this.fromid, str3: this.accountid, str4: this.nickname, num1: _SHOW_FLAG, num2: nowtime - this._launchtime }; this._report(JC_LOG_T.show, data, () => { bIgnoreFlag || this._saveflag(this.showflag); }, () => {}); }, logHide(bIgnoreFlag) { if (!bIgnoreFlag) { let bok = this.showflag && this.showflag == _SHOW_FLAG; if (!bok) return; this.showflag = _HIDE_FLAG; } let nowtime = new Date().getTime(); let data = { str1: this.localid, str2: this.fromid, str3: this.accountid, str4: this.nickname, num1: _HIDE_FLAG, num2: nowtime - this._launchtime }; this._report(JC_LOG_T.hide, data, () => { bIgnoreFlag || this._saveflag(this.showflag); }, () => {}); }, logProductItem(itemid, itemcount, reson, resonparam) { let data = { str1: this.nickname, num1: itemid, num2: itemcount, num3: reson, num4: resonparam }; this._report(JC_LOG_T.productitem, data); }, logUseItem(itemid, itemcount, reson, resonparam) { let data = { str1: this.nickname, num1: itemid, num2: itemcount, num3: reson, num4: resonparam }; this._report(JC_LOG_T.useitem, data); }, logBusiness(businessid, actionid) { let data = { str1: this.nickname, str2: this.localid, num1: businessid, num2: actionid }; this._report(JC_LOG_T.business, data); }, logEnterMainScene(dt) { let data = { str1: this.localid, str2: this.fromid, num1: dt || 0 }; this._report(JC_LOG_T.entermain, data); }, logJumpApp(appid, appparam, jumpres, qdid) { let obj = { param: appparam || "" }; "object" === typeof qdid ? Object.assign(obj, qdid) : obj["qd"] = qdid || ""; let data = { str1: this.localid, str2: this.fromid, str3: this.accountid, str4: this.nickname, str5: appid, str6: obj, num1: jumpres || 0 }; this._report(JC_LOG_T.jumpapp, data); }, logAdvInfo(advid, actiontype, errinfo, adtype, state) { let serr = ""; let ntype = 1; ntype = 2 == adtype ? 201 : 1 == adtype ? 101 : errinfo ? 2 : 1; if (errinfo) try { serr = JSON.stringify(errinfo); } catch (err) {} let n = state || 0; let data = { str1: this.nickname, str2: advid, num1: ntype, str3: serr, activity_id_str: "" + actiontype, adv_id_state: "" + n }; this._report(JC_LOG_T.advinfo, data); }, logVS_login() { let data = { str1: this.nickname }; this._report(JC_LOG_T.vslogin, data); }, logVS_reconnect(roomid) { let data = { str1: this.nickname, str2: roomid }; this._report(JC_LOG_T.vsreconnect, data); }, logVS_createRoom(roomname, maxplayer) { let data = { str1: this.nickname, str2: roomname, num1: maxplayer }; this._report(JC_LOG_T.vsroomcreate, data); }, logVS_joinRoom(roomid, customdata, israndom) { let data = { str1: this.nickname, str2: roomid || "", num1: israndom ? 1 : 0, str3: customdata }; this._report(JC_LOG_T.vsroomjoin, data); }, logVS_leaveRoom(roomid, customdata) { let data = { str1: this.nickname, str2: roomid, str3: customdata }; this._report(JC_LOG_T.vsroomleave, data); }, logVS_gameReady(roomid, customdata, isready) { let data = { str1: this.nickname, str2: roomid, num1: isready ? 1 : 0, str3: customdata }; this._report(JC_LOG_T.vsroomsetstate, data); }, logVS_gameStart(roomid, customdata) { let data = { str1: this.nickname, str2: roomid, num1: 2, str3: customdata }; this._report(JC_LOG_T.vsroomsetstate, data); }, logButtonClick(buttonname, param, buttonsubname) { let data = { nickname: this.nickname, button_name: buttonname, button_param: param || "" }; buttonsubname && (data.button_subname = buttonsubname); this._report(JC_LOG_T.buttonclick, data); }, logStatisticUserInfo(res) { if (!res) return; let data = { role_lv: res.role_lv, total_eq_lv: res.total_eq_lv, wing_fight: res.wing_fight, pet_fight: res.pet_fight, role_total_fight: res.role_total_fight }; this._report(JC_LOG_T.msgstatistical, data); }, logMsg(msgid, msgname, errcode, reqcontent, rspcontent, passtime) { let data = { msg_id: msgid, msg_name: msgname, msg_error: errcode, req_content: reqcontent, rsp_content: rspcontent, msg_cosumetime: passtime }; this._report(JC_LOG_T.msgevent, data); }, userSet(kvobj) { let data = { set: kvobj }; this._reportUser(data); }, userSetOnce(kvobj) { let data = { set_once: kvobj }; this._reportUser(data); }, userAdd(kvobj) { let data = { add: kvobj }; this._reportUser(data); }, userReport(setobj, setonceobj, addobj) { let data = { set: setobj, set_once: setonceobj, add: addobj }; this._reportUser(data); }, externalLog(externalID, logFunc, p1, p2, p3, p4) { let tmpid = this.gameid; this.gameid = externalID; logFunc && logFunc.call(this, p1, p2, p3, p4); this.gameid = tmpid; } }; }), { "../common/httpclient": 2, "../common/storage": 5, "../common/urlbuilder": 6 } ], 14: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); var urlbuilder = require("../common/urlbuilder"); module.exports = { init(channelid, gameid, isoffical, owner, url) { this.owner = owner; this.gameid = gameid; this.channelid = channelid; this.isoffical = isoffical; this.url = url.replace("webapp/index.php", "api/gift"); console.log("[jcgoodsctrl]init:" + gameid + "|" + channelid + "|" + isoffical); }, setAccountID(accountid, sessionid) { this.accountid = accountid; this.sessionid = sessionid; }, setNickName(nickname) { this.nickname = nickname; }, giftList(successcb, failcb) { if (!this.url) { failcb && failcb(0, -1234, "not inited!"); return; } const url = `${this.url}/list?gameId=${this.gameid}&channelId=${this.channelid}`; httpclient.httpGet(url, restext => { let obj; try { obj = httpclient.JSON_parse(restext); } catch (err) {} if (obj && 0 === obj.errcode) successcb && successcb(obj.result); else { console.log("[jcgoods] giftList failed!" + obj ? obj.errcode : ":" + obj ? obj.errmsg : ""); failcb && failcb(0, obj ? obj.errcode : -1235, obj ? obj.errmsg : ""); } }, (errcode, errmsg) => { console.log("[jcgoods] giftList failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }); }, reqExchange(giftId, listId, successcb, failcb) { if (!this.url) { failcb && failcb(0, -1234, "not inited!"); return; } let data = { accountId: this.owner.accountID, sessionId: this.owner.sessionID, gameId: this.gameid, channelId: this.channelid, giftId: giftId, listId: listId }; const url = `${this.url}/exchange`; httpclient.httpPost(url, JSON.stringify(data), restext => { let obj; try { obj = httpclient.JSON_parse(restext); } catch (err) {} if (obj && 0 === obj.errcode) { console.log("[jcgoods] reqExchange success", obj); successcb && successcb(obj); } else { console.log("[jcgoods] reqExchange failed!", obj ? obj.errcode : "", obj ? obj.errmsg : ""); failcb && failcb(0, obj ? obj.errcode : -1235, obj ? obj.errmsg : ""); } }, (errcode, errmsg) => { console.log("[jcgoods] reqExchange failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }, "application/json"); }, phoneRecharge(recordId, phone, successcb, failcb) { if (!this.url) { failcb && failcb(0, -1234, "not inited!"); return; } let data = { accountId: this.owner.accountID, sessionId: this.owner.sessionID, recordId: recordId, phone: phone }; const url = `${this.url}/tel`; httpclient.httpPost(url, JSON.stringify(data), restext => { let obj; try { obj = httpclient.JSON_parse(restext); } catch (err) {} if (obj && 0 === obj.errcode) { console.log("[jcgoods] phoneRecharge success", obj); successcb && successcb(obj); } else { console.log("[jcgoods] phoneRecharge failed!", obj ? obj.errcode : "", obj ? obj.errmsg : ""); failcb && failcb(0, obj ? obj.errcode : -1235, obj ? obj.errmsg : ""); } }, (errcode, errmsg) => { console.log("[jcgoods] phoneRecharge failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }, "application/json"); }, itemExchange(recordId, phone, successcb, failcb) { if (!this.url) { failcb && failcb(0, -1234, "not inited!"); return; } let data = { accountId: this.owner.accountID, sessionId: this.owner.sessionID, recordId: recordId, phone: phone }; const url = `${this.url}/goods`; httpclient.httpPost(url, JSON.stringify(data), restext => { let obj; try { obj = httpclient.JSON_parse(restext); } catch (err) {} if (obj && 0 === obj.errcode) { console.log("[jcgoods] phoneRecharge success", obj); successcb && successcb(obj); } else { console.log("[jcgoods] phoneRecharge failed!", obj ? obj.errcode : "", obj ? obj.errmsg : ""); failcb && failcb(0, obj ? obj.errcode : -1235, obj ? obj.errmsg : ""); } }, (errcode, errmsg) => { console.log("[jcgoods] phoneRecharge failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }, "application/json"); } }; }), { "../common/httpclient": 2, "../common/urlbuilder": 6 } ], 15: [ (function(require, module, exports) { module.exports = { init(owner, isoffical) { this._owner = owner; this._isoffical = isoffical; }, debug(msg) { this._isoffical || this.jcLog("", msg, "info"); }, warn(msg) { this.jcLog("W", msg, "warning"); }, err(msg) { this.jcLog("ERROR", msg, "error"); }, jcLog(e, t, n) { try { var i = "error" === n ? "background: #c4161e; color: #fff" : "warning" === n ? "background: #ff8c1c; color: #fff" : "info" === n ? "background: #ff0080; color: #fff" : "background: #44a5ab; color: #fff", r = console.log("%c %c %c jclog %c %c %c " + e + " ", "background: #9854d8", "background: #6c2ca7", "color: #fff; background: #450f78;", "background: #6c2ca7", "background: #9854d8", i, void 0 !== t ? t : ""); console.log.apply(console, r); } catch (e) { console.log(e); } } }; }), {} ], 16: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); var urlbuilder = require("../common/urlbuilder"); module.exports = { __login({channelid: channelid, gameid: gameid, token: token, isoffical: isoffical, successcb: successcb, failcb: failcb, openid: openid, isGuest: isGuest, anonymousToaken: anonymousToaken, pkgName: pkgName, polySdkChannel: polySdkChannel, polySdkSubchannel: polySdkSubchannel}) { this.urlbd.clear(); this.urlbd.addKV("c", "Login").addKV("a", "auth").addKV("gameid", gameid).addKV("channel", channelid).addKV("token", token); openid && "" != openid && this.urlbd.addKV("openid", openid); anonymousToaken && this.urlbd.addKV("anonymous_token", anonymousToaken); pkgName && this.urlbd.addKV("pkg_name", pkgName); polySdkChannel && this.urlbd.addKV("poly_sdk_channel", polySdkChannel); polySdkSubchannel && this.urlbd.addKV("poly_sdk_subchannel", polySdkSubchannel); this.env && this.urlbd.addKV("env", this.env); this.urlbd.addKV("is_guest", isGuest || 0); console.log("[__login]start: " + this.urlbd.baseurl); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__login]success!" + JSON.stringify(obj)); successcb && successcb(obj); } else { console.log("[__login]failed!" + restext); failcb && failcb(0, obj ? obj.errcode : -1, obj ? obj.errmsg : restext); } }), (function(errcode, errmsg) { console.log("[__login]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __activeWX(gameid, accountid, sessionid, raw, sign, encyptdata, iv, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Login").addKV("a", "activateWeiXinUser").addKV("gameid", gameid).addKV("account_id", accountid).addKV("session_id", sessionid).addKV("rawdata", raw).addKV("signature", sign).addKV("encrypted_data", encyptdata).addKV("iv", iv); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { if ("" == restext) { failcb && failcb(0, -1, "restext is nullstring!"); return; } var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__activeWX]success!" + JSON.stringify(obj)); successcb && successcb(obj); } else { console.log("[__activeWX]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__activeWX]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __updateInfo(accountid, sessionid, usrinfo, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Login").addKV("a", "updateUserInfo").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("nickname", usrinfo.nickname).addKV("city", usrinfo.city).addKV("province", usrinfo.province).addKV("avatar_url", usrinfo.avatar_url).addKV("country", usrinfo.country).addKV("sex", usrinfo.sex).addKV("birthday", usrinfo.birthday).addKV("phone", usrinfo.phone).addKV("location", usrinfo.location); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__updateInfo]success!" + JSON.stringify(obj)); obj.userInfo = usrinfo; successcb && successcb(obj); } else { console.log("[__updateInfo]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__updateInfo]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __generalSignature(accountid, sessionid, signdata, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Login").addKV("a", "signature").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("params", signdata); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__generalSignature]success!" + JSON.stringify(obj)); successcb && successcb(obj); } else { console.log("[__generalSignature]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__generalSignature]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __generalToken(accountid, sessionid, sceneid, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Login").addKV("a", "getAccessToken").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("scene", sceneid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__generalToken]success!" + JSON.stringify(obj)); successcb && successcb(obj); } else { console.log("[__generalToken]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__generalToken]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __getAnnouncement(channelid, gameid, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Annc").addKV("a", "getAnnouncement").addKV("gameid", gameid).addKV("channel", channelid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__getAnnouncement]success!" + JSON.stringify(obj)); successcb && successcb(obj); } else { console.log("[__getAnnouncement]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__getAnnouncement]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __getServerList(channelid, gameid, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "SrvList").addKV("a", "getSrvList").addKV("gameid", gameid).addKV("channel", channelid); this.env && this.urlbd.addKV("env", this.env); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__getServerList]success!" + JSON.stringify(obj)); successcb && successcb(obj.server_list); } else { console.log("[__getServerList]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__getServerList]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __loginYoume(accountid, sessionid, roleid, nickname, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "YouMe").addKV("a", "login").addKV("account_id", accountid).addKV("session_id", sessionid).addKV("nickname", nickname).addKV("role_id", roleid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__loginYoume]success!" + JSON.stringify(obj)); successcb && successcb(obj.token); } else { console.log("[__loginYoume]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__loginYoume]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __registerJCAccount(account, pwd, phone, smscode, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "SelfSdk").addKV("a", "registerAccount").addKV("account", account).addKV("passwd", pwd).addKV("phone", phone).addKV("sms_auth_code", smscode); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__registerAccount]success!" + JSON.stringify(obj)); successcb && successcb(obj.token); } else { console.log("[__registerAccount]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__registerAccount]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __loginJCAnonymous(successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "SelfSdk").addKV("a", "guestLogin"); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__loginJCAnonymous]success!" + JSON.stringify(obj)); successcb && successcb(obj.token); } else { console.log("[__loginJCAnonymous]failed!"); failcb && failcb(0, obj ? obj.errcode : -1, obj ? obj.errmsg : ""); } }), (function(errcode, errmsg) { console.log("[__loginJCAnonymous]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __loginJCByID(account, pwd, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "SelfSdk").addKV("a", "login").addKV("account", account).addKV("passwd", pwd); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__loginJC]success!" + JSON.stringify(obj)); successcb && successcb(obj.token); } else { console.log("[__loginJC]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__loginJC]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __loginJCBySMS(phone, smscode, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "SelfSdk").addKV("a", "smsLogin").addKV("phone", phone).addKV("sms_auth_code", smscode); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__loginSMS]success!" + JSON.stringify(obj)); successcb && successcb(obj.token); } else { console.log("[__loginSMS]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__loginSMS]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __sendSMSCode(phone, code_type, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "SelfSdk").addKV("a", "sendSmsCode").addKV("phone", phone).addKV("code_type", code_type); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__sendSMSCode]success!" + JSON.stringify(obj)); successcb && successcb(); } else { console.log("[__sendSMSCode]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__sendSMSCode]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __getIPInfo(successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Login").addKV("a", "getIpInfo"); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__getIPInfo]success!" + JSON.stringify(obj)); successcb && successcb(obj.token); } else { console.log("[__getIPInfo]failed!" + obj ? obj.errcode : "0:" + obj ? obj.errmsg : ""); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__getIPInfo]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, _checkUserInfo() { this._localinfoloaded && this._svinfoloaded && (this.userinfo.rawData ? 6001 != this.channelid || this.actived ? this._combineInfo(this.svuserinfo, this.userinfo) ? this.updateinfo(this.svuserinfo, this._activesuccess, this._activefail) : this._activesuccess && this._activesuccess(this.userinfo) : this.activewx(this.userinfo, this._activesuccess, this._activefail) : this._combineInfo(this.svuserinfo, this.userinfo) ? this.updateinfo(this.svuserinfo, this._activesuccess, this._activefail) : this._activesuccess && this._activesuccess(this.userinfo)); }, _checkNickName() { this.userinfo.nickname && this.owner && this.owner.setNickName(this.userinfo.nickname); }, _loadLocalInfo(info) { this.userinfo || (this.userinfo = {}); this.owner.plat.setUserInfo(this.userinfo, info); console.log("[_loadLocalInfo]finish"); this._localinfoloaded = true; }, _loadTokenInfo(tokeninfo) { this.userinfo || (this.userinfo = {}); this.owner.plat.setTokenInfo(this.userinfo, tokeninfo); this._localtokenloaded = true; }, _loadServerInfo(info) { this.svuserinfo || (this.svuserinfo = {}); this.svuserinfo.nickname = info.nickname; this.svuserinfo.country = info.country; this.svuserinfo.province = info.province; this.svuserinfo.city = info.city; this.svuserinfo.avatar_url = info.avatar_url; this.svuserinfo.sex = info.sex; this.svuserinfo.birthday = info.birthday; this.svuserinfo.phone = info.phone; this.svuserinfo.location = info.location; console.log("[_loadServerInfo]finish"); this._svinfoloaded = true; }, _combineInfo(svinfo, lcinfo) { let bupdated = false; if (lcinfo.nickname && svinfo.nickname != lcinfo.nickname) { console.log("[nickname]" + svinfo.nickname + "|" + lcinfo.nickname); svinfo.nickname = lcinfo.nickname; bupdated = true; } if (lcinfo.city && svinfo.city != lcinfo.city) { console.log("[city]" + svinfo.city + "|" + lcinfo.city); svinfo.city = lcinfo.city; bupdated = true; } if (lcinfo.province && svinfo.province != lcinfo.province) { console.log("[province]" + svinfo.province + "|" + lcinfo.province); svinfo.province = lcinfo.province; bupdated = true; } if (lcinfo.country && svinfo.country != lcinfo.country) { console.log("[country]" + svinfo.country + "|" + lcinfo.country); svinfo.country = lcinfo.country; bupdated = true; } if (lcinfo.avatar_url && svinfo.avatar_url != lcinfo.avatar_url) { console.log("[avatar_url]" + svinfo.avatar_url + "|" + lcinfo.avatar_url); svinfo.avatar_url = lcinfo.avatar_url; bupdated = true; } if (lcinfo.sex && svinfo.sex != lcinfo.sex) { console.log("[sex]" + svinfo.sex + "|" + lcinfo.sex); svinfo.sex = lcinfo.sex; bupdated = true; } if (lcinfo.birthday && svinfo.birthday != lcinfo.birthday) { console.log("[birthday]" + svinfo.birthday + "|" + lcinfo.birthday); svinfo.birthday = lcinfo.birthday; bupdated = true; } if (lcinfo.phone && svinfo.phone != lcinfo.phone) { console.log("[phone]" + svinfo.phone + "|" + lcinfo.phone); svinfo.phone = lcinfo.phone; bupdated = true; } if (lcinfo.location && svinfo.location != lcinfo.location) { console.log("[location]" + svinfo.location + "|" + lcinfo.location); svinfo.location = lcinfo.location; bupdated = true; } return bupdated; }, init(channelid, gameid, isoffical, owner, env, url) { this.owner = owner; this.channelid = channelid; this.gameid = gameid; this.sessionid = this.sessionid ? this.sessionid : ""; this.accountid = this.accountid ? this.accountid : ""; this.openid = this.openid ? this.openid : ""; this.env = env; this.isoffical = isoffical; this.logined = !!this.logined && this.logined; this.urlbd = new urlbuilder(url); console.log("[jclogin]init:" + gameid + "|" + channelid + "|" + isoffical); }, login({token: token, successcb: successcb, failcb: failcb, openid: openid, isGuest: isGuest, anonymousToaken: anonymousToaken, pkgName: pkgName, polySdkChannel: polySdkChannel, polySdkSubchannel: polySdkSubchannel}) { var self = this; this.__login({ channelid: this.channelid, gameid: this.gameid, token: token, pkgName: pkgName, isoffical: this.isoffical, successcb: function(obj) { let nowtime = new Date().getTime(); self.sessionid = obj.session_id; self.accountid = obj.account_id; self.openid = obj.openid; self.actived = true == obj.activated; self.logined = true; self.login_costtime = nowtime - self._loginstarttime; self._loadServerInfo(obj); self._checkUserInfo(); successcb && successcb(obj); }, failcb: failcb, openid: openid, isGuest: isGuest, anonymousToaken: anonymousToaken, polySdkChannel: polySdkChannel, polySdkSubchannel: polySdkSubchannel }); }, loginPT(successcb, failcb, exparam) { this._loginstarttime = new Date().getTime(); this.owner.plat.PTLogin(exparam, successcb, failcb); }, updatePTInfo(userinfo, tokeninfo, successcb, failcb) { this.updateuserinfo(userinfo, tokeninfo, successcb, failcb); }, loginYoume(uid, uname, successcb, failcb) { this.__loginYoume(this.accountid, this.sessionid, uid, uname, successcb, failcb); }, loginJC(info, successcb, failcb) { if (!info) { failcb && failcb(0, -1e3, "info is null!"); return; } if (!info.userinfo) { failcb && failcb(0, -2e3, "userinfo is null!"); return; } info.userinfo.isanonymous ? this.__loginJCAnonymous(code => { this.login(code, obj => { obj.token = code; successcb && successcb(obj); }, failcb); }, failcb) : info.userinfo.isnew ? this.registerJC(info, code => { this.login(code, obj => { obj.token = code; successcb && successcb(obj); }, failcb); }, failcb) : info.userinfo.phone && info.userinfo.sms ? this.__loginJCBySMS(info.userinfo.phone, info.userinfo.sms, code => { this.login(code, obj => { obj.token = code; successcb && successcb(obj); }, failcb); }, failcb) : this.__loginJCByID(info.userinfo.id, info.userinfo.pwd, code => { this.login(code, obj => { obj.token = code; successcb && successcb(obj); }, failcb); }, failcb); }, loginAnonymous(successcb, failcb) { this.__loginJCAnonymous(code => { this.login(code, obj => { obj.token = code; obj.isGuest = true; successcb && successcb(obj); }, failcb, "", 1); }, failcb); }, registerJC(info, successcb, failcb) { if (!info || !info.userinfo) { failcb && failcb(0, -1e3, "userinfo is null!"); return; } this.__registerJCAccount(info.userinfo.id, info.userinfo.pwd, info.userinfo.phone, info.userinfo.sms, successcb, failcb); }, sendSMSForLogin(phone, successcb, failcb) { this.__sendSMSCode(phone, 1, successcb, failcb); }, sendSMSForRegister(phone, successcb, failcb) { this.__sendSMSCode(phone, 2, successcb, failcb); }, updateuserinfo(userinfo, tokeninfo, successcb, failcb) { this._loadLocalInfo(userinfo); this._loadTokenInfo(tokeninfo); this._activesuccess = successcb; this._activefail = failcb; this._checkUserInfo(); this._checkNickName(); }, activewx(res, successcb, failcb) { var self = this; this.__activeWX(this.gameid, this.accountid, this.sessionid, res.rawData, res.signature, res.encryptedData, res.iv, (function(obj) { self.actived = true; successcb && successcb(obj); }), failcb); }, updateinfo(usrinfo, successcb, failcb) { this.__updateInfo(this.accountid, this.sessionid, usrinfo, successcb, failcb); }, getToken(sceneid, successcb, failcb) { this.__generalToken(this.accountid, this.sessionid, sceneid, successcb, failcb); }, getSignature(signdata, successcb, failcb) { this.__generalSignature(this.accountid, this.sessionid, signdata, successcb, failcb); }, getAnnouncement(successcb, failcb) { this.__getAnnouncement(this.channelid, this.gameid, successcb, failcb); }, getServerList(successcb, failcb) { this.__getServerList(this.channelid, this.gameid, successcb, failcb); }, isActived() { return this.actived; }, AccountID(openid) { if (this.accountid && "" != this.accountid) return this.accountid; return this.channelid + "_" + this.gameid + "_" + openid; }, setAccountID(accountid, sessionid) { this.accountid = accountid; this.sessionid = sessionid; }, setNickName(nickname) { this.nickname = nickname; }, setFromAppID(appid) { this.fromid = appid; }, setLocalUUID(uuid) { this.localid = uuid; }, clear() { this._localinfoloaded = false; this._svinfoloaded = false; }, setSystemInfo(info) {}, appendUserInfo(dstinfo, srcinfo) { if (!dstinfo) return false; dstinfo.nickname = dstinfo.nickname || ""; dstinfo.country = dstinfo.country || ""; dstinfo.province = dstinfo.province || ""; dstinfo.city = dstinfo.city || ""; dstinfo.avatar_url = dstinfo.avatar_url || ""; dstinfo.sex = dstinfo.sex || 0; dstinfo.birthday = dstinfo.birthday || ""; dstinfo.phone = dstinfo.phone || ""; dstinfo.location = dstinfo.location || ""; srcinfo && this.owner.plat.setUserInfo(dstinfo, srcinfo); } }; }), { "../common/httpclient": 2, "../common/urlbuilder": 6 } ], 17: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); var urlbuilder = require("../common/urlbuilder"); module.exports = { init(channelid, gameid, isoffical, owner, url) { this.owner = owner; this.gameid = gameid; this.channelid = channelid; this.isoffical = isoffical; this.urlbd = new urlbuilder(url); console.log("[jcmailctrl]init:" + gameid + "|" + channelid + "|" + isoffical); }, setAccountID(accountid, sessionid) { this.accountid = accountid; this.sessionid = sessionid; }, setNickName(nickname) { this.nickname = nickname; }, setFromAppID(appid) { this.fromid = appid; }, setLocalUUID(uuid) { this.localid = uuid; }, setSystemInfo(info) {}, setServerTime(servertime, localtime) { this.loginSrvTime = servertime; this.loginLocalTime = localtime; }, reqMailList(successcb, failcb) { if (!this.urlbd) { failcb && failcb(0, -1234, "not inited!"); return; } this.urlbd.clear(); this.urlbd.addKV("c", "Mail").addKV("a", "getMailList").addKV("session_id", this.sessionid).addKV("account_id", this.accountid); httpclient.httpGet(this.urlbd.baseurl, restext => { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[reqMailList]success!" + JSON.stringify(obj)); var maillist = obj.maillist; maillist ? successcb && successcb(maillist) : failcb && failcb(0, -1, "maillist is not obj"); } else { console.log("[reqMailList]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }, (errcode, errmsg) => { console.log("[reqMailList]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }); }, reqGetAttachment(mailids, successcb, failcb) { if (!this.urlbd) { failcb && failcb(0, -1234, "not inited!"); return; } let lst = mailids instanceof Array ? mailids : [ mailids ]; this.urlbd.clear(); this.urlbd.addKV("c", "Mail").addKV("a", "getAttachment").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("mail_ids", lst.join()); httpclient.httpGet(this.urlbd.baseurl, restext => { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[reqGetAttachment]success!" + JSON.stringify(obj)); successcb && successcb(lst); } else { console.log("[reqGetAttachment]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }, (errcode, errmsg) => { console.log("[reqGetAttachment]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }); }, reqMarkMail(nmailid, successcb, failcb) { if (!this.urlbd) { failcb && failcb(0, -1234, "not inited!"); return; } this.urlbd.clear(); this.urlbd.addKV("c", "Mail").addKV("a", "markMail").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("mailid", nmailid).addKV("flag", 1); httpclient.httpGet(this.urlbd.baseurl, restext => { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[reqMarkMail]success!" + JSON.stringify(obj)); successcb && successcb(nmailid); } else { console.log("[reqMarkMail]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }, (errcode, errmsg) => { console.log("[reqMarkMail]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }); }, reqGetUnreadMailCount(successcb, failcb) { if (!this.urlbd) { failcb && failcb(0, -1234, "not inited!"); return; } this.urlbd.clear(); this.urlbd.addKV("c", "Mail").addKV("a", "getUnreadMailCnt").addKV("session_id", this.sessionid).addKV("account_id", this.accountid); httpclient.httpGet(this.urlbd.baseurl, restext => { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[reqGetUnreadMailCount]success!" + JSON.stringify(obj)); successcb && successcb(obj.unread_mail_cnt); } else { console.log("[reqGetUnreadMailCount]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }, (errcode, errmsg) => { console.log("[reqGetUnreadMailCount]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }); } }; }), { "../common/httpclient": 2, "../common/urlbuilder": 6 } ], 18: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); var urlbuilder = require("../common/urlbuilder"); var storage = require("../common/storage"); const JC_NOTIFY_MSG_KEY = "jc_notify_msg"; module.exports = { __getMsglist(successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "MsgQueue").addKV("a", "getMsgList").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("sid", this.sid).addKV("wid", this.wid).addKV("ptid", this.ptid); httpclient.httpGet(this.urlbd.baseurl, restext => { console.log("[__getMsglist]result:"); var obj = httpclient.JSON_parse(restext); if (0 == obj.errcode) { console.log("[__getMsglist]success!" + JSON.stringify(obj)); var msglst = obj.msglist; msglst ? successcb && successcb(msglst) : failcb && failcb(0, -1, "msglst is not obj"); } else { console.log("[__getMsglist]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }, (errcode, errmsg) => { console.log("[__getMsglist]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }); }, __markMsgs(msgidlst) { let smsgs = msgidlst instanceof Array ? msgidlst.join() : msgidlst; this.urlbd.clear(); this.urlbd.addKV("c", "MsgQueue").addKV("a", "markMsg").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("sid", this.sid).addKV("wid", this.wid).addKV("ptid", this.ptid).addKV("msg_ids", smsgs); httpclient.httpGet(this.urlbd.baseurl, res => { this.isoffical || console.log("[__markMsgs]" + res); }, (err, errmsg) => { this.isoffical || console.log("[__markMsgs]Err:" + err + "|" + errmsg); }); }, init(channelid, gameid, isoffical, owner, url) { this.owner = owner; this.gameid = gameid; this.channelid = channelid; this.isoffical = isoffical; this.urlbd = new urlbuilder(url); this.initMsglist(); console.log("[jcnotify]init:" + gameid + "|" + channelid + "|" + isoffical); }, setAccountID(accountid, sessionid, exobj) { this.accountid = accountid; this.sessionid = sessionid; if (exobj) { this.wid = exobj.wid; this.sid = exobj.sid; this.ptid = exobj.ptid; } this.getMsglist(); }, setNickName(nickname) { this.nickname = nickname; }, setFromAppID(appid) { this.fromid = appid; }, setLocalUUID(uuid) { this.localid = uuid; }, setSystemInfo(info) {}, setServerTime(servertime, localtime) { this.loginSrvTime = servertime; this.loginLocalTime = localtime; }, getMsglist() { this.__getMsglist(res => { let idlst = []; res.forEach(element => { let obj = this.msglist.find(item => item.id == element.msg_id); if (obj) { obj.type = element.msg_type; obj.content = element.content; obj.name = element.msg_name; obj.sendtime = element.sendtime; obj.expiretime = element.expiretime ? element.expiretime : element.sendtime + 864e5; } else { obj = { id: element.msg_id, type: element.msg_type, content: element.content, name: element.msg_name, sendtime: element.sendtime, expiretime: element.expiretime ? element.expiretime : element.sendtime + 864e5 }; this.msglist.push(obj); } idlst.push(element.msg_id); }); idlst.length > 0 && this._checkMsglist(); this._reqMsglist(false); }, () => { this._reqMsglist(true); }); }, initMsglist() { this.msglist ? this.msglist.length = 0 : this.msglist = []; let obj = storage.getjson(JC_NOTIFY_MSG_KEY); obj && (this.msglist = this.msglist.concat(obj)); this._lastidx = this.msglist.length > 0 ? 0 : -1; }, resetMsglist() { storage.remove(JC_NOTIFY_MSG_KEY); this.msglist.length = 0; this.getMsglist(); }, _reqMsglist(breload) { let dt = breload ? 1e4 : 6e5; setTimeout(() => { this.getMsglist(); }, dt); }, _checkMsglist() { let tm = this._getServerNowTime(); let i = this.msglist.length; while (i--) { let obj = this.msglist[i]; this._isExpire(obj, tm) && this.msglist.splice(i, 1); } this.msglist.sort((a, b) => a.sendtime > b.sendtime); this._handleMsglist(this.msglist, this); storage.setjson(JC_NOTIFY_MSG_KEY, this.msglist); }, _getServerNowTime() { if (this.owner) return this.owner.getServerNowTime(); { let tm = new Date().getTime(); return this.loginSrvTime + (tm - this.loginLocalTime) / 1e3; } }, _isExpire: (msg, nowtime) => msg.expiretime < nowtime, getOneMsg() { if (!this.msglist) return ""; this._lastidx >= this.msglist.length && (this._lastidx = this.msglist.length > 0 ? 0 : -1); if (this._lastidx < this.msglist.length && this._lastidx >= 0) { let obj = this.msglist[this._lastidx]; this._lastidx++; return obj.content; } return ""; }, _handleMsglist(lst, owner) { this.owner && this.owner._handleNotifyMsgs && this.owner._handleNotifyMsgs(lst, owner); } }; }), { "../common/httpclient": 2, "../common/storage": 5, "../common/urlbuilder": 6 } ], 19: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); module.exports = { init(channelid, gameid, isoffical, owner, url) { this.owner = owner; this.gameid = gameid; this.channelid = channelid; this.isoffical = isoffical; this.url = url.replace("webapp/index.php", "api/games"); console.log("[jcrankctrl]init:" + gameid + "|" + channelid + "|" + isoffical); }, setNickName(nickname) { this.nickname = nickname || "\u533f\u540d\u73a9\u5bb6"; }, setAvatar(avatar) { this.avatar_url = avatar || "https://resource.kingsome.cn/share/1004/normal/5d42b6fb8e19260c1a16eefa.png"; }, setUserInfo(info) { info && info.avatar_url && this.setAvatar(info.avatar_url); }, canShowSelf() { return this.nickname || this.avatar_url; }, reqRankList(successcb, failcb) { if (!this.url) { failcb && failcb(0, -1234, "not inited!"); return; } const url = `${this.url}/rank`; let self = this; let data = { gameId: this.gameid, channelId: this.channelid, accountId: this.owner.accountID }; httpclient.httpPost(url, JSON.stringify(data), restext => { let obj; try { obj = httpclient.JSON_parse(restext); } catch (err) {} if (obj && 0 === obj.errcode) { self.recordList = obj.records; self.recordList ? successcb && successcb(self.recordList, obj.userRank, obj.userScore, obj.userTitle) : failcb && failcb(0, -1, "ranklist is not obj"); } else { console.log("[reqRankList]failed!" + obj ? obj.errcode : ":" + obj ? obj.errmsg : ""); failcb && failcb(0, obj ? obj.errcode : -1235, obj ? obj.errmsg : ""); } }, (errcode, errmsg) => { console.log("[reqRankList]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }); }, updateRank(score, successcb, failcb, title) { if (!this.url) { failcb && failcb(0, -1234, "not inited!"); return; } this.nickname = this.nickname || jc.nickName; if (!this.nickname && !this.avatar_url) { failcb && failcb(0, -1234, "not login!"); return; } const url = `${this.url}/rank/update`; let data = { gameId: this.gameid, channelId: this.channelid, accountId: this.owner.accountID, score: score, nickname: this.nickname, avatar: this.avatar_url, needType: 1 }; httpclient.httpPost(url, JSON.stringify(data), restext => { let obj; try { obj = httpclient.JSON_parse(restext); } catch (err) {} if (obj && 0 === obj.errcode) { let datas = []; if (obj.preRecord) { obj.preRecord.rank += 1; datas.push(obj.preRecord); } datas.push({ score: obj.userScore, rank: obj.userRank + 1, avatar: this.avatar_url, nickname: this.nickname }); if (obj.nextRecord) { obj.nextRecord.rank += 1; datas.push(obj.nextRecord); } successcb && successcb(datas); } else { console.log("[reqRankList]failed!" + obj ? obj.errcode : ":" + obj ? obj.errmsg : ""); failcb && failcb(0, obj ? obj.errcode : -1235, obj ? obj.errmsg : ""); } }, (errcode, errmsg) => { console.log("[updateRank]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }); }, rankChallenge(score, successcb, failcb, count) { if (!this.url) { failcb && failcb(0, -1234, "not inited!"); return; } count = count || 10; const url = `${this.url}/rank/challenge/0/${this.owner.accountID}/${count}`; let self = this; httpclient.httpGet(url, restext => { let obj; try { obj = httpclient.JSON_parse(restext); } catch (err) {} if (obj && 0 === obj.errcode) successcb && successcb(obj.users); else { console.log("[reqChallengeList]failed!" + obj ? obj.errcode : ":" + obj ? obj.errmsg : ""); failcb && failcb(0, obj ? obj.errcode : -1235, obj ? obj.errmsg : ""); } }, (errcode, errmsg) => { console.log("[reqChallengeList]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); }); }, jsonToKeyVal(data) { let str = ""; for (var key in data) { if (!data.hasOwnProperty(key)) continue; str += `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}&`; } return str.replace(/\$$/, ""); } }; }), { "../common/httpclient": 2 } ], 20: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); var urlbuilder = require("../common/urlbuilder"); module.exports = { init(channelid, gameid, isoffical, owner, url) { this.owner = owner; this.channelid = channelid; this.gameid = gameid; this.sessionid = this.sessionid ? this.sessionid : ""; this.accountid = this.accountid ? this.accountid : ""; this.openid = this.openid ? this.openid : ""; this.isoffical = isoffical; this.logined = !!this.logined && this.logined; this.urlbd = new urlbuilder(url); console.log("[jclogin]init:" + gameid + "|" + channelid + "|" + isoffical); }, start() {}, __Recharge(accountid, serverid, roleid, rolename, price, itemid, sign, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Pay").addKV("a", "getOrderId").addKV("accountid", accountid).addKV("serverid", serverid).addKV("roleid", roleid).addKV("rolename", rolename).addKV("price", price).addKV("sign", sign).addKV("itemid", itemid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__Recharge]success!" + JSON.stringify(obj)); successcb && successcb(); } else { console.log("[__Recharge]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__Recharge]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, __RechargeorderidSend(accountid, serverid, roleid, rolename, price, itemid, sign, successcb, failcb) { this.urlbd.clear(); this.urlbd = new urlbuilder("http://192.168.100.23:7055/webapp/index.php"); this.urlbd.addKV("c", "Pay").addKV("a", "getOrderId").addKV("accountid", accountid).addKV("serverid", serverid).addKV("roleid", roleid).addKV("rolename", rolename).addKV("price", price).addKV("itemid", itemid).addKV("sign", sign); console.log("URL: ", this.urlbd.baseurl); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__Recharge]success!" + JSON.stringify(obj)); this._orderidSend(1, obj.orderid, 1); } else { console.log("[__Recharge]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__Recharge]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, _orderidSend(pay_type, orderid, payresult) { this.urlbd.clear(); var url = 'http://192.168.100.23:7055/webapp/index.php?c=Pay&a=payNotify&pay_type=1&orderid="+orderid.toString()+"&payresult=1'; httpclient.httpGet(url, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[__Recharge]success!" + JSON.stringify(obj)); successcb && successcb(obj.token); } else { console.log("[__Recharge]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[__Recharge]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, setAccountID(accountid, sessionid) { this.accountid = accountid; this.sessionid = sessionid; }, setLocalUUID(uuid) { this.localid = uuid; }, setNickName(nickname) { this.nickname = nickname; }, setFromAppID(appid) { this.fromid = appid; } }; }), { "../common/httpclient": 2, "../common/urlbuilder": 6 } ], 21: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); var urlbuilder = require("../common/urlbuilder"); module.exports = { init(channelid, gameid, isoffical, owner, url) { this.owner = owner; this.gameid = gameid; this.channelid = channelid; this.urlbd = new urlbuilder(url); console.log("[jcshare]init:" + gameid + "|" + channelid + "|" + isoffical); }, setAccountID(accountid, sessionid) { this.accountid = accountid; this.sessionid = sessionid; }, setNickName(nickname) { this.nickname = nickname; }, setFromAppID(appid) { this.fromid = appid; }, setLocalUUID(uuid) { this.localid = uuid; }, setSystemInfo(info) {}, setUserInfo(info) { this.sex = info.sex; this.avatar_url = info.avatar_url; }, acceptInvite(actionid, inviterid, successcb, failcb) { if (!actionid) return; let sid = inviterid || ""; this.urlbd.clear(); this.urlbd.addKV("c", "Fission").addKV("a", "accept").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("business_no", actionid).addKV("inviter_id", sid).addKV("nickname", this.nickname).addKV("sex", this.sex).addKV("avatar_url", this.avatar_url); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode || 1 == obj.errcode || 2 == obj.errcode) { console.log("[acceptInvite]success!" + JSON.stringify(obj)); successcb && successcb(); } else { console.log("[acceptInvite]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[acceptInvite]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, queryShareStat(actionid, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Fission").addKV("a", "getChild").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("business_no", actionid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[queryShareStat]success!" + JSON.stringify(obj)); successcb && successcb(obj.nodes); } else { console.log("[queryShareStat]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[queryShareStat]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, queryShareDetail(actionid, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Fission").addKV("a", "getFriendsDetail").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("business_no", actionid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[queryShareDetail]success!" + JSON.stringify(obj)); successcb && successcb(obj.nodes); } else { console.log("[queryShareDetail]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[queryShareDetail]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, acceptDailyInvite(actionid, inviterid, successcb, failcb) { let sid = inviterid || ""; this.urlbd.clear(); this.urlbd.addKV("c", "DailyMission").addKV("a", "acceptInvite").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("inviter_id", sid).addKV("activity_param", actionid).addKV("nickname", this.nickname).addKV("sex", this.sex).addKV("avatar_url", this.avatar_url); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (!obj || 0 != obj.errcode && 1 != obj.errcode) { console.log("[acceptDailyInvite]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } else { console.log("[acceptDailyInvite]success!" + JSON.stringify(obj)); successcb && successcb(); } }), (function(errcode, errmsg) { console.log("[acceptDailyInvite]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, queryDailyShareStat(actionid, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "DailyMission").addKV("a", "getInviteeNum").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("activity_param", actionid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[queryDailyShareStat]success!" + JSON.stringify(obj)); successcb && successcb(obj); } else { console.log("[queryDailyShareStat]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[queryDailyShareStat]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, queryDailyShareDetail(actionid, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "DailyMission").addKV("a", "getInviteeList").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("activity_param", actionid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[queryDailyShareDetail]success!" + JSON.stringify(obj)); successcb && successcb(obj.invitee_list); } else { console.log("[queryDailyShareDetail]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[queryDailyShareDetail]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, queryActionCode(score, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Exchange").addKV("a", "reportScore").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("score", score); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[queryActionCode]success!" + JSON.stringify(obj)); successcb && successcb(obj.exchange_code); } else { console.log("[queryActionCode]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[queryActionCode]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, acceptRelayInvite(actionid, inviterid, successcb, failcb) { let sid = inviterid || ""; this.urlbd.clear(); this.urlbd.addKV("c", "Relay").addKV("a", "acceptInvite").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("inviter_id", sid).addKV("activity_param", actionid).addKV("nickname", this.nickname).addKV("sex", this.sex).addKV("avatar_url", this.avatar_url); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (!obj || 0 != obj.errcode && 1 != obj.errcode) { console.log("[acceptRelayInvite]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } else { console.log("[acceptRelayInvite]success!" + JSON.stringify(obj)); successcb && successcb(); } }), (function(errcode, errmsg) { console.log("[acceptRelayInvite]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, queryRelayShareStat(actionid, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "Relay").addKV("a", "getInviteeNum").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("activity_param", actionid); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[queryRelayShareStat]success!" + JSON.stringify(obj)); successcb && successcb(obj); } else { console.log("[queryRelayShareStat]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[queryRelayShareStat]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, acceptAchivementInvite(relationidlst, inviterid, successcb, failcb) { let sid = inviterid || ""; this.urlbd.clear(); this.urlbd.addKV("c", "AchievementShare").addKV("a", "acceptInvite").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("inviter_id", sid).addKV("relate_achivements", JSON.stringify(relationidlst)).addKV("nickname", this.nickname).addKV("sex", this.sex).addKV("avatar_url", this.avatar_url); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (!obj || 0 != obj.errcode && 1 != obj.errcode) { console.log("[acceptAchivementInvite]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } else { console.log("[acceptAchivementInvite]success!" + JSON.stringify(obj)); successcb && successcb(); } }), (function(errcode, errmsg) { console.log("[acceptAchivementInvite]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, queryAchievementShareStat(actionidlst, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "AchievementShare").addKV("a", "getInviteeNum").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("achievement_ids", actionidlst.join()); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[queryAchievementShareStat]success!" + JSON.stringify(obj)); successcb && successcb(obj); } else { console.log("[queryAchievementShareStat]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[queryAchievementShareStat]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); }, queryAchievementShareDetail(actionidlst, successcb, failcb) { this.urlbd.clear(); this.urlbd.addKV("c", "AchievementShare").addKV("a", "getInviteeList").addKV("session_id", this.sessionid).addKV("account_id", this.accountid).addKV("achievement_ids", actionidlst.join()); httpclient.httpGet(this.urlbd.baseurl, (function(restext) { var obj = httpclient.JSON_parse(restext); if (obj && 0 == obj.errcode) { console.log("[queryAchievementShareDetail]success!" + JSON.stringify(obj)); successcb && successcb(obj.invitee_list); } else { console.log("[queryAchievementShareDetail]failed!" + obj.errcode + ":" + obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg); } }), (function(errcode, errmsg) { console.log("[queryAchievementShareDetail]failed!" + errcode + ":" + errmsg); failcb && failcb(errcode, 0, errmsg); })); } }; }), { "../common/httpclient": 2, "../common/urlbuilder": 6 } ], 22: [ (function(require, module, exports) { var httpclient = require("../common/httpclient"); var urlbuilder = require("../common/urlbuilder"); const GAME_TIME_KEY = "jc_game_time_key"; module.exports = { _deftime: 6e4, _tid: 0, _heart() { this.urlbd.clear(); this.urlbd.addKV("c", "Stat").addKV("a", "updateSession").addKV("session_id", this.sessionid).addKV("account_id", this.accountid); httpclient.httpGet(this.urlbd.baseurl, res => { this.isoffical || console.log("[stat.heart]" + res); }, (err, errmsg) => { this.isoffical || console.log("[stat.heart]Err:" + err + "|" + errmsg); }); }, init(channelid, gameid, isoffical, owner, url) { this.owner = owner; this.gameid = gameid; this.channelid = channelid; this.isoffical = isoffical; this.urlbd = new urlbuilder(url); console.log("[jcstat]init:" + gameid + "|" + channelid + "|" + isoffical); }, setAccountID(accountid, sessionid) { this.accountid = accountid; this.sessionid = sessionid; this._heart(); this.setHeart(this._deftime); }, setNickName(nickname) { this.nickname = nickname; }, setFromAppID(appid) { this.fromid = appid; }, setLocalUUID(uuid) { this.localid = uuid; }, setSystemInfo(info) {}, setHeart(tm) { if (tm && "number" == typeof tm && tm > 0) { this._deftime = tm; if (this._tid) { clearInterval(this._tid); this._tid = 0; } this.accountid && 1008 != this.gameid && (this._tid = setInterval(() => { this._heart(); }, this._deftime)); } }, registGameTimeHandle() { let self = this; let resetTime = this.getResetTime(); console.log(`server reset time is: ${resetTime}`); this._beginTime = Date.now(); let obj = { onJCGameShow: function(obj) { console.log("registGameTimeHandle game show"); self._beginTime = Date.now(); }, onJCGameHide: function(obj) { console.log("registGameTimeHandle game hide"); let now = Date.now(); if (self._beginTime) { let time = parseInt((now - self._beginTime) / 1e3); jc.rw.getStorage(GAME_TIME_KEY, (function(value) { value && (time += parseInt(value)); jc.rw.setStorage(GAME_TIME_KEY, time, (function() { self._beginTime = now; }), (function() {}), 1, resetTime); }), (function() { console.log(); })); } } }; this.owner.addHandler(obj); }, getGameTime(cb, fcb) { let time = 0; let now = Date.now(); let resetTime = this.getResetTime(); console.log(`this._beginTime" ${this._beginTime}, now: ${now}, val: ${(now - this._beginTime) / 1e3}`); let self = this; let timeDiff = 0; if (this._beginTime) { timeDiff = parseInt((now - this._beginTime) / 1e3); time = timeDiff; } else this._beginTime = now; jc.rw.getStorage(GAME_TIME_KEY, (function(value) { value && (time += parseInt(value)); timeDiff ? jc.rw.setStorage(GAME_TIME_KEY, time, (function() { self._beginTime = now; cb && cb(time); }), (function() { fcb && fcb(); }), 1, resetTime) : cb && cb(time); }), (function() { fcb && fcb(); })); }, getResetTime() { let time = 0; jc.cloud.cfg["online_award"] && jc.cloud.cfg["online_award"]["reset_time"] && (time = jc.cloud.cfg["online_award"]["reset_time"]); return time; } }; }), { "../common/httpclient": 2, "../common/urlbuilder": 6 } ], 23: [ (function(require, module, exports) { module.exports = { getToday: function() { return new Date().toISOString().split("T")[0]; }, getFirstDay: function(millseconds) { var dt = millseconds ? new Date(millseconds) : new Date(); var day = dt.getDay() || 7; var newdt = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate() + 1 - day); newdt.setHours(0); newdt.setMinutes(0); newdt.setSeconds(0); newdt.setMilliseconds(0); return newdt; }, formatDateStr: function(dt) { return dt.getFullYear() + "-" + (dt.getMonth() + 1) + "-" + dt.getDate(); }, dateFormatter: function(formatter, date) { date = date ? new Date(date) : new Date(); const Y = date.getFullYear() + "", M = date.getMonth() + 1, D = date.getDate(), H = date.getHours(), m = date.getMinutes(), s = date.getSeconds(); return formatter.replace(/YYYY|yyyy/g, Y).replace(/YY|yy/g, Y.substr(2, 2)).replace(/MM/g, (M < 10 ? "0" : "") + M).replace(/DD/g, (D < 10 ? "0" : "") + D).replace(/HH|hh/g, (H < 10 ? "0" : "") + H).replace(/mm/g, (m < 10 ? "0" : "") + m).replace(/ss/g, (s < 10 ? "0" : "") + s); }, DateGetDay(dtime) { if (0 == dtime) return 0; var d = new Date(); var realdt = dtime - 6e4 * d.getTimezoneOffset(); var oneDayTime = 864e5; return parseInt(realdt / oneDayTime); }, isSameWeek: function(old, now) { var oldday = this.DateGetDay(old); var newday = this.DateGetDay(now); return parseInt((oldday + 3) / 7) == parseInt((newday + 3) / 7); }, isSameDay: function(old, now) { var oldday = this.DateGetDay(old); var newday = this.DateGetDay(now); return oldday == newday; }, isSerialDay: function(olddt) { var nowdt = new Date().getTime(); var oldday = this.DateGetDay(olddt); var newday = this.DateGetDay(nowdt); return newday - oldday == 1; }, isNowDay: function(day) { var now = new Date(); return this.isSameDay(day, now); }, betweenDays(time1, time2) { var v1 = Math.floor(time1 / 3600 / 24); var v2 = Math.floor(time2 / 3600 / 24); return Math.abs(v1 - v2); }, getDaySeconds: (time, incdays) => 3600 * (Math.floor(time / 1e3 / 3600 / 24) + incdays) * 24, getCurrMillSeconds: () => new Date().getTime(), getCurrSeconds() { var ms = this.getCurrMillSeconds(); return Math.floor(ms / 1e3); }, expiredSeconds(time_type, time_val, time_past) { let tmnow = this.getCurrSeconds(); let sec = 0; switch (time_type) { case 1: sec = tmnow - time_past; break; case 2: { let tmsec = this.getDaySeconds(1e3 * time_past, 0); sec = tmnow - tmsec; } break; case 3: { let fday = this.getFirstDay(1e3 * time_past); let tmsec = 1e3 * fday.getTime(); sec = tmnow - tmsec; } break; case 4: { var lasttm = new Date(1e3 * time_past); var fday = new Date(lasttm.getFullYear(), lasttm.getMonth(), 1, 0, 0, 0, 0); let tmsec = 1e3 * fday.getTime(); sec = tmnow - tmsec; } break; case 5: { var lasttm = new Date(1e3 * time_past); let y = lasttm.getFullYear(); let m = lasttm.getMonth(); if (11 == m) { m = 0; y++; } else m++; var fday = new Date(y, m, 1, 0, 0, 0, 0); let tmsec = 1e3 * fday.getTime(); sec = tmnow - tmsec; } } return time_val - sec; }, formatSeconds(countTime, showNum) { let str = ""; countTime = countTime < 0 ? 0 : countTime; let day = Math.floor(countTime / 86400); let hours = Math.floor((countTime - 86400 * day) / 3600); let min = Math.floor((countTime - 86400 * day - 3600 * hours) / 60); let sec = Math.floor(countTime - 86400 * day - 3600 * hours - 60 * min); let timeList = [ sec, min, hours, day ]; let timeMaxList = [ 60, 60, 24, 99 ]; let formatToStr = function(_index) { let num = 0; if (_index === showNum - 1 && showNum < 4) { for (let i = _index + 1; i < 4; i++) if (timeList[i] > 0) { let tempNum = timeList[i]; for (let j = i; j > _index; j--) tempNum *= timeMaxList[j - 1]; num += tempNum; } num += timeList[_index]; } else num = timeList[_index]; num = "" + num; num.length < 2 && (num = "0" + num); return num; }; for (let i = showNum - 1; i >= 0; i--) { let curStr = formatToStr(i); str += curStr; 0 !== i && (str += ":"); } return str; } }; }), {} ], 24: [ (function(require, module, exports) { Object.defineProperty(Array.prototype, "indexOf", { value: function(val) { for (var i = 0; i < this.length; i++) if (this[i] == val) return i; return -1; }, writable: true, enumerable: false, configurable: true }); Object.defineProperty(Array.prototype, "remove", { value: function(val) { var idx = this.indexOf(val); -1 !== idx && this.splice(idx, 1); }, writable: true, enumerable: false, configurable: true }); }), {} ], 25: [ (function(require, module, exports) { var storage = require("../common/storage"); var COMMON_STORAGE = { setStorage: function(skey, svalue, successcb, failcb, limitday, resetTime) { let to = 0; let tv = 0; let rt = 0; "number" == typeof resetTime && (rt = 3600 * resetTime); if (limitday) { to = 2; tv = 86400 * limitday + rt; } this._isoffical && this.cloud && this._iscloud ? this.cloud.setStorage(skey, svalue, successcb, failcb, to, tv) : storage.setStorage(skey, svalue, successcb, failcb, to, tv); }, setStorages: function(kvlist, successcb, failcb) { this._isoffical && this.cloud && this._iscloud ? this.cloud.setStorages(kvlist, successcb, failcb) : storage.setStorages(kvlist, successcb, failcb); }, getStorage: function(key, successcb, failcb) { this._isoffical && this.cloud && this._iscloud ? this.cloud.getStorage(key, successcb, failcb) : storage.getStorage(key, successcb, failcb); }, getStorages: function(keylist, successcb, failcb) { this._isoffical && this.cloud && this._iscloud ? this.cloud.getStorages(keylist, successcb, failcb) : storage.getStorages(keylist, successcb, failcb); }, init(owner, isoffical, cloud) { this._owner = owner; this._isoffical = isoffical; this._iscloud = isoffical; this.setCloud(cloud); }, setCloud: function(cloud) { this.cloud = cloud; }, setCloudFlag: function(iscloud) { this._iscloud = iscloud; }, getCloudFlag: function() { return this._iscloud; } }; jc.rw = COMMON_STORAGE; module.exports = COMMON_STORAGE; }), { "../common/storage": 5 } ], 26: [ (function(require, module, exports) { module.exports = { getLittleNumber(num) { var plus = num.toFixed(2); num >= 1e15 ? plus = (num / 1e15).toFixed(1) + "aa" : num >= 1e12 ? plus = (num / 1e12).toFixed(1) + "T" : num >= 1e9 ? plus = (num / 1e9).toFixed(1) + "B" : num >= 1e6 ? plus = (num / 1e6).toFixed(1) + "M" : num >= 1e3 ? plus = (num / 1e3).toFixed(1) + "K" : num < 1e3 && (plus = Math.floor(num)); return plus; }, getDotNumber(num) { num = Math.floor(num); var plus = ""; num >= 1e12 ? plus = "(" + (num / 1e12).toFixed(1) + "T)" : num >= 1e9 ? plus = "(" + (num / 1e9).toFixed(1) + "B)" : num >= 1e6 ? plus = "(" + (num / 1e6).toFixed(1) + "M)" : num >= 1e3 && (plus = "(" + (num / 1e3).toFixed(1) + "K)"); var snum = num + ""; var pos = 0; var numArr = []; for (var i = snum.length - 1; i >= 0; i--) { if (3 == pos) { numArr.push(","); pos = 0; } numArr.push(snum[i]); pos++; } snum = ""; for (var i = numArr.length - 1; i >= 0; i--) snum += numArr[i]; return snum + plus; }, randomInt(nMax, nMin) { let nmin = nMin || 0; var nRange = nMax - nmin; var Rand = Math.random(); var num = nmin + Math.round(Rand * nRange); return num; }, randomBool(percent, ratio) { let n = ratio || 1; var num = Math.random() * n; return num < percent; }, formatMoney: count => (count / 100).toFixed(2), initStringPrototype() { String.prototype.format = this._format; }, _format(args) { if (arguments.length > 0) { var result = this; if (1 == arguments.length && "object" == typeof args) if ("[object Array]" === Object.prototype.toString.call(args) && args.length > 0) for (var key in args) { var reg = new RegExp("({[" + key + "]})", "g"); result = result.replace(reg, args[key]); } else for (var key in args) { var reg = new RegExp("({" + key + "})", "g"); result = result.replace(reg, args[key]); } else for (var i = 0; i < arguments.length; i++) { if (void 0 == arguments[i]) return ""; var reg = new RegExp("({[" + i + "]})", "g"); result = result.replace(reg, arguments[i]); } return result; } return this; } }; }), {} ] }, {}, [ 8 ]); //# sourceMappingURL=jcfw.native_egret.js.map