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": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0.416015625,
|
||||
"y": 0.416015625,
|
||||
"x": 0.5703125,
|
||||
"y": 0.5703125,
|
||||
"z": 1
|
||||
},
|
||||
"_quat": {
|
||||
@ -12654,7 +12654,7 @@
|
||||
"__id__": 377
|
||||
}
|
||||
],
|
||||
"_active": false,
|
||||
"_active": true,
|
||||
"_level": 2,
|
||||
"_components": [
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31981,7 +31981,7 @@
|
||||
"__id__": 662
|
||||
},
|
||||
"pb_friend": {
|
||||
"__uuid__": "f5fe16a6-cbf6-489f-8f1d-dac0d59cba8c"
|
||||
"__uuid__": "1c680882-520e-49af-b19e-b28ac201d38e"
|
||||
},
|
||||
"_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": {}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,368 +1,368 @@
|
||||
var jcfw = require('jcfw');
|
||||
var Main = require('Main');
|
||||
var Utils = require('Utils');
|
||||
var jcfw = require("jcfw");
|
||||
var Main = require("Main");
|
||||
var Utils = require("Utils");
|
||||
//var playerData = require("playerData")
|
||||
var jcgamelog = jcfw.gamelog;
|
||||
var jcshare = jcfw.share;
|
||||
var NetManage = require('NetManage');
|
||||
var urlbuilder = require('urlbuilder');
|
||||
var httpclient = require('httpclient');
|
||||
var wxVoice = require('wxVoice');
|
||||
var NetManage = require("NetManage");
|
||||
var urlbuilder = require("urlbuilder");
|
||||
var httpclient = require("httpclient");
|
||||
var wxVoice = require("wxVoice");
|
||||
cc.interstitialAdTime = 0;
|
||||
cc.notreward = 0;
|
||||
var toCodePoint = function (unicodeSurrogates) {
|
||||
var r = [],
|
||||
c = 0,
|
||||
p = 0,
|
||||
i = 0;
|
||||
while (i < unicodeSurrogates.length) {
|
||||
var pos = i;
|
||||
c = unicodeSurrogates.charCodeAt(i++); //返回位置的字符的 Unicode 编码
|
||||
if (c == 0xfe0f) {
|
||||
continue;
|
||||
}
|
||||
if (p) {
|
||||
var value = 0x10000 + ((p - 0xd800) << 10) + (c - 0xdc00);
|
||||
r.push({
|
||||
v: value,
|
||||
pos: pos,
|
||||
}); //计算4字节的unicode
|
||||
p = 0;
|
||||
} else if (0xd800 <= c && c <= 0xdbff) {
|
||||
p = c; //如果unicode编码在oxD800-0xDBff之间,则需要与后一个字符放在一起
|
||||
} else {
|
||||
r.push({
|
||||
v: c,
|
||||
pos: pos,
|
||||
}); //如果是2字节,直接将码点转为对应的十六进制形式
|
||||
}
|
||||
}
|
||||
return r;
|
||||
var r = [],
|
||||
c = 0,
|
||||
p = 0,
|
||||
i = 0;
|
||||
while (i < unicodeSurrogates.length) {
|
||||
var pos = i;
|
||||
c = unicodeSurrogates.charCodeAt(i++); //返回位置的字符的 Unicode 编码
|
||||
if (c == 0xfe0f) {
|
||||
continue;
|
||||
}
|
||||
if (p) {
|
||||
var value = 0x10000 + ((p - 0xd800) << 10) + (c - 0xdc00);
|
||||
r.push({
|
||||
v: value,
|
||||
pos: pos,
|
||||
}); //计算4字节的unicode
|
||||
p = 0;
|
||||
} else if (0xd800 <= c && c <= 0xdbff) {
|
||||
p = c; //如果unicode编码在oxD800-0xDBff之间,则需要与后一个字符放在一起
|
||||
} else {
|
||||
r.push({
|
||||
v: c,
|
||||
pos: pos,
|
||||
}); //如果是2字节,直接将码点转为对应的十六进制形式
|
||||
}
|
||||
}
|
||||
return r;
|
||||
};
|
||||
var SDKManage = function () {
|
||||
this.isoffical = Main.config.mainConfig.isoffical;
|
||||
this.checking = false;
|
||||
this.gameId = 2006;
|
||||
this.nickName = 'test';
|
||||
this.avatarUrl = '';
|
||||
this.NodeId = 1;
|
||||
this.session_id = '';
|
||||
this.isoffical = Main.config.mainConfig.isoffical;
|
||||
this.checking = false;
|
||||
this.gameId = 2006;
|
||||
this.nickName = "test";
|
||||
this.avatarUrl = "";
|
||||
this.NodeId = 1;
|
||||
this.session_id = "";
|
||||
|
||||
this.m_hiID = 18001;
|
||||
this.account_id = 0; //玩家账号ID
|
||||
this.m_hiID = 18001;
|
||||
this.account_id = 0; //玩家账号ID
|
||||
|
||||
// playerData.SDKManage = this
|
||||
this.getplayerdata = function () {
|
||||
if (!this.playerData) {
|
||||
this.playerData = require('playerData');
|
||||
}
|
||||
return this.playerData;
|
||||
};
|
||||
this.sixstr = function (str, maxChars, suffix) {
|
||||
if (str == '' || str == null) {
|
||||
return ' ';
|
||||
}
|
||||
maxChars = maxChars == null ? 6 : maxChars;
|
||||
suffix = suffix == null ? '...' : suffix;
|
||||
maxChars *= 2;
|
||||
// playerData.SDKManage = this
|
||||
this.getplayerdata = function () {
|
||||
if (!this.playerData) {
|
||||
this.playerData = require("playerData");
|
||||
}
|
||||
return this.playerData;
|
||||
};
|
||||
this.sixstr = function (str, maxChars, suffix) {
|
||||
if (str == "" || str == null) {
|
||||
return " ";
|
||||
}
|
||||
maxChars = maxChars == null ? 6 : maxChars;
|
||||
suffix = suffix == null ? "..." : suffix;
|
||||
maxChars *= 2;
|
||||
|
||||
var codeArr = toCodePoint(str);
|
||||
var numChar = 0;
|
||||
var index = 0;
|
||||
for (var i = 0; i < codeArr.length; ++i) {
|
||||
var code = codeArr[i].v;
|
||||
var add = 1;
|
||||
if (code >= 128) {
|
||||
add = 2;
|
||||
}
|
||||
var codeArr = toCodePoint(str);
|
||||
var numChar = 0;
|
||||
var index = 0;
|
||||
for (var i = 0; i < codeArr.length; ++i) {
|
||||
var code = codeArr[i].v;
|
||||
var add = 1;
|
||||
if (code >= 128) {
|
||||
add = 2;
|
||||
}
|
||||
|
||||
//如果超过了限制,则按上一个为准
|
||||
if (numChar + add > maxChars) {
|
||||
break;
|
||||
}
|
||||
//如果超过了限制,则按上一个为准
|
||||
if (numChar + add > maxChars) {
|
||||
break;
|
||||
}
|
||||
|
||||
index = i;
|
||||
index = i;
|
||||
|
||||
//累加
|
||||
numChar += add;
|
||||
}
|
||||
//累加
|
||||
numChar += add;
|
||||
}
|
||||
|
||||
if (codeArr.length - 1 == index) {
|
||||
return str;
|
||||
}
|
||||
if (codeArr.length - 1 == index) {
|
||||
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 钱包
|
||||
this.init = function (channelid = 6513) {
|
||||
// this.nickName = this.sixstr(this.nickName)
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
this.ChannelId = 6001;
|
||||
} else if (cc.sys.platform == cc.sys.QQ_PLAY) {
|
||||
this.ChannelId = 6002;
|
||||
} else if (window.qg == cc.sys.QQ_PLAY) {
|
||||
this.ChannelId = 6003;
|
||||
} else {
|
||||
this.ChannelId = channelid; //for test
|
||||
}
|
||||
// this.getRecommendGames()
|
||||
cc.SDKManage = this;
|
||||
jcfw.init(this.ChannelId, this.gameId, this.isoffical);
|
||||
};
|
||||
// 6513 游客 6516 钱包
|
||||
this.init = function (channelid = 6513) {
|
||||
// this.nickName = this.sixstr(this.nickName)
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
this.ChannelId = 6001;
|
||||
} else if (cc.sys.platform == cc.sys.QQ_PLAY) {
|
||||
this.ChannelId = 6002;
|
||||
} else if (window.qg == cc.sys.QQ_PLAY) {
|
||||
this.ChannelId = 6003;
|
||||
} else {
|
||||
this.ChannelId = channelid; //for test
|
||||
}
|
||||
// this.getRecommendGames()
|
||||
cc.SDKManage = this;
|
||||
jcfw.init(this.ChannelId, this.gameId, this.isoffical);
|
||||
};
|
||||
|
||||
this.compareVersion = function (v1, v2) {
|
||||
v1 = v1.split('.');
|
||||
v2 = v2.split('.');
|
||||
const len = Math.max(v1.length, v2.length);
|
||||
this.compareVersion = function (v1, v2) {
|
||||
v1 = v1.split(".");
|
||||
v2 = v2.split(".");
|
||||
const len = Math.max(v1.length, v2.length);
|
||||
|
||||
while (v1.length < len) {
|
||||
v1.push('0');
|
||||
}
|
||||
while (v2.length < len) {
|
||||
v2.push('0');
|
||||
}
|
||||
while (v1.length < len) {
|
||||
v1.push("0");
|
||||
}
|
||||
while (v2.length < len) {
|
||||
v2.push("0");
|
||||
}
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
const num1 = parseInt(v1[i]);
|
||||
const num2 = parseInt(v2[i]);
|
||||
for (let i = 0; i < len; i++) {
|
||||
const num1 = parseInt(v1[i]);
|
||||
const num2 = parseInt(v2[i]);
|
||||
|
||||
if (num1 > num2) {
|
||||
return 1;
|
||||
} else if (num1 < num2) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (num1 > num2) {
|
||||
return 1;
|
||||
} else if (num1 < num2) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
return 0;
|
||||
};
|
||||
|
||||
this.doLogin = function (res) {
|
||||
if (this.loginStep < this.logincbarr.length) {
|
||||
this.logincbarr[this.loginStep](res);
|
||||
this.loginStep++;
|
||||
} else {
|
||||
this.logEvent('loginend', '登录完成');
|
||||
var lgtime = Number(new Date().getTime() - this.gameloginstartime);
|
||||
this.doLogin = function (res) {
|
||||
if (this.loginStep < this.logincbarr.length) {
|
||||
this.logincbarr[this.loginStep](res);
|
||||
this.loginStep++;
|
||||
} else {
|
||||
this.logEvent("loginend", "登录完成");
|
||||
var lgtime = Number(new Date().getTime() - this.gameloginstartime);
|
||||
|
||||
jcgamelog.logEnterMainScene(lgtime);
|
||||
this.loginOver();
|
||||
}
|
||||
};
|
||||
jcgamelog.logEnterMainScene(lgtime);
|
||||
this.loginOver();
|
||||
}
|
||||
};
|
||||
|
||||
this.gamelogin = function () {
|
||||
// this.time1 = new Date().getTime()
|
||||
this.gamelogin = function () {
|
||||
// this.time1 = new Date().getTime()
|
||||
|
||||
var token = cc.sys.localStorage.getItem('token');
|
||||
var self = this;
|
||||
var token = cc.sys.localStorage.getItem("token");
|
||||
var self = this;
|
||||
|
||||
if (!token || token == '') {
|
||||
token = jcfw.makeUUID();
|
||||
try {
|
||||
cc.sys.localStorage.setItem('token', token);
|
||||
} catch (e) {}
|
||||
}
|
||||
if (!token || token == "") {
|
||||
token = jcfw.makeUUID();
|
||||
try {
|
||||
cc.sys.localStorage.setItem("token", token);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
jcfw.loginUser(
|
||||
(res) => {
|
||||
cc.channelid = res.channel;
|
||||
self.hasLogin = true;
|
||||
self.logEvent('gamelogin', '游戏登录成功');
|
||||
jcfw.loginUser(
|
||||
(res) => {
|
||||
cc.channelid = res.channel;
|
||||
self.hasLogin = true;
|
||||
self.logEvent("gamelogin", "游戏登录成功");
|
||||
|
||||
self.account_id = res.account_id;
|
||||
self.session_id = res.session_id;
|
||||
self.openid = res.openid;
|
||||
self.account_id = res.account_id;
|
||||
self.session_id = res.session_id;
|
||||
self.openid = res.openid;
|
||||
|
||||
localStorage.setItem('loginaccount', res.account_id);
|
||||
localStorage.setItem('loginsession', res.session_id);
|
||||
localStorage.setItem("loginaccount", res.account_id);
|
||||
localStorage.setItem("loginsession", res.session_id);
|
||||
|
||||
self.doLogin();
|
||||
},
|
||||
(neterr, logicerr, errmsg) => {
|
||||
setTimeout(() => {
|
||||
self.gamelogin();
|
||||
}, 1000);
|
||||
}
|
||||
);
|
||||
};
|
||||
this.Login = function (cb) {
|
||||
this.loginStep = 0;
|
||||
if (cb) {
|
||||
this.loginOver = cb;
|
||||
}
|
||||
this.logincbarr = [];
|
||||
this.gameloginstartime = new Date().getTime();
|
||||
self.doLogin();
|
||||
},
|
||||
(neterr, logicerr, errmsg) => {
|
||||
setTimeout(() => {
|
||||
self.gamelogin();
|
||||
}, 1000);
|
||||
}
|
||||
);
|
||||
};
|
||||
this.Login = function (cb) {
|
||||
this.loginStep = 0;
|
||||
if (cb) {
|
||||
this.loginOver = cb;
|
||||
}
|
||||
this.logincbarr = [];
|
||||
this.gameloginstartime = new Date().getTime();
|
||||
|
||||
this.logincbarr = [
|
||||
this.gamelogin.bind(this),
|
||||
this.initNetManage.bind(this),
|
||||
this.getUserInfo.bind(this),
|
||||
this.getothers.bind(this),
|
||||
];
|
||||
this.doLogin();
|
||||
};
|
||||
this.logincbarr = [
|
||||
this.gamelogin.bind(this),
|
||||
this.initNetManage.bind(this),
|
||||
this.getUserInfo.bind(this),
|
||||
this.getothers.bind(this),
|
||||
];
|
||||
this.doLogin();
|
||||
};
|
||||
|
||||
this.getothers = function () {
|
||||
var self = this;
|
||||
this.allcount = 3;
|
||||
var cb = function () {
|
||||
self.allcount--;
|
||||
if (self.allcount <= 0) {
|
||||
self.gamelogin();
|
||||
}
|
||||
};
|
||||
NetManage.getHeroList(cb);
|
||||
NetManage.getSkinList(cb);
|
||||
NetManage.getItemList(cb);
|
||||
};
|
||||
this.getothers = function () {
|
||||
var self = this;
|
||||
this.allcount = 3;
|
||||
var cb = function () {
|
||||
self.allcount--;
|
||||
if (self.allcount <= 0) {
|
||||
self.gamelogin();
|
||||
}
|
||||
};
|
||||
NetManage.getHeroList(cb);
|
||||
NetManage.getSkinList(cb);
|
||||
NetManage.getItemList(cb);
|
||||
};
|
||||
|
||||
this.initFriendInfo = function () {
|
||||
var opt = {
|
||||
account_id: this.account_id,
|
||||
session_id: this.session_id,
|
||||
nickname: cc.playerData.name,
|
||||
avatar_url: cc.playerData.head_id,
|
||||
sex: 0,
|
||||
// "proto_version":this.friend_pversion,
|
||||
server_id: 1,
|
||||
vip_lv: 0, //性别
|
||||
head: Number(cc.playerData.head_frame), //头像框
|
||||
};
|
||||
cc.chatMgr.initengine(cc.SDKManage.isoffical, opt);
|
||||
};
|
||||
this.initFriendInfo = function () {
|
||||
var opt = {
|
||||
account_id: this.account_id,
|
||||
session_id: this.session_id,
|
||||
nickname: cc.playerData.name,
|
||||
avatar_url: cc.playerData.head_id,
|
||||
sex: 0,
|
||||
// "proto_version":this.friend_pversion,
|
||||
server_id: 1,
|
||||
vip_lv: 0, //性别
|
||||
head: Number(cc.playerData.head_frame), //头像框
|
||||
};
|
||||
cc.chatMgr.initengine(cc.SDKManage.isoffical, opt);
|
||||
};
|
||||
|
||||
this.getUserInfo = function () {
|
||||
var self = this;
|
||||
var cb = function (obj) {
|
||||
cc.playerData.refreshInfo(obj.info);
|
||||
self.logEvent('getUserInfo', '获取用户信息成功');
|
||||
self.initFriendInfo();
|
||||
self.doLogin();
|
||||
console.log('改名次数:' + obj.info.rename_count);
|
||||
if (obj.info.rename_count == 0) {
|
||||
window.canrename = true;
|
||||
} else {
|
||||
window.canrename = false;
|
||||
}
|
||||
};
|
||||
NetManage.logingame(cb);
|
||||
};
|
||||
this.getUserInfo = function () {
|
||||
var self = this;
|
||||
var cb = function (obj) {
|
||||
cc.playerData.refreshInfo(obj.info);
|
||||
self.logEvent("getUserInfo", "获取用户信息成功");
|
||||
self.initFriendInfo();
|
||||
self.doLogin();
|
||||
console.log("改名次数:" + obj.info.rename_count);
|
||||
if (obj.info.rename_count == 0) {
|
||||
window.canrename = true;
|
||||
} else {
|
||||
window.canrename = false;
|
||||
}
|
||||
};
|
||||
NetManage.logingame(cb);
|
||||
};
|
||||
|
||||
this.initNetManage = function () {
|
||||
var self = this;
|
||||
NetManage.init(
|
||||
self.account_id,
|
||||
self.session_id,
|
||||
self.nickName,
|
||||
self.avatarUrl
|
||||
);
|
||||
NetManage.getNodeID(() => {});
|
||||
// NetManage.getTime(() => {})
|
||||
this.initNetManage = function () {
|
||||
var self = this;
|
||||
NetManage.init(
|
||||
self.account_id,
|
||||
self.session_id,
|
||||
self.nickName,
|
||||
self.avatarUrl
|
||||
);
|
||||
NetManage.getNodeID(() => {});
|
||||
// NetManage.getTime(() => {})
|
||||
|
||||
console.log('start init 6516');
|
||||
self.logEvent('initNetManage', '初始化人物信息');
|
||||
setTimeout(() => {
|
||||
self.doLogin();
|
||||
}, 10);
|
||||
};
|
||||
console.log("start init 6516");
|
||||
self.logEvent("initNetManage", "初始化人物信息");
|
||||
setTimeout(() => {
|
||||
self.doLogin();
|
||||
}, 10);
|
||||
};
|
||||
|
||||
this.getGameConfig = function () {
|
||||
var self = this;
|
||||
var cb = function (res2) {
|
||||
self.logEvent('getGameConfig', '获取配置信息成功');
|
||||
var res = {};
|
||||
for (var i = 0; i < res2.length; i++) {
|
||||
res[res2[i].key] = res2[i].value;
|
||||
}
|
||||
this.getGameConfig = function () {
|
||||
var self = this;
|
||||
var cb = function (res2) {
|
||||
self.logEvent("getGameConfig", "获取配置信息成功");
|
||||
var res = {};
|
||||
for (var i = 0; i < res2.length; i++) {
|
||||
res[res2[i].key] = res2[i].value;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
self.doLogin();
|
||||
}, 10);
|
||||
};
|
||||
var cbf = function (res) {
|
||||
self.getGameConfig();
|
||||
};
|
||||
setTimeout(() => {
|
||||
self.doLogin();
|
||||
}, 10);
|
||||
};
|
||||
var cbf = function (res) {
|
||||
self.getGameConfig();
|
||||
};
|
||||
|
||||
//cb(this.config)
|
||||
//cb(this.config)
|
||||
|
||||
jcfw.cloud.getConfig('', cb, cbf);
|
||||
};
|
||||
jcfw.cloud.getConfig("", cb, cbf);
|
||||
};
|
||||
|
||||
this.checkRate = function (nubmer) {
|
||||
//判断正整数/[1−9]+[0−9]∗]∗/
|
||||
var re = /^[0-9]+.?[0-9]*/; //
|
||||
if (!re.test(nubmer)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
this.logEvent = function (k, v) {
|
||||
jcgamelog.logButtonClick(k, v);
|
||||
this.checkRate = function (nubmer) {
|
||||
//判断正整数/[1−9]+[0−9]∗]∗/
|
||||
var re = /^[0-9]+.?[0-9]*/; //
|
||||
if (!re.test(nubmer)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
this.logEvent = function (k, v) {
|
||||
jcgamelog.logButtonClick(k, v);
|
||||
|
||||
if (CC_JSB) {
|
||||
if (!v) {
|
||||
v = '';
|
||||
}
|
||||
if (cc.sys.os == cc.sys.OS_ANDROID) {
|
||||
//反射调用原生的隐藏方法
|
||||
jsb.reflection.callStaticMethod(
|
||||
'org/cocos2dx/javascript/AppActivity',
|
||||
'logEvent',
|
||||
'(Ljava/lang/String;Ljava/lang/String;)V',
|
||||
k + '',
|
||||
v
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (CC_JSB) {
|
||||
if (!v) {
|
||||
v = "";
|
||||
}
|
||||
if (cc.sys.os == cc.sys.OS_ANDROID) {
|
||||
//反射调用原生的隐藏方法
|
||||
jsb.reflection.callStaticMethod(
|
||||
"org/cocos2dx/javascript/AppActivity",
|
||||
"logEvent",
|
||||
"(Ljava/lang/String;Ljava/lang/String;)V",
|
||||
k + "",
|
||||
v
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.getBattleCounts = function () {
|
||||
var count = 0;
|
||||
var scount = cc.sys.localStorage.getItem('battleCount');
|
||||
var today = new Date();
|
||||
var datakey = today.getMonth() + '-' + today.getDate();
|
||||
var savedata = cc.sys.localStorage.getItem('datakey');
|
||||
if (savedata != datakey) {
|
||||
try {
|
||||
cc.sys.localStorage.setItem('datakey', datakey);
|
||||
} catch (err) {}
|
||||
try {
|
||||
cc.sys.localStorage.setItem('battleCount', 0);
|
||||
} catch (err) {}
|
||||
scount = null;
|
||||
}
|
||||
this.getBattleCounts = function () {
|
||||
var count = 0;
|
||||
var scount = cc.sys.localStorage.getItem("battleCount");
|
||||
var today = new Date();
|
||||
var datakey = today.getMonth() + "-" + today.getDate();
|
||||
var savedata = cc.sys.localStorage.getItem("datakey");
|
||||
if (savedata != datakey) {
|
||||
try {
|
||||
cc.sys.localStorage.setItem("datakey", datakey);
|
||||
} catch (err) {}
|
||||
try {
|
||||
cc.sys.localStorage.setItem("battleCount", 0);
|
||||
} catch (err) {}
|
||||
scount = null;
|
||||
}
|
||||
|
||||
if (scount != null && scount != '') {
|
||||
count = parseInt(scount);
|
||||
}
|
||||
return count;
|
||||
};
|
||||
this.saveBattleCount = function () {
|
||||
var count = this.getBattleCounts() + 1;
|
||||
try {
|
||||
cc.sys.localStorage.setItem('battleCount', count);
|
||||
} catch (err) {}
|
||||
};
|
||||
if (scount != null && scount != "") {
|
||||
count = parseInt(scount);
|
||||
}
|
||||
return count;
|
||||
};
|
||||
this.saveBattleCount = function () {
|
||||
var count = this.getBattleCounts() + 1;
|
||||
try {
|
||||
cc.sys.localStorage.setItem("battleCount", count);
|
||||
} catch (err) {}
|
||||
};
|
||||
|
||||
this.dirtyWordCheck = function (
|
||||
_str //检查敏感词汇
|
||||
) {
|
||||
NetManage.dirtyWordCheck(_str);
|
||||
};
|
||||
this.dirtyWordCheck = function (
|
||||
_str //检查敏感词汇
|
||||
) {
|
||||
NetManage.dirtyWordCheck(_str);
|
||||
};
|
||||
|
||||
this.initGameRes = function () //初始化进入游戏前数据
|
||||
{
|
||||
wxVoice.playbgm('bgm');
|
||||
cc.battleCache.loadwave();
|
||||
cc.highmode = true;
|
||||
//SDKManage.nickName = "战斗测试"
|
||||
cc.game.setFrameRate(60);
|
||||
cc.macro.CLEANUP_IMAGE_CACHE = false;
|
||||
cc.dynamicAtlasManager.enabled = true;
|
||||
cc.mygamedelta = 0.0167;
|
||||
};
|
||||
this.initGameRes = function () //初始化进入游戏前数据
|
||||
{
|
||||
wxVoice.playbgm("bgm");
|
||||
cc.battleCache.loadwave();
|
||||
cc.highmode = true;
|
||||
//SDKManage.nickName = "战斗测试"
|
||||
cc.game.setFrameRate(60);
|
||||
cc.macro.CLEANUP_IMAGE_CACHE = false;
|
||||
cc.dynamicAtlasManager.enabled = true;
|
||||
cc.mygamedelta = 0.0167;
|
||||
};
|
||||
};
|
||||
|
||||
var instance = new SDKManage();
|
||||
|
Loading…
x
Reference in New Issue
Block a user