123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- var CGPIndividualMission = require("CGPIndividualMission");
- var Global = require("Global");
- cc.Class({
- extends: cc.Component,
- properties: {
- sprHead:{ //头像图片
- default:null,
- type:cc.Node
- },
- labNickName:{ //头像图片
- default:null,
- type:cc.Label
- },
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- updateAccountHttpIP: function (userID) {
- if (!this._kReqPlayerInfo) {
- this._kReqPlayerInfo = new CGPIndividualMission({ URL: cc.vv.config.Address, Port: cc.vv.config.Port });
- this._kReqPlayerInfo.setMissionSink(this);
- }
- this._kReqPlayerInfo.queryIndividual(userID);
- },
-
- onGPAccountInfoHttpIP: function (kNetInfo) {
- // cc.vv.globalUserInfo.setUserHead(kNetInfo.HeadHttp);
- var self = this;
- cc.assetManager.loadRemote(kNetInfo.HeadHttp + '?aa=aa.jpg', function (err, tex) {
- if (!err) {
- self.setSprFrame(new cc.SpriteFrame(tex));
- }
- });
- var nickName = this.node.getChildByName("nickName");
- if (nickName) {
- nickName.getComponent(cc.Label).string = Global.gbk2Utf8(kNetInfo.NickName);
- }
- if (this.labNickName) {
- this.labNickName.string = Global.gbk2Utf8(kNetInfo.NickName);
- }
- },
- setSprFrame: function(spriteFrame) {
- var headImg = this.node.getChildByName("Head");
- if (headImg) {
- headImg.getComponent(cc.Sprite).spriteFrame = spriteFrame;
- }
- if (this.sprHead) {
- this.sprHead.getComponent(cc.Sprite).spriteFrame = spriteFrame;
- }
- },
- // update (dt) {},
- setUserId: function(userId) {
- this.updateAccountHttpIP(userId);
- },
-
- resetView: function() {
- var headImg = this.node.getChildByName("Head");
- if (headImg) {
- headImg.getComponent(cc.Sprite).spriteFrame = null;
- }
- if (this.sprHead) {
- this.sprHead.getComponent(cc.Sprite).spriteFrame = null;
- }
- if (this.labNickName) {
- this.labNickName.string = "";
- }
-
- },
- });
|