192 lines
5.7 KiB
JavaScript
192 lines
5.7 KiB
JavaScript
var SDKManage = require("SDKManage")
|
|
var NetManage = require("NetManage")
|
|
var playerData = require("playerData")
|
|
var gameConfig = require("gameConfig")
|
|
var vipColorConfig = require("vipColorConfig")
|
|
var Main = require("Main");
|
|
|
|
cc.Class({
|
|
extends: cc.viewcell,
|
|
|
|
properties: {
|
|
lb_name: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
sp_head: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
sp_head_back: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
sp_sex: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
sp_vip: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
|
|
sp_rank: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
|
|
sp_lv: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
|
|
lb_time: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
|
|
nd_bg: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad () {
|
|
cc.Notifier.on('showbg',this,this.showbg.bind(this));
|
|
},
|
|
|
|
onDestroy () {
|
|
cc.Notifier.off('showbg', this);
|
|
},
|
|
|
|
init: function (index, data, reload, group) {
|
|
if (index >= data.array.length) {//越界
|
|
this.node.active = false
|
|
return;
|
|
}
|
|
this.target = data.target
|
|
var sdata = data.array[index]
|
|
this.accountid =sdata.base_data.account_id
|
|
this.showsenderinfo(sdata.base_data)
|
|
this.showbg()
|
|
if(sdata.m_defaultSelect == 1)
|
|
{
|
|
this.target.showfriend(this.accountid, this.name)
|
|
cc.Notifier.emit('showbg')
|
|
sdata.m_defaultSelect = 0;
|
|
}
|
|
},
|
|
|
|
showbg() {
|
|
this.nd_bg.active = false
|
|
if (this.target.sendid == this.accountid) {
|
|
this.nd_bg.active = true
|
|
}
|
|
},
|
|
|
|
showsenderinfo(userdata) {
|
|
var self =this
|
|
var vg = gameConfig.vipConfig[userdata.vip_lv]
|
|
if (!vg) {
|
|
return
|
|
}
|
|
if (userdata.vip_lv != 0) {
|
|
cc.loader.loadRes("textures/icons/public/vip" + userdata.vip_lv, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.sp_vip.spriteFrame = res;
|
|
}
|
|
});
|
|
}
|
|
var coltring = vipColorConfig[vg.color]
|
|
this.lb_name.string = userdata.nickname
|
|
this.lb_name.node.color = coltring
|
|
this.name = userdata.nickname
|
|
var id = userdata.head
|
|
if (!id) {
|
|
id = 0
|
|
}
|
|
cc.loader.loadRes("textures/icons/headbg/head_bg" + id, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.sp_head_back.spriteFrame = res;
|
|
}
|
|
});
|
|
var avatar_id = 18201
|
|
var sex = 'm'
|
|
if (userdata.sex == 1) {
|
|
sex = 'f'
|
|
}
|
|
if(userdata.avatar_url && Number(userdata.avatar_url) >= 18000 && Number(userdata.avatar_url) <= 19000){
|
|
avatar_id = userdata.avatar_url
|
|
}
|
|
let tmpURL = SDKManage.getHeadIconURL();
|
|
let url = tmpURL+gameConfig.wai_itemConfig[avatar_id].icon;
|
|
cc.loader.loadRes(url, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.sp_head.spriteFrame = res;
|
|
}
|
|
});
|
|
|
|
var score = parseInt(userdata.user_value1.toString())
|
|
var level_list = playerData.getSeasonArr()
|
|
var fg
|
|
for (var i = 0; i < level_list.length; i++) {
|
|
if (score <= level_list[i].max_point ||
|
|
level_list[i].max_point == -1) {
|
|
fg = level_list[i]
|
|
break
|
|
}
|
|
}
|
|
|
|
if (!fg) {
|
|
return
|
|
}
|
|
cc.loader.loadRes("textures/icons/public/" + fg.icon, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
if(self.sp_rank){
|
|
self.sp_rank.spriteFrame = res;
|
|
}
|
|
}
|
|
});
|
|
if (fg.level != '') {
|
|
cc.loader.loadRes("textures/icons/public/" + fg.level, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
if(self.sp_lv){
|
|
|
|
self.sp_lv.spriteFrame = res;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
var sex = 'm'
|
|
if (userdata.sex == 1) {
|
|
sex = 'f'
|
|
}
|
|
cc.loader.loadRes("textures/icons/public/" + sex, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.sp_sex.spriteFrame = res;
|
|
}
|
|
});
|
|
|
|
var onlinearr = playerData.getonlinetime(userdata['value1'], userdata['_online'], userdata['last_login_time'])
|
|
this.lb_time.string = onlinearr.str
|
|
this.lb_time.node.color = onlinearr.color
|
|
},
|
|
onclick(){
|
|
this.target.showfriend(this.accountid, this.name)
|
|
cc.Notifier.emit('showbg')
|
|
// var flag = 0
|
|
// for (var i = 0; i < playerData.friend_list.length; i++ ) {
|
|
// if (playerData.friend_list[i].base_data['account_id'] == this.accountid) {
|
|
// flag = 1
|
|
// }
|
|
// }
|
|
// playerData.friend_accountid = this.accountid
|
|
// playerData.friend_rank = this.rank
|
|
// cc.Notifier.emit('showplayerinfo', flag)
|
|
}
|
|
// update (dt) {},
|
|
});
|