改善console.log

This commit is contained in:
zhl 2019-03-21 10:29:45 +08:00
parent 80a11defdb
commit 24fbe18a4a
9 changed files with 1218 additions and 1174 deletions

View File

@ -1,7 +1,7 @@
{ {
"description": "A WePY project", "description": "A WePY project",
"setting": { "setting": {
"urlCheck": true, "urlCheck": false,
"es6": false, "es6": false,
"postcss": false, "postcss": false,
"minified": false, "minified": false,

View File

@ -22,6 +22,8 @@ import wepy from 'wepy'
import 'wepy-async-function' import 'wepy-async-function'
import jcEvent from './common/jc-event'; import jcEvent from './common/jc-event';
import http from './utils/http'; import http from './utils/http';
import log, { hookConsoleLog } from './utils/logger';
import g from './common/global';
let sdkManage = require('./jcfw/SDKManage'); let sdkManage = require('./jcfw/SDKManage');
export default class extends wepy.app { export default class extends wepy.app {
@ -54,6 +56,7 @@ export default class extends wepy.app {
super(); super();
this.use('requestfix'); this.use('requestfix');
this.use('promisify'); this.use('promisify');
(g.env === 'test') && hookConsoleLog();
sdkManage.init(); sdkManage.init();
sdkManage.Login(() => { sdkManage.Login(() => {
let account = wepy.getStorageSync('account'); let account = wepy.getStorageSync('account');
@ -201,5 +204,11 @@ export default class extends wepy.app {
getShareCount(cb) { getShareCount(cb) {
sdkManage.getAchievInviteeNum(cb); sdkManage.getAchievInviteeNum(cb);
} }
getShareDetail(cb) {
sdkManage.queryAchievementShareDetail(cb);
}
updateUserInfo(allInfo, cb) {
sdkManage.updateUser(allInfo, cb);
}
} }
</script> </script>

View File

@ -1,4 +1,4 @@
const env = 'product'; //product, test const env = 'test'; //product, test
export default { export default {
env: env, env: env,
apiBase: env === 'test'? 'https://ghost-test.kingsome.cn' : 'https://ghost.kingsome.cn', apiBase: env === 'test'? 'https://ghost-test.kingsome.cn' : 'https://ghost.kingsome.cn',

View File

@ -189,8 +189,19 @@ var SDKManage = function() {
]; ];
this.doLogin(); this.doLogin();
}; };
this.queryAchievementShareDetail = function(cb) {
var callback = function(res) {
console.log('playerData.invitee_detail');
console.log(res);
if (cb) {
cb(res);
}
};
jcshare.queryAchievementShareDetail([1001], callback, function() {});
};
this.updateUser = function(allInfo, cb) {
jcfw.updateUser(allInfo, cb)
}
}; };

View File

@ -1,7 +1,7 @@
var jccloud = require('./service/jccloud'); var jccloud = require('./service/jccloud');
var jcgamelog = require( './service/jcgamelog'); var jcgamelog = require('./service/jcgamelog');
var jclogin = require( './service/jclogin'); var jclogin = require('./service/jclogin');
var jcshare = require( './service/jcshare'); var jcshare = require('./service/jcshare');
var jcAD = require('./service/jcAD'); var jcAD = require('./service/jcAD');
var jcStat = require('./service/jcstat'); var jcStat = require('./service/jcstat');
var jcNotify = require('./service/jcnotify'); var jcNotify = require('./service/jcnotify');
@ -16,11 +16,11 @@ const _GAME_INFO_HANDLER_UNBINDING = 'jc_gameinfo_handler_unbinding';
const JC_CLOUD_URL = 'cloud'; const JC_CLOUD_URL = 'cloud';
const JC_GAMELOG_URL = 'gamelog'; const JC_GAMELOG_URL = 'gamelog';
const JC_LOGIN_URL= 'login'; const JC_LOGIN_URL = 'login';
const JC_NOTIFY_URL= 'notify'; const JC_NOTIFY_URL = 'notify';
const JC_SVC_URL= 'service'; const JC_SVC_URL = 'service';
const JC_STAT_URL= 'stat'; const JC_STAT_URL = 'stat';
const JC_GAMELIST_URL= 'service'; const JC_GAMELIST_URL = 'service';
var JCFW = { var JCFW = {
cloud: jccloud, cloud: jccloud,
@ -41,9 +41,9 @@ var JCFW = {
_inited: false, _inited: false,
__getUrl(isoffical, key){ __getUrl(isoffical, key) {
let pre = key; let pre = key;
if(!isoffical){ if (!isoffical) {
pre += '-test'; pre += '-test';
} }
let str = 'https://' + pre + '.kingsome.cn/webapp/index.php'; let str = 'https://' + pre + '.kingsome.cn/webapp/index.php';
@ -66,9 +66,9 @@ var JCFW = {
* .onShare(***) * .onShare(***)
* .onShareFail(***) * .onShareFail(***)
*/ */
init(channelid, gameid, isoffical, response, env){ init(channelid, gameid, isoffical, response, env) {
if(this._inited){ if (this._inited) {
if(this.rsp != response){ if (this.rsp != response) {
this.rsp = response; this.rsp = response;
} }
return; return;
@ -110,13 +110,13 @@ var JCFW = {
* @param {object} failcb 失败回调初始化时设置了回调对象的话此处可不填 * @param {object} failcb 失败回调初始化时设置了回调对象的话此处可不填
* @param {string} ex_param 额外参数预留字段某些平台可能会使用此字段 * @param {string} ex_param 额外参数预留字段某些平台可能会使用此字段
*/ */
loginUser(successcb, failcb, ex_param){ loginUser(successcb, failcb, ex_param) {
//console.log('loginUser'); //console.log('loginUser');
if(this._logining){ if (this._logining) {
return 1; return 1;
} }
this.logining = true; this.logining = true;
this.login.loginPT((res) =>{ this.login.loginPT((res) => {
this._logining = false; this._logining = false;
this.logined = true; this.logined = true;
this.setAccountID(res.account_id, res.session_id, res); this.setAccountID(res.account_id, res.session_id, res);
@ -125,12 +125,14 @@ var JCFW = {
this.gamelog.logLoginSuccess(res, this.login.login_costtime); this.gamelog.logLoginSuccess(res, this.login.login_costtime);
this.gamelog.logShareInvite(this.shareInfo.inviter, this.shareInfo.type, this.shareInfo.id, this.shareInfo.param); this.gamelog.logShareInvite(this.shareInfo.inviter, this.shareInfo.type, this.shareInfo.id, this.shareInfo.param);
this.gamelog.logSystemInfo(this.systemInfo); this.gamelog.logSystemInfo(this.systemInfo);
if(this.shareInfo && this.shareInfo.id && this.shareInfo.id != ''){ if (this.shareInfo && this.shareInfo.id && this.shareInfo.id != '') {
this.share.acceptDailyInvite(this.shareInfo.param,this.shareInfo.id,()=>{}, ()=>{}); this.share.acceptDailyInvite(this.shareInfo.param, this.shareInfo.id, () => {
}, () => {
});
} }
this.rsp && this.rsp.onLogin && this.rsp.onLogin(res); this.rsp && this.rsp.onLogin && this.rsp.onLogin(res);
successcb && successcb(res); successcb && successcb(res);
if(this.cacheuser){ if (this.cacheuser) {
this.updateUser(this.cacheuser.info, this.cacheuser.success, this.cacheuser.fail); this.updateUser(this.cacheuser.info, this.cacheuser.success, this.cacheuser.fail);
} }
}, (neterr, logicerr, errmsg) => { }, (neterr, logicerr, errmsg) => {
@ -142,7 +144,7 @@ var JCFW = {
return 0; return 0;
}, },
loginUserByToken(token, successcb, failcb){ loginUserByToken(token, successcb, failcb) {
//console.log('loginUserByToken:' + token); //console.log('loginUserByToken:' + token);
return this.loginUser(successcb, failcb, token); return this.loginUser(successcb, failcb, token);
}, },
@ -154,35 +156,35 @@ var JCFW = {
* @param {object} successcb 成功回调初始化时设置了回调对象的话此处可不填 * @param {object} successcb 成功回调初始化时设置了回调对象的话此处可不填
* @param {object} failcb 失败回调初始化时设置了回调对象的话此处可不填 * @param {object} failcb 失败回调初始化时设置了回调对象的话此处可不填
*/ */
updateUser(allinfo, successcb, failcb){ updateUser(allinfo, successcb, failcb) {
//console.log('updateUser'); //console.log('updateUser');
if(!this.logined){ if (!this.logined) {
if(!this.cacheuser){ if (!this.cacheuser) {
this.cacheuser = {}; this.cacheuser = {};
} }
this.cacheuser.info = allinfo; this.cacheuser.info = allinfo;
this.cacheuser.success = successcb; this.cacheuser.success = successcb;
this.cacheuser.fail = failcb; this.cacheuser.fail = failcb;
return; return;
}else{ } else {
this.cacheuser = null; this.cacheuser = null;
} }
let userinfo = allinfo && allinfo.userInfo; let userinfo = allinfo && allinfo.userInfo;
if(!userinfo){ if (!userinfo) {
this.gamelog.logAuthFail(); this.gamelog.logAuthFail();
this.setUserInfo(null); this.setUserInfo(null);
}else{ } else {
this.gamelog.logAuthSuccess(userinfo); this.gamelog.logAuthSuccess(userinfo);
this.setUserInfo(userinfo); this.setUserInfo(userinfo);
} }
if(!allinfo || !userinfo){ if (!allinfo || !userinfo) {
this.rsp && this.rsp.onUpdateUserFail && this.rsp.onUpdateUserFail(0, -10000, 'info is NULL'); this.rsp && this.rsp.onUpdateUserFail && this.rsp.onUpdateUserFail(0, -10000, 'info is NULL');
failcb && failcb(0, -10000, 'info is NULL'); failcb && failcb(0, -10000, 'info is NULL');
return 0; return 0;
} }
if(this._userupdating){ if (this._userupdating) {
return 1; return 1;
} }
this._userupdating = true; this._userupdating = true;
@ -198,18 +200,18 @@ var JCFW = {
return 0; return 0;
}, },
initGlobalConfig(successcb, failcb){ initGlobalConfig(successcb, failcb) {
this.cloud.getServerConfig((cfg) => { this.cloud.getServerConfig((cfg) => {
this.rsp && this.rsp.onServerConfig && this.rsp.onServerConfig(cfg); this.rsp && this.rsp.onServerConfig && this.rsp.onServerConfig(cfg);
successcb && successcb(cfg); successcb && successcb(cfg);
}, (neterr, logicerr, errmsg) =>{ }, (neterr, logicerr, errmsg) => {
this.rsp && this.rsp.onServerConfigFail && this.rsp.onServerConfigFail(neterr, logicerr, errmsg); this.rsp && this.rsp.onServerConfigFail && this.rsp.onServerConfigFail(neterr, logicerr, errmsg);
failcb && failcb(neterr, logicerr, errmsg); failcb && failcb(neterr, logicerr, errmsg);
}); });
}, },
// 普通分享 // 普通分享
shareNormal(content, imgurl, sharetype, shareparam, extrainfo){ shareNormal(content, imgurl, sharetype, shareparam, extrainfo) {
this.share.shareNormal(content, imgurl, sharetype, shareparam, extrainfo, () => { this.share.shareNormal(content, imgurl, sharetype, shareparam, extrainfo, () => {
this.rsp && this.rsp.onShare && this.rsp.onShare(content, imgurl, sharetype, shareparam, extrainfo); this.rsp && this.rsp.onShare && this.rsp.onShare(content, imgurl, sharetype, shareparam, extrainfo);
}, () => { }, () => {
@ -218,7 +220,7 @@ var JCFW = {
}, },
// 截图分享 // 截图分享
shareCapture(content, capture_rect, sharetype, shareparam, extrainfo){ shareCapture(content, capture_rect, sharetype, shareparam, extrainfo) {
this.share.shareCapture(content, capture_rect, sharetype, shareparam, extrainfo, () => { this.share.shareCapture(content, capture_rect, sharetype, shareparam, extrainfo, () => {
this.rsp && this.rsp.onShare && this.rsp.onShare(content, capture_rect, sharetype, shareparam, extrainfo); this.rsp && this.rsp.onShare && this.rsp.onShare(content, capture_rect, sharetype, shareparam, extrainfo);
}, () => { }, () => {
@ -227,11 +229,11 @@ var JCFW = {
}, },
// 生成唯一ID【无需关注此函数】 // 生成唯一ID【无需关注此函数】
makeUUID(){ makeUUID() {
return this.gamelog.generateUUID(); return this.gamelog.generateUUID();
}, },
// 根据OpenID生成账号ID【通常情况不使用此函数】 // 根据OpenID生成账号ID【通常情况不使用此函数】
makeAccountID(openid){ makeAccountID(openid) {
return this.login.AccountID(openid); return this.login.AccountID(openid);
}, },
@ -244,15 +246,15 @@ var JCFW = {
// .onJCLaunchInfo(lauchscene, lauchfromid, launchparam){} // .onJCLaunchInfo(lauchscene, lauchfromid, launchparam){}
// .onJCGameStart(startmode, extparam){} // .onJCGameStart(startmode, extparam){}
// .onJCGameOver(score, bsuccess, extparam){} // .onJCGameOver(score, bsuccess, extparam){}
addHandler(handler){ addHandler(handler) {
this._checkListener(); this._checkListener();
if(!handler){ if (!handler) {
return false; return false;
} }
let obj = this._handlers.find(element => { let obj = this._handlers.find(element => {
return element == handler; return element == handler;
}); });
if(!obj){ if (!obj) {
this._handlers.push(handler); this._handlers.push(handler);
this._initHandler(handler); this._initHandler(handler);
} }
@ -260,14 +262,14 @@ var JCFW = {
}, },
// 删除监听处理器 // 删除监听处理器
delHandler(handler){ delHandler(handler) {
if(!handler || !this._handlers){ if (!handler || !this._handlers) {
return false; return false;
} }
let idx = this._handlers.findIndex((item) => { let idx = this._handlers.findIndex((item) => {
return item == handler; return item == handler;
}); });
if(idx < 0){ if (idx < 0) {
return true; return true;
} }
this._handlers.splice(idx, 1); this._handlers.splice(idx, 1);
@ -275,18 +277,18 @@ var JCFW = {
}, },
// 重置本地ID【通常情况不使用此函数】 // 重置本地ID【通常情况不使用此函数】
resetLocalID(){ resetLocalID() {
this._cleanLocalID(); this._cleanLocalID();
this._loadLocalID(); this._loadLocalID();
}, },
// 设置sdk回调 // 设置sdk回调
setResponse(rsp){ setResponse(rsp) {
this.rsp = rsp; this.rsp = rsp;
}, },
// 获取服务器当前时间【登陆完成后才能调用】 // 获取服务器当前时间【登陆完成后才能调用】
getServerNowTime(){ getServerNowTime() {
let tm = new Date().getTime(); let tm = new Date().getTime();
return this.loginSrvTime + (tm - this.loginLocalTime) / 1000; return this.loginSrvTime + (tm - this.loginLocalTime) / 1000;
}, },
@ -294,8 +296,8 @@ var JCFW = {
//游戏相关------------------------------------------------------- //游戏相关-------------------------------------------------------
// 游戏开始 // 游戏开始
// startmode: 0:正常开始游戏 1:重新开始 2:再来一次 // startmode: 0:正常开始游戏 1:重新开始 2:再来一次
gameStart(startmode, extparam){ gameStart(startmode, extparam) {
switch(startmode){ switch (startmode) {
case 0: case 0:
this.gamelog.logStartGame(extparam); this.gamelog.logStartGame(extparam);
break; break;
@ -310,47 +312,47 @@ var JCFW = {
}, },
// 游戏结束 // 游戏结束
gameOver(score, bsuccess, extparam){ gameOver(score, bsuccess, extparam) {
this.gamelog.logGameover(extparam, score, bsuccess? 1: 0); this.gamelog.logGameover(extparam, score, bsuccess ? 1 : 0);
this._handleGameOver(score, bsuccess, extparam); this._handleGameOver(score, bsuccess, extparam);
}, },
// 游戏显示 // 游戏显示
gameShow(showinfo){ gameShow(showinfo) {
this.gamelog.logShow(); this.gamelog.logShow();
this._handleGameShow(showinfo); this._handleGameShow(showinfo);
}, },
// 游戏隐藏 // 游戏隐藏
gameHide(){ gameHide() {
this.gamelog.logHide(); this.gamelog.logHide();
this._handGameHide(); this._handGameHide();
}, },
// 使用道具 // 使用道具
gameUseItem(itemid, itemcount, reson, extparam){ gameUseItem(itemid, itemcount, reson, extparam) {
this.gamelog.logUseItem(itemid, itemcount, reson, extparam); this.gamelog.logUseItem(itemid, itemcount, reson, extparam);
}, },
// 获得道具 // 获得道具
gameGetItem(itemid, itemcount, reson, extparam){ gameGetItem(itemid, itemcount, reson, extparam) {
this.gamelog.logProductItem(itemid, itemcount, reson, extparam); this.gamelog.logProductItem(itemid, itemcount, reson, extparam);
}, },
//----------------------------------------------------------------- //-----------------------------------------------------------------
// 以下函数无需手动调用 // 以下函数无需手动调用
setAccountID(accountid, sessionid, exobj){ setAccountID(accountid, sessionid, exobj) {
this.accountID = accountid; this.accountID = accountid;
this.sessionID = sessionid; this.sessionID = sessionid;
this.accountobj = exobj; this.accountobj = exobj;
if(exobj && exobj.wid){ if (exobj && exobj.wid) {
this.weakID = exobj.wid; this.weakID = exobj.wid;
} }
if(exobj && exobj.sid){ if (exobj && exobj.sid) {
this.strongID = exobj.sid; this.strongID = exobj.sid;
} }
if(exobj && exobj.ptid){ if (exobj && exobj.ptid) {
this.ptID = exobj.ptID; this.ptID = exobj.ptID;
} }
this.share.setAccountID(accountid, sessionid, exobj); this.share.setAccountID(accountid, sessionid, exobj);
@ -366,7 +368,7 @@ var JCFW = {
// this.logined = this.accountID && this.accountID != ''; // this.logined = this.accountID && this.accountID != '';
}, },
setLocalUUID(uuid){ setLocalUUID(uuid) {
this.localUUID = uuid; this.localUUID = uuid;
this.gamelog.setLocalUUID(uuid); this.gamelog.setLocalUUID(uuid);
this.cloud.setLocalUUID(uuid); this.cloud.setLocalUUID(uuid);
@ -380,8 +382,8 @@ var JCFW = {
this._handleLocalID(uuid); this._handleLocalID(uuid);
}, },
setNickName(nickname){ setNickName(nickname) {
if(nickname && nickname != '' && this.nickName != nickname){ if (nickname && nickname != '' && this.nickName != nickname) {
this.nickName = nickname; this.nickName = nickname;
this.gamelog.setNickName(nickname); this.gamelog.setNickName(nickname);
this.cloud.setNickName(nickname); this.cloud.setNickName(nickname);
@ -396,9 +398,9 @@ var JCFW = {
} }
}, },
setFromAppID(appid, scene, paramobj){ setFromAppID(appid, scene, paramobj) {
this.scene = scene; this.scene = scene;
if(appid){ if (appid) {
this.fromID = appid; this.fromID = appid;
this.gamelog.setFromAppID(appid); this.gamelog.setFromAppID(appid);
this.cloud.setFromAppID(appid); this.cloud.setFromAppID(appid);
@ -409,13 +411,13 @@ var JCFW = {
this.notify.setFromAppID(appid); this.notify.setFromAppID(appid);
} }
if(paramobj){ if (paramobj) {
this.lauchparam = paramobj; this.lauchparam = paramobj;
} }
this._handleLauchInfo(scene, appid, paramobj); this._handleLauchInfo(scene, appid, paramobj);
}, },
setSystemInfo(info){ setSystemInfo(info) {
this.systemInfo = info; this.systemInfo = info;
this.gamelog.setSystemInfo(info); this.gamelog.setSystemInfo(info);
this.cloud.setSystemInfo(info); this.cloud.setSystemInfo(info);
@ -426,21 +428,21 @@ var JCFW = {
this.notify.setSystemInfo(info); this.notify.setSystemInfo(info);
}, },
setUserInfo(info){ setUserInfo(info) {
if(!this._userInfo){ if (!this._userInfo) {
this._userinfo = {}; this._userinfo = {};
} }
this.login.appendUserInfo(this._userinfo, info); this.login.appendUserInfo(this._userinfo, info);
// this.userInfo = info; // this.userInfo = info;
if(this._userinfo.nickName){ if (this._userinfo.nickName) {
this.setNickName(this._userinfo.nickName); this.setNickName(this._userinfo.nickName);
} }
this.share.setUserInfo(this._userinfo); this.share.setUserInfo(this._userinfo);
this._handleUserInfo(this._userinfo); this._handleUserInfo(this._userinfo);
}, },
setServerTime(srvtime){ setServerTime(srvtime) {
if(!srvtime){ if (!srvtime) {
return; return;
} }
this.loginSrvTime = srvtime; this.loginSrvTime = srvtime;
@ -449,30 +451,30 @@ var JCFW = {
this._handleServerTime(srvtime, this.loginLocalTime); this._handleServerTime(srvtime, this.loginLocalTime);
}, },
_loadLocalID(){ _loadLocalID() {
let id = storage.get(_GAME_LOCALUUID); let id = storage.get(_GAME_LOCALUUID);
let bneedsave = false; let bneedsave = false;
if(!id){ if (!id) {
id = this.makeUUID(); id = this.makeUUID();
bneedsave = true; bneedsave = true;
} }
this.setLocalUUID(id); this.setLocalUUID(id);
if(bneedsave){ if (bneedsave) {
this._saveLocalID(); this._saveLocalID();
} }
}, },
_saveLocalID(){ _saveLocalID() {
if(!storage.set(_GAME_LOCALUUID, this.localUUID)){ if (!storage.set(_GAME_LOCALUUID, this.localUUID)) {
setTimeout(this._saveLocalID.bind(this), 5000); setTimeout(this._saveLocalID.bind(this), 5000);
} }
}, },
_cleanLocalID(){ _cleanLocalID() {
storage.remove(_GAME_LOCALUUID); storage.remove(_GAME_LOCALUUID);
}, },
_loadLaunchInfo(){ _loadLaunchInfo() {
this.lauchInfo = wx.getLaunchOptionsSync(); this.lauchInfo = wx.getLaunchOptionsSync();
this.gamelog.handlelaunch(this.lauchInfo, (sharetype, shareparam, shareid, inviterid, this.gamelog.handlelaunch(this.lauchInfo, (sharetype, shareparam, shareid, inviterid,
@ -486,7 +488,7 @@ var JCFW = {
}); });
}, },
_loadSystemInfo(){ _loadSystemInfo() {
let info = wx.getSystemInfoSync(); let info = wx.getSystemInfoSync();
this.gamelog.logLaunchSystemInfo(info); this.gamelog.logLaunchSystemInfo(info);
@ -495,145 +497,144 @@ var JCFW = {
}, },
_loadConfig(){ _loadConfig() {
this.initGlobalConfig(); this.initGlobalConfig();
}, },
_initHandler(obj){ _initHandler(obj) {
if(this.gameID && obj.onJCInit){ if (this.gameID && obj.onJCInit) {
obj.onJCInit(this.channelID, this.gameID, this.isOffical); obj.onJCInit(this.channelID, this.gameID, this.isOffical);
} }
if(this.accountID && this.sessionID && obj.onJCAccountID){ if (this.accountID && this.sessionID && obj.onJCAccountID) {
obj.onJCAccountID(this.accountID, this.sessionID, this.accountobj); obj.onJCAccountID(this.accountID, this.sessionID, this.accountobj);
} }
if(this.localUUID && obj.onJCLocalUUID){ if (this.localUUID && obj.onJCLocalUUID) {
obj.onJCLocalUUID(this.localUUID); obj.onJCLocalUUID(this.localUUID);
} }
if(this.nickName && obj.onJCNickName){ if (this.nickName && obj.onJCNickName) {
obj.onJCNickName(this.nickName); obj.onJCNickName(this.nickName);
} }
if(this._userinfo && obj.onJCUserInfo){ if (this._userinfo && obj.onJCUserInfo) {
obj.onJCUserInfo(this._userinfo); obj.onJCUserInfo(this._userinfo);
} }
if(this.fromID && obj.onJCLaunchInfo){ if (this.fromID && obj.onJCLaunchInfo) {
obj.onJCLaunchInfo(this.scene, this.fromID, this.lauchparam); obj.onJCLaunchInfo(this.scene, this.fromID, this.lauchparam);
} }
}, },
_handleInit(channelid, gameid, isoffical){ _handleInit(channelid, gameid, isoffical) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCInit){ if (element.onJCInit) {
element.onJCInit(channelid, gameid, isoffical); element.onJCInit(channelid, gameid, isoffical);
} }
}); });
}, },
_handleAccountID(accountid, sessionid, exobj){ _handleAccountID(accountid, sessionid, exobj) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCAccountID){ if (element.onJCAccountID) {
element.onJCAccountID(accountid, sessionid, exobj); element.onJCAccountID(accountid, sessionid, exobj);
} }
}); });
}, },
_handleLocalID(localuuid){ _handleLocalID(localuuid) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCLocalUUID){ if (element.onJCLocalUUID) {
element.onJCLocalUUID(localuuid); element.onJCLocalUUID(localuuid);
} }
}); });
}, },
_handleNickName(nickname){ _handleNickName(nickname) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCNickName){ if (element.onJCNickName) {
element.onJCNickName(nickname); element.onJCNickName(nickname);
} }
}); });
}, },
_handleUserInfo(userinfo){ _handleUserInfo(userinfo) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCUserInfo){ if (element.onJCUserInfo) {
element.onJCUserInfo(userinfo); element.onJCUserInfo(userinfo);
} }
}); });
}, },
_handleLauchInfo(lauchscene, lauchfromid, launchparam){ _handleLauchInfo(lauchscene, lauchfromid, launchparam) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCLaunchInfo){ if (element.onJCLaunchInfo) {
element.onJCLaunchInfo(lauchscene, lauchfromid, launchparam); element.onJCLaunchInfo(lauchscene, lauchfromid, launchparam);
} }
}); });
}, },
_handleServerTime(servertime, localtime){ _handleServerTime(servertime, localtime) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCServerTime){ if (element.onJCServerTime) {
element.onJCServerTime(servertime, localtime); element.onJCServerTime(servertime, localtime);
} }
}); });
}, },
_handleGameStart(startmode, extparam){ _handleGameStart(startmode, extparam) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCGameStart){ if (element.onJCGameStart) {
element.onJCGameStart(startmode, extparam); element.onJCGameStart(startmode, extparam);
} }
}); });
}, },
_handleGameOver(score, bsuccess, extparam){ _handleGameOver(score, bsuccess, extparam) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCGameOver){ if (element.onJCGameOver) {
element.onJCGameOver(score, bsuccess, extparam); element.onJCGameOver(score, bsuccess, extparam);
} }
}); });
}, },
_handleGameShow(showinfo){ _handleGameShow(showinfo) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCGameShow){ if (element.onJCGameShow) {
element.onJCGameShow(showinfo); element.onJCGameShow(showinfo);
} }
}); });
}, },
_handGameHide(hideinfo){ _handGameHide(hideinfo) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCGameHide){ if (element.onJCGameHide) {
element.onJCGameHide(hideinfo); element.onJCGameHide(hideinfo);
} }
}); });
}, },
_handleNotifyMsgs(lst, notifyobj){ _handleNotifyMsgs(lst, notifyobj) {
this._handlers.forEach(element => { this._handlers.forEach(element => {
if(element.onJCNotifyMsg){ if (element.onJCNotifyMsg) {
element.onJCNotifyMsg(lst, notifyobj); element.onJCNotifyMsg(lst, notifyobj);
} }
}); });
}, },
_checkListener(){ _checkListener() {
if(!this._listenerID){ if (!this._listenerID) {
this._listenerID = notification.on(_GAME_INFO_HANDLER_BINDING, (msgid, handler) => { this._listenerID = notification.on(_GAME_INFO_HANDLER_BINDING, (msgid, handler) => {
this.addHandler(handler); this.addHandler(handler);
}, this); }, this);
} }
if(!this._unlistenerID){ if (!this._unlistenerID) {
this._unlistenerID = notification.on(_GAME_INFO_HANDLER_UNBINDING, (msgid, handler) => { this._unlistenerID = notification.on(_GAME_INFO_HANDLER_UNBINDING, (msgid, handler) => {
this.delHandler(handler); this.delHandler(handler);
}, this); }, this);
} }
}, },
_fixChannelID(){ _fixChannelID() {
} }
}; };
module.exports = JCFW; module.exports = JCFW;

