1080 lines
22 KiB
JavaScript
1080 lines
22 KiB
JavaScript
// Learn cc.Class:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
|
|
// Learn Attribute:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
|
|
|
|
var httpclient = require('httpclient');
|
|
var urlbuilder = require('urlbuilder');
|
|
var storage = require('storage');
|
|
const BaseNet = require('../../BaseNet');
|
|
|
|
const JC_LOG_T = {
|
|
lauch: {
|
|
key: 1,
|
|
subkey: 1,
|
|
},
|
|
|
|
entermain: {
|
|
key: 1,
|
|
subkey: 2,
|
|
},
|
|
|
|
show: {
|
|
key: 1,
|
|
subkey: 3,
|
|
},
|
|
|
|
hide: {
|
|
key: 1,
|
|
subkey: 3,
|
|
},
|
|
|
|
jumpapp: {
|
|
key: 1,
|
|
subkey: 4,
|
|
},
|
|
|
|
loginFailed: {
|
|
key: 1,
|
|
subkey: 5,
|
|
},
|
|
|
|
launchsysteminfo: {
|
|
key: 1,
|
|
subkey: 6,
|
|
},
|
|
|
|
debuginfo: {
|
|
key: 1,
|
|
subkey: 10,
|
|
},
|
|
|
|
logined: {
|
|
key: 11,
|
|
subkey: 1,
|
|
},
|
|
|
|
authed: {
|
|
key: 11,
|
|
subkey: 2,
|
|
},
|
|
|
|
authfail: {
|
|
key: 11,
|
|
subkey: 3,
|
|
},
|
|
|
|
startgame: {
|
|
key: 11,
|
|
subkey: 4,
|
|
},
|
|
|
|
restartgame: {
|
|
key: 11,
|
|
subkey: 4,
|
|
},
|
|
|
|
gameover: {
|
|
key: 11,
|
|
subkey: 6,
|
|
},
|
|
|
|
againgame: {
|
|
key: 11,
|
|
subkey: 4,
|
|
},
|
|
|
|
productitem: {
|
|
key: 11,
|
|
subkey: 8,
|
|
},
|
|
|
|
useitem: {
|
|
key: 11,
|
|
subkey: 9,
|
|
},
|
|
|
|
share: {
|
|
key: 11,
|
|
subkey: 10,
|
|
},
|
|
|
|
inviter: {
|
|
key: 11,
|
|
subkey: 11,
|
|
},
|
|
|
|
systeminfo: {
|
|
key: 11,
|
|
subkey: 20,
|
|
},
|
|
|
|
advinfo: {
|
|
key: 11,
|
|
subkey: 21,
|
|
},
|
|
|
|
vslogin: {
|
|
key: 11,
|
|
subkey: 24,
|
|
},
|
|
|
|
vsreconnect: {
|
|
key: 11,
|
|
subkey: 25,
|
|
},
|
|
|
|
vsroomcreate: {
|
|
key: 11,
|
|
subkey: 26,
|
|
},
|
|
|
|
vsroomjoin: {
|
|
key: 11,
|
|
subkey: 27,
|
|
},
|
|
|
|
vsroomleave: {
|
|
key: 11,
|
|
subkey: 28,
|
|
},
|
|
|
|
vsroomsetstate: {
|
|
key: 11,
|
|
subkey: 29,
|
|
},
|
|
|
|
business: {
|
|
key: 11,
|
|
subkey: 30,
|
|
},
|
|
|
|
buttonclick: {
|
|
key: 11,
|
|
subkey: 31,
|
|
},
|
|
};
|
|
|
|
const _SHOW_FLAG = 2;
|
|
const _HIDE_FLAG = 1;
|
|
|
|
const _ONLINE_KEY = 'jc_online_flags';
|
|
|
|
//
|
|
|
|
module.exports = {
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {},
|
|
|
|
// start () {},
|
|
|
|
// update (dt) {},
|
|
__uuid(len, radix) {
|
|
var chars =
|
|
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(
|
|
''
|
|
);
|
|
var uuid = [],
|
|
i;
|
|
radix = radix || chars.length;
|
|
|
|
if (len) {
|
|
// Compact form
|
|
for (i = 0; i < len; i++)
|
|
uuid[i] = chars[0 | (Math.random() * radix)];
|
|
} else {
|
|
// rfc4122, version 4 form
|
|
var r;
|
|
|
|
// rfc4122 requires these characters
|
|
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
uuid[14] = '4';
|
|
|
|
// Fill in random data. At i==19 set the high bits of clock sequence as
|
|
// per rfc4122, sec. 4.1.5
|
|
for (i = 0; i < 36; i++) {
|
|
if (!uuid[i]) {
|
|
r = 0 | (Math.random() * 16);
|
|
uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
|
|
}
|
|
}
|
|
}
|
|
|
|
return uuid.join('');
|
|
},
|
|
|
|
_buildReportUrl(typeobj) {
|
|
if (CC_JSB && !cc.yschannel) {
|
|
cc.yschannel = true;
|
|
// var cid = jsb.reflection.callStaticMethod(
|
|
// "org/cocos2dx/javascript/AppActivity",
|
|
// "getqudaohao",
|
|
// "()Ljava/lang/String;"
|
|
// );
|
|
// if (cid != "") {
|
|
// this.channelid = cid
|
|
// }
|
|
console.log('sdk channel:' + this.channelid);
|
|
}
|
|
|
|
this.urlbd.clear();
|
|
this.urlbd
|
|
.addKV('c', 'GameLog')
|
|
.addKV('a', 'reportLog')
|
|
.addKV('gameid', this.gameid)
|
|
.addKV('channel', cc.subchannel ? cc.subchannel : this.channelid)
|
|
.addKV('account_id', this.accountid)
|
|
.addKV('session_id', this.sessionid)
|
|
.addKV('access_token', this.token)
|
|
.addKV('wid', this.wid)
|
|
.addKV('sid', this.sid)
|
|
.addKV('ptid', this.ptid)
|
|
.addKV('logclass1', typeobj.key)
|
|
.addKV('logclass2', typeobj.subkey)
|
|
.addKV('localuuid', this.localid)
|
|
.addKV('from_appid', this.fromid)
|
|
.addKV('ad_channel', this.adchannel);
|
|
|
|
if (cc.sdkdata) {
|
|
this.urlbd.addKV('poly_sdk_channel', 8001);
|
|
this.urlbd.addKV(
|
|
'poly_sdk_subchannel',
|
|
cc.sdkdata.poly_sdk_subchannel
|
|
);
|
|
}
|
|
|
|
// .addKV('subchannel', cc.subchannel? cc.subchannel : "");
|
|
console.log('[gamelog]');
|
|
console.log(JSON.stringify(typeobj));
|
|
return this.urlbd.baseurl;
|
|
},
|
|
|
|
_buildReportUserUrl() {
|
|
if (CC_JSB && !cc.yschannel) {
|
|
// cc.yschannel = true
|
|
// var cid = jsb.reflection.callStaticMethod(
|
|
// "org/cocos2dx/javascript/AppActivity",
|
|
// "getqudaohao",
|
|
// "()Ljava/lang/String;"
|
|
// );
|
|
// if (cid != "") {
|
|
// this.channelid = cid
|
|
// }
|
|
// console.log("sdk channel:"+this.channelid)
|
|
}
|
|
|
|
this.urlbd.clear();
|
|
this.urlbd
|
|
.addKV('c', 'GameLog')
|
|
.addKV('a', 'reportUser')
|
|
.addKV('gameid', this.gameid)
|
|
.addKV('channel', this.channelid)
|
|
.addKV('account_id', this.accountid)
|
|
.addKV('session_id', this.sessionid)
|
|
.addKV('access_token', this.token)
|
|
.addKV('localuuid', this.localid);
|
|
return this.urlbd.baseurl;
|
|
},
|
|
|
|
_buildShowHideMsg(showflag) {
|
|
let data = {
|
|
str1: this.localid,
|
|
str2: this.fromid,
|
|
str3: this.accountid,
|
|
str4: this.nickName,
|
|
num1: showflag,
|
|
num2: -1,
|
|
};
|
|
|
|
let msg = {
|
|
u: this._buildReportUrl(
|
|
showflag == _SHOW_FLAG ? JC_LOG_T.show : JC_LOG_T.hide
|
|
),
|
|
v: JSON.stringify(data),
|
|
ext: showflag,
|
|
};
|
|
|
|
return msg;
|
|
},
|
|
|
|
addOperation(type, parm1 = '', parm2 = '') {
|
|
var data = {
|
|
data1: parm1,
|
|
data2: parm2,
|
|
};
|
|
this._customReport(type, data);
|
|
},
|
|
|
|
_customReport(eventName, valueobj, successcb, failcb) {
|
|
if (!cc.sys.isNative) {
|
|
if (successcb) {
|
|
successcb();
|
|
}
|
|
return;
|
|
}
|
|
this.urlbd.clear();
|
|
this.urlbd
|
|
.addKV('c', 'GameLog')
|
|
.addKV('a', 'customReport')
|
|
.addKV('gameid', this.gameid)
|
|
.addKV('channel', this.channelid)
|
|
.addKV('event_name', eventName)
|
|
.addKV('account_id', this.accountid)
|
|
.addKV('session_id', this.sessionid)
|
|
.addKV('localuuid', this.localid);
|
|
const url = this.urlbd.baseurl;
|
|
let value = JSON.stringify(valueobj);
|
|
httpclient.httpPost(
|
|
url,
|
|
value,
|
|
function (restext) {
|
|
if (successcb) {
|
|
successcb();
|
|
}
|
|
},
|
|
function (errcode, errmsg) {
|
|
console.log('[_report]' + url);
|
|
console.log('[_report]failed!' + errcode + ':' + errmsg);
|
|
if (failcb) {
|
|
failcb();
|
|
}
|
|
}
|
|
);
|
|
},
|
|
|
|
_report(typeobj, valueobj, successcb, failcb) {
|
|
// return ;
|
|
if (!CC_JSB) {
|
|
return;
|
|
}
|
|
|
|
let url = this._buildReportUrl(typeobj);
|
|
let value = JSON.stringify(valueobj);
|
|
var self = this;
|
|
httpclient.httpPost(
|
|
url,
|
|
value,
|
|
function (restext) {
|
|
let obj = httpclient.JSON_parse(restext);
|
|
if (obj.errcode == 0) {
|
|
console.log('[_report]success!' + JSON.stringify(obj));
|
|
successcb && successcb();
|
|
} else {
|
|
console.log('[_report]' + url);
|
|
console.log(
|
|
'[_report]failed!' + obj.errcode + ':' + obj.errmsg
|
|
);
|
|
failcb && failcb(0, obj.errcode, obj.errmsg);
|
|
}
|
|
},
|
|
function (errcode, errmsg) {
|
|
console.log('[_report]' + url);
|
|
console.log('[_report]failed!' + errcode + ':' + errmsg);
|
|
failcb && failcb(errcode, 0, errmsg);
|
|
let nflag = -1;
|
|
if (
|
|
typeobj.key == JC_LOG_T.show.key &&
|
|
typeobj.subkey == JC_LOG_T.show.subkey
|
|
) {
|
|
nflag = valueobj.num1;
|
|
}
|
|
let msg = {
|
|
u: url,
|
|
v: value,
|
|
ext: nflag,
|
|
};
|
|
self.cachemsg.push(msg);
|
|
}
|
|
);
|
|
},
|
|
|
|
_reportUser(valueobj, successcb, failcb) {
|
|
let url = this._buildReportUserUrl();
|
|
let value = JSON.stringify(valueobj);
|
|
var self = this;
|
|
httpclient.httpPost(
|
|
url,
|
|
value,
|
|
function (restext) {
|
|
let obj = httpclient.JSON_parse(restext);
|
|
if (obj.errcode == 0) {
|
|
console.log('[_reportUser]success!' + JSON.stringify(obj));
|
|
successcb && successcb();
|
|
} else {
|
|
console.log(
|
|
'[_reportUser]failed!' + obj.errcode + ':' + obj.errmsg
|
|
);
|
|
failcb && failcb(0, obj.errcode, obj.errmsg);
|
|
}
|
|
},
|
|
function (errcode, errmsg) {
|
|
console.log('[_reportUser]failed!' + errcode + ':' + errmsg);
|
|
failcb && failcb(errcode, 0, errmsg);
|
|
let nflag = -1;
|
|
let msg = {
|
|
u: url,
|
|
v: value,
|
|
ext: nflag,
|
|
};
|
|
self.cachemsg.push(msg);
|
|
}
|
|
);
|
|
},
|
|
|
|
_retry() {
|
|
if (this.cachemsg.length > 0) {
|
|
let obj = this.cachemsg[0];
|
|
var self = this;
|
|
httpclient.httpPost(
|
|
obj.u,
|
|
obj.v,
|
|
function (restext) {
|
|
if (obj.ext >= 0) {
|
|
self.showflag = obj.ext;
|
|
self._saveflag(self.showflag);
|
|
}
|
|
self.cachemsg.shift();
|
|
},
|
|
function (errcode, errmsg) {
|
|
console.log(
|
|
'[_retry_report]failed!' + errcode + ':' + errmsg
|
|
);
|
|
}
|
|
);
|
|
}
|
|
},
|
|
|
|
_saveflag(showflag) {
|
|
storage.set(_ONLINE_KEY, showflag);
|
|
},
|
|
|
|
_loadflag() {
|
|
return storage.get(_ONLINE_KEY);
|
|
},
|
|
|
|
_handlelaunch(res) {
|
|
console.log(
|
|
'_handlelaunch_handlelaunch_handlelaunch_handlelaunch_handlelaunch'
|
|
);
|
|
if (res) {
|
|
if (res.query && res.query.weixinadinfo) {
|
|
let wxaddr = res.query.weixinadinfo.split('.');
|
|
let ad = wxaddr[0];
|
|
if (ad && ad != '') {
|
|
this.fromadvid = ad;
|
|
}
|
|
}
|
|
// this.adchannel = '';
|
|
if (res.query && res.query.channel) {
|
|
this.adchannel = '' + res.query.channel;
|
|
}
|
|
this.launchparam = res.query;
|
|
if (res.referrerInfo && res.referrerInfo.appId) {
|
|
this.setFromAppID(res.referrerInfo.appId);
|
|
this.launchparam = res.referrerInfo.extraData;
|
|
} else if (res.query && res.query.scene) {
|
|
let str = decodeURIComponent(res.query.scene);
|
|
let lst = str.split('=');
|
|
if (lst.length >= 2 && lst[0] == 'channel') {
|
|
this.adchannel = lst[1];
|
|
} else {
|
|
this.setFromAppID(str);
|
|
}
|
|
}
|
|
this.scene = res.scene ? res.scene : 0;
|
|
if (this.adchannel == '' && this.fromid != '') {
|
|
this.adchannel = this.fromid;
|
|
}
|
|
}
|
|
},
|
|
|
|
_handleLoginInfo(res) {
|
|
if (res.account_id && res.session_id) {
|
|
this.setAccountID(res.account_id, res.session_id);
|
|
}
|
|
if (res && res.nickname && res.nickname != '') {
|
|
this.setNickName(res.nickname);
|
|
}
|
|
},
|
|
|
|
_handleAuthInfo(res) {
|
|
if (res && res.nickname && res.nickname != '') {
|
|
this.setNickName(res.nickname);
|
|
}
|
|
},
|
|
|
|
//
|
|
generateUUID() {
|
|
return this.__uuid(32, 62);
|
|
},
|
|
|
|
//
|
|
init(channelid, gameid, isoffical) {
|
|
this.gameid = gameid;
|
|
this.channelid = channelid;
|
|
this.accountid = this.accountid ? this.accountid : '';
|
|
this.sessionid = this.sessionid ? this.sessionid : '';
|
|
this.token = this.token ? this.token : '';
|
|
this.localid = this.localid ? this.localid : '';
|
|
this.nickname = this.nickname ? this.nickname : '';
|
|
this.fromid = this.fromid ? this.fromid : '';
|
|
this.fromadvid = this.fromadvid ? this.fromadvid : '';
|
|
this.scene = this.scene ? this.scene : 0;
|
|
this._tempuuid = '';
|
|
this._starttime = 0;
|
|
this._launchtime = 0;
|
|
this.needsubmit = false;
|
|
this.urlbd = new urlbuilder(BaseNet.getNormalApiUrl('gamelog'));
|
|
this.showflag = this._loadflag();
|
|
this.cachemsg = [];
|
|
this.adchannel = this.adchannel ? this.adchannel : '';
|
|
if (this.showflag == _SHOW_FLAG) {
|
|
this.cachemsg.push(this._buildShowHideMsg(this.showflag));
|
|
}
|
|
this.showflag = null;
|
|
setInterval(this._retry.bind(this), 3000);
|
|
console.log(
|
|
'[jcgamelog]init:' + gameid + '|' + channelid + '|' + isoffical
|
|
);
|
|
},
|
|
|
|
//
|
|
setSubmitFlag(bsubmit) {
|
|
this.needsubmit = bsubmit;
|
|
},
|
|
|
|
//
|
|
setAccountID(accountid, sessionid, exobj) {
|
|
if (!this.accountid || this.accountid != accountid) {
|
|
this.accountid = accountid;
|
|
}
|
|
if (!this.sessionid || this.sessionid != sessionid) {
|
|
this.sessionid = sessionid;
|
|
}
|
|
if (exobj) {
|
|
this.wid = exobj.wid;
|
|
this.sid = exobj.sid;
|
|
this.ptid = exobj.ptid;
|
|
}
|
|
},
|
|
|
|
//
|
|
setNickName(nickname) {
|
|
if (!this.nickname || this.nickname != nickname) {
|
|
this.nickname = nickname;
|
|
}
|
|
},
|
|
|
|
//
|
|
setFromAppID(appid) {
|
|
if (!this.fromid || this.fromid != appid) {
|
|
this.fromid = appid;
|
|
}
|
|
},
|
|
|
|
//
|
|
setLocalUUID(uuid) {
|
|
if (!this.localid || this.localid != uuid) {
|
|
this.localid = uuid;
|
|
}
|
|
},
|
|
|
|
setSystemInfo(info) {},
|
|
|
|
//
|
|
setToken(token) {
|
|
this.token = token;
|
|
},
|
|
|
|
handlelaunch(res, cb) {
|
|
this._launchtime = new Date().getTime();
|
|
if (res) {
|
|
this._handlelaunch(res);
|
|
|
|
this.logLauchDefault(res);
|
|
|
|
var param = res.query.activity_param ? res.query.activity_param : 0;
|
|
var uid = res.query.localuuid ? res.query.localuuid : '';
|
|
var stype = res.query.sharetype ? res.query.sharetype : 0;
|
|
cb &&
|
|
cb(
|
|
stype,
|
|
param,
|
|
uid,
|
|
res.query.inviter_id,
|
|
this.fromid,
|
|
this.scene,
|
|
this.launchparam
|
|
);
|
|
} else {
|
|
cb && cb();
|
|
}
|
|
},
|
|
|
|
|
|
logLaunch(launch_option) {
|
|
this._launchtime = new Date().getTime();
|
|
this._handlelaunch(launch_option);
|
|
this.logLauchDefault(launch_option);
|
|
},
|
|
|
|
|
|
logLauchDefault(launch_option) {
|
|
let data = {
|
|
str1: this.localid,
|
|
str2: this.fromid,
|
|
ext: launch_option ? JSON.stringify(launch_option) : null,
|
|
str3: this.fromadvid,
|
|
num1: this.scene,
|
|
};
|
|
this._report(JC_LOG_T.lauch, data);
|
|
},
|
|
logLauch2() {
|
|
let data = {
|
|
str1: this.localid,
|
|
};
|
|
this._report(JC_LOG_T.lauch, data);
|
|
},
|
|
|
|
|
|
logLoginSuccess(res, costtime) {
|
|
let nowtime = new Date().getTime();
|
|
this._handleLoginInfo(res);
|
|
let data = {
|
|
str1: res.nickname,
|
|
str2: res.unionid,
|
|
str3: res.country,
|
|
str4: res.province,
|
|
str5: res.city,
|
|
str6: this.localid,
|
|
num1: costtime ? costtime : 0,
|
|
num2: nowtime - this._launchtime,
|
|
str7: this.fromadvid,
|
|
};
|
|
this._report(JC_LOG_T.logined, data);
|
|
},
|
|
|
|
|
|
logLoginFailed(neterr, logicerr, errmsg) {
|
|
let data = {
|
|
error_code_net: neterr,
|
|
error_code_logic: logicerr,
|
|
error_msg: errmsg,
|
|
};
|
|
this._report(JC_LOG_T.loginFailed, data);
|
|
},
|
|
|
|
|
|
logAuthSuccess(res) {
|
|
this._handleAuthInfo(res);
|
|
let data = {
|
|
str1: res.nickName,
|
|
num1: res.gender,
|
|
str3: res.country,
|
|
str4: res.province,
|
|
str5: res.city,
|
|
str6: this.localid,
|
|
str7: res.avatarUrl ? res.avatarUrl : '',
|
|
str8: res.language,
|
|
};
|
|
this._report(JC_LOG_T.authed, data);
|
|
},
|
|
|
|
|
|
logAuthFail() {
|
|
let data = {
|
|
str1: this.nickName,
|
|
str2: this.localid,
|
|
};
|
|
this._report(JC_LOG_T.authfail, data);
|
|
},
|
|
|
|
|
|
logShare(businessid, sharetokenid, param) {
|
|
let data = {
|
|
str1: this.nickname,
|
|
str2: sharetokenid ? sharetokenid : '',
|
|
num1: businessid,
|
|
str3: param ? param : '',
|
|
};
|
|
this._report(JC_LOG_T.share, data);
|
|
},
|
|
|
|
|
|
logShareInvite(inviterid, businessid, sharetokenid, param) {
|
|
let data = {
|
|
str1: this.nickName,
|
|
str2: inviterid,
|
|
num1: businessid,
|
|
str3: sharetokenid ? sharetokenid : sharetokenid,
|
|
str4: param ? param : '',
|
|
};
|
|
this._report(JC_LOG_T.inviter, data);
|
|
},
|
|
|
|
|
|
logSysInfo(res, typeobj) {
|
|
let data = {
|
|
str1: res.brand,
|
|
str2: res.model,
|
|
str3: res.language,
|
|
str4: res.version,
|
|
str5: res.platform,
|
|
str6: res.SDKVersion,
|
|
str7: res.system,
|
|
num1: res.pixelRatio,
|
|
num2: res.screenWidth,
|
|
num3: res.screenHeight,
|
|
num4: res.windowWidth,
|
|
num5: res.windowHeight,
|
|
num6: res.benchmarkLevel,
|
|
// ext: JSON.stringify(res)
|
|
};
|
|
this._report(typeobj, data);
|
|
},
|
|
|
|
logSystemInfo(res) {
|
|
if (!res) {
|
|
return;
|
|
}
|
|
this.logSysInfo(res, JC_LOG_T.systeminfo);
|
|
},
|
|
|
|
logLaunchSystemInfo(res) {
|
|
if (!res) {
|
|
return;
|
|
}
|
|
this.logSysInfo(res, JC_LOG_T.launchsysteminfo);
|
|
},
|
|
|
|
|
|
logStartGame(param, startmode) {
|
|
this._tempuuid = this.generateUUID();
|
|
this._starttime = new Date().getTime();
|
|
let data = {
|
|
str1: this.fromid,
|
|
str2: this._tempuuid,
|
|
str3: param ? param : '',
|
|
str4: this.nickname,
|
|
str5: this.localid,
|
|
num1: startmode ? startmode : 0,
|
|
};
|
|
this._report(JC_LOG_T.startgame, data);
|
|
},
|
|
|
|
|
|
logRestartGame(param) {
|
|
this._tempuuid = this.generateUUID();
|
|
this._starttime = new Date().getTime();
|
|
let data = {
|
|
str1: this.fromid,
|
|
str2: this._tempuuid,
|
|
str3: param ? param : '',
|
|
str4: this.nickname,
|
|
str5: this.localid,
|
|
num1: 1,
|
|
};
|
|
this._report(JC_LOG_T.restartgame, data);
|
|
},
|
|
|
|
|
|
logGameover(param, score, endflag) {
|
|
let nowtime = new Date().getTime();
|
|
let data = {
|
|
str1: this.fromid,
|
|
str2: this._tempuuid,
|
|
str3: param ? param : '',
|
|
num1: score,
|
|
str4: this.nickname,
|
|
str5: this.localid,
|
|
num2: nowtime - this._starttime,
|
|
num3: endflag ? endflag : 0,
|
|
};
|
|
this._report(JC_LOG_T.gameover, data);
|
|
},
|
|
|
|
|
|
logTryAgain(param) {
|
|
this._tempuuid = this.generateUUID();
|
|
let data = {
|
|
str1: this.fromid,
|
|
str2: this._tempuuid,
|
|
str3: param ? param : '',
|
|
str4: this.nickname,
|
|
str5: this.localid,
|
|
num1: 2,
|
|
};
|
|
this._report(JC_LOG_T.againgame, data);
|
|
},
|
|
|
|
|
|
logShow(bIgnoreFlag) {
|
|
if (!bIgnoreFlag) {
|
|
let bok = !this.showflag || this.showflag == _HIDE_FLAG;
|
|
if (!bok) {
|
|
return;
|
|
}
|
|
this.showflag = _SHOW_FLAG;
|
|
}
|
|
|
|
let nowtime = new Date().getTime();
|
|
let data = {
|
|
str1: this.localid,
|
|
str2: this.fromid,
|
|
str3: this.accountid,
|
|
str4: this.nickName,
|
|
num1: _SHOW_FLAG,
|
|
num2: nowtime - this._launchtime,
|
|
};
|
|
this._report(
|
|
JC_LOG_T.show,
|
|
data,
|
|
() => {
|
|
if (!bIgnoreFlag) {
|
|
this._saveflag(this.showflag);
|
|
}
|
|
},
|
|
() => {}
|
|
);
|
|
},
|
|
|
|
|
|
logHide(bIgnoreFlag) {
|
|
if (!bIgnoreFlag) {
|
|
let bok = this.showflag && this.showflag == _SHOW_FLAG;
|
|
if (!bok) {
|
|
return;
|
|
}
|
|
this.showflag = _HIDE_FLAG;
|
|
}
|
|
let nowtime = new Date().getTime();
|
|
let data = {
|
|
str1: this.localid,
|
|
str2: this.fromid,
|
|
str3: this.accountid,
|
|
str4: this.nickName,
|
|
num1: _HIDE_FLAG,
|
|
num2: nowtime - this._launchtime,
|
|
};
|
|
this._report(
|
|
JC_LOG_T.hide,
|
|
data,
|
|
() => {
|
|
if (!bIgnoreFlag) {
|
|
this._saveflag(this.showflag);
|
|
}
|
|
},
|
|
() => {}
|
|
);
|
|
},
|
|
|
|
|
|
logProductItem(itemid, itemcount, reson, resonparam) {
|
|
let data = {
|
|
str1: this.nickname,
|
|
num1: itemid,
|
|
num2: itemcount,
|
|
num3: reson,
|
|
num4: resonparam,
|
|
};
|
|
this._report(JC_LOG_T.productitem, data);
|
|
},
|
|
|
|
|
|
logUseItem(itemid, itemcount, reson, resonparam) {
|
|
let data = {
|
|
str1: this.nickname,
|
|
num1: itemid,
|
|
num2: itemcount,
|
|
num3: reson,
|
|
num4: resonparam,
|
|
};
|
|
this._report(JC_LOG_T.useitem, data);
|
|
},
|
|
|
|
|
|
logBusiness(businessid, actionid) {
|
|
let data = {
|
|
str1: this.nickName,
|
|
str2: this.localid,
|
|
num1: businessid,
|
|
num2: actionid,
|
|
};
|
|
this._report(JC_LOG_T.business, data);
|
|
},
|
|
|
|
|
|
logEnterMainScene(dt) {
|
|
let data = {
|
|
str1: this.localid,
|
|
str2: this.fromid,
|
|
num1: dt ? dt : 0,
|
|
};
|
|
this._report(JC_LOG_T.entermain, data);
|
|
},
|
|
|
|
logJumpApp(appid, appparam, jumpres) {
|
|
let data = {
|
|
str1: this.localid,
|
|
str2: this.fromid,
|
|
str3: this.accountid,
|
|
str4: this.nickName,
|
|
str5: appid,
|
|
str6: appparam,
|
|
num1: jumpres ? jumpres : 0,
|
|
};
|
|
this._report(JC_LOG_T.jumpapp, data);
|
|
},
|
|
|
|
|
|
logAdvInfo(advid, actiontype, actionparam) {
|
|
let data = {
|
|
str1: this.nickname,
|
|
str2: advid,
|
|
num1: actiontype,
|
|
str3: actionparam,
|
|
};
|
|
this._report(JC_LOG_T.advinfo, data);
|
|
},
|
|
|
|
|
|
logVS_login() {
|
|
let data = {
|
|
str1: this.nickName,
|
|
};
|
|
this._report(JC_LOG_T.vslogin, data);
|
|
},
|
|
|
|
|
|
logVS_reconnect(roomid) {
|
|
let data = {
|
|
str1: this.nickName,
|
|
str2: roomid,
|
|
};
|
|
this._report(JC_LOG_T.vsreconnect, data);
|
|
},
|
|
|
|
|
|
logVS_createRoom(roomname, maxplayer) {
|
|
let data = {
|
|
str1: this.nickname,
|
|
str2: roomname,
|
|
num1: maxplayer,
|
|
};
|
|
this._report(JC_LOG_T.vsroomcreate, data);
|
|
},
|
|
|
|
|
|
logVS_joinRoom(roomid, customdata, israndom) {
|
|
let data = {
|
|
str1: this.nickname,
|
|
str2: roomid ? roomid : '',
|
|
num1: israndom ? 1 : 0,
|
|
str3: customdata,
|
|
};
|
|
this._report(JC_LOG_T.vsroomjoin, data);
|
|
},
|
|
|
|
|
|
logVS_leaveRoom(roomid, customdata) {
|
|
let data = {
|
|
str1: this.nickname,
|
|
str2: roomid,
|
|
str3: customdata,
|
|
};
|
|
this._report(JC_LOG_T.vsroomleave, data);
|
|
},
|
|
|
|
|
|
logVS_gameReady(roomid, customdata, isready) {
|
|
let data = {
|
|
str1: this.nickname,
|
|
str2: roomid,
|
|
num1: isready ? 1 : 0,
|
|
str3: customdata,
|
|
};
|
|
this._report(JC_LOG_T.vsroomsetstate, data);
|
|
},
|
|
|
|
|
|
logVS_gameStart(roomid, customdata) {
|
|
let data = {
|
|
str1: this.nickname,
|
|
str2: roomid,
|
|
num1: 2,
|
|
str3: customdata,
|
|
};
|
|
this._report(JC_LOG_T.vsroomsetstate, data);
|
|
},
|
|
|
|
|
|
logButtonClick(buttonname, param) {
|
|
let data = {
|
|
nickname: this.nickname,
|
|
button_name: buttonname,
|
|
button_param: param ? param : '',
|
|
// subchannel: cc.subchannel? cc.subchannel : ""
|
|
};
|
|
this._report(JC_LOG_T.buttonclick, data);
|
|
},
|
|
|
|
|
|
userSet(kvobj) {
|
|
let data = {
|
|
set: kvobj,
|
|
};
|
|
this._reportUser(data);
|
|
},
|
|
|
|
|
|
userSetOnce(kvobj) {
|
|
let data = {
|
|
set_once: kvobj,
|
|
};
|
|
this._reportUser(data);
|
|
},
|
|
|
|
|
|
userAdd(kvobj) {
|
|
let data = {
|
|
add: kvobj,
|
|
};
|
|
this._reportUser(data);
|
|
},
|
|
|
|
|
|
userReport(setobj, setonceobj, addobj) {
|
|
let data = {
|
|
set: setobj,
|
|
set_once: setonceobj,
|
|
add: addobj,
|
|
};
|
|
this._reportUser(data);
|
|
},
|
|
|
|
externalLog(externalID, logFunc, p1, p2, p3, p4) {
|
|
let tmpid = this.gameid;
|
|
this.gameid = externalID;
|
|
logFunc && logFunc.call(this, p1, p2, p3, p4);
|
|
this.gameid = tmpid;
|
|
},
|
|
|
|
logdebug(s1, s2) {
|
|
let data = {
|
|
channel: this.channelid,
|
|
from_appid: this.fromid,
|
|
localuuid: this.localid,
|
|
account_id: this.accountid,
|
|
str1: s1,
|
|
str2: s2,
|
|
};
|
|
this._report(JC_LOG_T.debuginfo, data);
|
|
},
|
|
};
|