1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- const Api = require('../net/Api');
- var DWTool = require('../utils/DWTool');
- cc.Class({
- extends: cc.Component,
- properties: {
- bgSprite: cc.Sprite,
- headSprite: cc.Sprite,
- nickLabel: cc.Label,
- starCountLabel: cc.Label,
- genderIcon: cc.Sprite,
- roleSprite: cc.Sprite,
- _itemId: 0,
- titleLabel: cc.Label,
- },
- onLoad() {
- this.titleLabel.node.opacity = 0;
- // this.headSprite.node.width = this.headSprite.node.width / 4;
- // this.headSprite.node.height = this.headSprite.node.height / 4;
- },
- /**
- * gender [int]
- * head [string]
- * nick [string]
- * stars [int]
- * uid [int]
- * */
- updateItem(userInfo, itemId) {
- this._itemId = itemId;
- this.user = userInfo;
- if (userInfo.isFriend) {
- this.roleSprite.node.active = true;
- } else {
- this.roleSprite.node.active = false;
- }
- DWTool.setGenderIcon(userInfo.gender).then((spriteFrame) => {
- this.genderIcon.node.active = true;
- this.genderIcon.spriteFrame = spriteFrame;
- }, (error) => {
- this.genderIcon.node.active = false;
- });
- this.nickLabel.string = userInfo.nick;
- this.starCountLabel.string = userInfo.stars;
- Api.createImageFromUrl(userInfo.head, (spriteFrame) => {
- this.headSprite.spriteFrame = spriteFrame;
- }, null);
- },
- });
|