View File

@ -10,7 +10,7 @@ module.exports = {
// update (dt) {}, // update (dt) {},
init(channelid, gameid, isoffical, owner, url){ init(channelid, gameid, isoffical, owner, url) {
this.owner = owner; this.owner = owner;
this.gameid = gameid; this.gameid = gameid;
this.channelid = channelid; this.channelid = channelid;
@ -18,28 +18,28 @@ module.exports = {
//console.log("[jcshare]init:"+gameid + "|" + channelid + "|" + isoffical); //console.log("[jcshare]init:"+gameid + "|" + channelid + "|" + isoffical);
}, },
setAccountID(accountid, sessionid){ setAccountID(accountid, sessionid) {
this.accountid = accountid; this.accountid = accountid;
this.sessionid = sessionid; this.sessionid = sessionid;
}, },
setNickName(nickname){ setNickName(nickname) {
this.nickname = nickname; this.nickname = nickname;
}, },
setFromAppID(appid){ setFromAppID(appid) {
this.fromid = appid; this.fromid = appid;
}, },
setLocalUUID(uuid){ setLocalUUID(uuid) {
this.localid = uuid; this.localid = uuid;
}, },
setSystemInfo(info){ setSystemInfo(info) {
}, },
setUserInfo(info){ setUserInfo(info) {
this.sex = info.sex; this.sex = info.sex;
this.avatar_url = info.avatar_url; this.avatar_url = info.avatar_url;
}, },
@ -51,11 +51,11 @@ module.exports = {
* @param {object} successcb 成功回调以下该名称都是此功能 * @param {object} successcb 成功回调以下该名称都是此功能
* @param {object} failcb 失败回调以下该名称都是此功能 * @param {object} failcb 失败回调以下该名称都是此功能
*/ */
acceptInvite(actionid, inviterid, successcb, failcb){ acceptInvite(actionid, inviterid, successcb, failcb) {
if(!actionid){ if (!actionid) {
return; return;
} }
let sid = inviterid? inviterid: ""; let sid = inviterid ? inviterid : '';
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'Fission') this.urlbd.addKV('c', 'Fission')
.addKV('a', 'accept') .addKV('a', 'accept')
@ -68,16 +68,16 @@ module.exports = {
.addKV('avatar_url', this.avatar_url) .addKV('avatar_url', this.avatar_url)
; ;
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0 || obj.errcode == 1 || obj.errcode == 2){ if (obj.errcode == 0 || obj.errcode == 1 || obj.errcode == 2) {
//console.log('[acceptInvite]success!'+JSON.stringify(obj)); //console.log('[acceptInvite]success!'+JSON.stringify(obj));
successcb && successcb(); successcb && successcb();
}else{ } else {
//console.log('[acceptInvite]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[acceptInvite]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[acceptInvite]failed!'+errcode+":"+errmsg); //console.log('[acceptInvite]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -89,7 +89,7 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
queryShareStat(actionid, successcb, failcb){ queryShareStat(actionid, successcb, failcb) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'Fission') this.urlbd.addKV('c', 'Fission')
.addKV('a', 'getChild') .addKV('a', 'getChild')
@ -97,16 +97,16 @@ module.exports = {
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('business_no', actionid); .addKV('business_no', actionid);
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0){ if (obj.errcode == 0) {
//console.log('[queryShareStat]success!'+JSON.stringify(obj)); //console.log('[queryShareStat]success!'+JSON.stringify(obj));
successcb && successcb(obj.nodes); successcb && successcb(obj.nodes);
}else{ } else {
//console.log('[queryShareStat]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[queryShareStat]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[queryShareStat]failed!'+errcode+":"+errmsg); //console.log('[queryShareStat]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -118,7 +118,7 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
queryShareDetail(actionid, successcb, failcb){ queryShareDetail(actionid, successcb, failcb) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'Fission') this.urlbd.addKV('c', 'Fission')
.addKV('a', 'getFriendsDetail') .addKV('a', 'getFriendsDetail')
@ -126,16 +126,16 @@ module.exports = {
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('business_no', actionid); .addKV('business_no', actionid);
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0){ if (obj.errcode == 0) {
//console.log('[queryShareDetail]success!'+JSON.stringify(obj)); //console.log('[queryShareDetail]success!'+JSON.stringify(obj));
successcb && successcb(obj.nodes); successcb && successcb(obj.nodes);
}else{ } else {
//console.log('[queryShareDetail]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[queryShareDetail]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[queryShareDetail]failed!'+errcode+":"+errmsg); //console.log('[queryShareDetail]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -148,8 +148,8 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
acceptDailyInvite(actionid, inviterid, successcb, failcb){ acceptDailyInvite(actionid, inviterid, successcb, failcb) {
let sid = inviterid? inviterid: ""; let sid = inviterid ? inviterid : '';
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'DailyMission') this.urlbd.addKV('c', 'DailyMission')
.addKV('a', 'acceptInvite') .addKV('a', 'acceptInvite')
@ -162,16 +162,16 @@ module.exports = {
.addKV('avatar_url', this.avatar_url) .addKV('avatar_url', this.avatar_url)
; ;
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0 || obj.errcode == 1){ if (obj.errcode == 0 || obj.errcode == 1) {
//console.log('[acceptDailyInvite]success!'+JSON.stringify(obj)); //console.log('[acceptDailyInvite]success!'+JSON.stringify(obj));
successcb && successcb(); successcb && successcb();
}else{ } else {
//console.log('[acceptDailyInvite]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[acceptDailyInvite]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[acceptDailyInvite]failed!'+errcode+":"+errmsg); //console.log('[acceptDailyInvite]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -183,7 +183,7 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
queryDailyShareStat(actionid, successcb, failcb){ queryDailyShareStat(actionid, successcb, failcb) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'DailyMission') this.urlbd.addKV('c', 'DailyMission')
.addKV('a', 'getInviteeNum') .addKV('a', 'getInviteeNum')
@ -191,16 +191,16 @@ module.exports = {
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('activity_param', actionid); .addKV('activity_param', actionid);
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0){ if (obj.errcode == 0) {
//console.log('[queryDailyShareStat]success!'+JSON.stringify(obj)); //console.log('[queryDailyShareStat]success!'+JSON.stringify(obj));
successcb && successcb(obj); successcb && successcb(obj);
}else{ } else {
//console.log('[queryDailyShareStat]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[queryDailyShareStat]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[queryDailyShareStat]failed!'+errcode+":"+errmsg); //console.log('[queryDailyShareStat]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -212,7 +212,7 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
queryDailyShareDetail(actionid, successcb, failcb){ queryDailyShareDetail(actionid, successcb, failcb) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'DailyMission') this.urlbd.addKV('c', 'DailyMission')
.addKV('a', 'getInviteeList') .addKV('a', 'getInviteeList')
@ -220,16 +220,16 @@ module.exports = {
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('activity_param', actionid); .addKV('activity_param', actionid);
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0){ if (obj.errcode == 0) {
//console.log('[queryDailyShareDetail]success!'+JSON.stringify(obj)); //console.log('[queryDailyShareDetail]success!'+JSON.stringify(obj));
successcb && successcb(obj.invitee_list); successcb && successcb(obj.invitee_list);
}else{ } else {
//console.log('[queryDailyShareDetail]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[queryDailyShareDetail]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[queryDailyShareDetail]failed!'+errcode+":"+errmsg); //console.log('[queryDailyShareDetail]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -241,7 +241,7 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
queryActionCode(score, successcb, failcb){ queryActionCode(score, successcb, failcb) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'Exchange') this.urlbd.addKV('c', 'Exchange')
.addKV('a', 'reportScore') .addKV('a', 'reportScore')
@ -249,16 +249,16 @@ module.exports = {
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('score', score); .addKV('score', score);
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0){ if (obj.errcode == 0) {
//console.log('[queryActionCode]success!'+JSON.stringify(obj)); //console.log('[queryActionCode]success!'+JSON.stringify(obj));
successcb && successcb(obj.exchange_code); successcb && successcb(obj.exchange_code);
}else{ } else {
//console.log('[queryActionCode]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[queryActionCode]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[queryActionCode]failed!'+errcode+":"+errmsg); //console.log('[queryActionCode]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -271,8 +271,8 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
acceptRelayInvite(actionid, inviterid, successcb, failcb){ acceptRelayInvite(actionid, inviterid, successcb, failcb) {
let sid = inviterid? inviterid: ""; let sid = inviterid ? inviterid : '';
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'Relay') this.urlbd.addKV('c', 'Relay')
.addKV('a', 'acceptInvite') .addKV('a', 'acceptInvite')
@ -285,16 +285,16 @@ module.exports = {
.addKV('avatar_url', this.avatar_url) .addKV('avatar_url', this.avatar_url)
; ;
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0 || obj.errcode == 1){ if (obj.errcode == 0 || obj.errcode == 1) {
//console.log('[acceptRelayInvite]success!'+JSON.stringify(obj)); //console.log('[acceptRelayInvite]success!'+JSON.stringify(obj));
successcb && successcb(); successcb && successcb();
}else{ } else {
//console.log('[acceptRelayInvite]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[acceptRelayInvite]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[acceptRelayInvite]failed!'+errcode+":"+errmsg); //console.log('[acceptRelayInvite]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -306,7 +306,7 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
queryRelayShareStat(actionid, successcb, failcb){ queryRelayShareStat(actionid, successcb, failcb) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'Relay') this.urlbd.addKV('c', 'Relay')
.addKV('a', 'getInviteeNum') .addKV('a', 'getInviteeNum')
@ -314,16 +314,16 @@ module.exports = {
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('activity_param', actionid); .addKV('activity_param', actionid);
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0){ if (obj.errcode == 0) {
//console.log('[queryRelayShareStat]success!'+JSON.stringify(obj)); //console.log('[queryRelayShareStat]success!'+JSON.stringify(obj));
successcb && successcb(obj); successcb && successcb(obj);
}else{ } else {
//console.log('[queryRelayShareStat]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[queryRelayShareStat]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[queryRelayShareStat]failed!'+errcode+":"+errmsg); //console.log('[queryRelayShareStat]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -336,8 +336,8 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
acceptAchivementInvite(relationidlst, inviterid, successcb, failcb){ acceptAchivementInvite(relationidlst, inviterid, successcb, failcb) {
let sid = inviterid? inviterid: ""; let sid = inviterid ? inviterid : '';
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'AchievementShare') this.urlbd.addKV('c', 'AchievementShare')
.addKV('a', 'acceptInvite') .addKV('a', 'acceptInvite')
@ -350,16 +350,16 @@ module.exports = {
.addKV('avatar_url', this.avatar_url) .addKV('avatar_url', this.avatar_url)
; ;
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0 || obj.errcode == 1){ if (obj.errcode == 0 || obj.errcode == 1) {
//console.log('[acceptAchivementInvite]success!'+JSON.stringify(obj)); //console.log('[acceptAchivementInvite]success!'+JSON.stringify(obj));
successcb && successcb(); successcb && successcb();
}else{ } else {
//console.log('[acceptAchivementInvite]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[acceptAchivementInvite]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[acceptAchivementInvite]failed!'+errcode+":"+errmsg); //console.log('[acceptAchivementInvite]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -371,7 +371,7 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
queryAchievementShareStat(actionidlst, successcb, failcb){ queryAchievementShareStat(actionidlst, successcb, failcb) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'AchievementShare') this.urlbd.addKV('c', 'AchievementShare')
.addKV('a', 'getInviteeNum') .addKV('a', 'getInviteeNum')
@ -379,16 +379,16 @@ module.exports = {
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('achievement_ids', actionidlst.join()); .addKV('achievement_ids', actionidlst.join());
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0){ if (obj.errcode == 0) {
//console.log('[queryAchievementShareStat]success!'+JSON.stringify(obj)); //console.log('[queryAchievementShareStat]success!'+JSON.stringify(obj));
successcb && successcb(obj); successcb && successcb(obj);
}else{ } else {
//console.log('[queryAchievementShareStat]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[queryAchievementShareStat]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[queryAchievementShareStat]failed!'+errcode+":"+errmsg); //console.log('[queryAchievementShareStat]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
@ -400,7 +400,7 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
queryAchievementShareDetail(actionidlst, successcb, failcb){ queryAchievementShareDetail(actionidlst, successcb, failcb) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'AchievementShare') this.urlbd.addKV('c', 'AchievementShare')
.addKV('a', 'getInviteeList') .addKV('a', 'getInviteeList')
@ -408,21 +408,20 @@ module.exports = {
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('achievement_ids', actionidlst.join()); .addKV('achievement_ids', actionidlst.join());
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj && obj.errcode == 0){ if (obj && obj.errcode == 0) {
//console.log('[queryAchievementShareDetail]success!'+JSON.stringify(obj)); //console.log('[queryAchievementShareDetail]success!'+JSON.stringify(obj));
successcb && successcb(obj.invitee_list); successcb && successcb(obj.invitee_list);
}else{ } else {
//console.log('[queryAchievementShareDetail]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[queryAchievementShareDetail]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[queryAchievementShareDetail]failed!'+errcode+":"+errmsg); //console.log('[queryAchievementShareDetail]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
}, },
};
/** /**
* 普通分享 * 普通分享
@ -434,17 +433,17 @@ module.exports = {
* @param {object} successcb * @param {object} successcb
* @param {object} failcb * @param {object} failcb
*/ */
shareNormal(content, imgurl, sharetype, shareparam, extrainfo, successcb, failcb){ shareNormal(content, imgurl, sharetype, shareparam, extrainfo, successcb, failcb) {
let uuid = this.owner? this.owner.makeUUID(): ''; let uuid = this.owner ? this.owner.makeUUID() : '';
let qstr = "inviter_id="+ this.accountid + "&activity_param=" let qstr = 'inviter_id=' + this.accountid + '&activity_param='
+ shareparam + '&localuuid=' + uuid + '&sharetype=' + sharetype; + shareparam + '&localuuid=' + uuid + '&sharetype=' + sharetype;
if(extrainfo){ if (extrainfo) {
qstr += '&'; qstr += '&';
qstr += extrainfo; qstr += extrainfo;
} }
switch(this.channelid){ switch (this.channelid) {
case 6001:{ case 6001: {
wx.shareAppMessage({ wx.shareAppMessage({
title: content, title: content,
imageUrl: imgurl, imageUrl: imgurl,
@ -452,31 +451,34 @@ module.exports = {
}); });
this.owner && this.owner.gamelog.logShare(sharetype, uuid, shareparam); this.owner && this.owner.gamelog.logShare(sharetype, uuid, shareparam);
successcb && successcb(); successcb && successcb();
}break;
case 6002:{
}break;
} }
}, break;
case 6002: {
}
break;
}
}
,
shareCapture(content, rc, sharetype, shareparam, extrainfo, successcb, failcb){ shareCapture(content, rc, sharetype, shareparam, extrainfo, successcb, failcb) {
let uuid = this.owner? this.owner.makeUUID(): ''; let uuid = this.owner ? this.owner.makeUUID() : '';
let qstr = "inviter_id="+ this.accountid + "&activity_param=" let qstr = 'inviter_id=' + this.accountid + '&activity_param='
+ shareparam + '&localuuid=' + uuid + '&sharetype=' + sharetype; + shareparam + '&localuuid=' + uuid + '&sharetype=' + sharetype;
if(extrainfo){ if (extrainfo) {
qstr += '&'; qstr += '&';
qstr += extrainfo; qstr += extrainfo;
} }
switch(this.channelid){ switch (this.channelid) {
case 6001:{ case 6001: {
let surl = canvas.toTempFilePathSync({ let surl = canvas.toTempFilePathSync({
x: rc.x, x: rc.x,
y: rc.y, y: rc.y,
width: rc.width, width: rc.width,
height: rc.height, height: rc.height,
destWidth: 500, destWidth: 500,
destHeight: 400, destHeight: 400
}); });
wx.shareAppMessage({ wx.shareAppMessage({
@ -486,58 +488,60 @@ module.exports = {
}); });
this.owner && this.owner.gamelog.logShare(sharetype, uuid, shareparam); this.owner && this.owner.gamelog.logShare(sharetype, uuid, shareparam);
successcb && successcb(); successcb && successcb();
}break; }
case 6002:{ break;
case 6002: {
}break; }
break;
} }
}, },
acceptAchievementInvite(inviter_id,achievement_id,relate_achivements){ acceptAchievementInvite(inviter_id, achievement_id, relate_achivements) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'AchievementShare') this.urlbd.addKV('c', 'AchievementShare')
.addKV('a', 'acceptInvite') .addKV('a', 'acceptInvite')
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('session_id', this.sessionid) .addKV('session_id', this.sessionid)
.addKV('inviter_id', inviter_id); .addKV('inviter_id', inviter_id);
if(relate_achivements){ if (relate_achivements) {
this.urlbd.addKV('relate_achivements', relate_achivements); this.urlbd.addKV('relate_achivements', relate_achivements);
} } else {
else{
this.urlbd.addKV('achievement_id', Number(achievement_id)); this.urlbd.addKV('achievement_id', Number(achievement_id));
} }
//console.log(this.urlbd.baseurl); //console.log(this.urlbd.baseurl);
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0){ if (obj.errcode == 0) {
//console.log('[acceptAchievementInvite]success!'+JSON.stringify(obj)); //console.log('[acceptAchievementInvite]success!'+JSON.stringify(obj));
}else{ } else {
//console.log('[acceptAchievementInvite]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[acceptAchievementInvite]failed!'+obj.errcode+":"+obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[acceptAchievementInvite]failed!'+errcode+":"+errmsg); //console.log('[acceptAchievementInvite]failed!'+errcode+":"+errmsg);
}); });
}, },
getAchievInviteeNum(successcb,failcb){ getAchievInviteeNum(successcb, failcb) {
this.urlbd.clear(); this.urlbd.clear();
this.urlbd.addKV('c', 'AchievementShare') this.urlbd.addKV('c', 'AchievementShare')
.addKV('a', 'getInviteeNum') .addKV('a', 'getInviteeNum')
.addKV('account_id', this.accountid) .addKV('account_id', this.accountid)
.addKV('session_id', this.sessionid) .addKV('session_id', this.sessionid);
// .addKV('achievement_ids', achievement_ids) // .addKV('achievement_ids', achievement_ids)
httpclient.httpGet(this.urlbd.baseurl, function(restext){ httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext); var obj = JSON.parse(restext);
if(obj.errcode == 0){ if (obj.errcode == 0) {
//console.log('[getAchievInviteeNum]success!'+JSON.stringify(obj)); //console.log('[getAchievInviteeNum]success!'+JSON.stringify(obj));
successcb && successcb(obj.invitee_nums); successcb && successcb(obj.invitee_nums);
}else{ } else {
//console.log('[getAchievInviteeNum]failed!'+obj.errcode+":"+obj.errmsg); //console.log('[getAchievInviteeNum]failed!'+obj.errcode+":"+obj.errmsg);
failcb && failcb(0, obj.errcode, obj.errmsg); failcb && failcb(0, obj.errcode, obj.errmsg);
} }
}, function(errcode, errmsg){ }, function(errcode, errmsg) {
//console.log('[getAchievInviteeNum]failed!'+errcode+":"+errmsg); //console.log('[getAchievInviteeNum]failed!'+errcode+":"+errmsg);
failcb && failcb(errcode, 0, errmsg); failcb && failcb(errcode, 0, errmsg);
}); });
}, }
};
}

View File

@ -1,5 +1,4 @@
import wepy from 'wepy' import wepy from 'wepy'
export default class baseMixin extends wepy.mixin { export default class baseMixin extends wepy.mixin {
/** /**
* [公共方法] * [公共方法]
@ -170,4 +169,15 @@ export default class baseMixin extends wepy.mixin {
console.log(info); console.log(info);
return (info.platform && (/^ios/.test(info.platform.toLowerCase()) || /^devtools/.test(info.platform.toLowerCase()))); return (info.platform && (/^ios/.test(info.platform.toLowerCase()) || /^devtools/.test(info.platform.toLowerCase())));
} }
jcLog(t, e, n) {
try {
n = n || 'debug';
e = e || n.toUpperCase();
const 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 ==JCLOGGER== %c %c %c ' + e + ' ', 'background: #9854d8', 'background: #6c2ca7', 'color: #fff; background: #450f78;', 'background: #6c2ca7', 'background: #9854d8', i, void 0 !== t ? t : '');
return console.log.bind(console, r);
} catch (e) {
return console.log(e);
}
}
} }

View File

@ -43,15 +43,15 @@
import wepy from 'wepy'; import wepy from 'wepy';
import Toast from 'wepy-com-toast'; import Toast from 'wepy-com-toast';
import http from '../utils/http'; import http from '../utils/http';
import base from '../mixins/base';
import tips from '../mixins/tips';
import cfg from '../mixins/cfg';
import recordCell from '../components/game-cell'; import recordCell from '../components/game-cell';
import recentGame from '../components/recent-game'; import recentGame from '../components/recent-game';
import zanLoadmore from '../components/zan-loadmore'; import zanLoadmore from '../components/zan-loadmore';
import jcEvent from '../common/jc-event'; import jcEvent from '../common/jc-event';
import image from '../common/images'; import image from '../common/images';
import global from '../common/global'; import global from '../common/global';
import base from '../mixins/base';
import tips from '../mixins/tips';
import cfg from '../mixins/cfg';
export default class Index extends wepy.page { export default class Index extends wepy.page {
mixins = [base, tips, cfg]; mixins = [base, tips, cfg];
@ -104,7 +104,6 @@
}) })
} }
}; };
onPullDownRefresh() { onPullDownRefresh() {
this.initPageParam(); this.initPageParam();
this.getAllData(); this.getAllData();
@ -123,6 +122,9 @@
async onLoad(options) { async onLoad(options) {
let self = this; let self = this;
wepy.showShareMenu({
withShareTicket: true
});
this.payVer = global.env === 'product' ? 'release' : 'develop'; this.payVer = global.env === 'product' ? 'release' : 'develop';
if (!this.$parent.checkClientLogin()) { if (!this.$parent.checkClientLogin()) {
this.getAllData(); this.getAllData();
@ -203,7 +205,9 @@
if (!cfg._getrewardtype) { if (!cfg._getrewardtype) {
wepy.hideShareMenu(); wepy.hideShareMenu();
} else { } else {
wepy.showShareMenu(); wepy.showShareMenu({
withShareTicket: true
});
} }
this.showAll = this.$showAll(); this.showAll = this.$showAll();
let userInfo = this.$parent.getUserInfo(); let userInfo = this.$parent.getUserInfo();
@ -248,7 +252,7 @@
async getUserInfo() { async getUserInfo() {
try { try {
let res = await http.post('/api/emulated/user_info', {type: 'all'}); let res = await http.post('/api/emulated/user_info', {type: 'all'});
console.log(res); this.debugLog(res);
if (res.userInfo) { if (res.userInfo) {
let user = res.userInfo; let user = res.userInfo;
this.score = user.score; this.score = user.score;
@ -301,7 +305,7 @@
self.noData = (self.records.length === 0); self.noData = (self.records.length === 0);
self.$apply(); self.$apply();
} else { } else {
console.log('get game data error'); this.debugLog('get game data error');
self.loading = false self.loading = false
} }
} catch (error) { } catch (error) {
@ -325,7 +329,7 @@
shareTicket: res.shareTickets[0] shareTicket: res.shareTickets[0]
}) })
.then(res => { .then(res => {
console.log(res); this.debugLog(res);
}) })
.catch(err => { .catch(err => {
console.log(err) console.log(err)

View File

@ -18,11 +18,15 @@
<script> <script>
import wepy from 'wepy' import wepy from 'wepy'
import zanToast from '../components/zan-toast' import zanToast from '../components/zan-toast'
import base from '../mixins/base';
import tips from '../mixins/tips';
import cfg from '../mixins/cfg';
export default class Login extends wepy.page { export default class Login extends wepy.page {
config = { config = {
navigationBarTitleText: '授权' navigationBarTitleText: '授权'
} }
mixins = [base, tips, cfg];
components = { components = {
zanToast: zanToast zanToast: zanToast
} }
@ -41,9 +45,10 @@
bindGetUserInfo: function(e) { bindGetUserInfo: function(e) {
let self = this let self = this
if (e.detail.userInfo) { if (e.detail.userInfo) {
console.log(e.detail.userInfo) this.jcLog(e.detail);
wepy.setStorageSync('userInfo', JSON.stringify(e.detail.userInfo)); wepy.setStorageSync('userInfo', JSON.stringify(e.detail.userInfo));
self.$parent.updateGlobalData('userInfo', e.detail.userInfo); self.$parent.updateGlobalData('userInfo', e.detail.userInfo);
self.$parent.updateUserInfo(e.detail);
wepy.navigateBack({ wepy.navigateBack({
delta: 1 delta: 1
}) })