UserInformation.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. var Api = require('../net/Api');
  2. var UserInformationApi = require('../net/UserInformationApi');
  3. const PackApi = require('../net/PackApi');
  4. var { UserInformationType, UserInformationRelateOptType, GameNotificationKey, UserInteractionType, JobPageType, UserJobType} = require('../utils/GameEnum');
  5. var DWTool = require('../utils/DWTool');
  6. const AlertManager = require('../utils/AlertManager');
  7. const GameModule = require('../utils/GameModule');
  8. const tipsInfo = require('UserInformationTips');
  9. cc.Class({
  10. extends: cc.Component,
  11. properties: {
  12. titleNode: cc.Node,
  13. figureNode: cc.Node,
  14. backgroundNode: cc.Node,
  15. infoBackgroundNode: cc.Node,
  16. informationNode: cc.Node, //用户信息节点
  17. userInformationNode: cc.Node, //左边当前人物信息节点
  18. userAvatar: cc.Sprite,
  19. userNicknameLabel: cc.RichText,
  20. artistNameText: cc.RichText,
  21. bossButton: cc.Button, //显示老板按钮
  22. bossInformationNode: cc.Node,
  23. bossAvatar: cc.Sprite,
  24. bossNicknameLabel: cc.Label,
  25. bossArtistNameText: cc.RichText,
  26. timelineNode: cc.Node, //动态节点
  27. //用户角色
  28. infoRole: {
  29. default:UserInformationType.Mine,
  30. visible: false,
  31. },
  32. //关系改变弹窗:抢夺、赎身、签约
  33. changeRelationNode: cc.Node,
  34. //修改艺名节点
  35. editNameNode: cc.Node,
  36. editboxName: cc.EditBox,
  37. //提示框节点
  38. errorNode: cc.Node,
  39. _userIdArray: [cc.Integer],
  40. themeNode: cc.Node,
  41. jobNode: cc.Node,
  42. //个人属性节点
  43. propertyNode: cc.Node,
  44. //互动、亲密度相关操作
  45. interactionPrefab: cc.Prefab,
  46. //背包预制
  47. packPrefab: cc.Prefab,
  48. //插卡操作节点
  49. insertCardNode: cc.Node,
  50. },
  51. // LIFE-CYCLE CALLBACKS:
  52. onLoad() {
  53. this.bossInformationNode.on('touchend', this.showBossInfoToView, this);
  54. this.editNameNode.on('touchend', this.closeEditName, this);
  55. this.jobNode.on('touchend', this.changeJob, this);
  56. let XHeight = 1624;
  57. this.winSize = cc.view.getVisibleSize();
  58. let nodeY = this.winSize.height / 2.0;
  59. this.node.y = nodeY;
  60. this.infoTop = 135;
  61. if (this.winSize.height >= XHeight) {
  62. this.titleNode.getComponent(cc.Widget).top = 80;
  63. this.infoBackgroundNode.getComponent(cc.Widget).top = -50;
  64. this.informationNode.getComponent(cc.Widget).top = 185;
  65. this.infoTop = 185;
  66. }
  67. let timelineHeight = (this.winSize.height - this.infoTop - this.informationNode.height);
  68. this.timelineNode.height = timelineHeight;
  69. this.timelineNode.y = timelineHeight - this.winSize.height;
  70. //适配pad尺寸修改
  71. if (this.winSize.height <= 1100) {
  72. this.backgroundNode.getComponent(cc.Widget).bottom = -500;
  73. this.scrollY = 0;
  74. this.node.setContentSize(cc.size(this.winSize.width, 1334));
  75. let maxHeight = 1334 - nodeY;
  76. this.node.on(cc.Node.EventType.TOUCH_START, function (event) {
  77. this.scrollY = event.getLocation().y;
  78. }, this);
  79. this.node.on(cc.Node.EventType.TOUCH_MOVE, function (event) {
  80. let moveY = event.getLocation().y;
  81. if (moveY <= this.scrollY) {
  82. if (this.node.y <= nodeY) {
  83. this.node.y = nodeY;
  84. } else {
  85. this.node.y -= Math.min((this.scrollY - moveY), 20);
  86. }
  87. } else {
  88. if (this.node.y >= maxHeight) {
  89. this.node.y = maxHeight;
  90. } else {
  91. this.node.y += Math.min((moveY - this.scrollY), 20);
  92. }
  93. }
  94. this.scrollY = moveY;
  95. }, this);
  96. let timelineHeight = (1334 - this.infoTop - this.informationNode.height);
  97. this.timelineNode.height = timelineHeight;
  98. this.timelineNode.y = timelineHeight - 1334;
  99. }
  100. this.artistNameText.getComponent('UserInformationRichText').init(this);
  101. this.errorMng = this.errorNode.getComponent('UserInformationAlert');
  102. this.timelineMng = this.timelineNode.getComponent('UserInformationTimeline');
  103. this.relationAlertMng = this.changeRelationNode.getComponent('UserInformationAlert');
  104. this.themeMng = this.themeNode.getComponent('UserInformationTheme');
  105. this.propertyMng = this.propertyNode.getComponent('UserInformationProperty');
  106. this.insertCardMng = this.insertCardNode.getComponent('UserInsertCard');
  107. this.figureNode = this.figureNode.getComponent('UserInformationFigure');
  108. //亲密度显示操作页面
  109. this.interaction = cc.instantiate(this.interactionPrefab);
  110. this.interaction = this.interaction.getComponent('UserInteraction');
  111. //背包页面
  112. this.pack = cc.instantiate(this.packPrefab);
  113. this.pack = this.pack.getComponent('UserPack');
  114. this.setEventListener();
  115. this.trainEvent = _.debounce(() => {
  116. //0为还没选择职业将不能进行培养,跳去选择职业界面
  117. if (this.userInfo.jobId == UserJobType.None) {
  118. AlertManager.showArtistTrainNoJob(() => {
  119. this.changeJob();
  120. }, this.node.zIndex);
  121. } else {
  122. AlertManager.showTrainAlert(this.userInfo.uid, this.node.zIndex);
  123. }
  124. }, 1000, true);
  125. this.visitEvent = _.debounce( () => {
  126. GameEvent.fire(GameNotificationKey.VisitFriendHome, this.userInfo.uid);
  127. }, 1000, true);
  128. },
  129. init(game, uid) {
  130. this.node.parent = cc.find("Canvas");
  131. this.node.setContentSize(cc.view.getVisibleSize());
  132. this.node.active = true;
  133. this.node.zIndex += 1;
  134. this.loadUserInformation(uid);
  135. this.game = game;
  136. },
  137. start() {
  138. },
  139. onEnable() {
  140. },
  141. setEventListener() {
  142. GameEvent.on(GameNotificationKey.ShowInteraction, this, () => {
  143. if (this.responseData.interactionInfo) {
  144. var isCommon = (this.infoRole == UserInformationType.Boss || this.infoRole == UserInformationType.MyArtist) ? false : true;
  145. this.interaction.showIntimacyInfo(isCommon);
  146. }
  147. });
  148. GameEvent.on(GameNotificationKey.RefreshUserInformation, this, () => {
  149. this.getNetworkData(true);
  150. });
  151. GameEvent.on(GameNotificationKey.OpenPack, this, (justOpen) => {
  152. this.openPack(justOpen);
  153. });
  154. GameEvent.on(GameNotificationKey.RefreshInsertCardsInfo, this, (cardInfo,isInsert) => {
  155. this.refreshCardsInfo(cardInfo,isInsert);
  156. });
  157. GameModule.homeGuide.on('Fire_state28', this.trainAction, this);
  158. GameModule.homeGuide.on('Fire_state31', this.showInseertCard, this);
  159. GameModule.homeGuide.on('Fire_state25', this.guideShowInteraction, this);
  160. GameModule.homeGuide.on('Fire_state15', this.changeRelationAction, this);
  161. },
  162. onDisable() {
  163. this.bossInformationNode.enabled = true;
  164. this.bossInformationNode.active = false;
  165. this.bossInformationNode.x = this.winSize.width / 2.0;
  166. this.bossButton.node.x = this.winSize.width / 2.0 - 80;
  167. this.bossButton.node.active = false;
  168. this.themeMng.relationButtonNode.enabled = true;
  169. this.themeMng.successNode.active = false;
  170. this.editNameNode.active = false;
  171. this.changeRelationNode.active = false;
  172. this.errorNode.active = false;
  173. this.node.zIndex = 0;
  174. this._userIdArray = [];
  175. this.clearUserData();
  176. if (this.winSize.height <= 1100) {
  177. this.node.y = this.winSize.height / 2.0;
  178. }
  179. },
  180. loadUserInformation(uid) {
  181. if (uid) {
  182. this.uid = uid;
  183. }
  184. if (Global.user.uid == this.uid) {
  185. this.isSelf = true;
  186. } else {
  187. this.isSelf = false;
  188. }
  189. this.getNetworkData(false);
  190. },
  191. //获取个人信息
  192. getNetworkData(isRefresh) {
  193. this.isRefresh = isRefresh;
  194. UserInformationApi.getUserInformation(this.uid, (responseData) => {
  195. // console.log("responseData: " + JSON.stringify(responseData));
  196. this.loadInformation(responseData);
  197. if (isRefresh == false) {
  198. this._userIdArray.push(this.uid);
  199. }
  200. this.clearUserData();
  201. }, (error) => {
  202. console.log('userinformation error' + error);
  203. this.bossInformationNode.enabled = true;
  204. });
  205. },
  206. loadInformation(responseData) {
  207. if (responseData) {
  208. this.role = responseData.role;
  209. this.userInfo = responseData.userInfo;
  210. this.bossInfo = responseData.bossInfo;
  211. this.responseData = responseData;
  212. this.refreshThemeUI();
  213. //获取到用户信息后再获取动态、插卡信息和抢夺条件
  214. this.timelineMng.loadUserTimeline(this.uid);
  215. this.getCardsInfo();
  216. this.getRelationCondition();
  217. }
  218. },
  219. //获取插卡信息
  220. getCardsInfo() {
  221. PackApi.getUserCardsInfo(this.uid, (responseData) => {
  222. // console.log("responseData: " + JSON.stringify(responseData));
  223. this.cardsList = responseData.list;
  224. this.themeMng.configCardsData(responseData.list, this.isRefresh);
  225. }, (error) => {
  226. console.log('userinformation error' + error);
  227. this.cardsList = null;
  228. this.themeMng.equipCardNode.active = false;
  229. });
  230. },
  231. //获取抢夺条件
  232. getRelationCondition() {
  233. var opt = UserInformationRelateOptType.None;
  234. switch (this.infoRole) {
  235. case UserInformationType.Boss:
  236. opt = UserInformationRelateOptType.Redeem;
  237. break;
  238. case UserInformationType.OtherArtist:
  239. opt = UserInformationRelateOptType.Loot;
  240. break;
  241. case UserInformationType.ArtistFree:
  242. opt = UserInformationRelateOptType.Sign;
  243. break;
  244. case UserInformationType.MyArtist:
  245. opt = UserInformationRelateOptType.Fire;
  246. break;
  247. default:
  248. break;
  249. }
  250. UserInformationApi.getRelationCondition(this.uid, opt, (responseData) => {
  251. // console.log("condition: " + JSON.stringify(responseData));
  252. this.conditionData = responseData;
  253. this.themeMng.refreshRelationNode();
  254. }, (error) => {
  255. console.log('condition error' + error);
  256. this.conditionData = null;
  257. this.themeMng.relationButtonNode.active = false;
  258. });
  259. },
  260. //关闭个人信息页
  261. closeInformationAction() {
  262. if (this._userIdArray.length > 1) {
  263. let uid = this._userIdArray[this._userIdArray.length - 2];
  264. this.loadUserInformation(uid);
  265. this.removeItems(this._userIdArray, 2);
  266. } else {
  267. this.node.active = false;
  268. if (this.game != undefined) {
  269. this.game.gameFSM.historyBack();
  270. }
  271. }
  272. },
  273. removeItems(arr, item) {
  274. for (var i = 0; i < item; i++) {
  275. arr.pop();
  276. }
  277. },
  278. //清除用户数据
  279. clearUserData() {
  280. this.cardsList = [];
  281. this.conditionData = null;
  282. this.themeMng.equipCardNode.active = false;
  283. this.themeMng.relationButtonNode.active = false;
  284. },
  285. // update (dt) {},
  286. //根据不同用户状态信息显示
  287. refreshThemeUI() {
  288. if (this.userInfo) {
  289. if (this.userInfo.head) {
  290. Api.createImageFromUrl(this.userInfo.head, (spriteFrame) => {
  291. this.userAvatar.spriteFrame = spriteFrame;
  292. });
  293. }
  294. if (this.isSelf) {
  295. this.infoRole = UserInformationType.Mine;
  296. } else {
  297. switch (this.role) {
  298. case UserInformationType.Boss:
  299. this.infoRole = UserInformationType.Boss;
  300. break;
  301. case UserInformationType.MyArtist:
  302. this.infoRole = UserInformationType.MyArtist;
  303. if (this.userInfo.artistName) {
  304. this.editNameNode.string = this.userInfo.artistName;
  305. }
  306. break;
  307. case UserInformationType.ArtistFree:
  308. this.infoRole = UserInformationType.ArtistFree;
  309. break;
  310. case UserInformationType.OtherArtist:
  311. this.infoRole = UserInformationType.OtherArtist;
  312. break;
  313. default:
  314. break
  315. }
  316. }
  317. var genderIcon = 'artist_female';
  318. if (this.userInfo.gender == 1) {
  319. genderIcon = 'artist_male';
  320. }
  321. if (this.userInfo.nick) {
  322. this.userNicknameLabel.string = "<img src='"+ genderIcon +"'/> " + this.userInfo.nick;
  323. }
  324. var artistName = " 无艺名 ";
  325. if (this.userInfo.artistName) {
  326. artistName = " " + this.userInfo.artistName.slice(0,5) + " ";
  327. }
  328. var artistString = artistName;
  329. if (this.infoRole == UserInformationType.MyArtist) {
  330. let editName = " <img src='artist_name_edit' click='clickEditName'/>";
  331. artistString += editName;
  332. }
  333. this.artistNameText.string = artistString;
  334. this.propertyMng.setUserData(this.userInfo, this.infoRole);
  335. }
  336. if (this.bossInfo) {
  337. this.bossButton.node.active = true;
  338. if (this.bossInfo.head) {
  339. Api.createImageFromUrl(this.bossInfo.head, (spriteFrame) => {
  340. this.bossAvatar.spriteFrame = spriteFrame;
  341. });
  342. }
  343. if (this.bossInfo.nick) {
  344. this.bossNicknameLabel.string = this.bossInfo.nick;
  345. }
  346. var genderIcon = 'user_female';
  347. if (this.bossInfo.gender == 1) {
  348. genderIcon = 'user_male';
  349. }
  350. var artistName = " 无艺名";
  351. if (this.bossInfo.artistName) {
  352. artistName = " " + this.bossInfo.artistName.slice(0,4);
  353. }
  354. var artistString = "<img src='"+ genderIcon +"'/> " + artistName;
  355. this.bossArtistNameText.string = artistString;
  356. } else {
  357. this.bossButton.node.active = false;
  358. }
  359. this.bossInformationNode.enabled = true;
  360. this.bossInformationNode.active = false;
  361. this.bossInformationNode.x = this.winSize.width / 2.0;
  362. this.bossButton.node.x = this.winSize.width / 2.0 - 80;
  363. let hasBoss = this.bossInfo ? true : false;
  364. let hasJob = this.userInfo.jobId != UserJobType.None;
  365. this.themeMng.changeTheme(this.infoRole, hasBoss, hasJob);
  366. this.figureNode.changeFigure(this.userInfo);
  367. if (this.responseData.interactionInfo) {
  368. this.interaction.init(this.uid, this.responseData.interactionInfo, this);
  369. this.configIntimacy(this.responseData.interactionInfo);
  370. }
  371. },
  372. showBossInfo() {
  373. if (this.bossInformationNode.active === true) {
  374. let callBack = cc.callFunc(function () {
  375. this.bossInformationNode.active = false;
  376. }, this);
  377. let positionAction = cc.moveBy(0.15, 153, 0);
  378. this.bossInformationNode.runAction(cc.sequence(positionAction, callBack));
  379. let buttonAction = cc.moveBy(0.15, 152, 0);
  380. this.bossButton.node.runAction(buttonAction);
  381. } else {
  382. this.bossInformationNode.active = true;
  383. let positionAction = cc.moveBy(0.15, -153, 0);
  384. this.bossInformationNode.runAction(positionAction);
  385. let buttonAction = cc.moveBy(0.15, -152, 0);
  386. this.bossButton.node.runAction(buttonAction);
  387. }
  388. },
  389. showBossInfoToView() {
  390. this.bossInformationNode.enabled = false;
  391. this.loadUserInformation(this.bossInfo.uid);
  392. },
  393. //抢夺、赎身、签约操作
  394. changeRelationAction() {
  395. if (!this.conditionData) {
  396. return;
  397. }
  398. this.themeMng.relationButtonNode.enabled = false;
  399. var opt = UserInformationRelateOptType.None;
  400. switch (this.infoRole) {
  401. case UserInformationType.Boss:
  402. opt = UserInformationRelateOptType.Redeem;
  403. break;
  404. case UserInformationType.OtherArtist:
  405. opt = UserInformationRelateOptType.Loot;
  406. break;
  407. case UserInformationType.ArtistFree:
  408. opt = UserInformationRelateOptType.Sign;
  409. break;
  410. case UserInformationType.MyArtist:
  411. opt = UserInformationRelateOptType.Fire;
  412. break;
  413. default:
  414. break;
  415. }
  416. let string = tipsInfo.changeRelationTitle[opt].content;
  417. this.relationAlertMng.showRelationAlert(string, this.conditionData, () => {
  418. this.changeRelationNode.active = false;
  419. }, () => {
  420. this.confirmChangeRelation(opt);
  421. });
  422. //其他人艺人或自由身显示才引导
  423. if (this.infoRole == UserInformationType.OtherArtist || this.infoRole == UserInformationType.ArtistFree ) {
  424. this.scheduleOnce(function() {
  425. GameModule.homeGuide.getComponent('HomeGuide').handleGuideStateNext('state15', 'state16');
  426. }, 0.1);
  427. }
  428. },
  429. confirmChangeRelation(opt) {
  430. this.changeRelate(opt);
  431. this.changeRelationNode.active = false;
  432. },
  433. /**
  434. * 修改用户状态
  435. * @param {UserInformationRelateOptType} type
  436. */
  437. changeRelate(opt) {
  438. UserInformationApi.postRelate(this.uid, opt, (responseData) => {
  439. // console.log("responseData: " + JSON.stringify(responseData));
  440. GameModule.audioMng.playSignSuccess();
  441. var bossUid = 0;
  442. switch (opt) {
  443. case UserInformationRelateOptType.Loot:
  444. bossUid = this.bossInfo.uid;
  445. break;
  446. default:
  447. break;
  448. }
  449. this.themeMng.showChangeRelationSuccess(tipsInfo.relationSuccess[opt].image);
  450. if (bossUid > 0) {
  451. GameEvent.fire(GameNotificationKey.NoticeRoleOpt, this.uid, opt, bossUid);
  452. } else {
  453. GameEvent.fire(GameNotificationKey.NoticeRoleOpt, this.uid, opt);
  454. }
  455. GameModule.userInfo.updateUserRes({
  456. grossIncome: -this.conditionData.coin,
  457. ticket: -this.conditionData.ticket,
  458. });
  459. this.themeMng.relationButtonNode.enabled = true;
  460. this.isRefresh = true;
  461. this.loadInformation(responseData);
  462. GameEvent.fire(GameNotificationKey.RefreshFriendList);
  463. }, (code, msg) => {
  464. GameModule.audioMng.playSignFail();
  465. var errorString = msg;
  466. if (code == 805) {
  467. errorString = tipsInfo.relationFail805[opt].content;
  468. }
  469. //防守成功失败扣除相应金币
  470. if (code == 100) {
  471. GameModule.userInfo.updateUserRes({
  472. grossIncome: -this.conditionData.coin,
  473. ticket: -this.conditionData.ticket,
  474. });
  475. }
  476. let errorImage = tipsInfo.relationFail[opt].image;
  477. this.errorMng.showRelationErrorAlert(errorImage, errorString, () => {
  478. });
  479. this.themeMng.relationButtonNode.enabled = true;
  480. });
  481. },
  482. //修改艺人名字
  483. showEditName() {
  484. this.editNameNode.active = true;
  485. if (this.userInfo.artistName) {
  486. this.editboxName.string = this.userInfo.artistName;
  487. }
  488. this.editboxName.setFocus(true);
  489. },
  490. confirmEditName() {
  491. UserInformationApi.editArtistName(this.uid, this.editboxName.string, (responseData) => {
  492. // console.log("修改艺名成功 " + JSON.stringify(responseData));
  493. this.reloadArtistName();
  494. this.closeEditName();
  495. }, (error) => {
  496. console.log('修改艺名失败' + error);
  497. });
  498. this.editNameNode.active = false;
  499. },
  500. reloadArtistName() {
  501. this.userInfo.artistName = this.editboxName.string;
  502. var genderIcon = 'artist_female';
  503. if (this.userInfo.gender == 1) {
  504. genderIcon = 'artist_male';
  505. }
  506. var artistName = " 无艺名 ";
  507. if (this.userInfo.artistName) {
  508. artistName = " " + this.userInfo.artistName.slice(0,5) + " ";
  509. }
  510. var artistString = artistName;
  511. if (this.infoRole == UserInformationType.MyArtist) {
  512. let editName = " <img src='artist_name_edit' click='clickEditName'/>";
  513. artistString += editName;
  514. }
  515. this.artistNameText.string = artistString;
  516. },
  517. closeEditName() {
  518. this.editboxName.setFocus(false);
  519. if (window.wx != undefined) {
  520. wx.hideKeyboard();
  521. }
  522. this.editNameNode.active = false;
  523. },
  524. //跳转到指定用户家园
  525. showUserHome() {
  526. this.node.active = false;
  527. this.visitEvent();
  528. },
  529. //培养按钮点击
  530. trainAction() {
  531. this.trainEvent();
  532. },
  533. //亲密度数据设置
  534. configIntimacy(interactionInfo) {
  535. this.themeMng.configIntimacyData(interactionInfo);
  536. },
  537. showInteraction(event,customEventData) {
  538. //判断互动是否正向
  539. var isGood = false;
  540. if (customEventData == 'true') {
  541. isGood = true;
  542. }
  543. var interactionType = UserInteractionType.Common;
  544. switch (this.infoRole) {
  545. case UserInformationType.Boss:
  546. interactionType = isGood ? UserInteractionType.PlayUp : UserInteractionType.Revolt;
  547. break;
  548. case UserInformationType.MyArtist:
  549. interactionType = isGood ? UserInteractionType.Pacify : UserInteractionType.Order;
  550. break;
  551. default:
  552. break;
  553. }
  554. this.interaction.showInteraction(interactionType);
  555. },
  556. guideShowInteraction() {
  557. this.scheduleOnce(function() {
  558. this.interaction.showInteraction(UserInteractionType.Pacify);
  559. }, 0.1);
  560. },
  561. //突破按钮点击,职业进阶
  562. levelUpgradeAction() {
  563. if (this.userInfo) {
  564. GameEvent.fire(GameNotificationKey.ShowJobPage, JobPageType.LevelUp, this.userInfo, this.node.zIndex);
  565. }
  566. },
  567. //选择或转换职业
  568. changeJob() {
  569. if (this.infoRole == UserInformationType.MyArtist && this.userInfo) {
  570. //0为还没有选择职业,其他为已选择职业转职
  571. if (this.userInfo.jobId == UserJobType.None) {
  572. GameEvent.fire(GameNotificationKey.ShowJobPage, JobPageType.ChooseJob, this.userInfo, this.node.zIndex);
  573. } else {
  574. GameEvent.fire(GameNotificationKey.ShowJobPage, JobPageType.ChangeJob, this.userInfo, this.node.zIndex);
  575. }
  576. }
  577. },
  578. //打开背包
  579. openPackAction() {
  580. GameEvent.fire(GameNotificationKey.OpenPack,true);
  581. },
  582. openPack(justOpen) {
  583. this.pack.init(justOpen,this.uid);
  584. this.pack.showPack();
  585. },
  586. //打开插卡页面
  587. showInseertCard() {
  588. this.insertCardNode.active = true;
  589. this.insertCardMng.init(this.cardsList, this.uid);
  590. },
  591. refreshCardsInfo(cardInfo,isInsert) {
  592. if (isInsert) {
  593. if (this.cardsList != undefined) {
  594. this.cardsList.push(cardInfo);
  595. } else {
  596. this.cardsList = [];
  597. this.cardsList.push(cardInfo);
  598. }
  599. } else {
  600. for(var index in this.cardsList) {
  601. let item = this.cardsList[index];
  602. if (item.id == cardInfo.id) {
  603. this.cardsList.splice(index,1);
  604. break;
  605. }
  606. }
  607. }
  608. this.themeMng.configCardsData(this.cardsList);
  609. }
  610. });