Game.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. const GameModule = require("./utils/GameModule");
  2. const FriendSystemApi = require('./net/FriendSystemApi');
  3. const ShareAction = require('./utils/ShareAction');
  4. const DWTool = require('./utils/DWTool');
  5. const DWAlert = require('./utils/DWAlert');
  6. const HomeApi = require("./net/HomeApi");
  7. const JobApi = require('./net/JobApi');
  8. const { GameNotificationKey, SenceMap, JobPageType } = require('./utils/GameEnum');
  9. const AlertManager = require('./utils/AlertManager');
  10. const tutorial = require('./utils/Bundle').tutorial;
  11. const StateMachine = require('./lib/StateMachine');
  12. const StateMachineHistory = require('./lib/StateMachineHistory');
  13. const WsManager = require('./net/Ws');
  14. cc.Class({
  15. extends: cc.Component,
  16. properties: {
  17. levelHomePrefab: cc.Prefab,
  18. levelFriendHomePrefab: cc.Prefab,
  19. wechatFriendNode: cc.Node,
  20. //用户信息页
  21. userInfoPrefab: cc.Prefab,
  22. myInfoTop: cc.Node,
  23. myTabBottom: cc.Node,
  24. friendInfoTop: cc.Node,
  25. friendTabBottom: cc.Node,
  26. _otherActor: cc.Node,
  27. friendSystemPrefab: cc.Prefab,
  28. friendHeadSprite: cc.Sprite,
  29. talentPagePrefab: cc.Prefab,
  30. noticePoint: cc.Node,
  31. chooseJob: cc.Node,
  32. transition: cc.Node,
  33. mapIcon: cc.Node,
  34. homeGuide: cc.Node
  35. },
  36. onLoad() {
  37. GameModule.game = this.node;
  38. this.homeGuide.zIndex = 99;
  39. GameModule.homeGuide = this.homeGuide;
  40. // 创建一个事件监听实例, 用来实现跨节点监听事件
  41. GameEvent.init();
  42. //我的家园
  43. let levelHome = cc.instantiate(this.levelHomePrefab);
  44. levelHome = levelHome.getComponent('LevelHome');
  45. levelHome.init(Global.user.uid, Global.devCityId);
  46. this.levelHome = levelHome;
  47. //好友系统Tab面板
  48. let friendSystem = cc.instantiate(this.friendSystemPrefab);
  49. this.friendSystem = friendSystem.getComponent('FriendSystem');
  50. //好友家园
  51. let friendHome = cc.instantiate(this.levelFriendHomePrefab);
  52. friendHome = friendHome.getComponent('LevelFriendHome')
  53. this.friendHome = friendHome;
  54. //突破界面
  55. let breakOut = "";
  56. this.breakOut = breakOut;
  57. // //转职界面
  58. // this.jobChange = cc.instantiate(this.jobChangePrefab);
  59. // this.jobChange = this.jobChange.getComponent('ChangeJob');
  60. // 星探界面
  61. this.finder = cc.instantiate(this.talentPagePrefab);
  62. this.finder = this.finder.getComponent('TalentPage');
  63. // 引导界面
  64. this.homeGuide = this.homeGuide.getComponent('HomeGuide')
  65. this.homeGuide.init(this)
  66. // cc.loader.loadRes('prefabs/home_guide', cc.Prefab, (err, res) => {
  67. // this.homeGuide = cc.instantiate(res)
  68. // cc.find('Canvas').addChild(this.homeGuide);
  69. // })
  70. // 监听事件
  71. this._setEventListener();
  72. // 初始化场景管理状态机
  73. this._initFSM()
  74. // 初始化socket链接
  75. this._initSocketMng();
  76. if (Global.shareUid != -1) {
  77. console.log('shareUid: ' + Global.shareUid);
  78. this.processShareAction();
  79. }
  80. this.friendHeadSprite.node.on(cc.Node.EventType.TOUCH_END, () => {
  81. GameEvent.fire(GameNotificationKey.ShowUserInfomation, this.friendHome.uid);
  82. }, this);
  83. this.setMapIconVisible(true);
  84. // this.scheduleOnce(() => {
  85. // Global.devCityId = 2;
  86. // this.gameFSM.visitcitymap(true);
  87. // }, 2);
  88. },
  89. setMapIconVisible(visible) {
  90. if (Global.devCityId > 1) {
  91. this.mapIcon.active = visible;
  92. } else {
  93. this.mapIcon.active = false;
  94. }
  95. },
  96. updateUIState(state) {
  97. if (!!state['state6'].pass) {
  98. if (!this.myTabBottom.active) {
  99. this.myTabBottom.active = true
  100. let actionBottom = cc.moveBy(0.4, cc.v2(0, this.myTabBottom.height + 27));
  101. this.myTabBottom.runAction(actionBottom);
  102. }
  103. }
  104. },
  105. _initSocketMng() {
  106. let ja0ckUrl = `ws://172.16.15.170:8108/connect?uid=${Global.user.uid}&token=${Global.user.token}&channel=LuciferChannel&ver=1&os=1`
  107. let testUrl = `wss://test-message-allstar.duowan.com/connect?uid=${Global.user.uid}&token=${Global.user.token}&channel=LuciferChannel&ver=1&os=1`
  108. let saUrl = "ws://172.16.12.245:3000"
  109. let Message = tutorial.Message;
  110. let ws = new WsManager(testUrl, {
  111. binaryType: 'arraybuffer',
  112. autoConnect: true, // 自动连接
  113. reconnection: true, // 断开自动重连
  114. reconnectionDelay: 3000, // 重连间隔时间,单位秒
  115. reconnectionAttempts: 5 // 最大重连尝试次数,默认为Infinity
  116. })
  117. let seq = 1;
  118. ws.on('open', (res) => {
  119. /**
  120. * targetUid : 目标用户uid
  121. * opt : 操作类型
  122. * {1: 赎身; 2: 抢夺; 3: 签约; 4: 解雇; 5: 入驻;6: 召回;7: 驱赶;8: 举报; 9:通过好友申请;10:成为好友}
  123. * exBossUid : 抢夺成功时,前任老板的uid
  124. */
  125. GameEvent.on(GameNotificationKey.NoticeRoleOpt, this, (targetUid, opt, exBossUid) => {
  126. let payload = {
  127. roleOptMessage: {
  128. targetUid: targetUid,
  129. opt: opt
  130. },
  131. type: 3
  132. }
  133. //抢夺成功时,需要加上前任老板的uid
  134. if (opt == 2) {
  135. payload.roleOptMessage['exBossUid'] = exBossUid
  136. }
  137. let msg = Message.create(payload);
  138. let buffer = Message.encode(msg).finish()
  139. console.log('[Send msg]: ', msg);
  140. ws.send(buffer);
  141. });
  142. })
  143. ws.on('message', (data) => {
  144. let u8Arr = new Uint8Array(data)
  145. let decodeMsg = Message.decode(u8Arr);
  146. console.log("[Response text msg]: ", decodeMsg);
  147. if (decodeMsg.notificationMessage) {
  148. switch (decodeMsg.notificationMessage.nType) {
  149. case 1:
  150. //有新的通知
  151. this.toggleNoticePoint(true)
  152. break;
  153. case 2:
  154. //刷新好友列表
  155. GameEvent.fire(GameNotificationKey.RefreshFriendList)
  156. // this.levelHome.init(Global.user.uid, Global.cityId);
  157. break;
  158. case 3:
  159. //刷新我的艺人列表
  160. GameEvent.fire(GameNotificationKey.RefreshArtistManagerList)
  161. break;
  162. case 4:
  163. // 刷新首页数据
  164. GameEvent.fire(GameNotificationKey.ReloadLevelHomeData)
  165. break;
  166. default:
  167. break;
  168. }
  169. }
  170. })
  171. ws.on('close', () => {
  172. GameEvent.off(GameNotificationKey.NoticeRoleOpt, this);
  173. })
  174. ws.on('error', () => {
  175. GameEvent.off(GameNotificationKey.NoticeRoleOpt, this);
  176. })
  177. },
  178. _initFSM() {
  179. let self = this
  180. let gameFSM = StateMachine.factory({
  181. init: 'levelhome',
  182. transitions: [
  183. { name: 'visitfriend', from: ['levelhome', 'userinfo', 'friendhome'], to: 'friendhome' },
  184. { name: 'showuserinfo', from: ['levelhome', 'friendhome'], to: 'userinfo' },
  185. { name: 'visitcitymap', from: 'levelhome', to: 'citymap' },
  186. { name: 'visitcity', from: 'citymap', to: 'levelhome' },
  187. { name: 'changejob', from: '', to: '' }
  188. ],
  189. methods: {
  190. onBeforeVisitcity(lifecycle, cid) {
  191. //新城市初始化所有状态
  192. self.levelHome.init(Global.user.uid, cid);
  193. },
  194. onVisitfriend(lifecycle, uid) {
  195. //如果是friendhome状态之间跳转,则不切换右下方操作区域UI
  196. let toggleTop = true, toggleBottom = cc.Node;
  197. if (lifecycle.from == "friendhome") {
  198. self._onLeaveFriendhome(toggleTop, toggleBottom)
  199. self._onEnterFriendhome(uid, toggleTop, toggleBottom)
  200. }
  201. self._closeFriendSystem();
  202. self.setMapIconVisible(false);
  203. },
  204. onShowuserinfo() {
  205. },
  206. onVisitcitymap() {
  207. },
  208. onEnterFriendhome(lifecycle, uid) {
  209. self._onEnterFriendhome(uid)
  210. },
  211. onLeaveFriendhome() {
  212. self._onLeaveFriendhome()
  213. },
  214. onEnterLevelhome() {
  215. self.setMapIconVisible(true);
  216. self._onEnterLevelhome()
  217. },
  218. onLeaveLevelhome() {
  219. self._onLeaveLevelhome()
  220. },
  221. onEnterUserinfo(lifecycle, uid) {
  222. self._enterUserInfo(uid)
  223. self._hideTabbar();
  224. },
  225. onLeaveUserinfo() {
  226. self._showTabbar();
  227. },
  228. onEnterCitymap(lifecycle, showAnim) {
  229. self._onEnterCitymap(showAnim);
  230. },
  231. onLeaveCitymap() {
  232. self._onLeaveCitymap()
  233. }
  234. },
  235. plugins: [
  236. new StateMachineHistory()
  237. ]
  238. })
  239. this.gameFSM = new gameFSM('levelhome')
  240. },
  241. /**
  242. * 进入好友家园
  243. * @param {Number} uid 用户id
  244. * @param {Boolean} showTop 是否显示顶部信息
  245. * @param {Boolean} showBottom 是否显示底部操作栏
  246. */
  247. _onEnterFriendhome(uid, showTop = true, showBottom = true) {
  248. if (uid) {
  249. this.friendHome.initFriend(uid, res => {
  250. this._showFriendUI(showTop, showBottom)
  251. this.friendHome.node.active = true;
  252. })
  253. } else {
  254. this.friendHome.reInitFriend(() => {
  255. this._showFriendUI(showTop, showBottom)
  256. this.friendHome.node.active = true;
  257. });
  258. }
  259. },
  260. /**
  261. * 离开好友家园
  262. * @param {Boolean} hideTop 是否隐藏顶部信息
  263. * @param {Boolean} hideBottom 是否隐藏底部操作栏
  264. */
  265. _onLeaveFriendhome(hideTop = true, hideBottom = true) {
  266. this._hideFriendUI(hideTop, hideBottom)
  267. this.friendHome.node.active = false;
  268. },
  269. /**
  270. * 进入我的家园
  271. */
  272. _onEnterLevelhome() {
  273. this._showHomeUI()
  274. if (!this.isFirstLoad) {
  275. this.isFirstLoad = true;
  276. this.transition.active = true;
  277. let actionFade = cc.sequence(cc.fadeOut(2), cc.callFunc(() => {
  278. this.transition.active = false;
  279. }))
  280. this.transition.runAction(actionFade.easing(cc.easeIn(1.5)));
  281. } else {
  282. this.transition.active = true;
  283. this.transition.opacity = 200;
  284. let actionFade = cc.sequence(cc.fadeOut(1), cc.callFunc(() => {
  285. this.transition.active = false;
  286. }))
  287. this.transition.runAction(actionFade.easing(cc.easeIn(1.5)));
  288. }
  289. this.levelHome.node.active = true;
  290. this.refreshActorNoJob();
  291. },
  292. /**
  293. * 离开我的家园
  294. */
  295. _onLeaveLevelhome() {
  296. this._hideHomeUI()
  297. },
  298. /**
  299. * 显示我的家园界面所需UI
  300. * 恢复LevelHome的位置到Canvas场景内
  301. */
  302. _showHomeUI() {
  303. let actionTop = cc.moveBy(0.4, cc.v2(0, -this.myInfoTop.height));
  304. this.myInfoTop.runAction(actionTop);
  305. this.levelHome.node.x = 0;
  306. },
  307. /**
  308. * 隐藏我的家园界面所需UI
  309. * 把LevelHome移出Canvas场景外
  310. */
  311. _hideHomeUI() {
  312. let actionTop = cc.moveBy(0.4, cc.v2(0, this.myInfoTop.height));
  313. this.myInfoTop.runAction(actionTop);
  314. setTimeout(() => {
  315. this.levelHome.node.x = -800;
  316. }, 500)
  317. },
  318. /**
  319. * 显示好友家园界面所需UI
  320. * @param {Boolean} showTop 是否显示顶部信息
  321. * @param {Boolean} showBottom 是否显示底部操作栏
  322. */
  323. _showFriendUI(showTop = true, showBottom = true) {
  324. if (showTop) {
  325. let actionTop = cc.moveBy(0.4, cc.v2(0, -this.friendInfoTop.height));
  326. this.friendInfoTop.runAction(actionTop);
  327. }
  328. if (showBottom) {
  329. let actionRight = cc.moveBy(0.4, cc.v2(-270, 0));
  330. this.friendTabBottom.runAction(actionRight);
  331. }
  332. },
  333. /**
  334. * 隐藏好友家园界面所需UI
  335. * @param {Boolean} hideTop 是否隐藏顶部信息
  336. * @param {Boolean} hideBottom 是否隐藏底部操作栏
  337. */
  338. _hideFriendUI(hideTop = true, hideBottom = true) {
  339. if (hideTop) {
  340. let actionTop = cc.moveBy(0.3, cc.v2(0, this.friendInfoTop.height));
  341. this.friendInfoTop.runAction(actionTop);
  342. }
  343. if (hideBottom) {
  344. let actionRight = cc.moveBy(0.3, cc.v2(270, 0));
  345. this.friendTabBottom.runAction(actionRight);
  346. }
  347. },
  348. /**
  349. * 恢复Tab的位置到Canvas场景内
  350. */
  351. _showTabbar() {
  352. this.myTabBottom.x = 0;
  353. },
  354. /**
  355. * 把Tab移出Canvas场景外
  356. */
  357. _hideTabbar() {
  358. setTimeout(() => {
  359. this.myTabBottom.x = -800;
  360. }, 200)
  361. },
  362. /**
  363. * 进入个人信息页
  364. */
  365. _enterUserInfo(uid) {
  366. if (this.userInfo) {
  367. this.userInfo.init(this, uid);
  368. } else {
  369. DWTool.loadResPrefab('./prefabs/user_information')
  370. .then((result) => {
  371. this.userInfo = cc.instantiate(result);
  372. this.userInfo = this.userInfo.getComponent('UserInformation');
  373. this.userInfo.init(this, uid);
  374. }).catch((err) => {
  375. cc.error(err);
  376. });
  377. }
  378. },
  379. _showFriendSystem() {
  380. this.friendSystem.show(this.wechatFriendNode);
  381. },
  382. _closeFriendSystem() {
  383. this.friendSystem.close();
  384. },
  385. /**
  386. * 进入城市地图界面
  387. * @param {Boolean} showAnim 是否播放迁移到新城市的动画
  388. */
  389. _onEnterCitymap(showAnim) {
  390. let self = this;
  391. let devCityId = showAnim ? Global.devCityId - 1 : Global.devCityId;
  392. if (this.cityMap) {
  393. this.cityMap.show(showAnim, devCityId);
  394. } else {
  395. cc.loader.loadRes('/prefabs/map', cc.Prefab, (error, prefab) => {
  396. if (error === null) {
  397. this.cityMap = cc.instantiate(prefab);
  398. cc.find('Canvas').addChild(this.cityMap);
  399. this.cityMap = this.cityMap.getComponent('CityMapCtrl');
  400. this.cityMap.init(this);
  401. this.cityMap.show(showAnim, devCityId);
  402. } else {
  403. console.log(JSON.stringify(error));
  404. }
  405. });
  406. }
  407. // this._hideLevelHome();
  408. // this.hideLevelHome();
  409. },
  410. /**
  411. * 离开城市地图界面
  412. */
  413. _onLeaveCitymap() {
  414. if (this.cityMap) {
  415. this.cityMap.node.active = false;
  416. }
  417. },
  418. /**
  419. * 查看他人艺人列表
  420. */
  421. showOtherActors() {
  422. DWTool.loadResPrefab('./prefabs/other_artist_list')
  423. .then((result) => {
  424. this._otherActor = cc.instantiate(result);
  425. this._otherActor.getComponent("OtherArtistList").uid = this.friendHome.uid;
  426. this._otherActor.parent = cc.find("Canvas");
  427. }).catch((err) => {
  428. cc.error(err);
  429. });
  430. },
  431. /**
  432. * 关闭他人艺人列表
  433. */
  434. closeOtherActors() {
  435. this._otherActor.destroy();
  436. },
  437. showCompanyMax() {
  438. ///由于阿德的上报等级不够及时,所以满级等5秒再显示去下个城市的按钮
  439. this.scheduleOnce(() => {
  440. if (Global.devCityId === 1) {
  441. this.showCatFlyAnimation();
  442. this.mapIcon.active = true;
  443. } else {
  444. this.showCompanyMaxAlert();
  445. }
  446. }, 5);
  447. },
  448. showCompanyMaxAlert() {
  449. cc.loader.loadRes('/prefabs/current_company_max', cc.Prefab, (error, prefab) => {
  450. if (error === null) {
  451. let companyMaxAlert = cc.instantiate(prefab);
  452. cc.find('Canvas').addChild(companyMaxAlert);
  453. } else {
  454. console.log(JSON.stringify(error));
  455. }
  456. });
  457. },
  458. //转职
  459. //选择职业
  460. //职业突破页面
  461. showJobPage(type, userInfo, zIndex) {
  462. let self = this;
  463. cc.loader.loadRes('/prefabs/change_job', cc.Prefab, (error, prefab) => {
  464. if (error === null) {
  465. let jobChange = cc.instantiate(prefab);
  466. self.jobChange = jobChange.getComponent('ChangeJob');
  467. self.jobChange.show(type, userInfo, zIndex);
  468. } else {
  469. console.log(JSON.stringify(error));
  470. }
  471. });
  472. },
  473. showChooseJob() {
  474. let self = this;
  475. cc.loader.loadRes('/prefabs/change_job', cc.Prefab, (error, prefab) => {
  476. if (error === null) {
  477. let jobChange = cc.instantiate(prefab);
  478. this.jobChange = jobChange.getComponent('ChangeJob');
  479. this.jobChange.showFromTalent(JobPageType.ChooseJob, self.noJobActors);
  480. } else {
  481. console.log(JSON.stringify(error));
  482. }
  483. });
  484. },
  485. showRank: _.debounce(() => {
  486. AlertManager.showRankPage();
  487. }, 1000, true),
  488. showMission: _.debounce(() => {
  489. AlertManager.showQuestPopup();
  490. }, 1000, true),
  491. //关闭转职,选择职业,突破页面
  492. closeJobPage() {
  493. this.jobChange.close();
  494. },
  495. showTalentPage() {
  496. this.finder.show();
  497. },
  498. /**
  499. * 是否显示按钮提示
  500. * @param {Boolean} flag
  501. */
  502. toggleNoticePoint(flag) {
  503. if (flag) {
  504. this.noticePoint.active = true
  505. } else {
  506. this.noticePoint.active = false
  507. }
  508. },
  509. showCatFlyAnimation() {
  510. GameEvent.fire(GameNotificationKey.showCatFlyAnimation, this.mapIcon.getPosition());
  511. },
  512. handleCityMap: _.debounce(() => {
  513. GameEvent.fire(GameNotificationKey.ShowCityMap, false);
  514. // GameEvent.fire(GameNotificationKey.showCatFlyAnimation, this.mapIcon.getPosition());
  515. }, 1000, true),
  516. handleNoticePopup: _.debounce((event) => {
  517. AlertManager.showNoticePopup();
  518. event.target.getChildByName("notice_point").active = false
  519. }, 1000, true),
  520. handleBack: _.debounce(() => {
  521. GameEvent.fire(GameNotificationKey.HistoryBack)
  522. }, 1000, true),
  523. // 监听事件
  524. _setEventListener() {
  525. GameEvent.on(GameNotificationKey.ShowCityMap, this, (showAnim) => {
  526. this.gameFSM.visitcitymap(showAnim);
  527. // this.showCatFlyAnimation();
  528. });
  529. GameEvent.on(GameNotificationKey.ShowFriendSystem, this, () => {
  530. this._showFriendSystem();
  531. });
  532. GameEvent.on(GameNotificationKey.VisitFriendHome, this, (uid) => {
  533. this.gameFSM.visitfriend(uid)
  534. });
  535. GameEvent.on(GameNotificationKey.HistoryBack, this, () => {
  536. this.gameFSM.historyBack()
  537. })
  538. GameEvent.on(GameNotificationKey.ShowUserInfomation, this, (uid) => {
  539. this.gameFSM.showuserinfo(uid)
  540. });
  541. GameEvent.on(GameNotificationKey.ProcessShareAction, this, this.processShareAction);
  542. GameEvent.on(GameNotificationKey.ShowJobPage, this, this.showJobPage);
  543. GameEvent.on(GameNotificationKey.ShowJobPageFromTalent, this, this.showChooseJob);
  544. GameEvent.on(GameNotificationKey.RefreshFriendList, this, this.refreshActorNoJob);
  545. GameEvent.on(GameNotificationKey.CurrentCompanyMax, this, this.showCompanyMax);
  546. GameEvent.on(GameNotificationKey.afterCatFly, this, this.showCompanyMaxAlert);
  547. },
  548. onDestroy() {
  549. GameEvent.off(GameNotificationKey.ShowFriendSystem, this);
  550. GameEvent.off(GameNotificationKey.VisitFriendHome, this);
  551. GameEvent.off(GameNotificationKey.HistoryBack, this);
  552. GameEvent.off(GameNotificationKey.ProcessShareAction, this);
  553. GameEvent.off(GameNotificationKey.ShowUserInfomation, this);
  554. GameEvent.off(GameNotificationKey.ShowJobChoose, this);
  555. GameEvent.off(GameNotificationKey.ShowJobPage, this);
  556. GameEvent.off(GameNotificationKey.RefreshFriendList, this);
  557. GameEvent.off(GameNotificationKey.ShowJobPageFromTalent, this);
  558. GameEvent.off(GameNotificationKey.ShowCityMap, this);
  559. GameEvent.off(GameNotificationKey.CurrentCompanyMax, this);
  560. GameEvent.off(GameNotificationKey.afterCatFly, this);
  561. },
  562. processShareAction() {
  563. console.log('processShareAction');
  564. if (Global.user != null) {
  565. if (Global.shareType == ShareAction.ADD_FRIEND) {
  566. let shareUid = Global.shareUid
  567. FriendSystemApi.addFriend(shareUid, () => {
  568. GameEvent.fire('refresh_friend_list');
  569. setTimeout(() => {
  570. GameEvent.fire(GameNotificationKey.NoticeRoleOpt, shareUid, 10);
  571. }, 2500)
  572. });
  573. } else if (Global.shareType == ShareAction.BECOME_ARTIST) {
  574. let shareUid = Global.shareUid
  575. FriendSystemApi.becomeArtist(shareUid, () => {
  576. GameEvent.fire('refresh_friend_list');
  577. setTimeout(() => {
  578. GameEvent.fire(GameNotificationKey.NoticeRoleOpt, shareUid, 10);
  579. }, 2500)
  580. });
  581. }
  582. Global.shareUid = -1;
  583. Global.shareType = ShareAction.None;
  584. }
  585. },
  586. refreshActorNoJob() {
  587. JobApi.actorsNoJob(
  588. (response) => {
  589. if (response.list && !_.isEmpty(response.list) && response.list.length > 0) {
  590. this.chooseJob.active = true;
  591. this.noJobActors = response.list;
  592. } else {
  593. this.chooseJob.active = false;
  594. }
  595. },
  596. (code, msg) => {
  597. // this.chooseJob.active = false;
  598. }
  599. );
  600. }
  601. });