UserInformation.js 24 KB

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