改善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",
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": false,
"postcss": false,
"minified": false,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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