uiPlayerInfo.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. var CGPIndividualMission = require("CGPIndividualMission");
  2. var Global = require("Global");
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. sprHead:{ //头像图片
  7. default:null,
  8. type:cc.Node
  9. },
  10. labNickName:{ //头像图片
  11. default:null,
  12. type:cc.Label
  13. },
  14. },
  15. // LIFE-CYCLE CALLBACKS:
  16. // onLoad () {},
  17. start () {
  18. },
  19. updateAccountHttpIP: function (userID) {
  20. if (!this._kReqPlayerInfo) {
  21. this._kReqPlayerInfo = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
  22. this._kReqPlayerInfo.setMissionSink(this);
  23. }
  24. this._kReqPlayerInfo.queryIndividual(userID);
  25. },
  26. onGPAccountInfoHttpIP: function (kNetInfo) {
  27. // cc.vv.globalUserInfo.setUserHead(kNetInfo.HeadHttp);
  28. var self = this;
  29. cc.assetManager.loadRemote(kNetInfo.HeadHttp + '?aa=aa.jpg', function (err, tex) {
  30. if (!err) {
  31. self.setSprFrame(new cc.SpriteFrame(tex));
  32. }
  33. });
  34. var nickName = this.node.getChildByName("nickName");
  35. if (nickName) {
  36. nickName.getComponent(cc.Label).string = Global.gbk2Utf8(kNetInfo.NickName);
  37. }
  38. if (this.labNickName) {
  39. this.labNickName.string = Global.gbk2Utf8(kNetInfo.NickName);
  40. }
  41. },
  42. setSprFrame: function(spriteFrame) {
  43. var headImg = this.node.getChildByName("Head");
  44. if (headImg) {
  45. headImg.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  46. }
  47. if (this.sprHead) {
  48. this.sprHead.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  49. }
  50. },
  51. // update (dt) {},
  52. setUserId: function(userId) {
  53. this.updateAccountHttpIP(userId);
  54. },
  55. resetView: function() {
  56. var headImg = this.node.getChildByName("Head");
  57. if (headImg) {
  58. headImg.getComponent(cc.Sprite).spriteFrame = null;
  59. }
  60. if (this.sprHead) {
  61. this.sprHead.getComponent(cc.Sprite).spriteFrame = null;
  62. }
  63. if (this.labNickName) {
  64. this.labNickName.string = "";
  65. }
  66. },
  67. });