123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- const Style = require('../utils/GameEnum').LevelHomeFriendItemStyle;
- const Api = require('../net/Api');
- const NotiKey = require('../utils/GameEnum').GameNotificationKey;
- const GameModule = require("../utils/GameModule");
- // var WeChat = require("../net/WeChat");
- // const DWTool = require('../utils/DWTool');
- // const AlertManager = require('../utils/AlertManager');
- cc.Class({
- extends: cc.Component,
- properties: {
- itemBg: cc.Node,
- allFriendNode: cc.Node,
- friendInfoNode: cc.Node,
- talentNode: cc.Node,
- identityNode: cc.Node,
- identitySpriteFrames: [cc.SpriteFrame],
- headSprite: cc.Sprite,
- nickLabel: cc.Label,
- starsLabel: cc.Label,
- noticeNode: cc.Node,
- style: {
- get: function () {
- if (!this._style) {
- this._style = Style.Friend;
- }
- return this._style;
- },
- set: function (value) {
- this._style = value;
- this.setEvent();
- this.layout();
- }
- },
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad() {
- },
- setEvent() {
- switch (this.style) {
- case Style.AllFriend:
- this.allFriendNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
- GameEvent.fire(NotiKey.ShowFriendSystem);
- GameModule.audioMng.playButton();
- }, 1000, true), this);
- break;
- case Style.Friend:
- this.friendInfoNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
- // GameEvent.fire(NotiKey.VisitFriendHome, this.info.uid);
- GameEvent.fire(NotiKey.ShowUserInfomation, this.info.uid);
- GameModule.audioMng.playButton();
- }, 1000, true), this);
- break;
- // case Style.Artist:
- // this.friendInfoNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
- // GameEvent.fire(NotiKey.ShowUserInfomation, this.info.uid);
- // }, 1000, true), this);
- // break;
- // case Style.Talent:
- // this.talentNode.on(cc.Node.EventType.TOUCH_END, function () {
- // cc.loader.loadRes('/prefabs/talent_mission', cc.Prefab, (error, prefab) => {
- // if (error === null) {
- // let mission = cc.instantiate(prefab);
- // mission = mission.getComponent('TalentMission');
- // mission.init();
- // } else {
- // console.log(JSON.stringify(error));
- // }
- // });
- // }, this);
- // break;
- }
- },
- setFriendInfo(info) {
- this.info = info;
- this.starsLabel.string = info.stars;
- this.nickLabel.string = info.nick;
- Api.createImageFromUrl(info.head, (spriteFrame) => {
- this.headSprite.spriteFrame = spriteFrame;
- }, null);
- if (info.role === 1) { // 我的老板
- this.identityNode.getComponent(cc.Sprite).spriteFrame = this.identitySpriteFrames[0];
- } else if(info.role == 2) { // 我的艺人
- this.identityNode.getComponent(cc.Sprite).spriteFrame = this.identitySpriteFrames[1];
- } else {
- this.identityNode.active = false;
- }
- // 显示消息提示节点
- // if (this.style === Style.Friend && info.isStationed) {
- // this.noticeNode.active = true
- // } else {
- // this.noticeNode.active = false
- // }
- },
- layout() {
- switch (this.style) {
- case Style.AllFriend:
- this.allFriendNode.active = true;
- this.friendInfoNode.active = false;
- this.talentNode.active = false;
- this.itemBg.active = false;
- // this.noticeNode.active = false
- break;
- case Style.Friend:
- this.friendInfoNode.active = true;
- this.allFriendNode.active = false;
- this.talentNode.active = false;
- this.identityNode.active = true;
- // this.itemBg.active = true;
- break;
- case Style.Invite:
- this.friendInfoNode.active = false;
- this.allFriendNode.active = false;
- this.talentNode.active = false;
- this.itemBg.active = true;
- // this.noticeNode.active = false
- break;
- case Style.Talent:
- this.friendInfoNode.active = false;
- this.allFriendNode.active = false;
- this.talentNode.active = true;
- this.itemBg.active = false;
- // this.noticeNode.active = false
- break;
- case Style.Artist:
- this.friendInfoNode.active = true;
- this.allFriendNode.active = false;
- this.talentNode.active = false;
- this.identityNode.active = true;
- this.itemBg.active = true;
- // this.noticeNode.active = false
- break;
- default:
- break;
- }
- },
- // update (dt) {},
- });
|