const Api = require('../net/Api'); var DWTool = require('../utils/DWTool'); cc.Class({ extends: cc.Component, properties: { avatarSprite: cc.Sprite, genderSprite: cc.Sprite, nickLabel: cc.Label, starCountLabel: cc.Label, }, bind(user) { Api.createImageFromUrl(user.head, (spriteFrame) => { this.avatarSprite.spriteFrame = spriteFrame; }); DWTool.setGenderIcon(user.gender).then(spriteFrame => { this.genderSprite.spriteFrame = spriteFrame; }); this.nickLabel.string = user.nick; this.starCountLabel.string = user.stars; }, });