- wxapi修改
①wxapi修改showLoading()方法.
showLoading(title,_success) {
_success();
}
②wxapi修改login方法
login(_func,_fail_func,hide_btns) {
if(!Juba.is_weixin_platform){
if(_func) _func();
return;
}
const self = this;
// 如果已经登录过, 直接进入游戏
if(Juba.third_key && Juba.openid && Juba.my_id){
if(_func)
_func();
return;
}
// 从聚吧来玩进来, 已经有个人信息, 不需要授权
if(JubaLaiWan.isLaiwanUser()) {
self.do_login(_func,_fail_func,Juba.my_info);
return;
}
...
}
③do_my_login 会尝试3次登录, 若都登录失败则回到首页, 由用户来点击按钮来登录.
// 请求自己的服务器
do_my_login(_func,_fail_func,js_code,rawData,count) {
const _fail = function () {
if(count < 3) {
Networker.statistics("wx_login_fail_"+count);
this.do_my_login(_func,_fail_func,js_code,rawData,count+1);
} else {
console.log('request login fail. error! cannot again');
Networker.statistics("wx_login_failed");
if(_fail_func) {
_fail_func();
}
}
}.bind(this);
const _success = function (res) {
console.log('request login success');
if(res && res.data && res.data.third_key){
PlatformCommon.login_success(res.data,_func);
Networker.statistics("wx_login_success_"+count);
} else {
_fail();
}
}.bind(this);
Networker.login(js_code.code,rawData,_success,_fail);
},
- Common.login修改
login(_success,_fail) {
switch (Juba.platform) {
case JubaPlatform.Wx :
if(Juba.is_dev)console.log('--------------common login wx ---------------------------');
wxapi.login(_success,_fail);
break;
case JubaPlatform.Qq :
if(Juba.is_dev)console.log('--------------common login qq ---------------------------');
qqapi.login(_success,_fail);
break;
case JubaPlatform.Browser:
_success();
break;
}
},
3.Networker.js中login方法修改
login(js_code,rawData,_success,_fail) {
let data = {js_code : js_code,rawData : rawData};
if(JubaLaiWan.isLaiwanUser()) {
data['chId'] = JubaLaiWan.extraData['chid'];
data['box_uid'] = JubaLaiWan.extraData['userInfo']['uid'];
}
this.base_request({
action : "login",
data : data,
success : _success,
fail : _fail,
encrypt : false
});
},
4.Networker.js修改statistics,将统计事件全部指向阿拉丁.
// 统计事件
statistics(name,event) {
if(!Juba.is_weixin_platform)
return;
if(event == null)
event = name;
if(!wx.aldSendEvent){
console.error(" not have ald alading");
return;
}
try{
wx.aldSendEvent(name,{'key' : event});
} catch (e) {
if(Juba.is_dev)
console.warn(e)
}
},
- 对战游戏在game.json增加:
"navigateToMiniProgramAppIdList": ["xxx"]
6.对战游戏收到的命令都调用阿拉丁统计,类似
Networker.statistics("收到--"+d['cmd']);
7.修改对战游戏房间状态
onLoad方法:
this.roomStatus = RoomStatus.Inited;
onOpen方法:
this.roomStatus = RoomStatus.Connect_Success
收到matched命令:
this.roomStatus = RoomStatus.Matched;
收到start命令
this.roomStatus = RoomStatus.Start;
8.matchView 点击取消按钮时添加统计:
cancel_match(){
if(D.battle.roomStatus == RoomStatus.Matched) {
return;
}
Networker.statistics("click取消匹配_"+D.battle.roomStatus);
}
9.OverView.js增加:
// 绑定脚本
this.laiwan_view = this.node.getChildByName('over_laiwan');
do_matched(msg){
if(JubaLaiWan.isLaiwanUser()) {
this.laiwan_script.set_user();
return;
}
}
...
do_quit() {
if(JubaLaiWan.isLaiwanUser()) {
this.laiwan_script.opponent_quit();
return;
}
}
...
another_ready() {
if(JubaLaiWan.isLaiwanUser()) {
this.laiwan_script.opponent_ready();
return;
}
}
10.Battle.js增加
joinRoom() {
this.roomStatus = RoomStatus.Subscribe_Success;
// 1 -> 陌生人匹配. 2 -> 好友对战 3 -> 高手对战 4 -> 单机
let type = 1;
if(JubaLaiWan.isLaiwanUser() && JubaLaiWan.extraData['mode'] != 2) {
type = JubaLaiWan.extraData['mode'];
}
let join_data = {type : type};
try {
// 聚吧来玩用户
if(JubaLaiWan.isLaiwanUser()) {
join_data['chId'] = JubaLaiWan.extraData['chid'];
join_data['type'] = JubaLaiWan.extraData['mode'];
join_data['boxUserId'] = JubaLaiWan.extraData['userInfo']['uid'];
}
} catch (e) { console.error(e)}
if(Juba.rid) {
join_data['roomId'] = Juba.rid;
join_data['type'] = 2;
}
this.join_room_type = join_data['type'];// 用于matchView
D.ws.send(wsFunction.cmd_message_with_tea(Cmd.Join_Room,join_data));
},
11.F.js增加
digitCount(num) {
if(num == 0)
return 1;
let count = 0;
num = Math.abs(num);
while(num > 0) {
num = (num-num%10)/10;
count++;
}
return count;
},