Merge branch 'zhuguoqing/dev' into 'master'
add friend See merge request client/pubgv3!1
This commit is contained in:
commit
a68805ba04
@ -47,8 +47,8 @@
|
|||||||
},
|
},
|
||||||
"_scale": {
|
"_scale": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0.416015625,
|
"x": 0.5703125,
|
||||||
"y": 0.416015625,
|
"y": 0.5703125,
|
||||||
"z": 1
|
"z": 1
|
||||||
},
|
},
|
||||||
"_quat": {
|
"_quat": {
|
||||||
@ -12654,7 +12654,7 @@
|
|||||||
"__id__": 377
|
"__id__": 377
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": false,
|
"_active": true,
|
||||||
"_level": 2,
|
"_level": 2,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -31981,7 +31981,7 @@
|
|||||||
"__id__": 662
|
"__id__": 662
|
||||||
},
|
},
|
||||||
"pb_friend": {
|
"pb_friend": {
|
||||||
"__uuid__": "f5fe16a6-cbf6-489f-8f1d-dac0d59cba8c"
|
"__uuid__": "1c680882-520e-49af-b19e-b28ac201d38e"
|
||||||
},
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
|
3933
assets/res/prefabs/NUI/singleFriend.prefab
Normal file
3933
assets/res/prefabs/NUI/singleFriend.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
assets/res/prefabs/NUI/singleFriend.prefab.meta
Normal file
7
assets/res/prefabs/NUI/singleFriend.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.1",
|
||||||
|
"uuid": "cef03361-18fb-4a3d-a4fd-6babd3277617",
|
||||||
|
"optimizationPolicy": "AUTO",
|
||||||
|
"asyncLoadAssets": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
71
assets/scripts/UI/UIFriend/SingleFriendList.js
Normal file
71
assets/scripts/UI/UIFriend/SingleFriendList.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
cc.Class({
|
||||||
|
extends: cc.Component,
|
||||||
|
|
||||||
|
properties: {
|
||||||
|
addToBlack: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
agree: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
refuse: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
addToFriend: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
playerHead: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
playerName: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
setToFriendList() {
|
||||||
|
this.addToBlack.active = true;
|
||||||
|
this.delete.active = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
setToApplyList() {
|
||||||
|
this.agree.active = true;
|
||||||
|
this.refuse.active = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
setToBlackList() {
|
||||||
|
this.addToFriend.active = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
// friendlist
|
||||||
|
onAddToBlacklist() {
|
||||||
|
console.log("加入黑名单");
|
||||||
|
},
|
||||||
|
|
||||||
|
onDelete() {
|
||||||
|
console.log("删除好友");
|
||||||
|
},
|
||||||
|
|
||||||
|
// applylist
|
||||||
|
onAgree() {
|
||||||
|
console.log("同意申请");
|
||||||
|
},
|
||||||
|
|
||||||
|
onRefuse() {
|
||||||
|
console.log("拒绝申请");
|
||||||
|
},
|
||||||
|
|
||||||
|
// blacklist
|
||||||
|
onAddToFriend() {
|
||||||
|
console.log("加入好友列表");
|
||||||
|
},
|
||||||
|
});
|
9
assets/scripts/UI/UIFriend/SingleFriendList.js.meta
Normal file
9
assets/scripts/UI/UIFriend/SingleFriendList.js.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.5",
|
||||||
|
"uuid": "10eaeefb-7816-45b9-a916-994bd57515fc",
|
||||||
|
"isPlugin": false,
|
||||||
|
"loadPluginInWeb": true,
|
||||||
|
"loadPluginInNative": true,
|
||||||
|
"loadPluginInEditor": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
141
assets/scripts/UI/UIFriend/UIFriendNew.js
Normal file
141
assets/scripts/UI/UIFriend/UIFriendNew.js
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
var SDKManage = require("SDKManage");
|
||||||
|
cc.Class({
|
||||||
|
extends: cc.Component,
|
||||||
|
|
||||||
|
properties: {
|
||||||
|
nd_friend: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
|
||||||
|
nd_apply: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
|
||||||
|
nd_blacklist: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
|
||||||
|
edit_find: {
|
||||||
|
default: null,
|
||||||
|
type: cc.EditBox,
|
||||||
|
},
|
||||||
|
|
||||||
|
pb_oneFriend: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Prefab,
|
||||||
|
},
|
||||||
|
|
||||||
|
// contents
|
||||||
|
content_friend: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
|
||||||
|
content_apply: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
|
||||||
|
content_blacklist: {
|
||||||
|
default: null,
|
||||||
|
type: cc.Node,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
// get friendlist
|
||||||
|
cc.chatMgr.sendmsg("CMFriendList");
|
||||||
|
cc.Notifier.on("friendlist", this, this.getFriendList.bind(this));
|
||||||
|
this.setToFriend();
|
||||||
|
},
|
||||||
|
|
||||||
|
start() {},
|
||||||
|
|
||||||
|
setToNone() {
|
||||||
|
this.edit_find.string = "";
|
||||||
|
this.nd_friend.active = false;
|
||||||
|
this.nd_apply.active = false;
|
||||||
|
this.nd_blacklist.active = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
testinitOne(index) {
|
||||||
|
for (let i = 0; i < 50; i += 1) {
|
||||||
|
const node = cc.instantiate(this.pb_oneFriend);
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
node.getComponent("SingleFriendList").setToFriendList();
|
||||||
|
this.content_friend.addChild(node);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
node.getComponent("SingleFriendList").setToApplyList();
|
||||||
|
this.content_apply.addChild(node);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
node.getComponent("SingleFriendList").setToBlackList();
|
||||||
|
this.content_blacklist.addChild(node);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setToFriend() {
|
||||||
|
this.setToNone();
|
||||||
|
this.nd_friend.active = true;
|
||||||
|
this.testinitOne(0);
|
||||||
|
},
|
||||||
|
|
||||||
|
setToApply() {
|
||||||
|
this.setToNone();
|
||||||
|
this.nd_apply.active = true;
|
||||||
|
this.testinitOne(1);
|
||||||
|
},
|
||||||
|
|
||||||
|
setToBlackList() {
|
||||||
|
this.setToNone();
|
||||||
|
this.nd_blacklist.active = true;
|
||||||
|
this.testinitOne(2);
|
||||||
|
},
|
||||||
|
|
||||||
|
onClose() {
|
||||||
|
this.node.destroy();
|
||||||
|
},
|
||||||
|
|
||||||
|
onSearch() {
|
||||||
|
console.log(`search:${this.edit_find.string}`);
|
||||||
|
},
|
||||||
|
|
||||||
|
onClickToggle(event, data) {
|
||||||
|
switch (data) {
|
||||||
|
case "0":
|
||||||
|
this.setToFriend();
|
||||||
|
break;
|
||||||
|
case "1":
|
||||||
|
this.setToApply();
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
this.setToBlackList();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getFriendList(msg) {
|
||||||
|
this.friend_list = [];
|
||||||
|
for (var m = 0; m < msg.friend_list.length; m++) {
|
||||||
|
this.friend_list.push(msg.friend_list[m]);
|
||||||
|
}
|
||||||
|
for (var i = this.friend_list.length - 1; i >= 0; i--) {
|
||||||
|
if (
|
||||||
|
this.friend_list[i].base_data["account_id"] ==
|
||||||
|
SDKManage.account_id
|
||||||
|
) {
|
||||||
|
this.friend_list.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(this.friend_list);
|
||||||
|
},
|
||||||
|
});
|
9
assets/scripts/UI/UIFriend/UIFriendNew.js.meta
Normal file
9
assets/scripts/UI/UIFriend/UIFriendNew.js.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.5",
|
||||||
|
"uuid": "37ef4feb-9e80-4537-bda1-a246edae68d9",
|
||||||
|
"isPlugin": false,
|
||||||
|
"loadPluginInWeb": true,
|
||||||
|
"loadPluginInNative": true,
|
||||||
|
"loadPluginInEditor": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
@ -1,368 +1,368 @@
|
|||||||
var jcfw = require('jcfw');
|
var jcfw = require("jcfw");
|
||||||
var Main = require('Main');
|
var Main = require("Main");
|
||||||
var Utils = require('Utils');
|
var Utils = require("Utils");
|
||||||
//var playerData = require("playerData")
|
//var playerData = require("playerData")
|
||||||
var jcgamelog = jcfw.gamelog;
|
var jcgamelog = jcfw.gamelog;
|
||||||
var jcshare = jcfw.share;
|
var jcshare = jcfw.share;
|
||||||
var NetManage = require('NetManage');
|
var NetManage = require("NetManage");
|
||||||
var urlbuilder = require('urlbuilder');
|
var urlbuilder = require("urlbuilder");
|
||||||
var httpclient = require('httpclient');
|
var httpclient = require("httpclient");
|
||||||
var wxVoice = require('wxVoice');
|
var wxVoice = require("wxVoice");
|
||||||
cc.interstitialAdTime = 0;
|
cc.interstitialAdTime = 0;
|
||||||
cc.notreward = 0;
|
cc.notreward = 0;
|
||||||
var toCodePoint = function (unicodeSurrogates) {
|
var toCodePoint = function (unicodeSurrogates) {
|
||||||
var r = [],
|
var r = [],
|
||||||
c = 0,
|
c = 0,
|
||||||
p = 0,
|
p = 0,
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < unicodeSurrogates.length) {
|
while (i < unicodeSurrogates.length) {
|
||||||
var pos = i;
|
var pos = i;
|
||||||
c = unicodeSurrogates.charCodeAt(i++); //返回位置的字符的 Unicode 编码
|
c = unicodeSurrogates.charCodeAt(i++); //返回位置的字符的 Unicode 编码
|
||||||
if (c == 0xfe0f) {
|
if (c == 0xfe0f) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (p) {
|
if (p) {
|
||||||
var value = 0x10000 + ((p - 0xd800) << 10) + (c - 0xdc00);
|
var value = 0x10000 + ((p - 0xd800) << 10) + (c - 0xdc00);
|
||||||
r.push({
|
r.push({
|
||||||
v: value,
|
v: value,
|
||||||
pos: pos,
|
pos: pos,
|
||||||
}); //计算4字节的unicode
|
}); //计算4字节的unicode
|
||||||
p = 0;
|
p = 0;
|
||||||
} else if (0xd800 <= c && c <= 0xdbff) {
|
} else if (0xd800 <= c && c <= 0xdbff) {
|
||||||
p = c; //如果unicode编码在oxD800-0xDBff之间,则需要与后一个字符放在一起
|
p = c; //如果unicode编码在oxD800-0xDBff之间,则需要与后一个字符放在一起
|
||||||
} else {
|
} else {
|
||||||
r.push({
|
r.push({
|
||||||
v: c,
|
v: c,
|
||||||
pos: pos,
|
pos: pos,
|
||||||
}); //如果是2字节,直接将码点转为对应的十六进制形式
|
}); //如果是2字节,直接将码点转为对应的十六进制形式
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
var SDKManage = function () {
|
var SDKManage = function () {
|
||||||
this.isoffical = Main.config.mainConfig.isoffical;
|
this.isoffical = Main.config.mainConfig.isoffical;
|
||||||
this.checking = false;
|
this.checking = false;
|
||||||
this.gameId = 2006;
|
this.gameId = 2006;
|
||||||
this.nickName = 'test';
|
this.nickName = "test";
|
||||||
this.avatarUrl = '';
|
this.avatarUrl = "";
|
||||||
this.NodeId = 1;
|
this.NodeId = 1;
|
||||||
this.session_id = '';
|
this.session_id = "";
|
||||||
|
|
||||||
this.m_hiID = 18001;
|
this.m_hiID = 18001;
|
||||||
this.account_id = 0; //玩家账号ID
|
this.account_id = 0; //玩家账号ID
|
||||||
|
|
||||||
// playerData.SDKManage = this
|
// playerData.SDKManage = this
|
||||||
this.getplayerdata = function () {
|
this.getplayerdata = function () {
|
||||||
if (!this.playerData) {
|
if (!this.playerData) {
|
||||||
this.playerData = require('playerData');
|
this.playerData = require("playerData");
|
||||||
}
|
}
|
||||||
return this.playerData;
|
return this.playerData;
|
||||||
};
|
};
|
||||||
this.sixstr = function (str, maxChars, suffix) {
|
this.sixstr = function (str, maxChars, suffix) {
|
||||||
if (str == '' || str == null) {
|
if (str == "" || str == null) {
|
||||||
return ' ';
|
return " ";
|
||||||
}
|
}
|
||||||
maxChars = maxChars == null ? 6 : maxChars;
|
maxChars = maxChars == null ? 6 : maxChars;
|
||||||
suffix = suffix == null ? '...' : suffix;
|
suffix = suffix == null ? "..." : suffix;
|
||||||
maxChars *= 2;
|
maxChars *= 2;
|
||||||
|
|
||||||
var codeArr = toCodePoint(str);
|
var codeArr = toCodePoint(str);
|
||||||
var numChar = 0;
|
var numChar = 0;
|
||||||
var index = 0;
|
var index = 0;
|
||||||
for (var i = 0; i < codeArr.length; ++i) {
|
for (var i = 0; i < codeArr.length; ++i) {
|
||||||
var code = codeArr[i].v;
|
var code = codeArr[i].v;
|
||||||
var add = 1;
|
var add = 1;
|
||||||
if (code >= 128) {
|
if (code >= 128) {
|
||||||
add = 2;
|
add = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果超过了限制,则按上一个为准
|
//如果超过了限制,则按上一个为准
|
||||||
if (numChar + add > maxChars) {
|
if (numChar + add > maxChars) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
index = i;
|
index = i;
|
||||||
|
|
||||||
//累加
|
//累加
|
||||||
numChar += add;
|
numChar += add;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codeArr.length - 1 == index) {
|
if (codeArr.length - 1 == index) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
var more = suffix ? 1 : 0;
|
var more = suffix ? 1 : 0;
|
||||||
|
|
||||||
return str.substring(0, codeArr[index - more].pos + 1) + suffix;
|
return str.substring(0, codeArr[index - more].pos + 1) + suffix;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 6513 游客 6516 钱包
|
// 6513 游客 6516 钱包
|
||||||
this.init = function (channelid = 6513) {
|
this.init = function (channelid = 6513) {
|
||||||
// this.nickName = this.sixstr(this.nickName)
|
// this.nickName = this.sixstr(this.nickName)
|
||||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||||
this.ChannelId = 6001;
|
this.ChannelId = 6001;
|
||||||
} else if (cc.sys.platform == cc.sys.QQ_PLAY) {
|
} else if (cc.sys.platform == cc.sys.QQ_PLAY) {
|
||||||
this.ChannelId = 6002;
|
this.ChannelId = 6002;
|
||||||
} else if (window.qg == cc.sys.QQ_PLAY) {
|
} else if (window.qg == cc.sys.QQ_PLAY) {
|
||||||
this.ChannelId = 6003;
|
this.ChannelId = 6003;
|
||||||
} else {
|
} else {
|
||||||
this.ChannelId = channelid; //for test
|
this.ChannelId = channelid; //for test
|
||||||
}
|
}
|
||||||
// this.getRecommendGames()
|
// this.getRecommendGames()
|
||||||
cc.SDKManage = this;
|
cc.SDKManage = this;
|
||||||
jcfw.init(this.ChannelId, this.gameId, this.isoffical);
|
jcfw.init(this.ChannelId, this.gameId, this.isoffical);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.compareVersion = function (v1, v2) {
|
this.compareVersion = function (v1, v2) {
|
||||||
v1 = v1.split('.');
|
v1 = v1.split(".");
|
||||||
v2 = v2.split('.');
|
v2 = v2.split(".");
|
||||||
const len = Math.max(v1.length, v2.length);
|
const len = Math.max(v1.length, v2.length);
|
||||||
|
|
||||||
while (v1.length < len) {
|
while (v1.length < len) {
|
||||||
v1.push('0');
|
v1.push("0");
|
||||||
}
|
}
|
||||||
while (v2.length < len) {
|
while (v2.length < len) {
|
||||||
v2.push('0');
|
v2.push("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
const num1 = parseInt(v1[i]);
|
const num1 = parseInt(v1[i]);
|
||||||
const num2 = parseInt(v2[i]);
|
const num2 = parseInt(v2[i]);
|
||||||
|
|
||||||
if (num1 > num2) {
|
if (num1 > num2) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (num1 < num2) {
|
} else if (num1 < num2) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.doLogin = function (res) {
|
this.doLogin = function (res) {
|
||||||
if (this.loginStep < this.logincbarr.length) {
|
if (this.loginStep < this.logincbarr.length) {
|
||||||
this.logincbarr[this.loginStep](res);
|
this.logincbarr[this.loginStep](res);
|
||||||
this.loginStep++;
|
this.loginStep++;
|
||||||
} else {
|
} else {
|
||||||
this.logEvent('loginend', '登录完成');
|
this.logEvent("loginend", "登录完成");
|
||||||
var lgtime = Number(new Date().getTime() - this.gameloginstartime);
|
var lgtime = Number(new Date().getTime() - this.gameloginstartime);
|
||||||
|
|
||||||
jcgamelog.logEnterMainScene(lgtime);
|
jcgamelog.logEnterMainScene(lgtime);
|
||||||
this.loginOver();
|
this.loginOver();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.gamelogin = function () {
|
this.gamelogin = function () {
|
||||||
// this.time1 = new Date().getTime()
|
// this.time1 = new Date().getTime()
|
||||||
|
|
||||||
var token = cc.sys.localStorage.getItem('token');
|
var token = cc.sys.localStorage.getItem("token");
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (!token || token == '') {
|
if (!token || token == "") {
|
||||||
token = jcfw.makeUUID();
|
token = jcfw.makeUUID();
|
||||||
try {
|
try {
|
||||||
cc.sys.localStorage.setItem('token', token);
|
cc.sys.localStorage.setItem("token", token);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
jcfw.loginUser(
|
jcfw.loginUser(
|
||||||
(res) => {
|
(res) => {
|
||||||
cc.channelid = res.channel;
|
cc.channelid = res.channel;
|
||||||
self.hasLogin = true;
|
self.hasLogin = true;
|
||||||
self.logEvent('gamelogin', '游戏登录成功');
|
self.logEvent("gamelogin", "游戏登录成功");
|
||||||
|
|
||||||
self.account_id = res.account_id;
|
self.account_id = res.account_id;
|
||||||
self.session_id = res.session_id;
|
self.session_id = res.session_id;
|
||||||
self.openid = res.openid;
|
self.openid = res.openid;
|
||||||
|
|
||||||
localStorage.setItem('loginaccount', res.account_id);
|
localStorage.setItem("loginaccount", res.account_id);
|
||||||
localStorage.setItem('loginsession', res.session_id);
|
localStorage.setItem("loginsession", res.session_id);
|
||||||
|
|
||||||
self.doLogin();
|
self.doLogin();
|
||||||
},
|
},
|
||||||
(neterr, logicerr, errmsg) => {
|
(neterr, logicerr, errmsg) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
self.gamelogin();
|
self.gamelogin();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
this.Login = function (cb) {
|
this.Login = function (cb) {
|
||||||
this.loginStep = 0;
|
this.loginStep = 0;
|
||||||
if (cb) {
|
if (cb) {
|
||||||
this.loginOver = cb;
|
this.loginOver = cb;
|
||||||
}
|
}
|
||||||
this.logincbarr = [];
|
this.logincbarr = [];
|
||||||
this.gameloginstartime = new Date().getTime();
|
this.gameloginstartime = new Date().getTime();
|
||||||
|
|
||||||
this.logincbarr = [
|
this.logincbarr = [
|
||||||
this.gamelogin.bind(this),
|
this.gamelogin.bind(this),
|
||||||
this.initNetManage.bind(this),
|
this.initNetManage.bind(this),
|
||||||
this.getUserInfo.bind(this),
|
this.getUserInfo.bind(this),
|
||||||
this.getothers.bind(this),
|
this.getothers.bind(this),
|
||||||
];
|
];
|
||||||
this.doLogin();
|
this.doLogin();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getothers = function () {
|
this.getothers = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.allcount = 3;
|
this.allcount = 3;
|
||||||
var cb = function () {
|
var cb = function () {
|
||||||
self.allcount--;
|
self.allcount--;
|
||||||
if (self.allcount <= 0) {
|
if (self.allcount <= 0) {
|
||||||
self.gamelogin();
|
self.gamelogin();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
NetManage.getHeroList(cb);
|
NetManage.getHeroList(cb);
|
||||||
NetManage.getSkinList(cb);
|
NetManage.getSkinList(cb);
|
||||||
NetManage.getItemList(cb);
|
NetManage.getItemList(cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.initFriendInfo = function () {
|
this.initFriendInfo = function () {
|
||||||
var opt = {
|
var opt = {
|
||||||
account_id: this.account_id,
|
account_id: this.account_id,
|
||||||
session_id: this.session_id,
|
session_id: this.session_id,
|
||||||
nickname: cc.playerData.name,
|
nickname: cc.playerData.name,
|
||||||
avatar_url: cc.playerData.head_id,
|
avatar_url: cc.playerData.head_id,
|
||||||
sex: 0,
|
sex: 0,
|
||||||
// "proto_version":this.friend_pversion,
|
// "proto_version":this.friend_pversion,
|
||||||
server_id: 1,
|
server_id: 1,
|
||||||
vip_lv: 0, //性别
|
vip_lv: 0, //性别
|
||||||
head: Number(cc.playerData.head_frame), //头像框
|
head: Number(cc.playerData.head_frame), //头像框
|
||||||
};
|
};
|
||||||
cc.chatMgr.initengine(cc.SDKManage.isoffical, opt);
|
cc.chatMgr.initengine(cc.SDKManage.isoffical, opt);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getUserInfo = function () {
|
this.getUserInfo = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var cb = function (obj) {
|
var cb = function (obj) {
|
||||||
cc.playerData.refreshInfo(obj.info);
|
cc.playerData.refreshInfo(obj.info);
|
||||||
self.logEvent('getUserInfo', '获取用户信息成功');
|
self.logEvent("getUserInfo", "获取用户信息成功");
|
||||||
self.initFriendInfo();
|
self.initFriendInfo();
|
||||||
self.doLogin();
|
self.doLogin();
|
||||||
console.log('改名次数:' + obj.info.rename_count);
|
console.log("改名次数:" + obj.info.rename_count);
|
||||||
if (obj.info.rename_count == 0) {
|
if (obj.info.rename_count == 0) {
|
||||||
window.canrename = true;
|
window.canrename = true;
|
||||||
} else {
|
} else {
|
||||||
window.canrename = false;
|
window.canrename = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
NetManage.logingame(cb);
|
NetManage.logingame(cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.initNetManage = function () {
|
this.initNetManage = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
NetManage.init(
|
NetManage.init(
|
||||||
self.account_id,
|
self.account_id,
|
||||||
self.session_id,
|
self.session_id,
|
||||||
self.nickName,
|
self.nickName,
|
||||||
self.avatarUrl
|
self.avatarUrl
|
||||||
);
|
);
|
||||||
NetManage.getNodeID(() => {});
|
NetManage.getNodeID(() => {});
|
||||||
// NetManage.getTime(() => {})
|
// NetManage.getTime(() => {})
|
||||||
|
|
||||||
console.log('start init 6516');
|
console.log("start init 6516");
|
||||||
self.logEvent('initNetManage', '初始化人物信息');
|
self.logEvent("initNetManage", "初始化人物信息");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
self.doLogin();
|
self.doLogin();
|
||||||
}, 10);
|
}, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getGameConfig = function () {
|
this.getGameConfig = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var cb = function (res2) {
|
var cb = function (res2) {
|
||||||
self.logEvent('getGameConfig', '获取配置信息成功');
|
self.logEvent("getGameConfig", "获取配置信息成功");
|
||||||
var res = {};
|
var res = {};
|
||||||
for (var i = 0; i < res2.length; i++) {
|
for (var i = 0; i < res2.length; i++) {
|
||||||
res[res2[i].key] = res2[i].value;
|
res[res2[i].key] = res2[i].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
self.doLogin();
|
self.doLogin();
|
||||||
}, 10);
|
}, 10);
|
||||||
};
|
};
|
||||||
var cbf = function (res) {
|
var cbf = function (res) {
|
||||||
self.getGameConfig();
|
self.getGameConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
//cb(this.config)
|
//cb(this.config)
|
||||||
|
|
||||||
jcfw.cloud.getConfig('', cb, cbf);
|
jcfw.cloud.getConfig("", cb, cbf);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.checkRate = function (nubmer) {
|
this.checkRate = function (nubmer) {
|
||||||
//判断正整数/[1−9]+[0−9]∗]∗/
|
//判断正整数/[1−9]+[0−9]∗]∗/
|
||||||
var re = /^[0-9]+.?[0-9]*/; //
|
var re = /^[0-9]+.?[0-9]*/; //
|
||||||
if (!re.test(nubmer)) {
|
if (!re.test(nubmer)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
this.logEvent = function (k, v) {
|
this.logEvent = function (k, v) {
|
||||||
jcgamelog.logButtonClick(k, v);
|
jcgamelog.logButtonClick(k, v);
|
||||||
|
|
||||||
if (CC_JSB) {
|
if (CC_JSB) {
|
||||||
if (!v) {
|
if (!v) {
|
||||||
v = '';
|
v = "";
|
||||||
}
|
}
|
||||||
if (cc.sys.os == cc.sys.OS_ANDROID) {
|
if (cc.sys.os == cc.sys.OS_ANDROID) {
|
||||||
//反射调用原生的隐藏方法
|
//反射调用原生的隐藏方法
|
||||||
jsb.reflection.callStaticMethod(
|
jsb.reflection.callStaticMethod(
|
||||||
'org/cocos2dx/javascript/AppActivity',
|
"org/cocos2dx/javascript/AppActivity",
|
||||||
'logEvent',
|
"logEvent",
|
||||||
'(Ljava/lang/String;Ljava/lang/String;)V',
|
"(Ljava/lang/String;Ljava/lang/String;)V",
|
||||||
k + '',
|
k + "",
|
||||||
v
|
v
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getBattleCounts = function () {
|
this.getBattleCounts = function () {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var scount = cc.sys.localStorage.getItem('battleCount');
|
var scount = cc.sys.localStorage.getItem("battleCount");
|
||||||
var today = new Date();
|
var today = new Date();
|
||||||
var datakey = today.getMonth() + '-' + today.getDate();
|
var datakey = today.getMonth() + "-" + today.getDate();
|
||||||
var savedata = cc.sys.localStorage.getItem('datakey');
|
var savedata = cc.sys.localStorage.getItem("datakey");
|
||||||
if (savedata != datakey) {
|
if (savedata != datakey) {
|
||||||
try {
|
try {
|
||||||
cc.sys.localStorage.setItem('datakey', datakey);
|
cc.sys.localStorage.setItem("datakey", datakey);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
try {
|
try {
|
||||||
cc.sys.localStorage.setItem('battleCount', 0);
|
cc.sys.localStorage.setItem("battleCount", 0);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
scount = null;
|
scount = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scount != null && scount != '') {
|
if (scount != null && scount != "") {
|
||||||
count = parseInt(scount);
|
count = parseInt(scount);
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
};
|
};
|
||||||
this.saveBattleCount = function () {
|
this.saveBattleCount = function () {
|
||||||
var count = this.getBattleCounts() + 1;
|
var count = this.getBattleCounts() + 1;
|
||||||
try {
|
try {
|
||||||
cc.sys.localStorage.setItem('battleCount', count);
|
cc.sys.localStorage.setItem("battleCount", count);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.dirtyWordCheck = function (
|
this.dirtyWordCheck = function (
|
||||||
_str //检查敏感词汇
|
_str //检查敏感词汇
|
||||||
) {
|
) {
|
||||||
NetManage.dirtyWordCheck(_str);
|
NetManage.dirtyWordCheck(_str);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.initGameRes = function () //初始化进入游戏前数据
|
this.initGameRes = function () //初始化进入游戏前数据
|
||||||
{
|
{
|
||||||
wxVoice.playbgm('bgm');
|
wxVoice.playbgm("bgm");
|
||||||
cc.battleCache.loadwave();
|
cc.battleCache.loadwave();
|
||||||
cc.highmode = true;
|
cc.highmode = true;
|
||||||
//SDKManage.nickName = "战斗测试"
|
//SDKManage.nickName = "战斗测试"
|
||||||
cc.game.setFrameRate(60);
|
cc.game.setFrameRate(60);
|
||||||
cc.macro.CLEANUP_IMAGE_CACHE = false;
|
cc.macro.CLEANUP_IMAGE_CACHE = false;
|
||||||
cc.dynamicAtlasManager.enabled = true;
|
cc.dynamicAtlasManager.enabled = true;
|
||||||
cc.mygamedelta = 0.0167;
|
cc.mygamedelta = 0.0167;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var instance = new SDKManage();
|
var instance = new SDKManage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user