123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- const Api = require('../net/Api');
- const FriendApi = require('../net/FriendSystemApi');
- const UserInformationType = require('../utils/GameEnum').UserInformationType;
- var ShaderUtil = require('../utils/ShaderUtil');
- const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
- var DWTool = require('../utils/DWTool');
- cc.Class({
- extends: cc.Component,
- properties: {
- bgSprite: cc.Sprite,
- content: cc.Node,
- headSprite: cc.Sprite,
- nickLabel: cc.Label,
- starCountLabel: cc.Label,
- jobLevelNode: cc.Node,
- jobLevelText: cc.RichText,
- genderIcon: cc.Sprite,
- homeNode: cc.Node,
- acceptButton: cc.Node,
- rejectButton: cc.Node,
- apply: cc.Node,
- topBarSprite: cc.Sprite,
- roleText: cc.RichText,
- stateSprite: cc.Sprite,
- _friendList: null,
- _itemId: 0,
- _listViewAdapter: null,
- clickable: true,
- titleLabel: cc.Label,
- },
-
- onLoad() {
- this.bgSprite.node.on(cc.Node.EventType.TOUCH_END, () => {
- if (this.user.isApplied) {
- return;
- }
- GameEvent.fire(GameNotificationKey.ShowUserInfomation, this.user.uid);
- }, this)
- this.homeNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
- GameEvent.fire(GameNotificationKey.VisitFriendHome, this.user.uid);
- }, 1000, true), this);
-
-
- },
- setFriendList(friendList) {
- this._friendList = friendList;
- },
- setListViewAdapter(listViewAdapter) {
- this._listViewAdapter = listViewAdapter;
- },
-
- updateItem(userInfo, itemId) {
- this._itemId = itemId;
- this.user = userInfo;
- if (userInfo.isApplied) {
- this.apply.active = true;
- this.homeNode.active = false;
- this.stateSprite.node.active = false;
- this.topBarSprite.node.active = false;
- this.roleText.node.active = false;
- this.titleLabel.node.active = false;
- this.content.y = 20;
- } else {
- this.apply.active = false;
- this.homeNode.active = true;
- this.topBarSprite.node.active = true;
- this.roleText.node.active = true;
- this.titleLabel.node.active = true;
- this.content.y = 0;
- let typeImage = '';
- let typeText = '';
- switch (userInfo.role) {
- case UserInformationType.Boss:
- this.stateSprite.node.active = false;
- typeImage = './friendList/my_boss_bar'
- typeText = '我的老板';
- break;
- case UserInformationType.MyArtist:
- this.stateSprite.node.active = false;
- typeImage = './friendList/my_actor_bar'
- typeText = '我的艺人';
- break;
- case UserInformationType.ArtistFree:
- this.stateSprite.node.active = true;
- DWTool.loadResSpriteFrame('./friendList/state_free').then(spriteFrame => {
- this.stateSprite.spriteFrame = spriteFrame;
- });
- typeImage = './friendList/free_bar'
- typeText = '自由身';
- break;
- case UserInformationType.OtherArtist:
- this.stateSprite.node.active = true;
- DWTool.loadResSpriteFrame('./friendList/state_other_actor').then(spriteFrame => {
- this.stateSprite.spriteFrame = spriteFrame;
- });
- typeImage = './friendList/other_actor_bar'
- typeText = '他人艺人';
- break;
- default:
- this.stateSprite.node.active = true;
- DWTool.loadResSpriteFrame('./friendList/state_free').then(spriteFrame => {
- this.stateSprite.spriteFrame = spriteFrame;
- });
- typeImage = './friendList/free_bar'
- typeText = '自由身';
- break;
- }
- DWTool.loadResSpriteFrame(typeImage).then(spriteFrame => {
- this.topBarSprite.spriteFrame = spriteFrame;
- });
- this.roleText.string = '<b>' + typeText + '</b>'
- if (userInfo.jobName) {
- this.jobLevelNode.active = true;
- this.titleLabel.string = userInfo.jobName;
- } else {
- this.jobLevelNode.active = false;
- }
- if (userInfo.jobLevel) {
- this.jobLevelText.string = `<outline color=#524340 width=2>${userInfo.jobLevel}</outline >`
- } else {
- this.jobLevelText.string = '';
- }
- }
- DWTool.setGenderIcon(userInfo.gender).then((spriteFrame) => {
- this.genderIcon.node.active = true;
- this.genderIcon.spriteFrame = spriteFrame;
- }, (error) => {
- this.genderIcon.node.active = true;
- });
- this.nickLabel.string = userInfo.nick;
- this.starCountLabel.string = userInfo.stars;
- Api.createImageFromUrl(userInfo.head, (spriteFrame) => {
- this.headSprite.spriteFrame = spriteFrame;
-
-
- }, () => {
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- start() {
- },
- deleteItem() {
- FriendApi.processApply(this.user.uid, -1);
- this._listViewAdapter.removeItem(this);
- },
- acceptApply() {
- FriendApi.processApply(this.user.uid, 1);
- this.user.isApplied = false;
- this.updateItem(this.user, this._itemId);
-
- let opt = 9;
- GameEvent.fire(GameNotificationKey.NoticeRoleOpt, this.user.uid, opt)
- },
-
- });
|